@crypticdot/defituna-core 3.4.5 → 3.4.6

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,5 +1,147 @@
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;
3
145
  export function _POSITION_BUNDLE_SIZE(): number;
4
146
  export function _FEE_RATE_MUL_VALUE(): number;
5
147
  export function _MAX_PROTOCOL_FEE_RATE(): number;
@@ -167,6 +309,12 @@ export function isFullRangeOnly(tick_spacing: number): boolean;
167
309
  * - A u32 integer representing the tick index in the tick array
168
310
  */
169
311
  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;
170
318
  /**
171
319
  * Calculate the quote for decreasing liquidity
172
320
  *
@@ -263,28 +411,6 @@ export function increaseLiquidityQuoteA(token_amount_a: bigint, slippage_toleran
263
411
  * - An IncreaseLiquidityQuote struct containing the estimated token amounts
264
412
  */
265
413
  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
- export function tryGetLiquidityFromA(token_delta_a: bigint, sqrt_price_lower: bigint, sqrt_price_upper: bigint): bigint;
267
- export function tryGetTokenAFromLiquidity(liquidity_delta: bigint, sqrt_price_lower: bigint, sqrt_price_upper: bigint, round_up: boolean): bigint;
268
- export function tryGetLiquidityFromB(token_delta_b: bigint, sqrt_price_lower: bigint, sqrt_price_upper: bigint): bigint;
269
- export function tryGetTokenBFromLiquidity(liquidity_delta: bigint, sqrt_price_lower: bigint, sqrt_price_upper: bigint, round_up: boolean): bigint;
270
- export function tryGetAmountsFromLiquidity(liquidity_delta: bigint, current_sqrt_price: bigint, tick_lower_index: number, tick_upper_index: number, round_up: boolean): TokenPair;
271
- export function tryGetLiquidityFromAmounts(sqrt_price: bigint, sqrt_price_a_x64: bigint, sqrt_price_b_x64: bigint, amount_a: bigint, amount_b: bigint): bigint;
272
- /**
273
- * Calculate fees owed for a position
274
- *
275
- * # Paramters
276
- * - `fusion_pool`: The fusion_pool state
277
- * - `position`: The position state
278
- * - `tick_lower`: The lower tick state
279
- * - `tick_upper`: The upper tick state
280
- * - `transfer_fee_a`: The transfer fee for token A
281
- * - `transfer_fee_b`: The transfer fee for token B
282
- *
283
- * # Returns
284
- * - `CollectFeesQuote`: The fees owed for token A and token B
285
- */
286
- export function collectFeesQuote(fusion_pool: FusionPoolFacade, position: PositionFacade, tick_lower: TickFacade, tick_upper: TickFacade, transfer_fee_a?: TransferFee | null, transfer_fee_b?: TransferFee | null): CollectFeesQuote;
287
- export function limitOrderFee(fusion_pool: FusionPoolFacade): number;
288
414
  /**
289
415
  * Calculate the amount A delta between two sqrt_prices
290
416
  *
@@ -442,147 +568,21 @@ export function limitOrderQuoteByOutputToken(amount_out: bigint, a_to_b_order: b
442
568
  export function limitOrderRewardByOutputToken(amount_out: bigint, fee_rate: number, protocol_fee_rate: number): bigint;
443
569
  export function decreaseLimitOrderQuote(fusion_pool: FusionPoolFacade, limit_order: LimitOrderFacade, tick: TickFacade, amount: bigint, transfer_fee_a?: TransferFee | null, transfer_fee_b?: TransferFee | null): LimitOrderDecreaseQuote;
444
570
  /**
445
- * Get the first unoccupied position in a bundle
446
- *
447
- * # Arguments
448
- * * `bundle` - The bundle to check
449
- *
450
- * # Returns
451
- * * `u32` - The first unoccupied position (None if full)
452
- */
453
- export function firstUnoccupiedPositionInBundle(bitmap: Uint8Array): number | undefined;
454
- /**
455
- * Check whether a position bundle is full
456
- * A position bundle can contain 256 positions
457
- *
458
- * # Arguments
459
- * * `bundle` - The bundle to check
460
- *
461
- * # Returns
462
- * * `bool` - Whether the bundle is full
463
- */
464
- export function isPositionBundleFull(bitmap: Uint8Array): boolean;
465
- /**
466
- * Check whether a position bundle is empty
467
- *
468
- * # Arguments
469
- * * `bundle` - The bundle to check
470
- *
471
- * # Returns
472
- * * `bool` - Whether the bundle is empty
473
- */
474
- export function isPositionBundleEmpty(bitmap: Uint8Array): boolean;
475
- /**
476
- * Check if a position is in range.
477
- * When a position is in range it is earning fees and rewards
478
- *
479
- * # Parameters
480
- * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
481
- * - `tick_index_1` - A i32 integer representing the first tick index of the position
482
- * - `tick_index_2` - A i32 integer representing the second tick index of the position
483
- *
484
- * # Returns
485
- * - A boolean value indicating if the position is in range
486
- */
487
- export function isPositionInRange(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): boolean;
488
- /**
489
- * Calculate the status of a position
490
- * The status can be one of three values:
491
- * - InRange: The position is in range
492
- * - BelowRange: The position is below the range
493
- * - AboveRange: The position is above the range
494
- *
495
- * # Parameters
496
- * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
497
- * - `tick_index_1` - A i32 integer representing the first tick index of the position
498
- * - `tick_index_2` - A i32 integer representing the second tick index of the position
499
- *
500
- * # Returns
501
- * - A PositionStatus enum value indicating the status of the position
502
- */
503
- export function positionStatus(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionStatus;
504
- /**
505
- * Calculate the token_a / token_b ratio of a (ficticious) position
506
- *
507
- * # Parameters
508
- * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
509
- * - `tick_index_1` - A i32 integer representing the first tick index of the position
510
- * - `tick_index_2` - A i32 integer representing the second tick index of the position
511
- *
512
- * # Returns
513
- * - A PositionRatio struct containing the ratio of token_a and token_b
514
- */
515
- export function positionRatioX64(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionRatio;
516
- /**
517
- * Convert a price into a sqrt priceX64
518
- * IMPORTANT: floating point operations can reduce the precision of the result.
519
- * Make sure to do these operations last and not to use the result for further calculations.
520
- *
521
- * # Parameters
522
- * * `price` - The price to convert
523
- * * `decimals_a` - The number of decimals of the base token
524
- * * `decimals_b` - The number of decimals of the quote token
525
- *
526
- * # Returns
527
- * * `u128` - The sqrt priceX64
528
- */
529
- export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
530
- /**
531
- * Convert a sqrt priceX64 into a tick index
532
- * IMPORTANT: floating point operations can reduce the precision of the result.
533
- * Make sure to do these operations last and not to use the result for further calculations.
534
- *
535
- * # Parameters
536
- * * `sqrt_price` - The sqrt priceX64 to convert
537
- * * `decimals_a` - The number of decimals of the base token
538
- * * `decimals_b` - The number of decimals of the quote token
539
- *
540
- * # Returns
541
- * * `f64` - The decimal price
542
- */
543
- export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
544
- /**
545
- * Invert a price
546
- * IMPORTANT: floating point operations can reduce the precision of the result.
547
- * Make sure to do these operations last and not to use the result for further calculations.
548
- *
549
- * # Parameters
550
- * * `price` - The price to invert
551
- * * `decimals_a` - The number of decimals of the base token
552
- * * `decimals_b` - The number of decimals of the quote token
553
- *
554
- * # Returns
555
- * * `f64` - The inverted price
556
- */
557
- export function invertPrice(price: number, decimals_a: number, decimals_b: number): number;
558
- /**
559
- * Convert a tick index into a price
560
- * IMPORTANT: floating point operations can reduce the precision of the result.
561
- * Make sure to do these operations last and not to use the result for further calculations.
562
- *
563
- * # Parameters
564
- * * `tick_index` - The tick index to convert
565
- * * `decimals_a` - The number of decimals of the base token
566
- * * `decimals_b` - The number of decimals of the quote token
567
- *
568
- * # Returns
569
- * * `f64` - The decimal price
570
- */
571
- export function tickIndexToPrice(tick_index: number, decimals_a: number, decimals_b: number): number;
572
- /**
573
- * Convert a price into a tick index
574
- * IMPORTANT: floating point operations can reduce the precision of the result.
575
- * Make sure to do these operations last and not to use the result for further calculations.
571
+ * Calculate fees owed for a position
576
572
  *
577
- * # Parameters
578
- * * `price` - The price to convert
579
- * * `decimals_a` - The number of decimals of the base token
580
- * * `decimals_b` - The number of decimals of the quote token
573
+ * # Paramters
574
+ * - `fusion_pool`: The fusion_pool state
575
+ * - `position`: The position state
576
+ * - `tick_lower`: The lower tick state
577
+ * - `tick_upper`: The upper tick state
578
+ * - `transfer_fee_a`: The transfer fee for token A
579
+ * - `transfer_fee_b`: The transfer fee for token B
581
580
  *
582
581
  * # Returns
583
- * * `i32` - The tick index
582
+ * - `CollectFeesQuote`: The fees owed for token A and token B
584
583
  */
585
- export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
584
+ export function collectFeesQuote(fusion_pool: FusionPoolFacade, position: PositionFacade, tick_lower: TickFacade, tick_upper: TickFacade, transfer_fee_a?: TransferFee | null, transfer_fee_b?: TransferFee | null): CollectFeesQuote;
585
+ export function limitOrderFee(fusion_pool: FusionPoolFacade): number;
586
586
  export function _TICK_ARRAY_NOT_EVENLY_SPACED(): string;
587
587
  export function _TICK_INDEX_OUT_OF_BOUNDS(): string;
588
588
  export function _INVALID_TICK_INDEX(): string;
@@ -593,6 +593,7 @@ export function _SQRT_PRICE_OUT_OF_BOUNDS(): string;
593
593
  export function _TICK_SEQUENCE_EMPTY(): string;
594
594
  export function _SQRT_PRICE_LIMIT_OUT_OF_BOUNDS(): string;
595
595
  export function _INVALID_SQRT_PRICE_LIMIT_DIRECTION(): string;
596
+ export function _INVALID_RANGE_BOUNDS(): string;
596
597
  export function _ZERO_TRADABLE_AMOUNT(): string;
597
598
  export function _INVALID_TIMESTAMP(): string;
598
599
  export function _INVALID_TRANSFER_FEE(): string;
@@ -734,20 +735,23 @@ export function _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR(): string;
734
735
  * Initialize Javascript logging and panic handler
735
736
  */
736
737
  export function solana_program_init(): void;
737
- export interface ExactOutSwapQuote {
738
- tokenOut: bigint;
739
- tokenEstIn: bigint;
740
- tokenMaxIn: bigint;
741
- tradeFee: bigint;
742
- nextSqrtPrice: bigint;
738
+ export interface CollectFeesQuote {
739
+ feeOwedA: bigint;
740
+ feeOwedB: bigint;
743
741
  }
744
742
 
745
- export interface ExactInSwapQuote {
746
- tokenIn: bigint;
747
- tokenEstOut: bigint;
748
- tokenMinOut: bigint;
749
- tradeFee: bigint;
750
- nextSqrtPrice: bigint;
743
+ export interface LimitOrderDecreaseQuote {
744
+ amountOutA: bigint;
745
+ amountOutB: bigint;
746
+ rewardA: bigint;
747
+ rewardB: bigint;
748
+ }
749
+
750
+ export interface LimitOrderFacade {
751
+ tickIndex: number;
752
+ amount: bigint;
753
+ aToB: boolean;
754
+ age: bigint;
751
755
  }
752
756
 
753
757
  export interface FusionPoolFacade {
@@ -767,33 +771,30 @@ export interface FusionPoolFacade {
767
771
  olpFeeOwedB: bigint;
768
772
  }
769
773
 
770
- export interface CollectFeesQuote {
771
- feeOwedA: bigint;
772
- feeOwedB: bigint;
773
- }
774
-
775
774
  export interface TokenPair {
776
775
  a: bigint;
777
776
  b: bigint;
778
777
  }
779
778
 
780
- export interface LimitOrderDecreaseQuote {
781
- amountOutA: bigint;
782
- amountOutB: bigint;
783
- rewardA: bigint;
784
- rewardB: bigint;
779
+ export interface TransferFee {
780
+ feeBps: number;
781
+ maxFee: bigint;
785
782
  }
786
783
 
787
- export interface LimitOrderFacade {
788
- tickIndex: number;
789
- amount: bigint;
790
- aToB: boolean;
791
- age: bigint;
784
+ export interface IncreaseLiquidityQuote {
785
+ liquidityDelta: bigint;
786
+ tokenEstA: bigint;
787
+ tokenEstB: bigint;
788
+ tokenMaxA: bigint;
789
+ tokenMaxB: bigint;
792
790
  }
793
791
 
794
- export interface TransferFee {
795
- feeBps: number;
796
- maxFee: bigint;
792
+ export interface DecreaseLiquidityQuote {
793
+ liquidityDelta: bigint;
794
+ tokenEstA: bigint;
795
+ tokenEstB: bigint;
796
+ tokenMinA: bigint;
797
+ tokenMinB: bigint;
797
798
  }
798
799
 
799
800
  export interface PositionFacade {
@@ -813,20 +814,20 @@ export interface PositionRatio {
813
814
  ratioB: bigint;
814
815
  }
815
816
 
816
- export interface IncreaseLiquidityQuote {
817
- liquidityDelta: bigint;
818
- tokenEstA: bigint;
819
- tokenEstB: bigint;
820
- tokenMaxA: bigint;
821
- tokenMaxB: bigint;
817
+ export interface ExactOutSwapQuote {
818
+ tokenOut: bigint;
819
+ tokenEstIn: bigint;
820
+ tokenMaxIn: bigint;
821
+ tradeFee: bigint;
822
+ nextSqrtPrice: bigint;
822
823
  }
823
824
 
824
- export interface DecreaseLiquidityQuote {
825
- liquidityDelta: bigint;
826
- tokenEstA: bigint;
827
- tokenEstB: bigint;
828
- tokenMinA: bigint;
829
- tokenMinB: bigint;
825
+ export interface ExactInSwapQuote {
826
+ tokenIn: bigint;
827
+ tokenEstOut: bigint;
828
+ tokenMinOut: bigint;
829
+ tradeFee: bigint;
830
+ nextSqrtPrice: bigint;
830
831
  }
831
832
 
832
833
  export interface TickArrayFacade {