@orca-so/whirlpools-core 1.0.4 → 3.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.
- package/dist/browser/orca_whirlpools_core_js_bindings.d.ts +275 -219
- package/dist/browser/orca_whirlpools_core_js_bindings_bg.js +456 -388
- package/dist/browser/orca_whirlpools_core_js_bindings_bg.wasm +0 -0
- package/dist/browser/orca_whirlpools_core_js_bindings_bg.wasm.d.ts +32 -24
- package/dist/browser/package.json +1 -1
- package/dist/nodejs/orca_whirlpools_core_js_bindings.d.ts +275 -219
- package/dist/nodejs/orca_whirlpools_core_js_bindings.js +456 -388
- package/dist/nodejs/orca_whirlpools_core_js_bindings_bg.wasm +0 -0
- package/dist/nodejs/orca_whirlpools_core_js_bindings_bg.wasm.d.ts +32 -24
- package/dist/nodejs/package.json +1 -1
- package/package.json +4 -2
|
@@ -1,5 +1,150 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Calculate the amount A delta between two sqrt_prices
|
|
5
|
+
*
|
|
6
|
+
* # 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
|
|
11
|
+
*
|
|
12
|
+
* # Returns
|
|
13
|
+
* - `u64`: The amount delta
|
|
14
|
+
*/
|
|
15
|
+
export function tryGetAmountDeltaA(sqrt_price_1: bigint, sqrt_price_2: bigint, liquidity: bigint, round_up: boolean): bigint;
|
|
16
|
+
/**
|
|
17
|
+
* Calculate the amount B delta between two sqrt_prices
|
|
18
|
+
*
|
|
19
|
+
* # 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
|
|
24
|
+
*
|
|
25
|
+
* # Returns
|
|
26
|
+
* - `u64`: The amount delta
|
|
27
|
+
*/
|
|
28
|
+
export function tryGetAmountDeltaB(sqrt_price_1: bigint, sqrt_price_2: bigint, liquidity: bigint, round_up: boolean): bigint;
|
|
29
|
+
/**
|
|
30
|
+
* Calculate the next square root price
|
|
31
|
+
*
|
|
32
|
+
* # 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
|
|
37
|
+
*
|
|
38
|
+
* # Returns
|
|
39
|
+
* - `u128`: The next square root price
|
|
40
|
+
*/
|
|
41
|
+
export function tryGetNextSqrtPriceFromA(current_sqrt_price: bigint, current_liquidity: bigint, amount: bigint, specified_input: boolean): bigint;
|
|
42
|
+
/**
|
|
43
|
+
* Calculate the next square root price
|
|
44
|
+
*
|
|
45
|
+
* # 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
|
|
50
|
+
*
|
|
51
|
+
* # Returns
|
|
52
|
+
* - `u128`: The next square root price
|
|
53
|
+
*/
|
|
54
|
+
export function tryGetNextSqrtPriceFromB(current_sqrt_price: bigint, current_liquidity: bigint, amount: bigint, specified_input: boolean): bigint;
|
|
55
|
+
/**
|
|
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.
|
|
59
|
+
*
|
|
60
|
+
* # Parameters
|
|
61
|
+
* - `amount`: The amount to apply the fee to
|
|
62
|
+
* - `transfer_fee`: The transfer fee to apply
|
|
63
|
+
*
|
|
64
|
+
* # Returns
|
|
65
|
+
* - `u64`: The amount after the fee has been applied
|
|
66
|
+
*/
|
|
67
|
+
export function tryApplyTransferFee(amount: bigint, transfer_fee: TransferFee): bigint;
|
|
68
|
+
/**
|
|
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.
|
|
72
|
+
*
|
|
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.
|
|
84
|
+
*
|
|
85
|
+
* # 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)
|
|
88
|
+
*
|
|
89
|
+
* # Returns
|
|
90
|
+
* - `u64`: The maximum amount
|
|
91
|
+
*/
|
|
92
|
+
export function tryGetMaxAmountWithSlippageTolerance(amount: bigint, slippage_tolerance_bps: number): bigint;
|
|
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.
|
|
96
|
+
*
|
|
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)
|
|
100
|
+
*
|
|
101
|
+
* # Returns
|
|
102
|
+
* - `u64`: The minimum amount
|
|
103
|
+
*/
|
|
104
|
+
export function tryGetMinAmountWithSlippageTolerance(amount: bigint, slippage_tolerance_bps: number): bigint;
|
|
105
|
+
/**
|
|
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.
|
|
109
|
+
*
|
|
110
|
+
* # Parameters
|
|
111
|
+
* - `amount`: The amount to apply the fee to
|
|
112
|
+
* - `fee_rate`: The fee rate to apply denominated in 1e6
|
|
113
|
+
*
|
|
114
|
+
* # Returns
|
|
115
|
+
* - `u64`: The amount after the fee has been applied
|
|
116
|
+
*/
|
|
117
|
+
export function tryApplySwapFee(amount: bigint, fee_rate: number): bigint;
|
|
118
|
+
/**
|
|
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.
|
|
122
|
+
*
|
|
123
|
+
* # 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
|
|
143
|
+
*
|
|
144
|
+
* # Returns
|
|
145
|
+
* - `CollectRewardsQuote`: The rewards owed for the 3 reward tokens.
|
|
146
|
+
*/
|
|
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;
|
|
3
148
|
/**
|
|
4
149
|
* Get the first tick index in the tick array that contains the specified tick index.
|
|
5
150
|
*
|
|
@@ -25,6 +170,7 @@ export function tickIndexToSqrtPrice(tick_index: number): bigint;
|
|
|
25
170
|
/**
|
|
26
171
|
* Derive the tick index from a sqrt price. The precision of this method is only guarranted
|
|
27
172
|
* if tick is within the bounds of {max, min} tick-index.
|
|
173
|
+
* This function will make panic for zero sqrt price.
|
|
28
174
|
*
|
|
29
175
|
* # Parameters
|
|
30
176
|
* - `sqrt_price` - A u128 integer representing the sqrt price
|
|
@@ -159,6 +305,13 @@ export function isFullRangeOnly(tick_spacing: number): boolean;
|
|
|
159
305
|
* - A u32 integer representing the tick index in the tick array
|
|
160
306
|
*/
|
|
161
307
|
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;
|
|
162
315
|
export function _FEE_RATE_DENOMINATOR(): number;
|
|
163
316
|
export function _TICK_ARRAY_SIZE(): number;
|
|
164
317
|
export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD(): number;
|
|
@@ -195,6 +348,47 @@ export function isPositionBundleFull(bitmap: Uint8Array): boolean;
|
|
|
195
348
|
* * `bool` - Whether the bundle is empty
|
|
196
349
|
*/
|
|
197
350
|
export function isPositionBundleEmpty(bitmap: Uint8Array): boolean;
|
|
351
|
+
/**
|
|
352
|
+
* Check if a position is in range.
|
|
353
|
+
* When a position is in range it is earning fees and rewards
|
|
354
|
+
*
|
|
355
|
+
* # 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
|
|
359
|
+
*
|
|
360
|
+
* # Returns
|
|
361
|
+
* - A boolean value indicating if the position is in range
|
|
362
|
+
*/
|
|
363
|
+
export function isPositionInRange(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): boolean;
|
|
364
|
+
/**
|
|
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
|
|
370
|
+
*
|
|
371
|
+
* # 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
|
|
375
|
+
*
|
|
376
|
+
* # Returns
|
|
377
|
+
* - A PositionStatus enum value indicating the status of the position
|
|
378
|
+
*/
|
|
379
|
+
export function positionStatus(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionStatus;
|
|
380
|
+
/**
|
|
381
|
+
* Calculate the token_a / token_b ratio of a (ficticious) position
|
|
382
|
+
*
|
|
383
|
+
* # 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
|
|
387
|
+
*
|
|
388
|
+
* # Returns
|
|
389
|
+
* - A PositionRatio struct containing the ratio of token_a and token_b
|
|
390
|
+
*/
|
|
391
|
+
export function positionRatio(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionRatio;
|
|
198
392
|
/**
|
|
199
393
|
* Convert a price into a sqrt priceX64
|
|
200
394
|
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
@@ -265,8 +459,6 @@ export function tickIndexToPrice(tick_index: number, decimals_a: number, decimal
|
|
|
265
459
|
* * `i32` - The tick index
|
|
266
460
|
*/
|
|
267
461
|
export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
|
|
268
|
-
export function _NUM_REWARDS(): number;
|
|
269
|
-
export function _POSITION_BUNDLE_SIZE(): number;
|
|
270
462
|
export function _TICK_ARRAY_NOT_EVENLY_SPACED(): string;
|
|
271
463
|
export function _TICK_INDEX_OUT_OF_BOUNDS(): string;
|
|
272
464
|
export function _INVALID_TICK_INDEX(): string;
|
|
@@ -281,175 +473,18 @@ export function _INVALID_TIMESTAMP(): string;
|
|
|
281
473
|
export function _INVALID_TRANSFER_FEE(): string;
|
|
282
474
|
export function _INVALID_SLIPPAGE_TOLERANCE(): string;
|
|
283
475
|
export function _TICK_INDEX_NOT_IN_ARRAY(): string;
|
|
476
|
+
export function _INVALID_TICK_ARRAY_SEQUENCE(): string;
|
|
477
|
+
export function _INVALID_ADAPTIVE_FEE_INFO(): string;
|
|
284
478
|
/**
|
|
285
|
-
* Check if
|
|
286
|
-
* When a position is in range it is earning fees and rewards
|
|
287
|
-
*
|
|
288
|
-
* # Parameters
|
|
289
|
-
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
290
|
-
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
291
|
-
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
292
|
-
*
|
|
293
|
-
* # Returns
|
|
294
|
-
* - A boolean value indicating if the position is in range
|
|
295
|
-
*/
|
|
296
|
-
export function isPositionInRange(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): boolean;
|
|
297
|
-
/**
|
|
298
|
-
* Calculate the status of a position
|
|
299
|
-
* The status can be one of three values:
|
|
300
|
-
* - InRange: The position is in range
|
|
301
|
-
* - BelowRange: The position is below the range
|
|
302
|
-
* - AboveRange: The position is above the range
|
|
303
|
-
*
|
|
304
|
-
* # Parameters
|
|
305
|
-
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
306
|
-
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
307
|
-
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
308
|
-
*
|
|
309
|
-
* # Returns
|
|
310
|
-
* - A PositionStatus enum value indicating the status of the position
|
|
311
|
-
*/
|
|
312
|
-
export function positionStatus(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionStatus;
|
|
313
|
-
/**
|
|
314
|
-
* Calculate the token_a / token_b ratio of a (ficticious) position
|
|
315
|
-
*
|
|
316
|
-
* # Parameters
|
|
317
|
-
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
318
|
-
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
319
|
-
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
479
|
+
* Check if the whirlpool is initialized with adaptive fee
|
|
320
480
|
*
|
|
321
|
-
* #
|
|
322
|
-
* -
|
|
323
|
-
*/
|
|
324
|
-
export function positionRatio(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionRatio;
|
|
325
|
-
/**
|
|
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.
|
|
394
|
-
*
|
|
395
|
-
* # Parameters
|
|
396
|
-
* - `amount`: The amount to reverse the fee from
|
|
397
|
-
* - `transfer_fee`: The transfer fee to reverse
|
|
398
|
-
*
|
|
399
|
-
* # Returns
|
|
400
|
-
* - `u64`: The amount before the fee has been applied
|
|
401
|
-
*/
|
|
402
|
-
export function tryReverseApplyTransferFee(amount: bigint, transfer_fee: TransferFee): bigint;
|
|
403
|
-
/**
|
|
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.
|
|
406
|
-
*
|
|
407
|
-
* # 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)
|
|
410
|
-
*
|
|
411
|
-
* # Returns
|
|
412
|
-
* - `u64`: The maximum amount
|
|
413
|
-
*/
|
|
414
|
-
export function tryGetMaxAmountWithSlippageTolerance(amount: bigint, slippage_tolerance_bps: number): bigint;
|
|
415
|
-
/**
|
|
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.
|
|
418
|
-
*
|
|
419
|
-
* # 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)
|
|
422
|
-
*
|
|
423
|
-
* # Returns
|
|
424
|
-
* - `u64`: The minimum amount
|
|
425
|
-
*/
|
|
426
|
-
export function tryGetMinAmountWithSlippageTolerance(amount: bigint, slippage_tolerance_bps: number): bigint;
|
|
427
|
-
/**
|
|
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.
|
|
431
|
-
*
|
|
432
|
-
* # Parameters
|
|
433
|
-
* - `amount`: The amount to apply the fee to
|
|
434
|
-
* - `fee_rate`: The fee rate to apply denominated in 1e6
|
|
435
|
-
*
|
|
436
|
-
* # Returns
|
|
437
|
-
* - `u64`: The amount after the fee has been applied
|
|
438
|
-
*/
|
|
439
|
-
export function tryApplySwapFee(amount: bigint, fee_rate: number): bigint;
|
|
440
|
-
/**
|
|
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.
|
|
444
|
-
*
|
|
445
|
-
* # Parameters
|
|
446
|
-
* - `amount`: The amount to reverse the fee from
|
|
447
|
-
* - `fee_rate`: The fee rate to reverse denominated in 1e6
|
|
481
|
+
* # Paramters
|
|
482
|
+
* - `whirlpool`: The whirlpool state
|
|
448
483
|
*
|
|
449
484
|
* # Returns
|
|
450
|
-
* -
|
|
485
|
+
* - A boolean value indicating if the whirlpool is initialized with adaptive fee
|
|
451
486
|
*/
|
|
452
|
-
export function
|
|
487
|
+
export function isInitializedWithAdaptiveFee(whirlpool: WhirlpoolFacade): boolean;
|
|
453
488
|
/**
|
|
454
489
|
* Computes the exact input or output amount for a swap transaction.
|
|
455
490
|
*
|
|
@@ -458,14 +493,16 @@ export function tryReverseApplySwapFee(amount: bigint, fee_rate: number): bigint
|
|
|
458
493
|
* - `specified_token_a`: If `true`, the input token is token A. Otherwise, it is token B.
|
|
459
494
|
* - `slippage_tolerance`: The slippage tolerance in basis points.
|
|
460
495
|
* - `whirlpool`: The whirlpool state.
|
|
496
|
+
* - `oracle`: The oracle data for the whirlpool.
|
|
461
497
|
* - `tick_arrays`: The tick arrays needed for the swap.
|
|
498
|
+
* - `timestamp`: The timestamp for the swap.
|
|
462
499
|
* - `transfer_fee_a`: The transfer fee for token A.
|
|
463
500
|
* - `transfer_fee_b`: The transfer fee for token B.
|
|
464
501
|
*
|
|
465
502
|
* # Returns
|
|
466
503
|
* The exact input or output amount for the swap transaction.
|
|
467
504
|
*/
|
|
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;
|
|
505
|
+
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
506
|
/**
|
|
470
507
|
* Computes the exact input or output amount for a swap transaction.
|
|
471
508
|
*
|
|
@@ -474,14 +511,16 @@ export function swapQuoteByInputToken(token_in: bigint, specified_token_a: boole
|
|
|
474
511
|
* - `specified_token_a`: If `true`, the output token is token A. Otherwise, it is token B.
|
|
475
512
|
* - `slippage_tolerance`: The slippage tolerance in basis points.
|
|
476
513
|
* - `whirlpool`: The whirlpool state.
|
|
514
|
+
* - `oracle`: The oracle data for the whirlpool.
|
|
477
515
|
* - `tick_arrays`: The tick arrays needed for the swap.
|
|
516
|
+
* - `timestamp`: The timestamp for the swap.
|
|
478
517
|
* - `transfer_fee_a`: The transfer fee for token A.
|
|
479
518
|
* - `transfer_fee_b`: The transfer fee for token B.
|
|
480
519
|
*
|
|
481
520
|
* # Returns
|
|
482
521
|
* The exact input or output amount for the swap transaction.
|
|
483
522
|
*/
|
|
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;
|
|
523
|
+
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
524
|
/**
|
|
486
525
|
* Calculate fees owed for a position
|
|
487
526
|
*
|
|
@@ -593,26 +632,22 @@ export function increaseLiquidityQuoteA(token_amount_a: bigint, slippage_toleran
|
|
|
593
632
|
* - An IncreaseLiquidityQuote struct containing the estimated token amounts
|
|
594
633
|
*/
|
|
595
634
|
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
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
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
|
-
export interface TransferFee {
|
|
614
|
-
feeBps: number;
|
|
615
|
-
maxFee: bigint;
|
|
635
|
+
export interface ExactOutSwapQuote {
|
|
636
|
+
tokenOut: bigint;
|
|
637
|
+
tokenEstIn: bigint;
|
|
638
|
+
tokenMaxIn: bigint;
|
|
639
|
+
tradeFee: bigint;
|
|
640
|
+
tradeFeeRateMin: number;
|
|
641
|
+
tradeFeeRateMax: number;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
export interface ExactInSwapQuote {
|
|
645
|
+
tokenIn: bigint;
|
|
646
|
+
tokenEstOut: bigint;
|
|
647
|
+
tokenMinOut: bigint;
|
|
648
|
+
tradeFee: bigint;
|
|
649
|
+
tradeFeeRateMin: number;
|
|
650
|
+
tradeFeeRateMax: number;
|
|
616
651
|
}
|
|
617
652
|
|
|
618
653
|
export interface IncreaseLiquidityQuote {
|
|
@@ -631,11 +666,6 @@ export interface DecreaseLiquidityQuote {
|
|
|
631
666
|
tokenMinB: bigint;
|
|
632
667
|
}
|
|
633
668
|
|
|
634
|
-
export interface CollectFeesQuote {
|
|
635
|
-
feeOwedA: bigint;
|
|
636
|
-
feeOwedB: bigint;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
669
|
export interface CollectRewardQuote {
|
|
640
670
|
rewardsOwed: bigint;
|
|
641
671
|
}
|
|
@@ -644,6 +674,16 @@ export interface CollectRewardsQuote {
|
|
|
644
674
|
rewards: CollectRewardQuote[];
|
|
645
675
|
}
|
|
646
676
|
|
|
677
|
+
export interface TransferFee {
|
|
678
|
+
feeBps: number;
|
|
679
|
+
maxFee: bigint;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
export interface CollectFeesQuote {
|
|
683
|
+
feeOwedA: bigint;
|
|
684
|
+
feeOwedB: bigint;
|
|
685
|
+
}
|
|
686
|
+
|
|
647
687
|
export interface TickArrayFacade {
|
|
648
688
|
startTickIndex: number;
|
|
649
689
|
ticks: TickFacade[];
|
|
@@ -663,18 +703,27 @@ export interface TickRange {
|
|
|
663
703
|
tickUpperIndex: number;
|
|
664
704
|
}
|
|
665
705
|
|
|
666
|
-
export interface
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
tokenMaxIn: bigint;
|
|
670
|
-
tradeFee: bigint;
|
|
706
|
+
export interface PositionRewardInfoFacade {
|
|
707
|
+
growthInsideCheckpoint: bigint;
|
|
708
|
+
amountOwed: bigint;
|
|
671
709
|
}
|
|
672
710
|
|
|
673
|
-
export interface
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
711
|
+
export interface PositionFacade {
|
|
712
|
+
liquidity: bigint;
|
|
713
|
+
tickLowerIndex: number;
|
|
714
|
+
tickUpperIndex: number;
|
|
715
|
+
feeGrowthCheckpointA: bigint;
|
|
716
|
+
feeOwedA: bigint;
|
|
717
|
+
feeGrowthCheckpointB: bigint;
|
|
718
|
+
feeOwedB: bigint;
|
|
719
|
+
rewardInfos: PositionRewardInfoFacade[];
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
export type PositionStatus = "priceInRange" | "priceBelowRange" | "priceAboveRange" | "invalid";
|
|
723
|
+
|
|
724
|
+
export interface PositionRatio {
|
|
725
|
+
ratioA: number;
|
|
726
|
+
ratioB: number;
|
|
678
727
|
}
|
|
679
728
|
|
|
680
729
|
export interface WhirlpoolRewardInfoFacade {
|
|
@@ -683,6 +732,7 @@ export interface WhirlpoolRewardInfoFacade {
|
|
|
683
732
|
}
|
|
684
733
|
|
|
685
734
|
export interface WhirlpoolFacade {
|
|
735
|
+
feeTierIndexSeed: ReadonlyUint8Array;
|
|
686
736
|
tickSpacing: number;
|
|
687
737
|
feeRate: number;
|
|
688
738
|
protocolFeeRate: number;
|
|
@@ -695,26 +745,32 @@ export interface WhirlpoolFacade {
|
|
|
695
745
|
rewardInfos: WhirlpoolRewardInfoFacade[];
|
|
696
746
|
}
|
|
697
747
|
|
|
698
|
-
export interface
|
|
699
|
-
|
|
700
|
-
|
|
748
|
+
export interface AdaptiveFeeInfo {
|
|
749
|
+
constants: AdaptiveFeeConstantsFacade;
|
|
750
|
+
variables: AdaptiveFeeVariablesFacade;
|
|
701
751
|
}
|
|
702
752
|
|
|
703
|
-
export interface
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
feeGrowthCheckpointB: bigint;
|
|
710
|
-
feeOwedB: bigint;
|
|
711
|
-
rewardInfos: PositionRewardInfoFacade[];
|
|
753
|
+
export interface AdaptiveFeeVariablesFacade {
|
|
754
|
+
lastReferenceUpdateTimestamp: bigint;
|
|
755
|
+
lastMajorSwapTimestamp: bigint;
|
|
756
|
+
volatilityReference: number;
|
|
757
|
+
tickGroupIndexReference: number;
|
|
758
|
+
volatilityAccumulator: number;
|
|
712
759
|
}
|
|
713
760
|
|
|
714
|
-
export
|
|
761
|
+
export interface AdaptiveFeeConstantsFacade {
|
|
762
|
+
filterPeriod: number;
|
|
763
|
+
decayPeriod: number;
|
|
764
|
+
reductionFactor: number;
|
|
765
|
+
adaptiveFeeControlFactor: number;
|
|
766
|
+
maxVolatilityAccumulator: number;
|
|
767
|
+
tickGroupSize: number;
|
|
768
|
+
majorSwapThresholdTicks: number;
|
|
769
|
+
}
|
|
715
770
|
|
|
716
|
-
export interface
|
|
717
|
-
|
|
718
|
-
|
|
771
|
+
export interface OracleFacade {
|
|
772
|
+
tradeEnableTimestamp: bigint;
|
|
773
|
+
adaptiveFeeConstants: AdaptiveFeeConstantsFacade;
|
|
774
|
+
adaptiveFeeVariables: AdaptiveFeeVariablesFacade;
|
|
719
775
|
}
|
|
720
776
|
|