@orca-so/whirlpools-core 1.0.4 → 2.0.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,5 +1,191 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ /**
4
+ * Check if the whirlpool is initialized with adaptive fee
5
+ *
6
+ * # Paramters
7
+ * - `whirlpool`: The whirlpool state
8
+ *
9
+ * # Returns
10
+ * - A boolean value indicating if the whirlpool is initialized with adaptive fee
11
+ */
12
+ export function isInitializedWithAdaptiveFee(whirlpool: WhirlpoolFacade): boolean;
13
+ /**
14
+ * Calculate the amount A delta between two sqrt_prices
15
+ *
16
+ * # Parameters
17
+ * - `sqrt_price_1`: The first square root price
18
+ * - `sqrt_price_2`: The second square root price
19
+ * - `liquidity`: The liquidity
20
+ * - `round_up`: Whether to round up or not
21
+ *
22
+ * # Returns
23
+ * - `u64`: The amount delta
24
+ */
25
+ export function tryGetAmountDeltaA(sqrt_price_1: bigint, sqrt_price_2: bigint, liquidity: bigint, round_up: boolean): bigint;
26
+ /**
27
+ * Calculate the amount B delta between two sqrt_prices
28
+ *
29
+ * # Parameters
30
+ * - `sqrt_price_1`: The first square root price
31
+ * - `sqrt_price_2`: The second square root price
32
+ * - `liquidity`: The liquidity
33
+ * - `round_up`: Whether to round up or not
34
+ *
35
+ * # Returns
36
+ * - `u64`: The amount delta
37
+ */
38
+ export function tryGetAmountDeltaB(sqrt_price_1: bigint, sqrt_price_2: bigint, liquidity: bigint, round_up: boolean): bigint;
39
+ /**
40
+ * Calculate the next square root price
41
+ *
42
+ * # Parameters
43
+ * - `current_sqrt_price`: The current square root price
44
+ * - `current_liquidity`: The current liquidity
45
+ * - `amount`: The amount
46
+ * - `specified_input`: Whether the input is specified
47
+ *
48
+ * # Returns
49
+ * - `u128`: The next square root price
50
+ */
51
+ export function tryGetNextSqrtPriceFromA(current_sqrt_price: bigint, current_liquidity: bigint, amount: bigint, specified_input: boolean): bigint;
52
+ /**
53
+ * Calculate the next square root price
54
+ *
55
+ * # Parameters
56
+ * - `current_sqrt_price`: The current square root price
57
+ * - `current_liquidity`: The current liquidity
58
+ * - `amount`: The amount
59
+ * - `specified_input`: Whether the input is specified
60
+ *
61
+ * # Returns
62
+ * - `u128`: The next square root price
63
+ */
64
+ export function tryGetNextSqrtPriceFromB(current_sqrt_price: bigint, current_liquidity: bigint, amount: bigint, specified_input: boolean): bigint;
65
+ /**
66
+ * Apply a transfer fee to an amount
67
+ * e.g. You send 10000 amount with 100 fee rate. The fee amount will be 100.
68
+ * So the amount after fee will be 9900.
69
+ *
70
+ * # Parameters
71
+ * - `amount`: The amount to apply the fee to
72
+ * - `transfer_fee`: The transfer fee to apply
73
+ *
74
+ * # Returns
75
+ * - `u64`: The amount after the fee has been applied
76
+ */
77
+ export function tryApplyTransferFee(amount: bigint, transfer_fee: TransferFee): bigint;
78
+ /**
79
+ * Reverse the application of a transfer fee to an amount
80
+ * e.g. You received 9900 amount with 100 fee rate. The fee amount will be 100.
81
+ * So the amount before fee will be 10000.
82
+ *
83
+ * # Parameters
84
+ * - `amount`: The amount to reverse the fee from
85
+ * - `transfer_fee`: The transfer fee to reverse
86
+ *
87
+ * # Returns
88
+ * - `u64`: The amount before the fee has been applied
89
+ */
90
+ export function tryReverseApplyTransferFee(amount: bigint, transfer_fee: TransferFee): bigint;
91
+ /**
92
+ * Get the maximum amount with a slippage tolerance
93
+ * e.g. Your estimated amount you send is 10000 with 100 slippage tolerance. The max you send will be 10100.
94
+ *
95
+ * # Parameters
96
+ * - `amount`: The amount to apply the fee to
97
+ * - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
98
+ *
99
+ * # Returns
100
+ * - `u64`: The maximum amount
101
+ */
102
+ export function tryGetMaxAmountWithSlippageTolerance(amount: bigint, slippage_tolerance_bps: number): bigint;
103
+ /**
104
+ * Get the minimum amount with a slippage tolerance
105
+ * e.g. Your estimated amount you receive is 10000 with 100 slippage tolerance. The min amount you receive will be 9900.
106
+ *
107
+ * # Parameters
108
+ * - `amount`: The amount to apply the fee to
109
+ * - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
110
+ *
111
+ * # Returns
112
+ * - `u64`: The minimum amount
113
+ */
114
+ export function tryGetMinAmountWithSlippageTolerance(amount: bigint, slippage_tolerance_bps: number): bigint;
115
+ /**
116
+ * Apply a swap fee to an amount
117
+ * e.g. You send 10000 amount with 10000 fee rate. The fee amount will be 100.
118
+ * So the amount after fee will be 9900.
119
+ *
120
+ * # Parameters
121
+ * - `amount`: The amount to apply the fee to
122
+ * - `fee_rate`: The fee rate to apply denominated in 1e6
123
+ *
124
+ * # Returns
125
+ * - `u64`: The amount after the fee has been applied
126
+ */
127
+ export function tryApplySwapFee(amount: bigint, fee_rate: number): bigint;
128
+ /**
129
+ * Reverse the application of a swap fee to an amount
130
+ * e.g. You received 9900 amount with 10000 fee rate. The fee amount will be 100.
131
+ * So the amount before fee will be 10000.
132
+ *
133
+ * # Parameters
134
+ * - `amount`: The amount to reverse the fee from
135
+ * - `fee_rate`: The fee rate to reverse denominated in 1e6
136
+ *
137
+ * # Returns
138
+ * - `u64`: The amount before the fee has been applied
139
+ */
140
+ export function tryReverseApplySwapFee(amount: bigint, fee_rate: number): bigint;
141
+ /**
142
+ * Calculate rewards owed for a position
143
+ *
144
+ * # Paramters
145
+ * - `whirlpool`: The whirlpool state
146
+ * - `position`: The position state
147
+ * - `tick_lower`: The lower tick state
148
+ * - `tick_upper`: The upper tick state
149
+ * - `current_timestamp`: The current timestamp
150
+ * - `transfer_fee_1`: The transfer fee for token 1
151
+ * - `transfer_fee_2`: The transfer fee for token 2
152
+ * - `transfer_fee_3`: The transfer fee for token 3
153
+ *
154
+ * # Returns
155
+ * - `CollectRewardsQuote`: The rewards owed for the 3 reward tokens.
156
+ */
157
+ 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;
158
+ /**
159
+ * Get the first unoccupied position in a bundle
160
+ *
161
+ * # Arguments
162
+ * * `bundle` - The bundle to check
163
+ *
164
+ * # Returns
165
+ * * `u32` - The first unoccupied position (None if full)
166
+ */
167
+ export function firstUnoccupiedPositionInBundle(bitmap: Uint8Array): number | undefined;
168
+ /**
169
+ * Check whether a position bundle is full
170
+ * A position bundle can contain 256 positions
171
+ *
172
+ * # Arguments
173
+ * * `bundle` - The bundle to check
174
+ *
175
+ * # Returns
176
+ * * `bool` - Whether the bundle is full
177
+ */
178
+ export function isPositionBundleFull(bitmap: Uint8Array): boolean;
179
+ /**
180
+ * Check whether a position bundle is empty
181
+ *
182
+ * # Arguments
183
+ * * `bundle` - The bundle to check
184
+ *
185
+ * # Returns
186
+ * * `bool` - Whether the bundle is empty
187
+ */
188
+ export function isPositionBundleEmpty(bitmap: Uint8Array): boolean;
3
189
  /**
4
190
  * Get the first tick index in the tick array that contains the specified tick index.
5
191
  *
@@ -146,126 +332,24 @@ export function orderTickIndexes(tick_index_1: number, tick_index_2: number): Ti
146
332
  * # Returns
147
333
  * - A boolean value indicating if the whirlpool is a full-range only pool
148
334
  */
