@orca-so/whirlpools-core 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,150 +1,136 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ export function _TICK_ARRAY_SIZE(): number;
4
+ export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD(): number;
5
+ export function _MIN_TICK_INDEX(): number;
6
+ export function _MAX_TICK_INDEX(): number;
3
7
  /**
4
- * Calculate the amount A delta between two sqrt_prices
8
+ * Convert a price into a sqrt priceX64
9
+ * IMPORTANT: floating point operations can reduce the precision of the result.
10
+ * Make sure to do these operations last and not to use the result for further calculations.
5
11
  *
6
12
  * # Parameters
7
- * - `sqrt_price_1`: The first square root price
8
- * - `sqrt_price_2`: The second square root price
9
- * - `liquidity`: The liquidity
10
- * - `round_up`: Whether to round up or not
13
+ * * `price` - The price to convert
14
+ * * `decimals_a` - The number of decimals of the base token
15
+ * * `decimals_b` - The number of decimals of the quote token
11
16
  *
12
17
  * # Returns
13
- * - `u64`: The amount delta
18
+ * * `u128` - The sqrt priceX64
14
19
  */
15
- export function tryGetAmountDeltaA(sqrt_price_1: bigint, sqrt_price_2: bigint, liquidity: bigint, round_up: boolean): bigint;
20
+ export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
16
21
  /**
17
- * Calculate the amount B delta between two sqrt_prices
22
+ * Convert a sqrt priceX64 into a tick index
23
+ * IMPORTANT: floating point operations can reduce the precision of the result.
24
+ * Make sure to do these operations last and not to use the result for further calculations.
18
25
  *
19
26
  * # Parameters
20
- * - `sqrt_price_1`: The first square root price
21
- * - `sqrt_price_2`: The second square root price
22
- * - `liquidity`: The liquidity
23
- * - `round_up`: Whether to round up or not
27
+ * * `sqrt_price` - The sqrt priceX64 to convert
28
+ * * `decimals_a` - The number of decimals of the base token
29
+ * * `decimals_b` - The number of decimals of the quote token
24
30
  *
25
31
  * # Returns
26
- * - `u64`: The amount delta
32
+ * * `f64` - The decimal price
27
33
  */
28
- export function tryGetAmountDeltaB(sqrt_price_1: bigint, sqrt_price_2: bigint, liquidity: bigint, round_up: boolean): bigint;
34
+ export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
29
35
  /**
30
- * Calculate the next square root price
36
+ * Invert a price
37
+ * IMPORTANT: floating point operations can reduce the precision of the result.
38
+ * Make sure to do these operations last and not to use the result for further calculations.
31
39
  *
32
40
  * # Parameters
33
- * - `current_sqrt_price`: The current square root price
34
- * - `current_liquidity`: The current liquidity
35
- * - `amount`: The amount
36
- * - `specified_input`: Whether the input is specified
41
+ * * `price` - The price to invert
42
+ * * `decimals_a` - The number of decimals of the base token
43
+ * * `decimals_b` - The number of decimals of the quote token
37
44
  *
38
45
  * # Returns
39
- * - `u128`: The next square root price
46
+ * * `f64` - The inverted price
40
47
  */
41
- export function tryGetNextSqrtPriceFromA(current_sqrt_price: bigint, current_liquidity: bigint, amount: bigint, specified_input: boolean): bigint;
48
+ export function invertPrice(price: number, decimals_a: number, decimals_b: number): number;
42
49
  /**
43
- * Calculate the next square root price
50
+ * Convert a tick index into a price
51
+ * IMPORTANT: floating point operations can reduce the precision of the result.
52
+ * Make sure to do these operations last and not to use the result for further calculations.
44
53
  *
45
54
  * # Parameters
46
- * - `current_sqrt_price`: The current square root price
47
- * - `current_liquidity`: The current liquidity
48
- * - `amount`: The amount
49
- * - `specified_input`: Whether the input is specified
55
+ * * `tick_index` - The tick index to convert
56
+ * * `decimals_a` - The number of decimals of the base token
57
+ * * `decimals_b` - The number of decimals of the quote token
50
58
  *
51
59
  * # Returns
52
- * - `u128`: The next square root price
60
+ * * `f64` - The decimal price
53
61
  */
