@crypticdot/defituna-core 3.4.6 → 3.4.7

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,147 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- /**
4
- * Get the first unoccupied position in a bundle
5
- *
6
- * # Arguments
7
- * * `bundle` - The bundle to check
8
- *
9
- * # Returns
10
- * * `u32` - The first unoccupied position (None if full)
11
- */
12
- export function firstUnoccupiedPositionInBundle(bitmap: Uint8Array): number | undefined;
13
- /**
14
- * Check whether a position bundle is full
15
- * A position bundle can contain 256 positions
16
- *
17
- * # Arguments
18
- * * `bundle` - The bundle to check
19
- *
20
- * # Returns
21
- * * `bool` - Whether the bundle is full
22
- */
23
- export function isPositionBundleFull(bitmap: Uint8Array): boolean;
24
- /**
25
- * Check whether a position bundle is empty
26
- *
27
- * # Arguments
28
- * * `bundle` - The bundle to check
29
- *
30
- * # Returns
31
- * * `bool` - Whether the bundle is empty
32
- */
33
- export function isPositionBundleEmpty(bitmap: Uint8Array): boolean;
34
- /**
35
- * Check if a position is in range.
36
- * When a position is in range it is earning fees and rewards
37
- *
38
- * # Parameters
39
- * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
40
- * - `tick_index_1` - A i32 integer representing the first tick index of the position
41
- * - `tick_index_2` - A i32 integer representing the second tick index of the position
42
- *
43
- * # Returns
44
- * - A boolean value indicating if the position is in range
45
- */
46
- export function isPositionInRange(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): boolean;
47
- /**
48
- * Calculate the status of a position
49
- * The status can be one of three values:
50
- * - InRange: The position is in range
51
- * - BelowRange: The position is below the range
52
- * - AboveRange: The position is above the range
53
- *
54
- * # Parameters
55
- * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
56
- * - `tick_index_1` - A i32 integer representing the first tick index of the position
57
- * - `tick_index_2` - A i32 integer representing the second tick index of the position
58
- *
59
- * # Returns
60
- * - A PositionStatus enum value indicating the status of the position
61
- */
62
- export function positionStatus(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionStatus;
63
- /**
64
- * Calculate the token_a / token_b ratio of a (ficticious) position
65
- *
66
- * # Parameters
67
- * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
68
- * - `tick_index_1` - A i32 integer representing the first tick index of the position
69
- * - `tick_index_2` - A i32 integer representing the second tick index of the position
70
- *
71
- * # Returns
72
- * - A PositionRatio struct containing the ratio of token_a and token_b
73
- */
74
- export function positionRatioX64(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionRatio;
75
- /**
76
- * Convert a price into a sqrt priceX64
77
- * IMPORTANT: floating point operations can reduce the precision of the result.
78
- * Make sure to do these operations last and not to use the result for further calculations.
79
- *
80
- * # Parameters
81
- * * `price` - The price to convert
82
- * * `decimals_a` - The number of decimals of the base token
83
- * * `decimals_b` - The number of decimals of the quote token
84
- *
85
- * # Returns
86
- * * `u128` - The sqrt priceX64
87
- */
88
- export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
89
- /**
90
- * Convert a sqrt priceX64 into a tick index
91
- * IMPORTANT: floating point operations can reduce the precision of the result.
92
- * Make sure to do these operations last and not to use the result for further calculations.
93
- *
94
- * # Parameters
95
- * * `sqrt_price` - The sqrt priceX64 to convert
96
- * * `decimals_a` - The number of decimals of the base token
97
- * * `decimals_b` - The number of decimals of the quote token
98
- *
99
- * # Returns
100
- * * `f64` - The decimal price
101
- */
102
- export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
103
- /**
104
- * Invert a price
105
- * IMPORTANT: floating point operations can reduce the precision of the result.
106
- * Make sure to do these operations last and not to use the result for further calculations.
107
- *
108
- * # Parameters
109
- * * `price` - The price to invert
110
- * * `decimals_a` - The number of decimals of the base token
111
- * * `decimals_b` - The number of decimals of the quote token
112
- *
113
- * # Returns
114
- * * `f64` - The inverted price
115
- */
116
- export function invertPrice(price: number, decimals_a: number, decimals_b: number): number;
117
- /**
118
- * Convert a tick index into a price
119
- * IMPORTANT: floating point operations can reduce the precision of the result.
120
- * Make sure to do these operations last and not to use the result for further calculations.
121
- *
122
- * # Parameters
123
- * * `tick_index` - The tick index to convert
124
- * * `decimals_a` - The number of decimals of the base token
125
- * * `decimals_b` - The number of decimals of the quote token
126
- *
127
- * # Returns
128
- * * `f64` - The decimal price
129
- */
130
- export function tickIndexToPrice(tick_index: number, decimals_a: number, decimals_b: number): number;
131
- /**
132
- * Convert a price into a tick index
133
- * IMPORTANT: floating point operations can reduce the precision of the result.
134
- * Make sure to do these operations last and not to use the result for further calculations.
135
- *
136
- * # Parameters
137
- * * `price` - The price to convert
138
- * * `decimals_a` - The number of decimals of the base token
139
- * * `decimals_b` - The number of decimals of the quote token
140
- *
141
- * # Returns
142
- * * `i32` - The tick index
143
- */
144
- export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
145
3
  export function _POSITION_BUNDLE_SIZE(): number;
146
4
  export function _FEE_RATE_MUL_VALUE(): number;
147
5
  export function _MAX_PROTOCOL_FEE_RATE(): number;
@@ -309,12 +167,6 @@ export function isFullRangeOnly(tick_spacing: number): boolean;
309
167
  * - A u32 integer representing the tick index in the tick array
310
168
  */
311
169
  export function getTickIndexInArray(tick_index: number, tick_array_start_index: number, tick_spacing: number): number;
312
- export function tryGetLiquidityFromAmountA(amount_a: bigint, sqrt_price_lower: bigint, sqrt_price_upper: bigint): bigint;
313
- export function tryGetAmountAFromLiquidity(liquidity: bigint, sqrt_price_lower: bigint, sqrt_price_upper: bigint, round_up: boolean): bigint;
314
- export function tryGetLiquidityFromAmountB(amount_b: bigint, sqrt_price_lower: bigint, sqrt_price_upper: bigint): bigint;
315
- export function tryGetAmountBFromLiquidity(liquidity: bigint, sqrt_price_lower: bigint, sqrt_price_upper: bigint, round_up: boolean): bigint;
316
- export function tryGetAmountsFromLiquidity(liquidity: bigint, sqrt_price: bigint, tick_lower_index: number, tick_upper_index: number, round_up: boolean): TokenPair;
317
- export function tryGetLiquidityFromAmounts(sqrt_price: bigint, sqrt_price_lower: bigint, sqrt_price_upper: bigint, amount_a: bigint, amount_b: bigint): bigint;
318
170
  /**
319
171
  * Calculate the quote for decreasing liquidity
320
172
  *
@@ -411,6 +263,154 @@ export function increaseLiquidityQuoteA(token_amount_a: bigint, slippage_toleran
411
263
  * - An IncreaseLiquidityQuote struct containing the estimated token amounts
412
264
  */
413
265
  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;
266
+ /**
267
+ * Get the first unoccupied position in a bundle
268
+ *
269
+ * # Arguments
270
+ * * `bundle` - The bundle to check
271
+ *
272
+ * # Returns
273
+ * * `u32` - The first unoccupied position (None if full)
274
+ */
275
+ export function firstUnoccupiedPositionInBundle(bitmap: Uint8Array): number | undefined;
276
+ /**
277
+ * Check whether a position bundle is full
278
+ * A position bundle can contain 256 positions
279
+ *
280
+ * # Arguments
281
+ * * `bundle` - The bundle to check
282
+ *
283
+ * # Returns
284
+ * * `bool` - Whether the bundle is full
285
+ */
286
+ export function isPositionBundleFull(bitmap: Uint8Array): boolean;
287
+ /**
288
+ * Check whether a position bundle is empty
289
+ *
290
+ * # Arguments
291
+ * * `bundle` - The bundle to check
292
+ *
293
+ * # Returns
294
+ * * `bool` - Whether the bundle is empty
295
+ */
296
+ export function isPositionBundleEmpty(bitmap: Uint8Array): boolean;
297
+ /**
298
+ * Check if a position is in range.
299
+ * When a position is in range it is earning fees and rewards
300
+ *
301
+ * # Parameters
302
+ * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
303
+ * - `tick_index_1` - A i32 integer representing the first tick index of the position
304
+ * - `tick_index_2` - A i32 integer representing the second tick index of the position
305
+ *
306
+ * # Returns
307
+ * - A boolean value indicating if the position is in range
308
+ */
309
+ export function isPositionInRange(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): boolean;
310
+ /**
311
+ * Calculate the status of a position
312
+ * The status can be one of three values:
313
+ * - InRange: The position is in range
314
+ * - BelowRange: The position is below the range
315
+ * - AboveRange: The position is above the range
316
+ *
317
+ * # Parameters
318
+ * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
319
+ * - `tick_index_1` - A i32 integer representing the first tick index of the position
320
+ * - `tick_index_2` - A i32 integer representing the second tick index of the position
321
+ *
322
+ * # Returns
323
+ * - A PositionStatus enum value indicating the status of the position
324
+ */
325
+ export function positionStatus(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionStatus;
326
+ /**
327
+ * Calculate the token_a / token_b ratio of a (ficticious) position
328
+ *
329
+ * # Parameters
330
+ * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
331
+ * - `tick_index_1` - A i32 integer representing the first tick index of the position
332
+ * - `tick_index_2` - A i32 integer representing the second tick index of the position
333
+ *
334
+ * # Returns
335
+ * - A PositionRatio struct containing the ratio of token_a and token_b
336
+ */
337
+ export function positionRatioX64(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionRatio;
338
+ /**
339
+ * Convert a price into a sqrt priceX64
340
+ * IMPORTANT: floating point operations can reduce the precision of the result.
341
+ * Make sure to do these operations last and not to use the result for further calculations.
342
+ *
343
+ * # Parameters
344
+ * * `price` - The price to convert
345
+ * * `decimals_a` - The number of decimals of the base token
346
+ * * `decimals_b` - The number of decimals of the quote token
347
+ *
348
+ * # Returns
349
+ * * `u128` - The sqrt priceX64
350
+ */
351
+ export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
352
+ /**
353
+ * Convert a sqrt priceX64 into a tick index
354
+ * IMPORTANT: floating point operations can reduce the precision of the result.
355
+ * Make sure to do these operations last and not to use the result for further calculations.
356
+ *
357
+ * # Parameters
358
+ * * `sqrt_price` - The sqrt priceX64 to convert
359
+ * * `decimals_a` - The number of decimals of the base token
360
+ * * `decimals_b` - The number of decimals of the quote token
361
+ *
362
+ * # Returns
363
+ * * `f64` - The decimal price
364
+ */
365
+ export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
366
+ /**
367
+ * Invert a price
368
+ * IMPORTANT: floating point operations can reduce the precision of the result.
369
+ * Make sure to do these operations last and not to use the result for further calculations.
370
+ *
371
+ * # Parameters
372
+ * * `price` - The price to invert
373
+ * * `decimals_a` - The number of decimals of the base token
374
+ * * `decimals_b` - The number of decimals of the quote token
375
+ *
376
+ * # Returns
377
+ * * `f64` - The inverted price
378
+ */
379
+ export function invertPrice(price: number, decimals_a: number, decimals_b: number): number;
380
+ /**
381
+ * Convert a tick index into a price
382
+ * IMPORTANT: floating point operations can reduce the precision of the result.
383
+ * Make sure to do these operations last and not to use the result for further calculations.
384
+ *
385
+ * # Parameters
386
+ * * `tick_index` - The tick index to convert
387
+ * * `decimals_a` - The number of decimals of the base token
388
+ * * `decimals_b` - The number of decimals of the quote token
389
+ *
390
+ * # Returns
391
+ * * `f64` - The decimal price
392
+ */
393
+ export function tickIndexToPrice(tick_index: number, decimals_a: number, decimals_b: number): number;
394
+ /**
395
+ * Convert a price into a tick index
396
+ * IMPORTANT: floating point operations can reduce the precision of the result.
397
+ * Make sure to do these operations last and not to use the result for further calculations.
398
+ *
399
+ * # Parameters
400
+ * * `price` - The price to convert
401
+ * * `decimals_a` - The number of decimals of the base token
402
+ * * `decimals_b` - The number of decimals of the quote token
403
+ *
404
+ * # Returns
405
+ * * `i32` - The tick index
406
+ */
407
+ export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
408
+ export function getLiquidityFromAmountA(amount_a: bigint, sqrt_price_lower: bigint, sqrt_price_upper: bigint): bigint;
409
+ export function getLiquidityFromAmountB(amount_b: bigint, sqrt_price_lower: bigint, sqrt_price_upper: bigint): bigint;
410
+ export function getAmountAFromLiquidity(liquidity: bigint, sqrt_price_lower: bigint, sqrt_price_upper: bigint, round_up: boolean): bigint;
411
+ export function getAmountBFromLiquidity(liquidity: bigint, sqrt_price_lower: bigint, sqrt_price_upper: bigint, round_up: boolean): bigint;
412
+ export function getAmountsFromLiquidity(liquidity: bigint, sqrt_price: bigint, sqrt_price_lower: bigint, sqrt_price_upper: bigint, round_up: boolean): TokenPair;
413
+ export function getLiquidityFromAmounts(sqrt_price: bigint, sqrt_price_lower: bigint, sqrt_price_upper: bigint, amount_a: bigint, amount_b: bigint): bigint;
414
414
  /**
415
415
  * Calculate the amount A delta between two sqrt_prices
416
416
  *
@@ -735,11 +735,6 @@ export function _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR(): string;
735
735
  * Initialize Javascript logging and panic handler
736
736
  */
737
737
  export function solana_program_init(): void;
738
- export interface CollectFeesQuote {
739
- feeOwedA: bigint;
740
- feeOwedB: bigint;
741
- }
742
-
743
738
  export interface LimitOrderDecreaseQuote {
744
739
  amountOutA: bigint;
745
740
  amountOutB: bigint;
@@ -754,6 +749,32 @@ export interface LimitOrderFacade {
754
749
  age: bigint;
755
750
  }
756
751
 
752
+ export interface TransferFee {
753
+ feeBps: number;
754
+ maxFee: bigint;
755
+ }
756
+
757
+ export interface IncreaseLiquidityQuote {
758
+ liquidityDelta: bigint;
759
+ tokenEstA: bigint;
760
+ tokenEstB: bigint;
761
+ tokenMaxA: bigint;
762
+ tokenMaxB: bigint;
763
+ }
764
+
765
+ export interface DecreaseLiquidityQuote {
766
+ liquidityDelta: bigint;
767
+ tokenEstA: bigint;
768
+ tokenEstB: bigint;
769
+ tokenMinA: bigint;
770
+ tokenMinB: bigint;
771
+ }
772
+
773
+ export interface CollectFeesQuote {
774
+ feeOwedA: bigint;
775
+ feeOwedB: bigint;
776
+ }
777
+
757
778
  export interface FusionPoolFacade {
758
779
  tickSpacing: number;
759
780
  feeRate: number;
@@ -776,27 +797,6 @@ export interface TokenPair {
776
797
  b: bigint;
777
798
  }
778
799
 
779
- export interface TransferFee {
780
- feeBps: number;
781
- maxFee: bigint;
782
- }
783
-
784
- export interface IncreaseLiquidityQuote {
785
- liquidityDelta: bigint;
786
- tokenEstA: bigint;
787
- tokenEstB: bigint;
788
- tokenMaxA: bigint;
789
- tokenMaxB: bigint;
790
- }
791
-
792
- export interface DecreaseLiquidityQuote {
793
- liquidityDelta: bigint;
794
- tokenEstA: bigint;
795
- tokenEstB: bigint;
796
- tokenMinA: bigint;
797
- tokenMinB: bigint;
798
- }
799
-
800
800
  export interface PositionFacade {
801
801
  liquidity: bigint;
802
802
  tickLowerIndex: number;