1.0.5 • Published 3 years ago
@xliger/sdk v1.0.5
LigerSwap SDK
Forked from the Uniswap SDK.
You can refer to the Uniswap SDK documentation uniswap.org.
Using Minimal Proxy To Create New XPair
Smart Contract
XFactory : 0xBBd189ceA5c833cE3c253A04739A8c25f7f63872
XPair Implementation :0xD6C082F30cdfEf3B765Dd300bdCc5886281F18F7
XLIGER/WBNB Proxy XPair : 0x67fE1DCCB7E9d847EDD4dB5E93ef38FADb37a2c1
Running tests
To run the tests, follow these steps. You must have at least node v10 and yarn installed.
First clone the repository:
git clone https://github.com/xliger/xliger-swap-sdk.git
Move into the xliger-swap-sdk working directory
cd xliger-swap-sdk/
Install dependencies
yarn install
Check get XPair address result base on tokens salt in init-code.mjs
// check this code before edit in ./src/constant.ts
const XPAIR_IMPLEMENTATION = 'D6C082F30cdfEf3B765Dd300bdCc5886281F18F7' // Remove 0x front of address
// XPair implementation address (get it after deploy factory => verify contract => read contract without run code)
const PROXYPAIR_BYTECODE = `3d602d80600a3d3981f3363d3d373d3d3d363d73${XPAIR_IMPLEMENTATION}5af43d82803e903d91602b57fd5bf3`
// #! Dont touch this code
// standart minimal proxy bytecode according to EIP-1167: Minimal Proxy Contract
// please refer to this website - https://eips.ethereum.org/EIPS/eip-1167
const FACTORY_ADDRESS = '0xBBd189ceA5c833cE3c253A04739A8c25f7f63872'
/// Change this base on your deployment contract address
// core factory address
const ACTUAL_INITCODE_PROXYPAIR_HASH = '0xac763168d0f9bcbb937abeace7e0a4f7e8ea92158168f41bc3db11e3924b3ec8'
// (get it from deployment factory contract)
const ACTUAL_PAIR_ADDRESS = '0x67fE1DCCB7E9d847EDD4dB5E93ef38FADb37a2c1'
// (get it after create new pair using factory)
// Change this base on your deployment contract address and your selected token
const Token0 = '0x888888E8c80e2AeAeccF2e46Be905c20e125A1DB' // Token A e.g XLIGER mainnet/testnet
const Token1 = '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c' // Token B e.g WBNB mainnet
Run check init code
yarn check:initcode
Run tests
yarn test
You should see output like the following:
yarn run v1.22.17
$ tsdx test
PASS test/fraction.test.ts
PASS test/trade.test.ts
PASS test/constants.test.ts
PASS test/router.test.ts
PASS test/miscellaneous.test.ts
PASS test/route.test.ts
PASS test/token.test.ts
PASS test/pair.test.ts (7.361s)
Test Suites: 1 skipped, 8 passed, 8 of 9 total
Tests: 3 skipped, 101 passed, 104 total
Snapshots: 0 total
Time: 11.892s, estimated 12s
Ran all test suites.
Done in 20.99s.