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
function price0CumulativeLast() external view returns (uint);
138
-
function price1CumulativeLast() external view returns (uint);
139
-
function kLast() external view returns (uint);
140
-
141
-
function mint(address to) external returns (uint liquidity);
142
-
function burn(address to) external returns (uint amount0, uint amount1);
143
-
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
144
-
function skim(address to) external;
145
-
function sync() external;
146
-
147
-
function initialize(address, address) external;
148
-
```
130
+
### Uniswap V2 Factory
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.
133
+
134
+
```
135
+
function createPair(address tokenA, address tokenB) external returns (address pair);
136
+
```
137
+
138
+
Further, after we create a pair of tokens, we could then validate the factory by checking its read-only functions.
139
+
140
+
```
141
+
function getPair(address tokenA, address tokenB) external view returns (address pair);
142
+
function allPairs(uint) external view returns (address pair);
143
+
```
144
+
145
+
With the above process with could test the correctness of Uniswap V2 Factory.
146
+
147
+
For more testing process, please checkout [UniswapV2Factory test script](https://github.com/Uniswap/v2-core/blob/master/test/UniswapV2Factory.spec.ts)
148
+
149
+
150
+
151
+
### Uniswap V2 Pair
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,
154
+
155
+
1. Mint `function mint(address to) external returns (uint liquidity);`
+ The `price{0,1}CumulativeLast` is used by oracle to fetch the current accumulated price value
165
+
+ price0CumulativeLast = Token_1 / Token_0
166
+
+ price1CumulativeLast = Token_0 / Token_1
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
+
169
+
For more testing process, please checkout [UniswapV2Pair test script](https://github.com/Uniswap/v2-core/blob/master/test/UniswapV2Pair.spec.ts)
0 commit comments