@orca-so/whirlpools-core 1.0.3 → 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.
- package/dist/browser/orca_whirlpools_core_js_bindings.d.ts +286 -231
- package/dist/browser/orca_whirlpools_core_js_bindings_bg.js +472 -406
- package/dist/browser/orca_whirlpools_core_js_bindings_bg.wasm +0 -0
- package/dist/browser/orca_whirlpools_core_js_bindings_bg.wasm.d.ts +26 -18
- package/dist/browser/package.json +1 -1
- package/dist/nodejs/orca_whirlpools_core_js_bindings.d.ts +286 -231
- package/dist/nodejs/orca_whirlpools_core_js_bindings.js +472 -406
- package/dist/nodejs/orca_whirlpools_core_js_bindings_bg.wasm +0 -0
- package/dist/nodejs/orca_whirlpools_core_js_bindings_bg.wasm.d.ts +26 -18
- package/dist/nodejs/package.json +1 -1
- package/package.json +6 -5
|
@@ -1,113 +1,191 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
export function _NUM_REWARDS(): number;
|
|
4
|
-
export function _POSITION_BUNDLE_SIZE(): number;
|
|
5
|
-
export function _TICK_ARRAY_SIZE(): number;
|
|
6
|
-
export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD(): number;
|
|
7
|
-
export function _MIN_TICK_INDEX(): number;
|
|
8
|
-
export function _MAX_TICK_INDEX(): number;
|
|
9
3
|
/**
|
|
10
|
-
*
|
|
4
|
+
* Check if the whirlpool is initialized with adaptive fee
|
|
11
5
|
*
|
|
12
|
-
* #
|
|
13
|
-
*
|
|
6
|
+
* # Paramters
|
|
7
|
+
* - `whirlpool`: The whirlpool state
|
|
14
8
|
*
|
|
15
9
|
* # Returns
|
|
16
|
-
*
|
|
10
|
+
* - A boolean value indicating if the whirlpool is initialized with adaptive fee
|
|
17
11
|
*/
|
|
18
|
-
export function
|
|
12
|
+
export function isInitializedWithAdaptiveFee(whirlpool: WhirlpoolFacade): boolean;
|
|
19
13
|
/**
|
|
20
|
-
*
|
|
21
|
-
* A position bundle can contain 256 positions
|
|
14
|
+
* Calculate the amount A delta between two sqrt_prices
|
|
22
15
|
*
|
|
23
|
-
* #
|
|
24
|
-
*
|
|
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
|
|
25
21
|
*
|
|
26
22
|
* # Returns
|
|
27
|
-
*
|
|
23
|
+
* - `u64`: The amount delta
|
|
28
24
|
*/
|
|
29
|
-
export function
|
|
25
|
+
export function tryGetAmountDeltaA(sqrt_price_1: bigint, sqrt_price_2: bigint, liquidity: bigint, round_up: boolean): bigint;
|
|
30
26
|
/**
|
|
31
|
-
*
|
|
27
|
+
* Calculate the amount B delta between two sqrt_prices
|
|
32
28
|
*
|
|
33
|
-
* #
|
|
34
|
-
*
|
|
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
|
|
35
34
|
*
|
|
36
35
|
* # Returns
|
|
37
|
-
*
|
|
36
|
+
* - `u64`: The amount delta
|
|
38
37
|
*/
|
|
39
|
-
export function
|
|
38
|
+
export function tryGetAmountDeltaB(sqrt_price_1: bigint, sqrt_price_2: bigint, liquidity: bigint, round_up: boolean): bigint;
|
|
40
39
|
/**
|
|
41
|
-
*
|
|
42
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
43
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
40
|
+
* Calculate the next square root price
|
|
44
41
|
*
|
|
45
42
|
* # Parameters
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
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
|
|
49
47
|
*
|
|
50
48
|
* # Returns
|
|
51
|
-
*
|
|
49
|
+
* - `u128`: The next square root price
|
|
52
50
|
*/
|
|
53
|
-
export function
|
|
51
|
+
export function tryGetNextSqrtPriceFromA(current_sqrt_price: bigint, current_liquidity: bigint, amount: bigint, specified_input: boolean): bigint;
|
|
54
52
|
/**
|
|
55
|
-
*
|
|
56
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
57
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
53
|
+
* Calculate the next square root price
|
|
58
54
|
*
|
|
59
55
|
* # Parameters
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
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
|
|
63
60
|
*
|
|
64
61
|
* # Returns
|
|
65
|
-
*
|
|
62
|
+
* - `u128`: The next square root price
|
|
66
63
|
*/
|
|
67
|
-
export function
|
|
64
|
+
export function tryGetNextSqrtPriceFromB(current_sqrt_price: bigint, current_liquidity: bigint, amount: bigint, specified_input: boolean): bigint;
|
|
68
65
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
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.
|
|
72
69
|
*
|
|
73
70
|
* # Parameters
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
71
|
+
* - `amount`: The amount to apply the fee to
|
|
72
|
+
* - `transfer_fee`: The transfer fee to apply
|
|
77
73
|
*
|
|
78
74
|
* # Returns
|
|
79
|
-
*
|
|
75
|
+
* - `u64`: The amount after the fee has been applied
|
|
80
76
|
*/
|
|
81
|
-
export function
|
|
77
|
+
export function tryApplyTransferFee(amount: bigint, transfer_fee: TransferFee): bigint;
|
|
82
78
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
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.
|
|
86
82
|
*
|
|
87
83
|
* # Parameters
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
84
|
+
* - `amount`: The amount to reverse the fee from
|
|
85
|
+
* - `transfer_fee`: The transfer fee to reverse
|
|
91
86
|
*
|
|
92
87
|
* # Returns
|
|
93
|
-
*
|
|
88
|
+
* - `u64`: The amount before the fee has been applied
|
|
94
89
|
*/
|
|
95
|
-
export function
|
|
90
|
+
export function tryReverseApplyTransferFee(amount: bigint, transfer_fee: TransferFee): bigint;
|
|
96
91
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
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.
|
|
100
94
|
*
|
|
101
95
|
* # Parameters
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
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)
|
|
105
98
|
*
|
|
106
99
|
* # Returns
|
|
107
|
-
*
|
|
100
|
+
* - `u64`: The maximum amount
|
|
108
101
|
*/
|
|
109
|
-
export function
|
|
110
|
-
|
|
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;
|
|
111
189
|
/**
|
|
112
190
|
* Get the first tick index in the tick array that contains the specified tick index.
|
|
113
191
|
*
|
|
@@ -267,6 +345,12 @@ export function isFullRangeOnly(tick_spacing: number): boolean;
|
|
|
267
345
|
* - A u32 integer representing the tick index in the tick array
|
|
268
346
|
*/
|
|
269
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;
|
|
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;
|
|
272
356
|
export function _INVALID_TICK_INDEX(): 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
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
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
|
-
*
|
|
397
|
-
*
|
|
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
|
-
*
|
|
428
|
+
* * `u128` - The sqrt priceX64
|
|
401
429
|
*/
|
|
402
|
-
export function
|
|
430
|
+
export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
|
|
403
431
|
/**
|
|
404
|
-
*
|
|
405
|
-
*
|
|
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
|
-
*
|
|
409
|
-
*
|
|
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
|
-
*
|
|
442
|
+
* * `f64` - The decimal price
|
|
413
443
|
*/
|
|
414
|
-
export function
|
|
444
|
+
export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
|
|
415
445
|
/**
|
|
416
|
-
*
|
|
417
|
-
*
|
|
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
|
-
*
|
|
421
|
-
*
|
|
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
|
-
*
|
|
456
|
+
* * `f64` - The inverted price
|
|
425
457
|
*/
|
|
426
|
-
export function
|
|
458
|
+
export function invertPrice(price: number, decimals_a: number, decimals_b: number): number;
|
|
427
459
|
/**
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
*
|
|
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
|
-
*
|
|
434
|
-
*
|
|
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
|
-
*
|
|
470
|
+
* * `f64` - The decimal price
|
|
438
471
|
*/
|
|
439
|
-
export function
|
|
472
|
+
export function tickIndexToPrice(tick_index: number, decimals_a: number, decimals_b: number): number;
|
|
440
473
|
/**
|
|
441
|
-
*
|
|
442
|
-
*
|
|
443
|
-
*
|
|
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
|
-
*
|
|
447
|
-
*
|
|
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
|
-
*
|
|
484
|
+
* * `i32` - The tick index
|
|
451
485
|
*/
|
|
452
|
-
export function
|
|
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,23 +631,50 @@ 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
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
634
|
+
export interface TransferFee {
|
|
635
|
+
feeBps: number;
|
|
636
|
+
maxFee: bigint;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
export interface CollectFeesQuote {
|
|
640
|
+
feeOwedA: bigint;
|
|
641
|
+
feeOwedB: bigint;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
export interface IncreaseLiquidityQuote {
|
|
645
|
+
liquidityDelta: bigint;
|
|
646
|
+
tokenEstA: bigint;
|
|
647
|
+
tokenEstB: bigint;
|
|
648
|
+
tokenMaxA: bigint;
|
|
649
|
+
tokenMaxB: bigint;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
export interface DecreaseLiquidityQuote {
|
|
653
|
+
liquidityDelta: bigint;
|
|
654
|
+
tokenEstA: bigint;
|
|
655
|
+
tokenEstB: bigint;
|
|
656
|
+
tokenMinA: bigint;
|
|
657
|
+
tokenMinB: bigint;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
export interface ExactOutSwapQuote {
|
|
661
|
+
tokenOut: bigint;
|
|
662
|
+
tokenEstIn: bigint;
|
|
663
|
+
tokenMaxIn: bigint;
|
|
664
|
+
tradeFee: bigint;
|
|
665
|
+
tradeFeeRateMin: number;
|
|
666
|
+
tradeFeeRateMax: number;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
export interface ExactInSwapQuote {
|
|
670
|
+
tokenIn: bigint;
|
|
671
|
+
tokenEstOut: bigint;
|
|
672
|
+
tokenMinOut: bigint;
|
|
673
|
+
tradeFee: bigint;
|
|
674
|
+
tradeFeeRateMin: number;
|
|
675
|
+
tradeFeeRateMax: number;
|
|
676
|
+
}
|
|
677
|
+
|
|
613
678
|
export interface TickArrayFacade {
|
|
614
679
|
startTickIndex: number;
|
|
615
680
|
ticks: TickFacade[];
|
|
@@ -629,18 +694,27 @@ export interface TickRange {
|
|
|
629
694
|
tickUpperIndex: number;
|
|
630
695
|
}
|
|
631
696
|
|
|
632
|
-
export interface
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
tokenMaxIn: bigint;
|
|
636
|
-
tradeFee: bigint;
|
|
697
|
+
export interface PositionRewardInfoFacade {
|
|
698
|
+
growthInsideCheckpoint: bigint;
|
|
699
|
+
amountOwed: bigint;
|
|
637
700
|
}
|
|
638
701
|
|
|
639
|
-
export interface
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
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;
|
|
644
718
|
}
|
|
645
719
|
|
|
646
720
|
export interface WhirlpoolRewardInfoFacade {
|
|
@@ -649,6 +723,7 @@ export interface WhirlpoolRewardInfoFacade {
|
|
|
649
723
|
}
|
|
650
724
|
|
|
651
725
|
export interface WhirlpoolFacade {
|
|
726
|
+
feeTierIndexSeed: ReadonlyUint8Array;
|
|
652
727
|
tickSpacing: number;
|
|
653
728
|
feeRate: number;
|
|
654
729
|
protocolFeeRate: number;
|
|
@@ -661,30 +736,33 @@ export interface WhirlpoolFacade {
|
|
|
661
736
|
rewardInfos: WhirlpoolRewardInfoFacade[];
|
|
662
737
|
}
|
|
663
738
|
|
|
664
|
-
export interface
|
|
665
|
-
|
|
666
|
-
|
|
739
|
+
export interface AdaptiveFeeInfo {
|
|
740
|
+
constants: AdaptiveFeeConstantsFacade;
|
|
741
|
+
variables: AdaptiveFeeVariablesFacade;
|
|
667
742
|
}
|
|
668
743
|
|
|
669
|
-
export interface
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
744
|
+
export interface AdaptiveFeeVariablesFacade {
|
|
745
|
+
lastReferenceUpdateTimestamp: bigint;
|
|
746
|
+
lastMajorSwapTimestamp: bigint;
|
|
747
|
+
volatilityReference: number;
|
|
748
|
+
tickGroupIndexReference: number;
|
|
749
|
+
volatilityAccumulator: number;
|
|
675
750
|
}
|
|
676
751
|
|
|
677
|
-
export interface
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
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;
|
|
683
760
|
}
|
|
684
761
|
|
|
685
|
-
export interface
|
|
686
|
-
|
|
687
|
-
|
|
762
|
+
export interface OracleFacade {
|
|
763
|
+
tradeEnableTimestamp: bigint;
|
|
764
|
+
adaptiveFeeConstants: AdaptiveFeeConstantsFacade;
|
|
765
|
+
adaptiveFeeVariables: AdaptiveFeeVariablesFacade;
|
|
688
766
|
}
|
|
689
767
|
|
|
690
768
|
export interface CollectRewardQuote {
|
|
@@ -695,26 +773,3 @@ export interface CollectRewardsQuote {
|
|
|
695
773
|
rewards: CollectRewardQuote[];
|
|
696
774
|
}
|
|
697
775
|
|
|
698
|
-
export interface PositionRewardInfoFacade {
|
|
699
|
-
growthInsideCheckpoint: bigint;
|
|
700
|
-
amountOwed: bigint;
|
|
701
|
-
}
|
|
702
|
-
|
|
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[];
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
export type PositionStatus = "priceInRange" | "priceBelowRange" | "priceAboveRange" | "invalid";
|
|
715
|
-
|
|
716
|
-
export interface PositionRatio {
|
|
717
|
-
ratioA: number;
|
|
718
|
-
ratioB: number;
|
|
719
|
-
}
|
|
720
|
-
|