54
- export function tryGetNextSqrtPriceFromB(current_sqrt_price: bigint, current_liquidity: bigint, amount: bigint, specified_input: boolean): bigint;
62
+ export function tickIndexToPrice(tick_index: number, decimals_a: number, decimals_b: number): number;
55
63
  /**
56
- * Apply a transfer fee to an amount
57
- * e.g. You send 10000 amount with 100 fee rate. The fee amount will be 100.
58
- * So the amount after fee will be 9900.
64
+ * Convert a price into a tick index
65
+ * IMPORTANT: floating point operations can reduce the precision of the result.
66
+ * Make sure to do these operations last and not to use the result for further calculations.
59
67
  *
60
68
  * # Parameters
61
- * - `amount`: The amount to apply the fee to
62
- * - `transfer_fee`: The transfer fee to apply
69
+ * * `price` - The price to convert
70
+ * * `decimals_a` - The number of decimals of the base token
71
+ * * `decimals_b` - The number of decimals of the quote token
63
72
  *
64
73
  * # Returns
65
- * - `u64`: The amount after the fee has been applied
74
+ * * `i32` - The tick index
66
75
  */
67
- export function tryApplyTransferFee(amount: bigint, transfer_fee: TransferFee): bigint;
76
+ export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
68
77
  /**
69
- * Reverse the application of a transfer fee to an amount
70
- * e.g. You received 9900 amount with 100 fee rate. The fee amount will be 100.
71
- * So the amount before fee will be 10000.
78
+ * Computes min/max sqrt-price bounds for slippage protection.
72
79
  *
73
- * # Parameters
74
- * - `amount`: The amount to reverse the fee from
75
- * - `transfer_fee`: The transfer fee to reverse
76
- *
77
- * # Returns
78
- * - `u64`: The amount before the fee has been applied
79
- */
80
- export function tryReverseApplyTransferFee(amount: bigint, transfer_fee: TransferFee): bigint;
81
- /**
82
- * Get the maximum amount with a slippage tolerance
83
- * e.g. Your estimated amount you send is 10000 with 100 slippage tolerance. The max you send will be 10100.
80
+ * Cap: `slippage_tolerance_bps` is clamped to BPS_DENOMINATOR (10_000) so the radicands
81
+ * `(10000 ± bps)` stay non-negative and we never take sqrt of a negative.
84
82
  *
85
83
  * # Parameters
86
- * - `amount`: The amount to apply the fee to
87
- * - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
84
+ * * `sqrt_price` - The current sqrt priceX64
85
+ * * `slippage_tolerance_bps` - The slippage tolerance in basis points
88
86
  *
89
87
  * # Returns
90
- * - `u64`: The maximum amount
88
+ * * `SqrtPriceSlippageBounds` - The min and max sqrt price bounds
91
89
  */
92
- export function tryGetMaxAmountWithSlippageTolerance(amount: bigint, slippage_tolerance_bps: number): bigint;
90
+ export function getSqrtPriceSlippageBounds(sqrt_price: bigint, slippage_tolerance_bps: number): SqrtPriceSlippageBounds;
91
+ export function _POSITION_BUNDLE_SIZE(): number;
92
+ export function _FEE_RATE_DENOMINATOR(): number;
93
93
  /**
94
- * Get the minimum amount with a slippage tolerance
95
- * e.g. Your estimated amount you receive is 10000 with 100 slippage tolerance. The min amount you receive will be 9900.
94
+ * Check if a position is in range.
95
+ * When a position is in range it is earning fees and rewards
96
96
  *
97
97
  * # Parameters
98
- * - `amount`: The amount to apply the fee to
99
- * - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
98
+ * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
99
+ * - `tick_index_1` - A i32 integer representing the first tick index of the position
100
+ * - `tick_index_2` - A i32 integer representing the second tick index of the position
100
101
  *
101
102
  * # Returns
102
- * - `u64`: The minimum amount
103
+ * - A boolean value indicating if the position is in range
103
104
  */
