@@ -3,9 +3,7 @@ import { BigNumber } from "ethers";
3
3
import { ether } from "@utils/index" ;
4
4
import { Account } from "@utils/test/types" ;
5
5
import { Address } from "@utils/types" ;
6
- import {
7
- ZERO ,
8
- } from "@utils/constants" ;
6
+ import { ZERO } from "@utils/constants" ;
9
7
import { ArrakisUniswapV3AmmAdapter } from "@utils/contracts" ;
10
8
import DeployHelper from "@utils/deploys" ;
11
9
import {
@@ -14,7 +12,7 @@ import {
14
12
getSystemFixture ,
15
13
getUniswapV3Fixture ,
16
14
getArrakisV1Fixture ,
17
- getWaffleExpect
15
+ getWaffleExpect ,
18
16
} from "@utils/test/index" ;
19
17
20
18
import { SystemFixture , UniswapV3Fixture , ArrakisV1Fixture } from "@utils/fixtures" ;
@@ -30,30 +28,29 @@ describe("ArrakisUniswapV3AmmAdapter", () => {
30
28
let arrakisUniswapV3AmmAdapter : ArrakisUniswapV3AmmAdapter ;
31
29
32
30
before ( async ( ) => {
33
- [
34
- owner ,
35
- ] = await getAccounts ( ) ;
31
+ [ owner ] = await getAccounts ( ) ;
36
32
37
33
deployer = new DeployHelper ( owner . wallet ) ;
38
34
setup = getSystemFixture ( owner . address ) ;
39
35
await setup . initialize ( ) ;
40
36
41
37
uniswapV3Setup = getUniswapV3Fixture ( owner . address ) ;
42
- await uniswapV3Setup . initialize (
38
+ await uniswapV3Setup . initialize ( owner , setup . weth , 2500 , setup . wbtc , 35000 , setup . dai ) ;
39
+
40
+ arrakisV1Setup = getArrakisV1Fixture ( owner . address ) ;
41
+ await arrakisV1Setup . initialize (
43
42
owner ,
43
+ uniswapV3Setup ,
44
44
setup . weth ,
45
45
2500 ,
46
46
setup . wbtc ,
47
47
35000 ,
48
- setup . dai
48
+ setup . dai ,
49
49
) ;
50
50
51
- arrakisV1Setup = getArrakisV1Fixture ( owner . address ) ;
52
- await arrakisV1Setup . initialize ( owner , uniswapV3Setup , setup . weth , 2500 , setup . wbtc , 35000 , setup . dai ) ;
53
-
54
51
arrakisUniswapV3AmmAdapter = await deployer . adapters . deployArrakisUniswapV3AmmAdapter (
55
52
arrakisV1Setup . router . address ,
56
- uniswapV3Setup . factory . address
53
+ uniswapV3Setup . factory . address ,
57
54
) ;
58
55
} ) ;
59
56
@@ -63,7 +60,7 @@ describe("ArrakisUniswapV3AmmAdapter", () => {
63
60
async function subject ( ) : Promise < ArrakisUniswapV3AmmAdapter > {
64
61
return await deployer . adapters . deployArrakisUniswapV3AmmAdapter (
65
62
arrakisV1Setup . router . address ,
66
- uniswapV3Setup . factory . address
63
+ uniswapV3Setup . factory . address ,
67
64
) ;
68
65
}
69
66
@@ -160,7 +157,6 @@ describe("ArrakisUniswapV3AmmAdapter", () => {
160
157
expect ( status ) . to . be . false ;
161
158
} ) ;
162
159
} ) ;
163
-
164
160
} ) ;
165
161
166
162
describe ( "getProvideLiquiditySingleAssetCalldata" , async ( ) => {
@@ -182,7 +178,8 @@ describe("ArrakisUniswapV3AmmAdapter", () => {
182
178
subjectAmmPool ,
183
179
subjectComponent ,
184
180
subjectMaxTokenIn ,
185
- subjectMinLiquidity ) ;
181
+ subjectMinLiquidity ,
182
+ ) ;
186
183
}
187
184
188
185
it ( "should revert" , async ( ) => {
@@ -209,7 +206,8 @@ describe("ArrakisUniswapV3AmmAdapter", () => {
209
206
subjectAmmPool ,
210
207
subjectComponent ,
211
208
subjectMinTokenOut ,
212
- subjectLiquidity ) ;
209
+ subjectLiquidity ,
210
+ ) ;
213
211
}
214
212
215
213
it ( "should revert" , async ( ) => {
@@ -231,9 +229,12 @@ describe("ArrakisUniswapV3AmmAdapter", () => {
231
229
setup . weth . address ,
232
230
setup . dai . address ,
233
231
subjectMaxTokensIn [ 0 ] ,
234
- subjectMaxTokensIn [ 1 ]
232
+ subjectMaxTokensIn [ 1 ] ,
233
+ ) ;
234
+ const mintAmount = await arrakisV1Setup . wethDaiPool . getMintAmounts (
235
+ orderedMaxTokensIn [ 0 ] ,
236
+ orderedMaxTokensIn [ 1 ] ,
235
237
) ;
236
- const mintAmount = await arrakisV1Setup . wethDaiPool . getMintAmounts ( orderedMaxTokensIn [ 0 ] , orderedMaxTokensIn [ 1 ] ) ;
237
238
subjectMinLiquidity = mintAmount [ 2 ] ;
238
239
} ) ;
239
240
@@ -243,7 +244,8 @@ describe("ArrakisUniswapV3AmmAdapter", () => {
243
244
subjectAmmPool ,
244
245
subjectComponents ,
245
246
subjectMaxTokensIn ,
246
- subjectMinLiquidity ) ;
247
+ subjectMinLiquidity ,
248
+ ) ;
247
249
}
248
250
249
251
it ( "should return the correct provide liquidity calldata" , async ( ) => {
@@ -254,9 +256,12 @@ describe("ArrakisUniswapV3AmmAdapter", () => {
254
256
setup . weth . address ,
255
257
setup . dai . address ,
256
258
subjectMaxTokensIn [ 0 ] ,
257
- subjectMaxTokensIn [ 1 ]
259
+ subjectMaxTokensIn [ 1 ] ,
260
+ ) ;
261
+ const mintAmount = await arrakisV1Setup . wethDaiPool . getMintAmounts (
262
+ orderedMaxTokensIn [ 0 ] ,
263
+ orderedMaxTokensIn [ 1 ] ,
258
264
) ;
259
- const mintAmount = await arrakisV1Setup . wethDaiPool . getMintAmounts ( orderedMaxTokensIn [ 0 ] , orderedMaxTokensIn [ 1 ] ) ;
260
265
const amountAMin = mintAmount [ 0 ] ;
261
266
const amountBMin = mintAmount [ 1 ] ;
262
267
@@ -266,9 +271,11 @@ describe("ArrakisUniswapV3AmmAdapter", () => {
266
271
orderedMaxTokensIn [ 1 ] ,
267
272
amountAMin ,
268
273
amountBMin ,
269
- owner . address
274
+ owner . address ,
270
275
] ) ;
271
- expect ( JSON . stringify ( calldata ) ) . to . eq ( JSON . stringify ( [ arrakisV1Setup . router . address , ZERO , expectedCallData ] ) ) ;
276
+ expect ( JSON . stringify ( calldata ) ) . to . eq (
277
+ JSON . stringify ( [ arrakisV1Setup . router . address , ZERO , expectedCallData ] ) ,
278
+ ) ;
272
279
} ) ;
273
280
274
281
describe ( "when the either of the _maxTokensIn is zero" , async ( ) => {
@@ -287,7 +294,9 @@ describe("ArrakisUniswapV3AmmAdapter", () => {
287
294
} ) ;
288
295
289
296
it ( "should revert" , async ( ) => {
290
- await expect ( subject ( ) ) . to . be . revertedWith ( "_minLiquidity is too high for input token limit" ) ;
297
+ await expect ( subject ( ) ) . to . be . revertedWith (
298
+ "_minLiquidity is too high for input token limit" ,
299
+ ) ;
291
300
} ) ;
292
301
} ) ;
293
302
} ) ;
@@ -311,7 +320,8 @@ describe("ArrakisUniswapV3AmmAdapter", () => {
311
320
subjectAmmPool ,
312
321
subjectComponents ,
313
322
subjectMinTokensOut ,
314
- subjectLiquidity ) ;
323
+ subjectLiquidity ,
324
+ ) ;
315
325
}
316
326
317
327
it ( "should return the correct remove liquidity calldata" , async ( ) => {
@@ -320,27 +330,33 @@ describe("ArrakisUniswapV3AmmAdapter", () => {
320
330
setup . weth . address ,
321
331
setup . dai . address ,
322
332
subjectMinTokensOut [ 0 ] ,
323
- subjectMinTokensOut [ 1 ]
333
+ subjectMinTokensOut [ 1 ] ,
334
+ ) ;
335
+ const expectedCallData = arrakisV1Setup . router . interface . encodeFunctionData (
336
+ "removeLiquidity" ,
337
+ [
338
+ subjectAmmPool ,
339
+ subjectLiquidity ,
340
+ orderedMinTokensOut [ 0 ] ,
341
+ orderedMinTokensOut [ 1 ] ,
342
+ owner . address ,
343
+ ] ,
344
+ ) ;
345
+ expect ( JSON . stringify ( calldata ) ) . to . eq (
346
+ JSON . stringify ( [ arrakisV1Setup . router . address , ZERO , expectedCallData ] ) ,
324
347
) ;
325
- const expectedCallData = arrakisV1Setup . router . interface . encodeFunctionData ( "removeLiquidity" , [
326
- subjectAmmPool ,
327
- subjectLiquidity ,
328
- orderedMinTokensOut [ 0 ] ,
329
- orderedMinTokensOut [ 1 ] ,
330
- owner . address
331
- ] ) ;
332
- expect ( JSON . stringify ( calldata ) ) . to . eq ( JSON . stringify ( [ arrakisV1Setup . router . address , ZERO , expectedCallData ] ) ) ;
333
348
} ) ;
334
349
335
350
describe ( "when the _liquidity is more than available" , async ( ) => {
336
351
beforeEach ( async ( ) => {
337
- subjectLiquidity = ( await arrakisV1Setup . wethDaiPool . balanceOf ( owner . address ) ) . add ( ether ( 1 ) ) ;
352
+ subjectLiquidity = ( await arrakisV1Setup . wethDaiPool . balanceOf ( owner . address ) ) . add (
353
+ ether ( 1 ) ,
354
+ ) ;
338
355
} ) ;
339
356
340
357
it ( "should revert" , async ( ) => {
341
358
await expect ( subject ( ) ) . to . be . revertedWith ( "_liquidity must be <= to current balance" ) ;
342
359
} ) ;
343
360
} ) ;
344
361
} ) ;
345
-
346
362
} ) ;
0 commit comments