@@ -25,7 +25,7 @@ describe('max tick cross spec', () => {
25
25
const searchLimit = SEARCH_RANGE * tickSpacing
26
26
const txGasLimit = 5000000n
27
27
const positionOwnerMint = ( 1n << 128n ) as TokenAmount
28
- const swapperMint = ( 1n << 30n ) as TokenAmount
28
+ const swapperMint = ( 1n << 50n ) as TokenAmount
29
29
const supply = ( positionOwnerMint + swapperMint ) as TokenAmount
30
30
const liquidityDelta = toLiquidity ( 10000000n )
31
31
let admin : PrivateKeyWallet
@@ -50,9 +50,9 @@ describe('max tick cross spec', () => {
50
50
poolKey = newPoolKey ( tokenX . contractId , tokenY . contractId , feeTier )
51
51
} )
52
52
53
- test ( 'max tick cross swap xToY and ByAmountIn, no liquidity gap between positions' , async ( ) => {
54
- const lastInitializedTick = - 250n
55
- const amount = 40282n as TokenAmount
53
+ test . only ( 'max tick cross swap xToY and ByAmountIn, no liquidity gap between positions' , async ( ) => {
54
+ const lastInitializedTick = - 750n
55
+ const amount = 301241n as TokenAmount
56
56
const xToY = true
57
57
const slippage = MIN_SQRT_PRICE
58
58
const byAmountIn = true
@@ -87,17 +87,17 @@ describe('max tick cross spec', () => {
87
87
xToY ,
88
88
amount ,
89
89
byAmountIn ,
90
- targetSqrtPrice
90
+ slippage
91
91
)
92
92
const poolAfter = await getPool ( invariant , poolKey )
93
93
94
94
const crosses = ( poolAfter . currentTickIndex - poolBefore . currentTickIndex ) / - 10n
95
- expect ( crosses ) . toBe ( 8n )
95
+ expect ( crosses ) . toBe ( 59n )
96
96
expect ( gasAmount ) . toBeLessThan ( txGasLimit )
97
97
} , 100000 )
98
98
test ( 'max tick cross swap yToX and ByAmountIn, no liquidity gap between positions' , async ( ) => {
99
- const lastInitializedTick = 120n
100
- const amount = 44998n as TokenAmount
99
+ const lastInitializedTick = 1120n
100
+ const amount = 337572n as TokenAmount
101
101
const xToY = false
102
102
const slippage = MAX_SQRT_PRICE
103
103
const byAmountIn = true
@@ -138,12 +138,12 @@ describe('max tick cross spec', () => {
138
138
139
139
const poolAfter = await getPool ( invariant , poolKey )
140
140
const crosses = ( poolAfter . currentTickIndex - poolBefore . currentTickIndex ) / 10n
141
- expect ( crosses ) . toBe ( 8n )
141
+ expect ( crosses ) . toBe ( 66n )
142
142
expect ( gasAmount ) . toBeLessThan ( txGasLimit )
143
143
} , 100000 )
144
144
test ( 'max tick cross swap xToY and ByAmountIn, liquidity gap between positions' , async ( ) => {
145
- const lastInitializedTick = - 250n
146
- const amount = 35250n as TokenAmount
145
+ const lastInitializedTick = - 1250n
146
+ const amount = 200032n as TokenAmount
147
147
const xToY = true
148
148
const slippage = MIN_SQRT_PRICE
149
149
const byAmountIn = true
@@ -182,12 +182,12 @@ describe('max tick cross spec', () => {
182
182
)
183
183
const poolAfter = await getPool ( invariant , poolKey )
184
184
const crosses = ( poolAfter . currentTickIndex - poolBefore . currentTickIndex ) / - 10n
185
- expect ( crosses ) . toBe ( 13n )
185
+ expect ( crosses ) . toBe ( 77n )
186
186
expect ( gasAmount ) . toBeLessThan ( txGasLimit )
187
187
} , 100000 )
188
188
test ( 'max tick cross swap yToX and ByAmountIn, liquidity gap between positions' , async ( ) => {
189
- const lastInitializedTick = 240n
190
- const amount = 40000n as TokenAmount
189
+ const lastInitializedTick = 2400n
190
+ const amount = 215744n as TokenAmount
191
191
const xToY = false
192
192
const slippage = MAX_SQRT_PRICE
193
193
const byAmountIn = true
@@ -227,12 +227,12 @@ describe('max tick cross spec', () => {
227
227
228
228
const poolAfter = await getPool ( invariant , poolKey )
229
229
const crosses = ( poolAfter . currentTickIndex - poolBefore . currentTickIndex ) / 10n
230
- expect ( crosses ) . toBe ( 14n )
230
+ expect ( crosses ) . toBe ( 83n )
231
231
expect ( gasAmount ) . toBeLessThan ( txGasLimit )
232
232
} , 100000 )
233
233
test ( 'max tick cross swap xToY and ByAmountIn, positions between search limit range' , async ( ) => {
234
- const lastInitializedTick = - 35000n
235
- const amount = 13569916n as TokenAmount
234
+ const lastInitializedTick = - 150000n
235
+ const amount = 1395687588n as TokenAmount
236
236
const xToY = true
237
237
const slippage = MIN_SQRT_PRICE
238
238
const byAmountIn = true
@@ -270,12 +270,12 @@ describe('max tick cross spec', () => {
270
270
)
271
271
const poolAfter = await getPool ( invariant , poolKey )
272
272
const crosses = ( poolAfter . currentTickIndex - poolBefore . currentTickIndex ) / - searchLimit
273
- expect ( crosses ) . toBe ( 6n )
273
+ expect ( crosses ) . toBe ( 38n )
274
274
expect ( gasAmount ) . toBeLessThan ( txGasLimit )
275
275
} , 100000 )
276
276
test ( 'max tick cross swap yToX and ByAmountIn, positions between search limit range' , async ( ) => {
277
- const lastInitializedTick = 25000n
278
- const amount = 17947500n as TokenAmount
277
+ const lastInitializedTick = 150000n
278
+ const amount = 2460737677n as TokenAmount
279
279
const xToY = false
280
280
const slippage = MAX_SQRT_PRICE
281
281
const byAmountIn = true
@@ -313,13 +313,13 @@ describe('max tick cross spec', () => {
313
313
314
314
const poolAfter = await getPool ( invariant , poolKey )
315
315
const crosses = ( poolAfter . currentTickIndex - poolBefore . currentTickIndex ) / searchLimit
316
- expect ( crosses ) . toBe ( 7n )
316
+ expect ( crosses ) . toBe ( 42n )
317
317
expect ( gasAmount ) . toBeLessThan ( txGasLimit )
318
318
} , 100000 )
319
319
test ( 'max tick cross swap xToY and ByAmountOut, no liquidity gap between positions' , async ( ) => {
320
- const lastInitializedTick = - 250n
321
- const mintAmount = 60000n as TokenAmount
322
- const swapAmount = 44500n as TokenAmount
320
+ const lastInitializedTick = - 750n
321
+ const mintAmount = 600000n as TokenAmount
322
+ const swapAmount = 339068n as TokenAmount
323
323
const xToY = true
324
324
const slippage = MIN_SQRT_PRICE
325
325
const byAmountIn = false
@@ -368,13 +368,14 @@ describe('max tick cross spec', () => {
368
368
const poolAfter = await getPool ( invariant , poolKey )
369
369
370
370
const crosses = ( poolAfter . currentTickIndex - poolBefore . currentTickIndex ) / - 10n
371
- expect ( crosses ) . toBe ( 9n )
371
+ expect ( crosses ) . toBe ( 69n )
372
+ console . log ( gasAmount , txGasLimit )
372
373
expect ( gasAmount ) . toBeLessThan ( txGasLimit )
373
374
} , 100000 )
374
375
test ( 'max tick cross swap yToX and ByAmountOut, no liquidity gap between positions' , async ( ) => {
375
- const lastInitializedTick = 120n
376
- const mintAmount = 60000n as TokenAmount
377
- const swapAmount = 39000n as TokenAmount
376
+ const lastInitializedTick = 900n
377
+ const mintAmount = 600000n as TokenAmount
378
+ const swapAmount = 314889n as TokenAmount
378
379
379
380
const xToY = false
380
381
const slippage = MAX_SQRT_PRICE
@@ -423,13 +424,13 @@ describe('max tick cross spec', () => {
423
424
424
425
const poolAfter = await getPool ( invariant , poolKey )
425
426
const crosses = ( poolAfter . currentTickIndex - poolBefore . currentTickIndex ) / 10n
426
- expect ( crosses ) . toBe ( 7n )
427
+ expect ( crosses ) . toBe ( 64n )
427
428
expect ( gasAmount ) . toBeLessThan ( txGasLimit )
428
429
} , 100000 )
429
430
test ( 'max tick cross swap xToY and ByAmountOut, liquidity gap between positions' , async ( ) => {
430
- const lastInitializedTick = - 500n
431
- const mintAmount = 60000n as TokenAmount
432
- const swapAmount = 39500n as TokenAmount
431
+ const lastInitializedTick = - 1000n
432
+ const mintAmount = 600000n as TokenAmount
433
+ const swapAmount = 210363n as TokenAmount
433
434
const xToY = true
434
435
const slippage = MIN_SQRT_PRICE
435
436
const byAmountIn = false
@@ -462,7 +463,6 @@ describe('max tick cross spec', () => {
462
463
byAmountIn ,
463
464
slippage
464
465
)
465
-
466
466
const poolBefore = await getPool ( invariant , poolKey )
467
467
468
468
const { gasAmount } = await initSwap (
@@ -478,13 +478,15 @@ describe('max tick cross spec', () => {
478
478
const poolAfter = await getPool ( invariant , poolKey )
479
479
480
480
const crosses = ( poolAfter . currentTickIndex - poolBefore . currentTickIndex ) / - 10n
481
- expect ( crosses ) . toBe ( 16n )
481
+ expect ( crosses ) . toBe ( 86n )
482
+ console . log ( gasAmount , txGasLimit )
482
483
expect ( gasAmount ) . toBeLessThan ( txGasLimit )
483
484
} , 100000 )
484
485
test ( 'max tick cross swap yToX and ByAmountOut, liquidity gap between positions' , async ( ) => {
485
- const lastInitializedTick = 360n
486
- const mintAmount = 60000n as TokenAmount
487
- const swapAmount = 39000n as TokenAmount
486
+ console . log ( invariant . address , swapper . address )
487
+ const lastInitializedTick = 1360n
488
+ const mintAmount = 600000000n as TokenAmount
489
+ const swapAmount = 200872n as TokenAmount
488
490
489
491
const xToY = false
490
492
const slippage = MAX_SQRT_PRICE
@@ -507,9 +509,9 @@ describe('max tick cross spec', () => {
507
509
slippageLimit
508
510
)
509
511
}
512
+ const poolBefore = await getPool ( invariant , poolKey )
510
513
511
514
await withdrawTokens ( swapper , [ tokenY , mintAmount ] )
512
-
513
515
const { targetSqrtPrice } = await quote (
514
516
invariant ,
515
517
poolKey ,
@@ -519,7 +521,6 @@ describe('max tick cross spec', () => {
519
521
slippage
520
522
)
521
523
522
- const poolBefore = await getPool ( invariant , poolKey )
523
524
const { gasAmount } = await initSwap (
524
525
invariant ,
525
526
swapper ,
@@ -533,17 +534,17 @@ describe('max tick cross spec', () => {
533
534
534
535
const poolAfter = await getPool ( invariant , poolKey )
535
536
const crosses = ( poolAfter . currentTickIndex - poolBefore . currentTickIndex ) / 10n
536
- expect ( crosses ) . toBe ( 14n )
537
+ expect ( crosses ) . toBe ( 80n )
538
+ console . log ( gasAmount , txGasLimit )
537
539
expect ( gasAmount ) . toBeLessThan ( txGasLimit )
538
- } , 100000 )
540
+ } , 1000000000 )
539
541
test ( 'max tick cross swap xToY and ByAmountOut, positions between search limit range' , async ( ) => {
540
- const lastInitializedTick = - 25000n
541
- const mintAmount = 20000000n as TokenAmount
542
- const swapAmount = 6050000n as TokenAmount
542
+ const lastInitializedTick = - 155040n
543
+ const mintAmount = 200000000000n as TokenAmount
543
544
const xToY = true
544
545
const slippage = MIN_SQRT_PRICE
545
546
const byAmountIn = false
546
-
547
+ const swapAmount = 9956848n as TokenAmount
547
548
for ( let i = lastInitializedTick ; i < 0n ; i += searchLimit ) {
548
549
const positionOwnerBalanceX = await balanceOf ( tokenX . contractId , positionOwner . address )
549
550
const positionOwnerBalanceY = await balanceOf ( tokenY . contractId , positionOwner . address )
@@ -587,13 +588,13 @@ describe('max tick cross spec', () => {
587
588
)
588
589
const poolAfter = await getPool ( invariant , poolKey )
589
590
const crosses = ( poolAfter . currentTickIndex - poolBefore . currentTickIndex ) / - searchLimit
590
- expect ( crosses ) . toBe ( 7n )
591
+ expect ( crosses ) . toBe ( 42n )
591
592
expect ( gasAmount ) . toBeLessThan ( txGasLimit )
592
593
} , 100000 )
593
594
test ( 'max tick cross swap yToX and ByAmountOut, positions between search limit range' , async ( ) => {
594
- const lastInitializedTick = 25000n
595
- const mintAmount = 20000000n as TokenAmount
596
- const swapAmount = 6408000n as TokenAmount
595
+ const lastInitializedTick = 155000n
596
+ const mintAmount = 20000000000n as TokenAmount
597
+ const swapAmount = 9959260n as TokenAmount
597
598
const xToY = false
598
599
const slippage = MAX_SQRT_PRICE
599
600
const byAmountIn = false
@@ -641,7 +642,8 @@ describe('max tick cross spec', () => {
641
642
642
643
const poolAfter = await getPool ( invariant , poolKey )
643
644
const crosses = ( poolAfter . currentTickIndex - poolBefore . currentTickIndex ) / searchLimit
644
- expect ( crosses ) . toBe ( 7n )
645
+ console . log ( gasAmount , txGasLimit )
646
+ expect ( crosses ) . toBe ( 43n )
645
647
expect ( gasAmount ) . toBeLessThan ( txGasLimit )
646
648
} , 100000 )
647
649
} )
0 commit comments