149
- export function isFullRangeOnly(tick_spacing: number): boolean;
150
- /**
151
- * Get the index of a tick in a tick array.
152
- *
153
- * # Parameters
154
- * - `tick_index` - A i32 integer representing the tick index
155
- * - `tick_array_start_index` - A i32 integer representing the start tick index of the tick array
156
- * - `tick_spacing` - A u16 integer representing the tick spacing
157
- *
158
- * # Returns
159
- * - A u32 integer representing the tick index in the tick array
160
- */
161
- export function getTickIndexInArray(tick_index: number, tick_array_start_index: number, tick_spacing: number): number;
162
- export function _FEE_RATE_DENOMINATOR(): number;
163
- export function _TICK_ARRAY_SIZE(): number;
164
- export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD(): number;
165
- export function _MIN_TICK_INDEX(): number;
166
- export function _MAX_TICK_INDEX(): number;
167
- /**
168
- * Get the first unoccupied position in a bundle
169
- *
170
- * # Arguments
171
- * * `bundle` - The bundle to check
172
- *
173
- * # Returns
174
- * * `u32` - The first unoccupied position (None if full)
175
- */
176
- export function firstUnoccupiedPositionInBundle(bitmap: Uint8Array): number | undefined;
177
- /**
178
- * Check whether a position bundle is full
179
- * A position bundle can contain 256 positions
180
- *
181
- * # Arguments
182
- * * `bundle` - The bundle to check
183
- *
184
- * # Returns
185
- * * `bool` - Whether the bundle is full
186
- */
187
- export function isPositionBundleFull(bitmap: Uint8Array): boolean;
188
- /**
189
- * Check whether a position bundle is empty
190
- *
191
- * # Arguments
192
- * * `bundle` - The bundle to check
193
- *
194
- * # Returns
195
- * * `bool` - Whether the bundle is empty
196
- */
197
- export function isPositionBundleEmpty(bitmap: Uint8Array): boolean;
198
- /**
199
- * Convert a price into a sqrt priceX64
200
- * IMPORTANT: floating point operations can reduce the precision of the result.
201
- * Make sure to do these operations last and not to use the result for further calculations.
202
- *
203
- * # Parameters
204
- * * `price` - The price to convert
205
- * * `decimals_a` - The number of decimals of the base token
206
- * * `decimals_b` - The number of decimals of the quote token
207
- *
208
- * # Returns
209
- * * `u128` - The sqrt priceX64
210
- */
211
- export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
212
- /**
213
- * Convert a sqrt priceX64 into a tick index
214
- * IMPORTANT: floating point operations can reduce the precision of the result.
215
- * Make sure to do these operations last and not to use the result for further calculations.
216
- *
217
- * # Parameters
218
- * * `sqrt_price` - The sqrt priceX64 to convert
219
- * * `decimals_a` - The number of decimals of the base token
220
- * * `decimals_b` - The number of decimals of the quote token
221
- *
222
- * # Returns
223
- * * `f64` - The decimal price
224
- */
225
- export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
226
- /**
227
- * Invert a price
228
- * IMPORTANT: floating point operations can reduce the precision of the result.
229
- * Make sure to do these operations last and not to use the result for further calculations.
230
- *
231
- * # Parameters
232
- * * `price` - The price to invert
233
- * * `decimals_a` - The number of decimals of the base token
234
- * * `decimals_b` - The number of decimals of the quote token
235
- *
236
- * # Returns
237
- * * `f64` - The inverted price
238
- */
239
- export function invertPrice(price: number, decimals_a: number, decimals_b: number): number;
240
- /**
241
- * Convert a tick index into a price
242
- * IMPORTANT: floating point operations can reduce the precision of the result.
243
- * Make sure to do these operations last and not to use the result for further calculations.
244
- *
245
- * # Parameters
246
- * * `tick_index` - The tick index to convert
247
- * * `decimals_a` - The number of decimals of the base token
248
- * * `decimals_b` - The number of decimals of the quote token
249
- *
250
- * # Returns
251
- * * `f64` - The decimal price
252
- */
253
- export function tickIndexToPrice(tick_index: number, decimals_a: number, decimals_b: number): number;
335
+ export function isFullRangeOnly(tick_spacing: number): boolean;
254
336
  /**
255
- * Convert a price into a tick index
256
- * IMPORTANT: floating point operations can reduce the precision of the result.
257
- * Make sure to do these operations last and not to use the result for further calculations.
337
+ * Get the index of a tick in a tick array.
258
338
  *
259
339
  * # Parameters
260
- * * `price` - The price to convert
261
- * * `decimals_a` - The number of decimals of the base token
262
- * * `decimals_b` - The number of decimals of the quote token
340
+ * - `tick_index` - A i32 integer representing the tick index
341
+ * - `tick_array_start_index` - A i32 integer representing the start tick index of the tick array
342
+ * - `tick_spacing` - A u16 integer representing the tick spacing
263
343
  *
264
344
  * # Returns
265
- * * `i32` - The tick index
345
+ * - A u32 integer representing the tick index in the tick array
266
346
  */
