@orca-so/whirlpools-core 1.0.2 → 1.0.4

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,112 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function _FEE_RATE_DENOMINATOR(): number;
4
- export function _TICK_ARRAY_SIZE(): number;
5
- export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD(): number;
6
- export function _MIN_TICK_INDEX(): number;
7
- export function _MAX_TICK_INDEX(): number;
8
- /**
9
- * Get the first unoccupied position in a bundle
10
- *
11
- * # Arguments
12
- * * `bundle` - The bundle to check
13
- *
14
- * # Returns
15
- * * `u32` - The first unoccupied position (None if full)
16
- */
17
- export function firstUnoccupiedPositionInBundle(bitmap: Uint8Array): number | undefined;
18
- /**
19
- * Check whether a position bundle is full
20
- * A position bundle can contain 256 positions
21
- *
22
- * # Arguments
23
- * * `bundle` - The bundle to check
24
- *
25
- * # Returns
26
- * * `bool` - Whether the bundle is full
27
- */
28
- export function isPositionBundleFull(bitmap: Uint8Array): boolean;
29
- /**
30
- * Check whether a position bundle is empty
31
- *
32
- * # Arguments
33
- * * `bundle` - The bundle to check
34
- *
35
- * # Returns
36
- * * `bool` - Whether the bundle is empty
37
- */
38
- export function isPositionBundleEmpty(bitmap: Uint8Array): boolean;
39
- /**
40
- * Convert a price into a sqrt priceX64
41
- * IMPORTANT: floating point operations can reduce the precision of the result.
42
- * Make sure to do these operations last and not to use the result for further calculations.
43
- *
44
- * # Parameters
45
- * * `price` - The price to convert
46
- * * `decimals_a` - The number of decimals of the base token
47
- * * `decimals_b` - The number of decimals of the quote token
48
- *
49
- * # Returns
50
- * * `u128` - The sqrt priceX64
51
- */
52
- export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
53
- /**
54
- * Convert a sqrt priceX64 into a tick index
55
- * IMPORTANT: floating point operations can reduce the precision of the result.
56
- * Make sure to do these operations last and not to use the result for further calculations.
57
- *
58
- * # Parameters
59
- * * `sqrt_price` - The sqrt priceX64 to convert
60
- * * `decimals_a` - The number of decimals of the base token
61
- * * `decimals_b` - The number of decimals of the quote token
62
- *
63
- * # Returns
64
- * * `f64` - The decimal price
65
- */
66
- export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
67
- /**
68
- * Invert a price
69
- * IMPORTANT: floating point operations can reduce the precision of the result.
70
- * Make sure to do these operations last and not to use the result for further calculations.
71
- *
72
- * # Parameters
73
- * * `price` - The price to invert
74
- * * `decimals_a` - The number of decimals of the base token
75
- * * `decimals_b` - The number of decimals of the quote token
76
- *
77
- * # Returns
78
- * * `f64` - The inverted price
79
- */
80
- export function invertPrice(price: number, decimals_a: number, decimals_b: number): number;
81
- /**
82
- * Convert a tick index into a price
83
- * IMPORTANT: floating point operations can reduce the precision of the result.
84
- * Make sure to do these operations last and not to use the result for further calculations.
85
- *
86
- * # Parameters
87
- * * `tick_index` - The tick index to convert
88
- * * `decimals_a` - The number of decimals of the base token
89
- * * `decimals_b` - The number of decimals of the quote token
90
- *
91
- * # Returns
92
- * * `f64` - The decimal price
93
- */
94
- export function tickIndexToPrice(tick_index: number, decimals_a: number, decimals_b: number): number;
95
- /**
96
- * Convert a price into a tick index
97
- * IMPORTANT: floating point operations can reduce the precision of the result.
98
- * Make sure to do these operations last and not to use the result for further calculations.
99
- *
100
- * # Parameters
101
- * * `price` - The price to convert
102
- * * `decimals_a` - The number of decimals of the base token
103
- * * `decimals_b` - The number of decimals of the quote token
104
- *
105
- * # Returns
106
- * * `i32` - The tick index
107
- */
108
- export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
109
- export function _NUM_REWARDS(): number;
110
3
  /**
111
4
  * Get the first tick index in the tick array that contains the specified tick index.
112
5
  *
@@ -152,7 +45,7 @@ export function sqrtPriceToTickIndex(sqrt_price: bigint): number;
152
45
  * # Returns
153
46
  * - A i32 integer representing the previous initializable tick index
154
47
  */
