diff --git a/example/uniswap-v2/README.md b/example/uniswap-v2/README.md index b89dd81c..f5055cee 100644 --- a/example/uniswap-v2/README.md +++ b/example/uniswap-v2/README.md @@ -9,8 +9,8 @@ We could use solc to compile solidity into YUL IR. solc --ir UniswapV2ERC20.sol > UniswapV2ERC20.yul ``` -However, the compiled ir has deployment code. This test does not contain runtime test, so you need to remove the deployment code manually. -It could be done by extract `object "UniswapV2ERC20_431_deployed"` into a single YUL file. +However, the compiled IR has deployment code. This test does not contain a runtime test, so you need to remove the deployment code manually. +It could be done by extracting` object "UniswapV2ERC20_431_deployed"` into a single YUL file. A preprocessed `UniswapV2ERC20.yul` is included in the folder, you could use the file directly. @@ -118,10 +118,10 @@ return: 1 ## Testing other Uniswap Interfaces -If we want to test Factory/Pair Interface, we need to setup a chain to initialize tokens. -However, the testing environment cannot support contract deployment, so we cannot test the full function of the interface. +If we want to test Factory/Pair Interface, we need to set up a chain to initialize tokens. +However, the testing environment cannot support contract deployment, so we cannot test the full functionality of the interface. -Some interfaces inherented from ERC20 and some basic function could still be tested with this environment. +Some interfaces inherited from ERC20 and some basic functions could still be tested with this environment. ``` python uniswap-test.py --input UniswapV2Pair.wasm @@ -129,7 +129,7 @@ python uniswap-test.py --input UniswapV2Pair.wasm ### Uniswap V2 Factory -After ERC20 tokens are deployed at some address, say `tokenA` is deployed at `addressA` and `tokenB` is deployed at `addressB` , we could create pair with Uniswap V2 Factory. We could call `createPair` API to create a pair of tokens. +After ERC20 tokens are deployed at some address, say `tokenA` is deployed at `addressA` and `tokenB` is deployed at `addressB`, we could create pair with Uniswap V2 Factory. We could call `createPair` API to create a pair of tokens. ``` function createPair(address tokenA, address tokenB) external returns (address pair); @@ -142,20 +142,20 @@ function getPair(address tokenA, address tokenB) external view returns (address function allPairs(uint) external view returns (address pair); ``` -With the above process with could test the correctness of Uniswap V2 Factory. +The above process could test the correctness of Uniswap V2 Factory. -For more testing process, please checkout [UniswapV2Factory test script](https://github.com/Uniswap/v2-core/blob/master/test/UniswapV2Factory.spec.ts) +For more testing processes, please checkout [UniswapV2Factory test script](https://github.com/Uniswap/v2-core/blob/master/test/UniswapV2Factory.spec.ts) ### Uniswap V2 Pair -After we validate Uniswap V2 Factory, we could then validate Uniswap V2 Pair, which is the main interface of Uniswap. Pairs serve as automated market makers and keep track of pool token balances. List 5 test below, +After we validate Uniswap V2 Factory, we could then validate Uniswap V2 Pair, which is the main interface of Uniswap. Pairs serve as automated market makers and keep track of pool token balances. List 5 tests below, 1. Mint `function mint(address to) external returns (uint liquidity);` + Creates pool tokens to some address 2. Swap token `function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;` - + Two direction of swapping + + Two directions of swapping + pay for the withdrawn ERC20 tokens with the corresponding pair tokens + return the withdrawn ERC20 tokens along with a small fee 3. burn `function burn(address to) external returns (uint amount0, uint amount1);` @@ -166,4 +166,5 @@ After we validate Uniswap V2 Factory, we could then validate Uniswap V2 Pair, wh + price1CumulativeLast = Token_0 / Token_1 + To calculate the correct price, please check [utilities.ts:encodePrice](https://github.com/Uniswap/v2-core/blob/master/test/shared/utilities.ts#L97), it divide the liquidity of 2 toekns -For more testing process, please checkout [UniswapV2Pair test script](https://github.com/Uniswap/v2-core/blob/master/test/UniswapV2Pair.spec.ts) +For more testing processes, please checkout [UniswapV2Pair test script](https://github.com/Uniswap/v2-core/blob/master/test/UniswapV2Pair.spec.ts) +