267
- export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
268
- export function _NUM_REWARDS(): number;
347
+ export function getTickIndexInArray(tick_index: number, tick_array_start_index: number, tick_spacing: number): number;
348
+ export function _VOLATILITY_ACCUMULATOR_SCALE_FACTOR(): number;
349
+ export function _REDUCTION_FACTOR_DENOMINATOR(): number;
350
+ export function _ADAPTIVE_FEE_CONTROL_FACTOR_DENOMINATOR(): number;
351
+ export function _MAX_REFERENCE_AGE(): bigint;
352
+ export function _FEE_RATE_HARD_LIMIT(): number;
269
353
  export function _POSITION_BUNDLE_SIZE(): number;
270
354
  export function _TICK_ARRAY_NOT_EVENLY_SPACED(): string;
271
355
  export function _TICK_INDEX_OUT_OF_BOUNDS(): string;
@@ -281,6 +365,14 @@ export function _INVALID_TIMESTAMP(): string;
281
365
  export function _INVALID_TRANSFER_FEE(): string;
282
366
  export function _INVALID_SLIPPAGE_TOLERANCE(): string;
283
367
  export function _TICK_INDEX_NOT_IN_ARRAY(): string;
368
+ export function _INVALID_TICK_ARRAY_SEQUENCE(): string;
369
+ export function _INVALID_ADAPTIVE_FEE_INFO(): string;
370
+ export function _NUM_REWARDS(): number;
371
+ export function _FEE_RATE_DENOMINATOR(): number;
372
+ export function _TICK_ARRAY_SIZE(): number;
373
+ export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD(): number;
374
+ export function _MIN_TICK_INDEX(): number;
375
+ export function _MAX_TICK_INDEX(): number;
284
376
  /**
285
377
  * Check if a position is in range.
286
378
  * When a position is in range it is earning fees and rewards
@@ -323,133 +415,75 @@ export function positionStatus(current_sqrt_price: bigint, tick_index_1: number,
323
415
  */
