You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: example/uniswap-v2/README.md
+12-11Lines changed: 12 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,8 +9,8 @@ We could use solc to compile solidity into YUL IR.
9
9
solc --ir UniswapV2ERC20.sol > UniswapV2ERC20.yul
10
10
```
11
11
12
-
However, the compiled ir has deployment code. This test does not contain runtime test, so you need to remove the deployment code manually.
13
-
It could be done by extract `object "UniswapV2ERC20_431_deployed"` into a single YUL file.
12
+
However, the compiled IR has deployment code. This test does not contain a runtime test, so you need to remove the deployment code manually.
13
+
It could be done by extracting`object "UniswapV2ERC20_431_deployed"` into a single YUL file.
14
14
15
15
A preprocessed `UniswapV2ERC20.yul` is included in the folder, you could use the file directly.
16
16
@@ -118,18 +118,18 @@ return: 1
118
118
119
119
## Testing other Uniswap Interfaces
120
120
121
-
If we want to test Factory/Pair Interface, we need to setup a chain to initialize tokens.
122
-
However, the testing environment cannot support contract deployment, so we cannot test the full function of the interface.
121
+
If we want to test Factory/Pair Interface, we need to set up a chain to initialize tokens.
122
+
However, the testing environment cannot support contract deployment, so we cannot test the full functionality of the interface.
123
123
124
-
Some interfaces inherented from ERC20 and some basic function could still be tested with this environment.
124
+
Some interfaces inherited from ERC20 and some basic functions could still be tested with this environment.
125
125
126
126
```
127
127
python uniswap-test.py --input UniswapV2Pair.wasm
128
128
```
129
129
130
130
### Uniswap V2 Factory
131
131
132
-
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.
132
+
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.
133
133
134
134
```
135
135
function createPair(address tokenA, address tokenB) external returns (address pair);
function allPairs(uint) external view returns (address pair);
143
143
```
144
144
145
-
With the above process with could test the correctness of Uniswap V2 Factory.
145
+
The above process could test the correctness of Uniswap V2 Factory.
146
146
147
-
For more testing process, please checkout [UniswapV2Factory test script](https://github.com/Uniswap/v2-core/blob/master/test/UniswapV2Factory.spec.ts)
147
+
For more testing processes, please checkout [UniswapV2Factory test script](https://github.com/Uniswap/v2-core/blob/master/test/UniswapV2Factory.spec.ts)
148
148
149
149
150
150
151
151
### Uniswap V2 Pair
152
152
153
-
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,
153
+
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,
154
154
155
155
1. Mint `function mint(address to) external returns (uint liquidity);`
@@ -166,4 +166,5 @@ After we validate Uniswap V2 Factory, we could then validate Uniswap V2 Pair, wh
166
166
+ price1CumulativeLast = Token_0 / Token_1
167
167
+ 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
168
168
169
-
For more testing process, please checkout [UniswapV2Pair test script](https://github.com/Uniswap/v2-core/blob/master/test/UniswapV2Pair.spec.ts)
169
+
For more testing processes, please checkout [UniswapV2Pair test script](https://github.com/Uniswap/v2-core/blob/master/test/UniswapV2Pair.spec.ts)
0 commit comments