First clone the repository:
git clone https://github.com/levelkdev/swapr-sdk.git
Move into the dxswap-sdk working directory
cd swapr-sdk
Install dependencies
yarn install
Generate GraphQL
yarn codegen
Build
yarn build
Connect package an app to sdk locally
yarn link
And on the app repo
yarn link "../swapr-sdk/" #e.g. path to sdk
To run the tests, follow these steps. You must have at least node v16 installed.
Run tests
yarn test
Swapr uses multiple trades to find best protocol and route for traders. Currently supported DEXs are
Protocol | Ethereum | Arbitrum One | Gnosis Chain | Polygon | BNB Chain | Optimism | ZkSync Era |
---|---|---|---|---|---|---|---|
0x | β | β | β | β | β | β | β |
1Inch | β | β | β | β | β | β | β |
Baoswap | β | β | β | β | β | β | β |
BiSwap | β | β | β | β | β | β | β |
CoW Protocol | β | β | β | β | β | β | β |
Curve | β | β | β | β | β | β | β |
DFYN | β | β | β | β | β | β | β |
Honeyswap | β | β | β | β | β | β | β |
Levinswap | β | β | β | β | β | β | β |
Pancakeswap | β | β | β | β | β | β | β |
Quickswap | β | β | β | β | β | β | β |
SushiSwap | β | β | β | β | β | β | β |
Swapr | β | β | β | β | β | β | β |
Uniswap v2 | β | β | β | β | β | β | β |
Velodrome | β | β | β | β | β | β | β |
The Trade
class is extendable. New DEXs can be added to the SDK by extending the Trade
and adding required methods.
First, open the file UniswapV2RoutablePlatform.ts
. Here, you'll find several examples of already integrated DEXs.
Next, you need to search for the following information about the platform you want to integrate:
- Supported chains by the DEX.
- Factory Address: You can find it in the protocol docs.
- Router Address: You can find it in the protocol docs.
- Init Code Hash: Looking at the Factory Address in a blockchain explorer, you can go to the
Contract tab > Read Contract > INIT_CODE_HASH
. - Default Swap Fee: You may find it in the protocol official docs or in the Factory Address code.
- Subgraph Endpoint (optional).
Once you have this information, you can create an instance of UniswapV2RoutablePlatform
for the DEX you're trying to integrate and then consume it from the file entities/pair.ts
so you can add it to the PAIR_ADDRESS_CACHE
.