104
- export function tryGetMinAmountWithSlippageTolerance(amount: bigint, slippage_tolerance_bps: number): bigint;
105
+ export function isPositionInRange(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): boolean;
105
106
  /**
106
- * Apply a swap fee to an amount
107
- * e.g. You send 10000 amount with 10000 fee rate. The fee amount will be 100.
108
- * So the amount after fee will be 9900.
107
+ * Calculate the status of a position
108
+ * The status can be one of three values:
109
+ * - InRange: The position is in range
110
+ * - BelowRange: The position is below the range
111
+ * - AboveRange: The position is above the range
109
112
  *
110
113
  * # Parameters
111
- * - `amount`: The amount to apply the fee to
112
- * - `fee_rate`: The fee rate to apply denominated in 1e6
114
+ * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
115
+ * - `tick_index_1` - A i32 integer representing the first tick index of the position
116
+ * - `tick_index_2` - A i32 integer representing the second tick index of the position
113
117
  *
114
118
  * # Returns
115
- * - `u64`: The amount after the fee has been applied
119
+ * - A PositionStatus enum value indicating the status of the position
116
120
  */
117
- export function tryApplySwapFee(amount: bigint, fee_rate: number): bigint;
121
+ export function positionStatus(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionStatus;
118
122
  /**
119
- * Reverse the application of a swap fee to an amount
120
- * e.g. You received 9900 amount with 10000 fee rate. The fee amount will be 100.
121
- * So the amount before fee will be 10000.
123
+ * Calculate the token_a / token_b ratio of a (ficticious) position
122
124
  *
123
125
  * # Parameters
124
- * - `amount`: The amount to reverse the fee from
125
- * - `fee_rate`: The fee rate to reverse denominated in 1e6
126
- *
127
- * # Returns
128
- * - `u64`: The amount before the fee has been applied
129
- */
130
- export function tryReverseApplySwapFee(amount: bigint, fee_rate: number): bigint;
131
- /**
132
- * Calculate rewards owed for a position
133
- *
134
- * # Paramters
135
- * - `whirlpool`: The whirlpool state
136
- * - `position`: The position state
137
- * - `tick_lower`: The lower tick state
138
- * - `tick_upper`: The upper tick state
139
- * - `current_timestamp`: The current timestamp
140
- * - `transfer_fee_1`: The transfer fee for token 1
141
- * - `transfer_fee_2`: The transfer fee for token 2
142
- * - `transfer_fee_3`: The transfer fee for token 3
126
+ * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
127
+ * - `tick_index_1` - A i32 integer representing the first tick index of the position
128
+ * - `tick_index_2` - A i32 integer representing the second tick index of the position
143
129
  *
144
130
  * # Returns
145
- * - `CollectRewardsQuote`: The rewards owed for the 3 reward tokens.
131
+ * - A PositionRatio struct containing the ratio of token_a and token_b
146
132
  */
147
- export function collectRewardsQuote(whirlpool: WhirlpoolFacade, position: PositionFacade, tick_lower: TickFacade, tick_upper: TickFacade, current_timestamp: bigint, transfer_fee_1?: TransferFee | null, transfer_fee_2?: TransferFee | null, transfer_fee_3?: TransferFee | null): CollectRewardsQuote;
133
+ export function positionRatio(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionRatio;
148
134
  /**
149
135
  * Get the first tick index in the tick array that contains the specified tick index.
150
136
  *
@@ -189,7 +175,7 @@ export function sqrtPriceToTickIndex(sqrt_price: bigint): number;
189
175
  * - `round_up` - A boolean value indicating if the supplied tick index should be rounded up. None will round to the nearest.
190
176
  *
191
177
  * # Returns
192
- * - A i32 integer representing the previous initializable tick index
178
+ * - A i32 representing the initializable tick index (rounded per round_up or nearest).
193
179
  */
194
180
  export function getInitializableTickIndex(tick_index: number, tick_spacing: number, round_up?: boolean | null): number;
195
181
  /**
@@ -305,160 +291,213 @@ export function isFullRangeOnly(tick_spacing: number): boolean;
305
291
  * - A u32 integer representing the tick index in the tick array
306
292
  */
307
293
  export function getTickIndexInArray(tick_index: number, tick_array_start_index: number, tick_spacing: number): number;
308
- export function _VOLATILITY_ACCUMULATOR_SCALE_FACTOR(): number;
309
- export function _REDUCTION_FACTOR_DENOMINATOR(): number;
310
- export function _ADAPTIVE_FEE_CONTROL_FACTOR_DENOMINATOR(): number;
311
- export function _MAX_REFERENCE_AGE(): bigint;
312
- export function _FEE_RATE_HARD_LIMIT(): number;
313
- export function _POSITION_BUNDLE_SIZE(): number;
314
- export function _NUM_REWARDS(): number;
315
- export function _FEE_RATE_DENOMINATOR(): number;
316
- export function _TICK_ARRAY_SIZE(): number;
317
- export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD(): number;
318
- export function _MIN_TICK_INDEX(): number;
319
- export function _MAX_TICK_INDEX(): number;
320
294
  /**
321
- * Get the first unoccupied position in a bundle
295
+ * Calculate the amount A delta between two sqrt_prices
322
296
  *
323
- * # Arguments
324
- * * `bundle` - The bundle to check
297
+ * # Parameters
298
+ * - `sqrt_price_1`: The first square root price
299
+ * - `sqrt_price_2`: The second square root price
300
+ * - `liquidity`: The liquidity
301
+ * - `round_up`: Whether to round up or not
325
302
  *
326
303
  * # Returns
327
- * * `u32` - The first unoccupied position (None if full)
304
+ * - `u64`: The amount delta
328
305
  */
329
- export function firstUnoccupiedPositionInBundle(bitmap: Uint8Array): number | undefined;
306
+ export function tryGetAmountDeltaA(sqrt_price_1: bigint, sqrt_price_2: bigint, liquidity: bigint, round_up: boolean): bigint;
330
307
  /**
331
- * Check whether a position bundle is full
332
- * A position bundle can contain 256 positions
308
+ * Calculate the amount B delta between two sqrt_prices
333
309
  *
334
- * # Arguments
335
- * * `bundle` - The bundle to check
310
+ * # Parameters
311
+ * - `sqrt_price_1`: The first square root price
312
+ * - `sqrt_price_2`: The second square root price
313
+ * - `liquidity`: The liquidity
314
+ * - `round_up`: Whether to round up or not
336
315
  *
337
316
  * # Returns
338
- * * `bool` - Whether the bundle is full
317
+ * - `u64`: The amount delta
339
318
  */
340
- export function isPositionBundleFull(bitmap: Uint8Array): boolean;
319
+ export function tryGetAmountDeltaB(sqrt_price_1: bigint, sqrt_price_2: bigint, liquidity: bigint, round_up: boolean): bigint;
341
320
  /**
342
- * Check whether a position bundle is empty
321
+ * Calculate the next square root price
343
322
  *
344
- * # Arguments
345
- * * `bundle` - The bundle to check
323
+ * # Parameters
324
+ * - `current_sqrt_price`: The current square root price
325
+ * - `current_liquidity`: The current liquidity
326
+ * - `amount`: The amount
327
+ * - `specified_input`: Whether the input is specified
346
328
  *
347
329
  * # Returns
348
- * * `bool` - Whether the bundle is empty
330
+ * - `u128`: The next square root price
349
331
  */
350
- export function isPositionBundleEmpty(bitmap: Uint8Array): boolean;
332
+ export function tryGetNextSqrtPriceFromA(current_sqrt_price: bigint, current_liquidity: bigint, amount: bigint, specified_input: boolean): bigint;
351
333
  /**
352
- * Check if a position is in range.
353
- * When a position is in range it is earning fees and rewards
334
+ * Calculate the next square root price
354
335
  *
355
336
  * # Parameters
356
- * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
357
- * - `tick_index_1` - A i32 integer representing the first tick index of the position
358
- * - `tick_index_2` - A i32 integer representing the second tick index of the position
337
+ * - `current_sqrt_price`: The current square root price
338
+ * - `current_liquidity`: The current liquidity
339
+ * - `amount`: The amount
340
+ * - `specified_input`: Whether the input is specified
359
341
  *
360
342
  * # Returns
361
- * - A boolean value indicating if the position is in range
343
+ * - `u128`: The next square root price
362
344
  */
363
- export function isPositionInRange(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): boolean;
345
+ export function tryGetNextSqrtPriceFromB(current_sqrt_price: bigint, current_liquidity: bigint, amount: bigint, specified_input: boolean): bigint;
364
346
  /**
365
- * Calculate the status of a position
366
- * The status can be one of three values:
367
- * - InRange: The position is in range
368
- * - BelowRange: The position is below the range
369
- * - AboveRange: The position is above the range
347
+ * Apply a transfer fee to an amount
348
+ * e.g. You send 10000 amount with 100 fee rate. The fee amount will be 100.
349
+ * So the amount after fee will be 9900.
370
350
  *
371
351
  * # Parameters
372
- * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
373
- * - `tick_index_1` - A i32 integer representing the first tick index of the position
374
- * - `tick_index_2` - A i32 integer representing the second tick index of the position
352
+ * - `amount`: The amount to apply the fee to
353
+ * - `transfer_fee`: The transfer fee to apply
375
354
  *
376
355
  * # Returns
377
- * - A PositionStatus enum value indicating the status of the position
356
+ * - `u64`: The amount after the fee has been applied
378
357
  */
379
- export function positionStatus(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionStatus;
358
+ export function tryApplyTransferFee(amount: bigint, transfer_fee: TransferFee): bigint;
380
359
  /**
381
- * Calculate the token_a / token_b ratio of a (ficticious) position
360
+ * Reverse the application of a transfer fee to an amount
361
+ * e.g. You received 9900 amount with 100 fee rate. The fee amount will be 100.
362
+ * So the amount before fee will be 10000.
382
363
  *
383
364
  * # Parameters
384
- * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
385
- * - `tick_index_1` - A i32 integer representing the first tick index of the position
386
- * - `tick_index_2` - A i32 integer representing the second tick index of the position
365
+ * - `amount`: The amount to reverse the fee from
366
+ * - `transfer_fee`: The transfer fee to reverse
387
367
  *
388
368
  * # Returns
389
- * - A PositionRatio struct containing the ratio of token_a and token_b
369
+ * - `u64`: The amount before the fee has been applied
390
370
  */
391
- export function positionRatio(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionRatio;
371
+ export function tryReverseApplyTransferFee(amount: bigint, transfer_fee: TransferFee): bigint;
392
372
  /**
393
- * Convert a price into a sqrt priceX64
394
- * IMPORTANT: floating point operations can reduce the precision of the result.
395
- * Make sure to do these operations last and not to use the result for further calculations.
373
+ * Get the maximum amount with a slippage tolerance
374
+ * e.g. Your estimated amount you send is 10000 with 100 slippage tolerance. The max you send will be 10100.
396
375
  *
397
376
  * # Parameters
398
- * * `price` - The price to convert
399
- * * `decimals_a` - The number of decimals of the base token
400
- * * `decimals_b` - The number of decimals of the quote token
377
+ * - `amount`: The amount to apply the fee to
378
+ * - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
401
379
  *
402
380
  * # Returns
403
- * * `u128` - The sqrt priceX64
381
+ * - `u64`: The maximum amount
404
382
  */
405
- export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
383
+ export function tryGetMaxAmountWithSlippageTolerance(amount: bigint, slippage_tolerance_bps: number): bigint;
406
384
  /**
407
- * Convert a sqrt priceX64 into a tick index
408
- * IMPORTANT: floating point operations can reduce the precision of the result.
409
- * Make sure to do these operations last and not to use the result for further calculations.
385
+ * Get the minimum amount with a slippage tolerance
386
+ * e.g. Your estimated amount you receive is 10000 with 100 slippage tolerance. The min amount you receive will be 9900.
410
387
  *
411
388
  * # Parameters
412
- * * `sqrt_price` - The sqrt priceX64 to convert
413
- * * `decimals_a` - The number of decimals of the base token
414
- * * `decimals_b` - The number of decimals of the quote token
389
+ * - `amount`: The amount to apply the fee to
390
+ * - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
415
391
  *
416
392
  * # Returns
417
- * * `f64` - The decimal price
393
+ * - `u64`: The minimum amount
418
394
  */
419
- export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
395
+ export function tryGetMinAmountWithSlippageTolerance(amount: bigint, slippage_tolerance_bps: number): bigint;
420
396
  /**
421
- * Invert a price
422
- * IMPORTANT: floating point operations can reduce the precision of the result.
423
- * Make sure to do these operations last and not to use the result for further calculations.
397
+ * Apply a swap fee to an amount
398
+ * e.g. You send 10000 amount with 10000 fee rate. The fee amount will be 100.
399
+ * So the amount after fee will be 9900.
424
400
  *
425
401
  * # Parameters
426
- * * `price` - The price to invert
427
- * * `decimals_a` - The number of decimals of the base token
428
- * * `decimals_b` - The number of decimals of the quote token
402
+ * - `amount`: The amount to apply the fee to
403
+ * - `fee_rate`: The fee rate to apply denominated in 1e6
429
404
  *
430
405
  * # Returns
431
- * * `f64` - The inverted price
406
+ * - `u64`: The amount after the fee has been applied
432
407
  */
433
- export function invertPrice(price: number, decimals_a: number, decimals_b: number): number;
408
+ export function tryApplySwapFee(amount: bigint, fee_rate: number): bigint;
434
409
  /**
435
- * Convert a tick index into a price
436
- * IMPORTANT: floating point operations can reduce the precision of the result.
437
- * Make sure to do these operations last and not to use the result for further calculations.
410
+ * Reverse the application of a swap fee to an amount
411
+ * e.g. You received 9900 amount with 10000 fee rate. The fee amount will be 100.
412
+ * So the amount before fee will be 10000.
438
413
  *
439
414
  * # Parameters
440
- * * `tick_index` - The tick index to convert
441
- * * `decimals_a` - The number of decimals of the base token
442
- * * `decimals_b` - The number of decimals of the quote token
415
+ * - `amount`: The amount to reverse the fee from
416
+ * - `fee_rate`: The fee rate to reverse denominated in 1e6
443
417
  *
444
418
  * # Returns
445
- * * `f64` - The decimal price
419
+ * - `u64`: The amount before the fee has been applied
446
420
  */
447
- export function tickIndexToPrice(tick_index: number, decimals_a: number, decimals_b: number): number;
421
+ export function tryReverseApplySwapFee(amount: bigint, fee_rate: number): bigint;
448
422
  /**
449
- * Convert a price into a tick index
450
- * IMPORTANT: floating point operations can reduce the precision of the result.
451
- * Make sure to do these operations last and not to use the result for further calculations.
423
+ * Calculate fees owed for a position
452
424
  *
453
- * # Parameters
454
- * * `price` - The price to convert
455
- * * `decimals_a` - The number of decimals of the base token
456
- * * `decimals_b` - The number of decimals of the quote token
425
+ * # Paramters
426
+ * - `whirlpool`: The whirlpool state
427
+ * - `position`: The position state
428
+ * - `tick_lower`: The lower tick state
429
+ * - `tick_upper`: The upper tick state
430
+ * - `transfer_fee_a`: The transfer fee for token A
431
+ * - `transfer_fee_b`: The transfer fee for token B
457
432
  *
458
433
  * # Returns
459
- * * `i32` - The tick index
434
+ * - `CollectFeesQuote`: The fees owed for token A and token B
460
435
  */
461
- export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
436
+ export function collectFeesQuote(whirlpool: WhirlpoolFacade, position: PositionFacade, tick_lower: TickFacade, tick_upper: TickFacade, transfer_fee_a?: TransferFee | null, transfer_fee_b?: TransferFee | null): CollectFeesQuote;
437
+ export function _NUM_REWARDS(): number;
438
+ /**
439
+ * Check if the whirlpool is initialized with adaptive fee
440
+ *
441
+ * # Paramters
442
+ * - `whirlpool`: The whirlpool state
443
+ *
444
+ * # Returns
445
+ * - A boolean value indicating if the whirlpool is initialized with adaptive fee
446
+ */
447
+ export function isInitializedWithAdaptiveFee(whirlpool: WhirlpoolFacade): boolean;
448
+ /**
449
+ * Calculate rewards owed for a position
450
+ *
451
+ * # Paramters
452
+ * - `whirlpool`: The whirlpool state
453
+ * - `position`: The position state
454
+ * - `tick_lower`: The lower tick state
455
+ * - `tick_upper`: The upper tick state
456
+ * - `current_timestamp`: The current timestamp
457
+ * - `transfer_fee_1`: The transfer fee for token 1
458
+ * - `transfer_fee_2`: The transfer fee for token 2
459
+ * - `transfer_fee_3`: The transfer fee for token 3
460
+ *
461
+ * # Returns
462
+ * - `CollectRewardsQuote`: The rewards owed for the 3 reward tokens.
463
+ */
464
+ export function collectRewardsQuote(whirlpool: WhirlpoolFacade, position: PositionFacade, tick_lower: TickFacade, tick_upper: TickFacade, current_timestamp: bigint, transfer_fee_1?: TransferFee | null, transfer_fee_2?: TransferFee | null, transfer_fee_3?: TransferFee | null): CollectRewardsQuote;
465
+ /**
466
+ * Get the first unoccupied position in a bundle
467
+ *
468
+ * # Arguments
469
+ * * `bundle` - The bundle to check
470
+ *
471
+ * # Returns
472
+ * * `u32` - The first unoccupied position (None if full)
473
+ */
474
+ export function firstUnoccupiedPositionInBundle(bitmap: Uint8Array): number | undefined;
475
+ /**
476
+ * Check whether a position bundle is full
477
+ * A position bundle can contain 256 positions
478
+ *
479
+ * # Arguments
480
+ * * `bundle` - The bundle to check
481
+ *
482
+ * # Returns
483
+ * * `bool` - Whether the bundle is full
484
+ */
485
+ export function isPositionBundleFull(bitmap: Uint8Array): boolean;
486
+ /**
487
+ * Check whether a position bundle is empty
488
+ *
489
+ * # Arguments
490
+ * * `bundle` - The bundle to check
491
+ *
492
+ * # Returns
493
+ * * `bool` - Whether the bundle is empty
494
+ */
495
+ export function isPositionBundleEmpty(bitmap: Uint8Array): boolean;
496
+ export function _VOLATILITY_ACCUMULATOR_SCALE_FACTOR(): number;
497
+ export function _REDUCTION_FACTOR_DENOMINATOR(): number;
498
+ export function _ADAPTIVE_FEE_CONTROL_FACTOR_DENOMINATOR(): number;
499
+ export function _MAX_REFERENCE_AGE(): bigint;
500
+ export function _FEE_RATE_HARD_LIMIT(): number;
462
501
  export function _TICK_ARRAY_NOT_EVENLY_SPACED(): string;
463
502
  export function _TICK_INDEX_OUT_OF_BOUNDS(): string;
464
503
  export function _INVALID_TICK_INDEX(): string;
@@ -475,16 +514,6 @@ export function _INVALID_SLIPPAGE_TOLERANCE(): string;
475
514
  export function _TICK_INDEX_NOT_IN_ARRAY(): string;
476
515
  export function _INVALID_TICK_ARRAY_SEQUENCE(): string;
477
516
  export function _INVALID_ADAPTIVE_FEE_INFO(): string;
478
- /**
479
- * Check if the whirlpool is initialized with adaptive fee
480
- *
481
- * # Paramters
482
- * - `whirlpool`: The whirlpool state
483
- *
484
- * # Returns
485
- * - A boolean value indicating if the whirlpool is initialized with adaptive fee
486
- */
487
- export function isInitializedWithAdaptiveFee(whirlpool: WhirlpoolFacade): boolean;
488
517
  /**
489
518
  * Computes the exact input or output amount for a swap transaction.
490
519
  *
@@ -521,21 +550,6 @@ export function swapQuoteByInputToken(token_in: bigint, specified_token_a: boole
521
550
  * The exact input or output amount for the swap transaction.
522
551
  */
523
552
  export function swapQuoteByOutputToken(token_out: bigint, specified_token_a: boolean, slippage_tolerance_bps: number, whirlpool: WhirlpoolFacade, oracle: OracleFacade | null | undefined, tick_arrays: TickArrayFacade[], timestamp: bigint, transfer_fee_a?: TransferFee | null, transfer_fee_b?: TransferFee | null): ExactOutSwapQuote;
524
- /**
525
- * Calculate fees owed for a position
526
- *
527
- * # Paramters
528
- * - `whirlpool`: The whirlpool state
529
- * - `position`: The position state
530
- * - `tick_lower`: The lower tick state
531
- * - `tick_upper`: The upper tick state
532
- * - `transfer_fee_a`: The transfer fee for token A
533
- * - `transfer_fee_b`: The transfer fee for token B
534
- *
535
- * # Returns
536
- * - `CollectFeesQuote`: The fees owed for token A and token B
537
- */
538
- export function collectFeesQuote(whirlpool: WhirlpoolFacade, position: PositionFacade, tick_lower: TickFacade, tick_upper: TickFacade, transfer_fee_a?: TransferFee | null, transfer_fee_b?: TransferFee | null): CollectFeesQuote;
539
553
  /**
540
554
  * Calculate the quote for decreasing liquidity
541
555
  *
@@ -650,6 +664,14 @@ export interface ExactInSwapQuote {
650
664
  tradeFeeRateMax: number;
651
665
  }
652
666
 
667
+ export interface CollectRewardQuote {
668
+ rewardsOwed: bigint;
669
+ }
670
+
671
+ export interface CollectRewardsQuote {
672
+ rewards: CollectRewardQuote[];
673
+ }
674
+
653
675
  export interface IncreaseLiquidityQuote {
654
676
  liquidityDelta: bigint;
655
677
  tokenEstA: bigint;
@@ -666,12 +688,9 @@ export interface DecreaseLiquidityQuote {
666
688
  tokenMinB: bigint;
667
689
  }
668
690
 
669
- export interface CollectRewardQuote {
670
- rewardsOwed: bigint;
671
- }
672
-
673
- export interface CollectRewardsQuote {
674
- rewards: CollectRewardQuote[];
691
+ export interface SqrtPriceSlippageBounds {
692
+ minSqrtPrice: bigint;
693
+ maxSqrtPrice: bigint;
675
694
  }
676
695
 
677
696
  export interface TransferFee {
@@ -679,30 +698,6 @@ export interface TransferFee {
679
698
  maxFee: bigint;
680
699
  }
681
700
 
682
- export interface CollectFeesQuote {
683
- feeOwedA: bigint;
684
- feeOwedB: bigint;
685
- }
686
-
687
- export interface TickArrayFacade {
688
- startTickIndex: number;
689
- ticks: TickFacade[];
690
- }
691
-
692
- export interface TickFacade {
693
- initialized: boolean;
694
- liquidityNet: bigint;
695
- liquidityGross: bigint;
696
- feeGrowthOutsideA: bigint;
697
- feeGrowthOutsideB: bigint;
698
- rewardGrowthsOutside: bigint[];
699
- }
700
-
701
- export interface TickRange {
702
- tickLowerIndex: number;
703
- tickUpperIndex: number;
704
- }
705
-
706
701
  export interface PositionRewardInfoFacade {
707
702
  growthInsideCheckpoint: bigint;
708
703
  amountOwed: bigint;
@@ -726,6 +721,25 @@ export interface PositionRatio {
726
721
  ratioB: number;
727
722
  }
728
723
 
724
+ export interface TickArrayFacade {
725
+ startTickIndex: number;
726
+ ticks: TickFacade[];
727
+ }
728
+
729
+ export interface TickFacade {
730
+ initialized: boolean;
731
+ liquidityNet: bigint;
732
+ liquidityGross: bigint;
733
+ feeGrowthOutsideA: bigint;
734
+ feeGrowthOutsideB: bigint;
735
+ rewardGrowthsOutside: bigint[];
736
+ }
737
+
738
+ export interface TickRange {
739
+ tickLowerIndex: number;
740
+ tickUpperIndex: number;
741
+ }
742
+
729
743
  export interface WhirlpoolRewardInfoFacade {
730
744
  emissionsPerSecondX64: bigint;
731
745
  growthGlobalX64: bigint;
@@ -774,3 +788,8 @@ export interface OracleFacade {
774
788
  adaptiveFeeVariables: AdaptiveFeeVariablesFacade;
775
789
  }
776
790
 
791
+ export interface CollectFeesQuote {
792
+ feeOwedA: bigint;
793
+ feeOwedB: bigint;
794
+ }
795
+