@orca-so/whirlpools-core 0.2.0 → 0.2.2

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,154 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function _POSITION_BUNDLE_SIZE(): number;
4
- export function _NUM_REWARDS(): number;
5
- export function _FEE_RATE_DENOMINATOR(): number;
6
- export function _TICK_ARRAY_SIZE(): number;
7
- export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD(): number;
8
- export function _MIN_TICK_INDEX(): number;
9
- export function _MAX_TICK_INDEX(): number;
10
- /**
11
- * Get the first unoccupied position in a bundle
12
- *
13
- * # Arguments
14
- * * `bundle` - The bundle to check
15
- *
16
- * # Returns
17
- * * `u32` - The first unoccupied position (None if full)
18
- */
19
- export function firstUnoccupiedPositionInBundle(bitmap: Uint8Array): number | undefined;
20
- /**
21
- * Check whether a position bundle is full
22
- * A position bundle can contain 256 positions
23
- *
24
- * # Arguments
25
- * * `bundle` - The bundle to check
26
- *
27
- * # Returns
28
- * * `bool` - Whether the bundle is full
29
- */
30
- export function isPositionBundleFull(bitmap: Uint8Array): boolean;
31
- /**
32
- * Check whether a position bundle is empty
33
- *
34
- * # Arguments
35
- * * `bundle` - The bundle to check
36
- *
37
- * # Returns
38
- * * `bool` - Whether the bundle is empty
39
- */
40
- export function isPositionBundleEmpty(bitmap: Uint8Array): boolean;
41
- /**
42
- * Check if a position is in range.
43
- * When a position is in range it is earning fees and rewards
44
- *
45
- * # Parameters
46
- * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
47
- * - `tick_index_1` - A i32 integer representing the first tick index of the position
48
- * - `tick_index_2` - A i32 integer representing the second tick index of the position
49
- *
50
- * # Returns
51
- * - A boolean value indicating if the position is in range
52
- */
53
- export function isPositionInRange(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): boolean;
54
- /**
55
- * Calculate the status of a position
56
- * The status can be one of three values:
57
- * - InRange: The position is in range
58
- * - BelowRange: The position is below the range
59
- * - AboveRange: The position is above the range
60
- *
61
- * # Parameters
62
- * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
63
- * - `tick_index_1` - A i32 integer representing the first tick index of the position
64
- * - `tick_index_2` - A i32 integer representing the second tick index of the position
65
- *
66
- * # Returns
67
- * - A PositionStatus enum value indicating the status of the position
68
- */
69
- export function positionStatus(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionStatus;
70
- /**
71
- * Calculate the token_a / token_b ratio of a (ficticious) position
72
- *
73
- * # Parameters
74
- * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
75
- * - `tick_index_1` - A i32 integer representing the first tick index of the position
76
- * - `tick_index_2` - A i32 integer representing the second tick index of the position
77
- *
78
- * # Returns
79
- * - A PositionRatio struct containing the ratio of token_a and token_b
80
- */
81
- export function positionRatio(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionRatio;
82
- /**
83
- * Convert a price into a sqrt priceX64
84
- * IMPORTANT: floating point operations can reduce the precision of the result.
85
- * Make sure to do these operations last and not to use the result for further calculations.
86
- *
87
- * # Parameters
88
- * * `price` - The price to convert
89
- * * `decimals_a` - The number of decimals of the base token
90
- * * `decimals_b` - The number of decimals of the quote token
91
- *
92
- * # Returns
93
- * * `u128` - The sqrt priceX64
94
- */
95
- export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
96
- /**
97
- * Convert a sqrt priceX64 into a tick index
98
- * IMPORTANT: floating point operations can reduce the precision of the result.
99
- * Make sure to do these operations last and not to use the result for further calculations.
100
- *
101
- * # Parameters
102
- * * `sqrt_price` - The sqrt priceX64 to convert
103
- * * `decimals_a` - The number of decimals of the base token
104
- * * `decimals_b` - The number of decimals of the quote token
105
- *
106
- * # Returns
107
- * * `f64` - The decimal price
108
- */
109
- export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
110
- /**
111
- * Invert a price
112
- * IMPORTANT: floating point operations can reduce the precision of the result.
113
- * Make sure to do these operations last and not to use the result for further calculations.
114
- *
115
- * # Parameters
116
- * * `price` - The price to invert
117
- * * `decimals_a` - The number of decimals of the base token
118
- * * `decimals_b` - The number of decimals of the quote token
119
- *
120
- * # Returns
121
- * * `f64` - The inverted price
122
- */
123
- export function invertPrice(price: number, decimals_a: number, decimals_b: number): number;
124
- /**
125
- * Convert a tick index into a price
126
- * IMPORTANT: floating point operations can reduce the precision of the result.
127
- * Make sure to do these operations last and not to use the result for further calculations.
128
- *
129
- * # Parameters
130
- * * `tick_index` - The tick index to convert
131
- * * `decimals_a` - The number of decimals of the base token
132
- * * `decimals_b` - The number of decimals of the quote token
133
- *
134
- * # Returns
135
- * * `f64` - The decimal price
136
- */
137
- export function tickIndexToPrice(tick_index: number, decimals_a: number, decimals_b: number): number;
138
- /**
139
- * Convert a price into a tick index
140
- * IMPORTANT: floating point operations can reduce the precision of the result.
141
- * Make sure to do these operations last and not to use the result for further calculations.
142
- *
143
- * # Parameters
144
- * * `price` - The price to convert
145
- * * `decimals_a` - The number of decimals of the base token
146
- * * `decimals_b` - The number of decimals of the quote token
147
- *
148
- * # Returns
149
- * * `i32` - The tick index
150
- */
151
- export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
152
3
  /**
153
4
  * Get the first tick index in the tick array that contains the specified tick index.
154
5
  *
@@ -305,9 +156,41 @@ export function isFullRangeOnly(tick_spacing: number): boolean;
305
156
  * - `tick_spacing` - A u16 integer representing the tick spacing
306
157
  *
307
158
  * # Returns
308
- * - A i32 integer representing the tick index in the tick array
159
+ * - A u32 integer representing the tick index in the tick array
309
160
  */
310
161
  export function getTickIndexInArray(tick_index: number, tick_array_start_index: number, tick_spacing: number): number;
162
+ /**
163
+ * Get the first unoccupied position in a bundle
164
+ *
165
+ * # Arguments
166
+ * * `bundle` - The bundle to check
167
+ *
168
+ * # Returns
169
+ * * `u32` - The first unoccupied position (None if full)
170
+ */
171
+ export function firstUnoccupiedPositionInBundle(bitmap: Uint8Array): number | undefined;
172
+ /**
173
+ * Check whether a position bundle is full
174
+ * A position bundle can contain 256 positions
175
+ *
176
+ * # Arguments
177
+ * * `bundle` - The bundle to check
178
+ *
179
+ * # Returns
180
+ * * `bool` - Whether the bundle is full
181
+ */
182
+ export function isPositionBundleFull(bitmap: Uint8Array): boolean;
183
+ /**
184
+ * Check whether a position bundle is empty
185
+ *
186
+ * # Arguments
187
+ * * `bundle` - The bundle to check
188
+ *
189
+ * # Returns
190
+ * * `bool` - Whether the bundle is empty
191
+ */
192
+ export function isPositionBundleEmpty(bitmap: Uint8Array): boolean;
193
+ export function _POSITION_BUNDLE_SIZE(): number;
311
194
  export function _TICK_ARRAY_NOT_EVENLY_SPACED(): number;
312
195
  export function _TICK_INDEX_OUT_OF_BOUNDS(): number;
313
196
  export function _INVALID_TICK_INDEX(): number;
@@ -321,6 +204,124 @@ export function _ZERO_TRADABLE_AMOUNT(): number;
321
204
  export function _INVALID_TIMESTAMP(): number;
322
205
  export function _INVALID_TRANSFER_FEE(): number;
323
206
  export function _INVALID_SLIPPAGE_TOLERANCE(): number;
207
+ export function _TICK_INDEX_NOT_IN_ARRAY(): number;
208
+ export function _NUM_REWARDS(): number;
209
+ export function _FEE_RATE_DENOMINATOR(): number;
210
+ export function _TICK_ARRAY_SIZE(): number;
211
+ export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD(): number;
212
+ export function _MIN_TICK_INDEX(): number;
213
+ export function _MAX_TICK_INDEX(): number;
214
+ /**
215
+ * Check if a position is in range.
216
+ * When a position is in range it is earning fees and rewards
217
+ *
218
+ * # Parameters
219
+ * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
220
+ * - `tick_index_1` - A i32 integer representing the first tick index of the position
221
+ * - `tick_index_2` - A i32 integer representing the second tick index of the position
222
+ *
223
+ * # Returns
224
+ * - A boolean value indicating if the position is in range
225
+ */
226
+ export function isPositionInRange(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): boolean;
227
+ /**
228
+ * Calculate the status of a position
229
+ * The status can be one of three values:
230
+ * - InRange: The position is in range
231
+ * - BelowRange: The position is below the range
232
+ * - AboveRange: The position is above the range
233
+ *
234
+ * # Parameters
235
+ * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
236
+ * - `tick_index_1` - A i32 integer representing the first tick index of the position
237
+ * - `tick_index_2` - A i32 integer representing the second tick index of the position
238
+ *
239
+ * # Returns
240
+ * - A PositionStatus enum value indicating the status of the position
241
+ */
242
+ export function positionStatus(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionStatus;
243
+ /**
244
+ * Calculate the token_a / token_b ratio of a (ficticious) position
245
+ *
246
+ * # Parameters
247
+ * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
248
+ * - `tick_index_1` - A i32 integer representing the first tick index of the position
249
+ * - `tick_index_2` - A i32 integer representing the second tick index of the position
250
+ *
251
+ * # Returns
252
+ * - A PositionRatio struct containing the ratio of token_a and token_b
253
+ */
254
+ export function positionRatio(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionRatio;
255
+ /**
256
+ * Convert a price into a sqrt priceX64
257
+ * IMPORTANT: floating point operations can reduce the precision of the result.
258
+ * Make sure to do these operations last and not to use the result for further calculations.
259
+ *
260
+ * # Parameters
261
+ * * `price` - The price to convert
262
+ * * `decimals_a` - The number of decimals of the base token
263
+ * * `decimals_b` - The number of decimals of the quote token
264
+ *
265
+ * # Returns
266
+ * * `u128` - The sqrt priceX64
267
+ */
268
+ export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
269
+ /**
270
+ * Convert a sqrt priceX64 into a tick index
271
+ * IMPORTANT: floating point operations can reduce the precision of the result.
272
+ * Make sure to do these operations last and not to use the result for further calculations.
273
+ *
274
+ * # Parameters
275
+ * * `sqrt_price` - The sqrt priceX64 to convert
276
+ * * `decimals_a` - The number of decimals of the base token
277
+ * * `decimals_b` - The number of decimals of the quote token
278
+ *
279
+ * # Returns
280
+ * * `f64` - The decimal price
281
+ */
282
+ export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
283
+ /**
284
+ * Invert a price
285
+ * IMPORTANT: floating point operations can reduce the precision of the result.
286
+ * Make sure to do these operations last and not to use the result for further calculations.
287
+ *
288
+ * # Parameters
289
+ * * `price` - The price to invert
290
+ * * `decimals_a` - The number of decimals of the base token
291
+ * * `decimals_b` - The number of decimals of the quote token
292
+ *
293
+ * # Returns
294
+ * * `f64` - The inverted price
295
+ */
296
+ export function invertPrice(price: number, decimals_a: number, decimals_b: number): number;
297
+ /**
298
+ * Convert a tick index into a price
299
+ * IMPORTANT: floating point operations can reduce the precision of the result.
300
+ * Make sure to do these operations last and not to use the result for further calculations.
301
+ *
302
+ * # Parameters
303
+ * * `tick_index` - The tick index to convert
304
+ * * `decimals_a` - The number of decimals of the base token
305
+ * * `decimals_b` - The number of decimals of the quote token
306
+ *
307
+ * # Returns
308
+ * * `f64` - The decimal price
309
+ */
310
+ export function tickIndexToPrice(tick_index: number, decimals_a: number, decimals_b: number): number;
311
+ /**
312
+ * Convert a price into a tick index
313
+ * IMPORTANT: floating point operations can reduce the precision of the result.
314
+ * Make sure to do these operations last and not to use the result for further calculations.
315
+ *
316
+ * # Parameters
317
+ * * `price` - The price to convert
318
+ * * `decimals_a` - The number of decimals of the base token
319
+ * * `decimals_b` - The number of decimals of the quote token
320
+ *
321
+ * # Returns
322
+ * * `i32` - The tick index
323
+ */
324
+ export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
324
325
  /**
325
326
  * Calculate the amount A delta between two sqrt_prices
326
327
  *
@@ -653,38 +654,6 @@ export interface CollectFeesQuote {
653
654
  feeOwedB: bigint;
654
655
  }
655
656
 
656
- export interface ExactOutSwapQuote {
657
- tokenOut: bigint;
658
- tokenEstIn: bigint;
659
- tokenMaxIn: bigint;
660
- tradeFee: bigint;
661
- }
662
-
663
- export interface ExactInSwapQuote {
664
- tokenIn: bigint;
665
- tokenEstOut: bigint;
666
- tokenMinOut: bigint;
667
- tradeFee: bigint;
668
- }
669
-
670
- export interface WhirlpoolRewardInfoFacade {
671
- emissionsPerSecondX64: bigint;
672
- growthGlobalX64: bigint;
673
- }
674
-
675
- export interface WhirlpoolFacade {
676
- tickSpacing: number;
677
- feeRate: number;
678
- protocolFeeRate: number;
679
- liquidity: bigint;
680
- sqrtPrice: bigint;
681
- tickCurrentIndex: number;
682
- feeGrowthGlobalA: bigint;
683
- feeGrowthGlobalB: bigint;
684
- rewardLastUpdatedTimestamp: bigint;
685
- rewardInfos: WhirlpoolRewardInfoFacade[];
686
- }
687
-
688
657
  export interface TransferFee {
689
658
  feeBps: number;
690
659
  maxFee: bigint;
@@ -717,3 +686,35 @@ export interface CollectRewardsQuote {
717
686
  rewards: CollectRewardQuote[];
718
687
  }
719
688
 
689
+ export interface ExactOutSwapQuote {
690
+ tokenOut: bigint;
691
+ tokenEstIn: bigint;
692
+ tokenMaxIn: bigint;
693
+ tradeFee: bigint;
694
+ }
695
+
696
+ export interface ExactInSwapQuote {
697
+ tokenIn: bigint;
698
+ tokenEstOut: bigint;
699
+ tokenMinOut: bigint;
700
+ tradeFee: bigint;
701
+ }
702
+
703
+ export interface WhirlpoolRewardInfoFacade {
704
+ emissionsPerSecondX64: bigint;
705
+ growthGlobalX64: bigint;
706
+ }
707
+
708
+ export interface WhirlpoolFacade {
709
+ tickSpacing: number;
710
+ feeRate: number;
711
+ protocolFeeRate: number;
712
+ liquidity: bigint;
713
+ sqrtPrice: bigint;
714
+ tickCurrentIndex: number;
715
+ feeGrowthGlobalA: bigint;
716
+ feeGrowthGlobalB: bigint;
717
+ rewardLastUpdatedTimestamp: bigint;
718
+ rewardInfos: WhirlpoolRewardInfoFacade[];
719
+ }
720
+