项目作者: project-serum

项目描述 :
React Component for Swapping on the Serum DEX
高级语言: TypeScript
项目地址: git://github.com/project-serum/swap-ui.git
创建时间: 2021-05-13T03:43:36Z
项目社区:https://github.com/project-serum/swap-ui

开源协议:Apache License 2.0

下载


@project-serum/swap-ui

Build Status
@project-serum/swap-ui"">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.

  1. 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.

  1. 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,

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

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

  1. yarn

Build

  1. 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

  1. yarn start