155
- export function getInitializableTickIndex(tick_index: number, tick_spacing: number, round_up?: boolean): number;
48
+ export function getInitializableTickIndex(tick_index: number, tick_spacing: number, round_up?: boolean | null): number;
156
49
  /**
157
50
  * Get the previous initializable tick index.
158
51
  *
@@ -266,6 +159,113 @@ export function isFullRangeOnly(tick_spacing: number): boolean;
266
159
  * - A u32 integer representing the tick index in the tick array
267
160
  */
268
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;
254
+ /**
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.
258
+ *
259
+ * # 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
263
+ *
264
+ * # Returns
265
+ * * `i32` - The tick index
266
+ */
267
+ export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
268
+ export function _NUM_REWARDS(): number;
269
269
  export function _POSITION_BUNDLE_SIZE(): number;
270
270
  export function _TICK_ARRAY_NOT_EVENLY_SPACED(): string;
271
271
  export function _TICK_INDEX_OUT_OF_BOUNDS(): string;
@@ -465,7 +465,7 @@ export function tryReverseApplySwapFee(amount: bigint, fee_rate: number): bigint
465
465
  * # Returns
466
466
  * The exact input or output amount for the swap transaction.
467
467
  */
468
- export function swapQuoteByInputToken(token_in: bigint, specified_token_a: boolean, slippage_tolerance_bps: number, whirlpool: WhirlpoolFacade, tick_arrays: TickArrayFacade[], transfer_fee_a?: TransferFee, transfer_fee_b?: TransferFee): ExactInSwapQuote;
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;
469
469
  /**
470
470
  * Computes the exact input or output amount for a swap transaction.
471
471
  *
@@ -481,7 +481,7 @@ export function swapQuoteByInputToken(token_in: bigint, specified_token_a: boole
481
481
  * # Returns
482
482
  * The exact input or output amount for the swap transaction.
483
483
  */
484
- export function swapQuoteByOutputToken(token_out: bigint, specified_token_a: boolean, slippage_tolerance_bps: number, whirlpool: WhirlpoolFacade, tick_arrays: TickArrayFacade[], transfer_fee_a?: TransferFee, transfer_fee_b?: TransferFee): ExactOutSwapQuote;
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;
485
485
  /**
486
486
  * Calculate fees owed for a position
487
487
  *
@@ -496,7 +496,7 @@ export function swapQuoteByOutputToken(token_out: bigint, specified_token_a: boo
496
496
  * # Returns
497
497
  * - `CollectFeesQuote`: The fees owed for token A and token B
498
498
  */
499
- export function collectFeesQuote(whirlpool: WhirlpoolFacade, position: PositionFacade, tick_lower: TickFacade, tick_upper: TickFacade, transfer_fee_a?: TransferFee, transfer_fee_b?: TransferFee): CollectFeesQuote;
499
+ export function collectFeesQuote(whirlpool: WhirlpoolFacade, position: PositionFacade, tick_lower: TickFacade, tick_upper: TickFacade, transfer_fee_a?: TransferFee | null, transfer_fee_b?: TransferFee | null): CollectFeesQuote;
500
500
  /**
501
501
  * Calculate the quote for decreasing liquidity
502
502
  *
@@ -512,7 +512,7 @@ export function collectFeesQuote(whirlpool: WhirlpoolFacade, position: PositionF
512
512
  * # Returns
513
513
  * - A DecreaseLiquidityQuote struct containing the estimated token amounts
514
514
  */
515
- export function decreaseLiquidityQuote(liquidity_delta: bigint, slippage_tolerance_bps: number, current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number, transfer_fee_a?: TransferFee, transfer_fee_b?: TransferFee): DecreaseLiquidityQuote;
515
+ export function decreaseLiquidityQuote(liquidity_delta: 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): DecreaseLiquidityQuote;
516
516
  /**
517
517
  * Calculate the quote for decreasing liquidity given a token a amount
518
518
  *
@@ -528,7 +528,7 @@ export function decreaseLiquidityQuote(liquidity_delta: bigint, slippage_toleran
528
528
  * # Returns
529
529
  * - A DecreaseLiquidityQuote struct containing the estimated token amounts
530
530
  */