324
416
  export function positionRatio(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionRatio;
325
417
  /**
326
- * Calculate the amount A delta between two sqrt_prices
327
- *
328
- * # Parameters
329
- * - `sqrt_price_1`: The first square root price
330
- * - `sqrt_price_2`: The second square root price
331
- * - `liquidity`: The liquidity
332
- * - `round_up`: Whether to round up or not
333
- *
334
- * # Returns
335
- * - `u64`: The amount delta
336
- */
337
- export function tryGetAmountDeltaA(sqrt_price_1: bigint, sqrt_price_2: bigint, liquidity: bigint, round_up: boolean): bigint;
338
- /**
339
- * Calculate the amount B delta between two sqrt_prices
340
- *
341
- * # Parameters
342
- * - `sqrt_price_1`: The first square root price
343
- * - `sqrt_price_2`: The second square root price
344
- * - `liquidity`: The liquidity
345
- * - `round_up`: Whether to round up or not
346
- *
347
- * # Returns
348
- * - `u64`: The amount delta
349
- */
350
- export function tryGetAmountDeltaB(sqrt_price_1: bigint, sqrt_price_2: bigint, liquidity: bigint, round_up: boolean): bigint;
351
- /**
352
- * Calculate the next square root price
353
- *
354
- * # Parameters
355
- * - `current_sqrt_price`: The current square root price
356
- * - `current_liquidity`: The current liquidity
357
- * - `amount`: The amount
358
- * - `specified_input`: Whether the input is specified
359
- *
360
- * # Returns
361
- * - `u128`: The next square root price
362
- */
363
- export function tryGetNextSqrtPriceFromA(current_sqrt_price: bigint, current_liquidity: bigint, amount: bigint, specified_input: boolean): bigint;
364
- /**
365
- * Calculate the next square root price
366
- *
367
- * # Parameters
368
- * - `current_sqrt_price`: The current square root price
369
- * - `current_liquidity`: The current liquidity
370
- * - `amount`: The amount
371
- * - `specified_input`: Whether the input is specified
372
- *
373
- * # Returns
374
- * - `u128`: The next square root price
375
- */
376
- export function tryGetNextSqrtPriceFromB(current_sqrt_price: bigint, current_liquidity: bigint, amount: bigint, specified_input: boolean): bigint;
377
- /**
378
- * Apply a transfer fee to an amount
379
- * e.g. You send 10000 amount with 100 fee rate. The fee amount will be 100.
380
- * So the amount after fee will be 9900.
381
- *
382
- * # Parameters
383
- * - `amount`: The amount to apply the fee to
384
- * - `transfer_fee`: The transfer fee to apply
385
- *
386
- * # Returns
387
- * - `u64`: The amount after the fee has been applied
388
- */
389
- export function tryApplyTransferFee(amount: bigint, transfer_fee: TransferFee): bigint;
390
- /**
391
- * Reverse the application of a transfer fee to an amount
392
- * e.g. You received 9900 amount with 100 fee rate. The fee amount will be 100.
393
- * So the amount before fee will be 10000.
418
+ * Convert a price into a sqrt priceX64
419
+ * IMPORTANT: floating point operations can reduce the precision of the result.
420
+ * Make sure to do these operations last and not to use the result for further calculations.
394
421
  *
395
422
  * # Parameters
396
- * - `amount`: The amount to reverse the fee from
397
- * - `transfer_fee`: The transfer fee to reverse
423
+ * * `price` - The price to convert
424
+ * * `decimals_a` - The number of decimals of the base token
425
+ * * `decimals_b` - The number of decimals of the quote token
398
426
  *
399
427
  * # Returns
400
- * - `u64`: The amount before the fee has been applied
428
+ * * `u128` - The sqrt priceX64
401
429
  */
402
- export function tryReverseApplyTransferFee(amount: bigint, transfer_fee: TransferFee): bigint;
430
+ export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
403
431
  /**
404
- * Get the maximum amount with a slippage tolerance
405
- * e.g. Your estimated amount you send is 10000 with 100 slippage tolerance. The max you send will be 10100.
432
+ * Convert a sqrt priceX64 into a tick index
433
+ * IMPORTANT: floating point operations can reduce the precision of the result.
434
+ * Make sure to do these operations last and not to use the result for further calculations.
406
435
  *
407
436
  * # Parameters
408
- * - `amount`: The amount to apply the fee to
409
- * - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
437
+ * * `sqrt_price` - The sqrt priceX64 to convert
438
+ * * `decimals_a` - The number of decimals of the base token
439
+ * * `decimals_b` - The number of decimals of the quote token
410
440
  *
411
441
  * # Returns
412
- * - `u64`: The maximum amount
442
+ * * `f64` - The decimal price
413
443
  */
414
- export function tryGetMaxAmountWithSlippageTolerance(amount: bigint, slippage_tolerance_bps: number): bigint;
444
+ export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
415
445
  /**
416
- * Get the minimum amount with a slippage tolerance
417
- * e.g. Your estimated amount you receive is 10000 with 100 slippage tolerance. The min amount you receive will be 9900.
446
+ * Invert a price
447
+ * IMPORTANT: floating point operations can reduce the precision of the result.
448
+ * Make sure to do these operations last and not to use the result for further calculations.
418
449
  *
419
450
  * # Parameters
420
- * - `amount`: The amount to apply the fee to
421
- * - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
451
+ * * `price` - The price to invert
452
+ * * `decimals_a` - The number of decimals of the base token
453
+ * * `decimals_b` - The number of decimals of the quote token
422
454
  *
423
455
  * # Returns
424
- * - `u64`: The minimum amount
456
+ * * `f64` - The inverted price
425
457
  */
426
- export function tryGetMinAmountWithSlippageTolerance(amount: bigint, slippage_tolerance_bps: number): bigint;
458
+ export function invertPrice(price: number, decimals_a: number, decimals_b: number): number;
427
459
  /**
428
- * Apply a swap fee to an amount
429
- * e.g. You send 10000 amount with 10000 fee rate. The fee amount will be 100.
430
- * So the amount after fee will be 9900.
460
+ * Convert a tick index into a price
461
+ * IMPORTANT: floating point operations can reduce the precision of the result.
462
+ * Make sure to do these operations last and not to use the result for further calculations.
431
463
  *
432
464
  * # Parameters
433
- * - `amount`: The amount to apply the fee to
434
- * - `fee_rate`: The fee rate to apply denominated in 1e6
465
+ * * `tick_index` - The tick index to convert
466
+ * * `decimals_a` - The number of decimals of the base token
467
+ * * `decimals_b` - The number of decimals of the quote token
435
468
  *
436
469
  * # Returns
437
- * - `u64`: The amount after the fee has been applied
470
+ * * `f64` - The decimal price
438
471
  */
439
- export function tryApplySwapFee(amount: bigint, fee_rate: number): bigint;
472
+ export function tickIndexToPrice(tick_index: number, decimals_a: number, decimals_b: number): number;
440
473
  /**
441
- * Reverse the application of a swap fee to an amount
442
- * e.g. You received 9900 amount with 10000 fee rate. The fee amount will be 100.
443
- * So the amount before fee will be 10000.
474
+ * Convert a price into a tick index
475
+ * IMPORTANT: floating point operations can reduce the precision of the result.
476
+ * Make sure to do these operations last and not to use the result for further calculations.
444
477
  *
445
478
  * # Parameters
446
- * - `amount`: The amount to reverse the fee from
447
- * - `fee_rate`: The fee rate to reverse denominated in 1e6
479
+ * * `price` - The price to convert
480
+ * * `decimals_a` - The number of decimals of the base token
481
+ * * `decimals_b` - The number of decimals of the quote token
448
482
  *
449
483
  * # Returns
450
- * - `u64`: The amount before the fee has been applied
484
+ * * `i32` - The tick index
451
485
  */
452
- export function tryReverseApplySwapFee(amount: bigint, fee_rate: number): bigint;
486
+ export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
453
487
  /**
454
488
  * Computes the exact input or output amount for a swap transaction.
455
489
  *
@@ -458,14 +492,16 @@ export function tryReverseApplySwapFee(amount: bigint, fee_rate: number): bigint
458
492
  * - `specified_token_a`: If `true`, the input token is token A. Otherwise, it is token B.
459
493
  * - `slippage_tolerance`: The slippage tolerance in basis points.
460
494
  * - `whirlpool`: The whirlpool state.
495
+ * - `oracle`: The oracle data for the whirlpool.
461
496
  * - `tick_arrays`: The tick arrays needed for the swap.
497
+ * - `timestamp`: The timestamp for the swap.
462
498
  * - `transfer_fee_a`: The transfer fee for token A.
463
499
  * - `transfer_fee_b`: The transfer fee for token B.
464
500
  *
465
501
  * # Returns
466
502
  * The exact input or output amount for the swap transaction.
467
503
  */
468
- export function swapQuoteByInputToken(token_in: bigint, specified_token_a: boolean, slippage_tolerance_bps: number, whirlpool: WhirlpoolFacade, tick_arrays: TickArrayFacade[], transfer_fee_a?: TransferFee | null, transfer_fee_b?: TransferFee | null): ExactInSwapQuote;
504
+ export function swapQuoteByInputToken(token_in: 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): ExactInSwapQuote;
469
505
  /**
470
506
  * Computes the exact input or output amount for a swap transaction.
471
507
  *
@@ -474,14 +510,16 @@ export function swapQuoteByInputToken(token_in: bigint, specified_token_a: boole
474
510
  * - `specified_token_a`: If `true`, the output token is token A. Otherwise, it is token B.
475
511
  * - `slippage_tolerance`: The slippage tolerance in basis points.
476
512
  * - `whirlpool`: The whirlpool state.
513
+ * - `oracle`: The oracle data for the whirlpool.
477
514
  * - `tick_arrays`: The tick arrays needed for the swap.
515
+ * - `timestamp`: The timestamp for the swap.
478
516
  * - `transfer_fee_a`: The transfer fee for token A.
479
517
  * - `transfer_fee_b`: The transfer fee for token B.
480
518
  *
481
519
  * # Returns
482
520
  * The exact input or output amount for the swap transaction.
483
521
  */
484
- export function swapQuoteByOutputToken(token_out: bigint, specified_token_a: boolean, slippage_tolerance_bps: number, whirlpool: WhirlpoolFacade, tick_arrays: TickArrayFacade[], transfer_fee_a?: TransferFee | null, transfer_fee_b?: TransferFee | null): ExactOutSwapQuote;
522
+ 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;
485
523
  /**
486
524
  * Calculate fees owed for a position
487
525
  *
@@ -593,28 +631,16 @@ export function increaseLiquidityQuoteA(token_amount_a: bigint, slippage_toleran
593
631
  * - An IncreaseLiquidityQuote struct containing the estimated token amounts
594
632
  */
595
633
  export function increaseLiquidityQuoteB(token_amount_b: bigint, slippage_tolerance_bps: number, current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number, transfer_fee_a?: TransferFee | null, transfer_fee_b?: TransferFee | null): IncreaseLiquidityQuote;
596
- /**
597
- * Calculate rewards owed for a position
598
- *
599
- * # Paramters
600
- * - `whirlpool`: The whirlpool state
601
- * - `position`: The position state
602
- * - `tick_lower`: The lower tick state
603
- * - `tick_upper`: The upper tick state
604
- * - `current_timestamp`: The current timestamp
605
- * - `transfer_fee_1`: The transfer fee for token 1
606
- * - `transfer_fee_2`: The transfer fee for token 2
607
- * - `transfer_fee_3`: The transfer fee for token 3
608
- *
609
- * # Returns
610
- * - `CollectRewardsQuote`: The rewards owed for the 3 reward tokens.
611
- */
612
- 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;
613
634
  export interface TransferFee {
614
635
  feeBps: number;
615
636
  maxFee: bigint;
616
637
  }
617
638
 
639
+ export interface CollectFeesQuote {
640
+ feeOwedA: bigint;
641
+ feeOwedB: bigint;
642
+ }
643
+
618
644
  export interface IncreaseLiquidityQuote {
619
645
  liquidityDelta: bigint;
620
646
  tokenEstA: bigint;
@@ -631,17 +657,22 @@ export interface DecreaseLiquidityQuote {
631
657
  tokenMinB: bigint;
632
658
  }
633
659
 
634
- export interface CollectFeesQuote {
635
- feeOwedA: bigint;
636
- feeOwedB: bigint;
637
- }
638
-
639
- export interface CollectRewardQuote {
640
- rewardsOwed: bigint;
660
+ export interface ExactOutSwapQuote {
661
+ tokenOut: bigint;
662
+ tokenEstIn: bigint;
663
+ tokenMaxIn: bigint;
664
+ tradeFee: bigint;
665
+ tradeFeeRateMin: number;
666
+ tradeFeeRateMax: number;
641
667
  }
642
668
 
643
- export interface CollectRewardsQuote {
644
- rewards: CollectRewardQuote[];
669
+ export interface ExactInSwapQuote {
670
+ tokenIn: bigint;
671
+ tokenEstOut: bigint;
672
+ tokenMinOut: bigint;
673
+ tradeFee: bigint;
674
+ tradeFeeRateMin: number;
675
+ tradeFeeRateMax: number;
645
676
  }
646
677
 
647
678
  export interface TickArrayFacade {
@@ -663,18 +694,27 @@ export interface TickRange {
663
694
  tickUpperIndex: number;
664
695
  }
665
696
 
666
- export interface ExactOutSwapQuote {
667
- tokenOut: bigint;
668
- tokenEstIn: bigint;
669
- tokenMaxIn: bigint;
670
- tradeFee: bigint;
697
+ export interface PositionRewardInfoFacade {
698
+ growthInsideCheckpoint: bigint;
699
+ amountOwed: bigint;
671
700
  }
672
701
 
673
- export interface ExactInSwapQuote {
674
- tokenIn: bigint;
675
- tokenEstOut: bigint;
676
- tokenMinOut: bigint;
677
- tradeFee: bigint;
702
+ export interface PositionFacade {
703
+ liquidity: bigint;
704
+ tickLowerIndex: number;
705
+ tickUpperIndex: number;
706
+ feeGrowthCheckpointA: bigint;
707
+ feeOwedA: bigint;
708
+ feeGrowthCheckpointB: bigint;
709
+ feeOwedB: bigint;
710
+ rewardInfos: PositionRewardInfoFacade[];
711
+ }
712
+
713
+ export type PositionStatus = "priceInRange" | "priceBelowRange" | "priceAboveRange" | "invalid";
714
+
715
+ export interface PositionRatio {
716
+ ratioA: number;
717
+ ratioB: number;
678
718
  }
679
719
 
680
720
  export interface WhirlpoolRewardInfoFacade {
@@ -683,6 +723,7 @@ export interface WhirlpoolRewardInfoFacade {
683
723
  }
684
724
 
685
725
  export interface WhirlpoolFacade {
726
+ feeTierIndexSeed: ReadonlyUint8Array;
686
727
  tickSpacing: number;
687
728
  feeRate: number;
688
729
  protocolFeeRate: number;
@@ -695,26 +736,40 @@ export interface WhirlpoolFacade {
695
736
  rewardInfos: WhirlpoolRewardInfoFacade[];
696
737
  }
697
738
 
698
- export interface PositionRewardInfoFacade {
699
- growthInsideCheckpoint: bigint;
700
- amountOwed: bigint;
739
+ export interface AdaptiveFeeInfo {
740
+ constants: AdaptiveFeeConstantsFacade;
741
+ variables: AdaptiveFeeVariablesFacade;
701
742
  }
702
743
 
703
- export interface PositionFacade {
704
- liquidity: bigint;
705
- tickLowerIndex: number;
706
- tickUpperIndex: number;
707
- feeGrowthCheckpointA: bigint;
708
- feeOwedA: bigint;
709
- feeGrowthCheckpointB: bigint;
710
- feeOwedB: bigint;
711
- rewardInfos: PositionRewardInfoFacade[];
744
+ export interface AdaptiveFeeVariablesFacade {
745
+ lastReferenceUpdateTimestamp: bigint;
746
+ lastMajorSwapTimestamp: bigint;
747
+ volatilityReference: number;
748
+ tickGroupIndexReference: number;
749
+ volatilityAccumulator: number;
712
750
  }
713
751
 
714
- export type PositionStatus = "priceInRange" | "priceBelowRange" | "priceAboveRange" | "invalid";
752
+ export interface AdaptiveFeeConstantsFacade {
753
+ filterPeriod: number;
754
+ decayPeriod: number;
755
+ reductionFactor: number;
756
+ adaptiveFeeControlFactor: number;
757
+ maxVolatilityAccumulator: number;
758
+ tickGroupSize: number;
759
+ majorSwapThresholdTicks: number;
760
+ }
715
761
 
716
- export interface PositionRatio {
717
- ratioA: number;
718
- ratioB: number;
762
+ export interface OracleFacade {
763
+ tradeEnableTimestamp: bigint;
764
+ adaptiveFeeConstants: AdaptiveFeeConstantsFacade;
765
+ adaptiveFeeVariables: AdaptiveFeeVariablesFacade;
766
+ }
767
+
768
+ export interface CollectRewardQuote {
769
+ rewardsOwed: bigint;
770
+ }
771
+
772
+ export interface CollectRewardsQuote {
773
+ rewards: CollectRewardQuote[];
719
774
  }
720
775