1.0.12 • Published 5 months ago

@zeroxvault/sdk v1.0.12

Weekly downloads
-
License
AGPL-3.0-or-later
Repository
github
Last release
5 months ago

ZeroXVault SDK

Getting Started

Running tests

To run the tests, follow these steps. You must have at least node v16 installed.

First clone the repository:

git clone https://github.com/0xvault/sdk.git

Move into the 0xvault-sdk working directory

cd sdk

Install dependencies

npm install

Run tests

npm run test

Eco Router Trades

ZeroXVault uses multiple trades to find best protocol and route for traders. Currently supported DEXs are

ProtocolEthereumArbitrum OnePolygonBNB ChainOptimismZkSync Era
0x
1Inch
Baoswap
BiSwap
CoW Protocol
Curve
DFYN
Pancakeswap
Quickswap
SushiSwap
ZeroXVault
Uniswap v2
Velodrome

The Trade class is extendable. New DEXs can be added to the SDK by extending the Trade and adding required methods.

How To Add Routable Platforms

For UniV2 Forks

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.