531
- export function decreaseLiquidityQuoteA(token_amount_a: bigint, slippage_tolerance_bps: number, current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number, transfer_fee_a?: TransferFee, transfer_fee_b?: TransferFee): DecreaseLiquidityQuote;
531
+ export function decreaseLiquidityQuoteA(token_amount_a: 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): DecreaseLiquidityQuote;
532
532
  /**
533
533
  * Calculate the quote for decreasing liquidity given a token b amount
534
534
  *
@@ -544,7 +544,7 @@ export function decreaseLiquidityQuoteA(token_amount_a: bigint, slippage_toleran
544
544
  * # Returns
545
545
  * - A DecreaseLiquidityQuote struct containing the estimated token amounts
546
546
  */
547
- export function decreaseLiquidityQuoteB(token_amount_b: bigint, slippage_tolerance_bps: number, current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number, transfer_fee_a?: TransferFee, transfer_fee_b?: TransferFee): DecreaseLiquidityQuote;
547
+ export function decreaseLiquidityQuoteB(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): DecreaseLiquidityQuote;
548
548
  /**
549
549
  * Calculate the quote for increasing liquidity
550
550
  *
@@ -560,7 +560,7 @@ export function decreaseLiquidityQuoteB(token_amount_b: bigint, slippage_toleran
560
560
  * # Returns
561
561
  * - An IncreaseLiquidityQuote struct containing the estimated token amounts
562
562
  */
563
- export function increaseLiquidityQuote(liquidity_delta: bigint, slippage_tolerance_bps: number, current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number, transfer_fee_a?: TransferFee, transfer_fee_b?: TransferFee): IncreaseLiquidityQuote;
563
+ export function increaseLiquidityQuote(liquidity_delta: 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;
564
564
  /**
565
565
  * Calculate the quote for increasing liquidity given a token a amount
566
566
  *
@@ -576,7 +576,7 @@ export function increaseLiquidityQuote(liquidity_delta: bigint, slippage_toleran
576
576
  * # Returns
577
577
  * - An IncreaseLiquidityQuote struct containing the estimated token amounts
578
578
  */
579
- export function increaseLiquidityQuoteA(token_amount_a: bigint, slippage_tolerance_bps: number, current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number, transfer_fee_a?: TransferFee, transfer_fee_b?: TransferFee): IncreaseLiquidityQuote;
579
+ export function increaseLiquidityQuoteA(token_amount_a: 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;
580
580
  /**
581
581
  * Calculate the quote for increasing liquidity given a token b amount
582
582
  *
@@ -592,7 +592,7 @@ export function increaseLiquidityQuoteA(token_amount_a: bigint, slippage_toleran
592
592
  * # Returns
593
593
  * - An IncreaseLiquidityQuote struct containing the estimated token amounts
594
594
  */
595
- 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, transfer_fee_b?: TransferFee): IncreaseLiquidityQuote;
595
+ 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
596
  /**
597
597
  * Calculate rewards owed for a position
598
598
  *
@@ -609,7 +609,7 @@ export function increaseLiquidityQuoteB(token_amount_b: bigint, slippage_toleran
609
609
  * # Returns
610
610
  * - `CollectRewardsQuote`: The rewards owed for the 3 reward tokens.
611
611
  */
612
- export function collectRewardsQuote(whirlpool: WhirlpoolFacade, position: PositionFacade, tick_lower: TickFacade, tick_upper: TickFacade, current_timestamp: bigint, transfer_fee_1?: TransferFee, transfer_fee_2?: TransferFee, transfer_fee_3?: TransferFee): CollectRewardsQuote;
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
613
  export interface TransferFee {
614
614
  feeBps: number;
615
615
  maxFee: bigint;
@@ -636,6 +636,14 @@ export interface CollectFeesQuote {
636
636
  feeOwedB: bigint;
637
637
  }
638
638
 
639
+ export interface CollectRewardQuote {
640
+ rewardsOwed: bigint;
641
+ }
642
+
643
+ export interface CollectRewardsQuote {
644
+ rewards: CollectRewardQuote[];
645
+ }
646
+
639
647
  export interface TickArrayFacade {
640
648
  startTickIndex: number;
641
649
  ticks: TickFacade[];
@@ -687,14 +695,6 @@ export interface WhirlpoolFacade {
687
695
  rewardInfos: WhirlpoolRewardInfoFacade[];
688
696
  }
689
697
 
690
- export interface CollectRewardQuote {
691
- rewardsOwed: bigint;
692
- }
693
-
694
- export interface CollectRewardsQuote {
695
- rewards: CollectRewardQuote[];
696
- }
697
-
698
698
  export interface PositionRewardInfoFacade {
699
699
  growthInsideCheckpoint: bigint;
700
700
  amountOwed: bigint;