Go to file
armaniferrante bb04675789
stash
2021-06-02 00:31:29 -07:00
example Extract example into its own directory (#22) 2021-05-21 14:58:01 -07:00
src stash 2021-06-02 00:31:29 -07:00
types/buffer-layout Basic UI scaffolding 2021-05-12 20:43:10 -07:00
.gitignore Readme updates and typedoc (#23) 2021-05-21 15:42:20 -07:00
.travis.yml Add travis ci 2021-05-15 16:38:39 -07:00
LICENSE Add LICENSE and README 2021-05-12 20:50:35 -07:00
README.md Readme updates and typedoc (#23) 2021-05-21 15:42:20 -07:00
package.json stash 2021-06-02 00:31:29 -07:00
tsconfig.json Extract example into its own directory (#22) 2021-05-21 14:58:01 -07:00
yarn.lock stash 2021-06-02 00:31:29 -07:00

README.md

@project-serum/swap-ui

Build Status npm

A reusable React component for swapping on the Serum DEX. The Solana program can be found here.

Usage

Install

First install the required peer dependencies into your React project.

yarn add @material-ui/core @material-ui/icons @material-ui/lab @project-serum/anchor @solana/spl-token-registry @solana/web3.js material-ui-popup-state react-async-hook

Then install the package.

yarn add @project-serum/swap-ui

Add the Swap Component

To embed the Swap component into your application, one can minimally provide an Anchor Provider and TokenListContainer. For example,

<Swap provider={provider} tokenList={tokenList} />

All of the complexity of communicating with the Serum DEX and managing its data is handled internally by the component.

Referral Fees

To earn referral fees, one can also pass in a referral property, which is the PublicKey of the Solana wallet that owns the associated token accounts in which referral fees are paid (i.e., USDC and USDT).

Developing

Install dependencies

yarn

Build

yarn build

Run the example app

For local development and educational purposes, a minimal React app is provided in the example/ subdirectory.

To run, change directories via cd example/ and start the app.

Start the app

yarn start