@orca-so/whirlpools-core 1.0.0 → 1.0.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,62 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- /**
4
- * Check if a position is in range.
5
- * When a position is in range it is earning fees and rewards
6
- *
7
- * # Parameters
8
- * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
9
- * - `tick_index_1` - A i32 integer representing the first tick index of the position
10
- * - `tick_index_2` - A i32 integer representing the second tick index of the position
11
- *
12
- * # Returns
13
- * - A boolean value indicating if the position is in range
14
- */
15
- export function isPositionInRange(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): boolean;
16
- /**
17
- * Calculate the status of a position
18
- * The status can be one of three values:
19
- * - InRange: The position is in range
20
- * - BelowRange: The position is below the range
21
- * - AboveRange: The position is above the range
22
- *
23
- * # Parameters
24
- * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
25
- * - `tick_index_1` - A i32 integer representing the first tick index of the position
26
- * - `tick_index_2` - A i32 integer representing the second tick index of the position
27
- *
28
- * # Returns
29
- * - A PositionStatus enum value indicating the status of the position
30
- */
31
- export function positionStatus(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionStatus;
32
- /**
33
- * Calculate the token_a / token_b ratio of a (ficticious) position
34
- *
35
- * # Parameters
36
- * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
37
- * - `tick_index_1` - A i32 integer representing the first tick index of the position
38
- * - `tick_index_2` - A i32 integer representing the second tick index of the position
39
- *
40
- * # Returns
41
- * - A PositionRatio struct containing the ratio of token_a and token_b
42
- */
43
- export function positionRatio(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionRatio;
44
- export function _POSITION_BUNDLE_SIZE(): number;
45
- export function _TICK_ARRAY_NOT_EVENLY_SPACED(): string;
46
- export function _TICK_INDEX_OUT_OF_BOUNDS(): string;
47
- export function _INVALID_TICK_INDEX(): string;
48
- export function _ARITHMETIC_OVERFLOW(): string;
49
- export function _AMOUNT_EXCEEDS_MAX_U64(): string;
50
- export function _SQRT_PRICE_OUT_OF_BOUNDS(): string;
51
- export function _TICK_SEQUENCE_EMPTY(): string;
52
- export function _SQRT_PRICE_LIMIT_OUT_OF_BOUNDS(): string;
53
- export function _INVALID_SQRT_PRICE_LIMIT_DIRECTION(): string;
54
- export function _ZERO_TRADABLE_AMOUNT(): string;
55
- export function _INVALID_TIMESTAMP(): string;
56
- export function _INVALID_TRANSFER_FEE(): string;
57
- export function _INVALID_SLIPPAGE_TOLERANCE(): string;
58
- export function _TICK_INDEX_NOT_IN_ARRAY(): string;
59
- export function _NUM_REWARDS(): number;
60
3
  export function _FEE_RATE_DENOMINATOR(): number;
61
4
  export function _TICK_ARRAY_SIZE(): number;
62
5
  export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD(): number;
@@ -93,6 +36,77 @@ export function isPositionBundleFull(bitmap: Uint8Array): boolean;
93
36
  * * `bool` - Whether the bundle is empty
94
37
  */
95
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;
96
110
  /**
97
111
  * Get the first tick index in the tick array that contains the specified tick index.
98
112
  *
@@ -252,6 +266,62 @@ export function isFullRangeOnly(tick_spacing: number): boolean;
252
266
  * - A u32 integer representing the tick index in the tick array
253
267
  */
254
268
  export function getTickIndexInArray(tick_index: number, tick_array_start_index: number, tick_spacing: number): number;
269
+ export function _POSITION_BUNDLE_SIZE(): number;
270
+ export function _TICK_ARRAY_NOT_EVENLY_SPACED(): string;
271
+ export function _TICK_INDEX_OUT_OF_BOUNDS(): string;
272
+ export function _INVALID_TICK_INDEX(): string;
273
+ export function _ARITHMETIC_OVERFLOW(): string;
274
+ export function _AMOUNT_EXCEEDS_MAX_U64(): string;
275
+ export function _SQRT_PRICE_OUT_OF_BOUNDS(): string;
276
+ export function _TICK_SEQUENCE_EMPTY(): string;
277
+ export function _SQRT_PRICE_LIMIT_OUT_OF_BOUNDS(): string;
278
+ export function _INVALID_SQRT_PRICE_LIMIT_DIRECTION(): string;
279
+ export function _ZERO_TRADABLE_AMOUNT(): string;
280
+ export function _INVALID_TIMESTAMP(): string;
281
+ export function _INVALID_TRANSFER_FEE(): string;
282
+ export function _INVALID_SLIPPAGE_TOLERANCE(): string;
283
+ export function _TICK_INDEX_NOT_IN_ARRAY(): string;
284
+ /**
285
+ * Check if a position is in range.
286
+ * When a position is in range it is earning fees and rewards
287
+ *
288
+ * # Parameters
289
+ * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
290
+ * - `tick_index_1` - A i32 integer representing the first tick index of the position
291
+ * - `tick_index_2` - A i32 integer representing the second tick index of the position
292
+ *
293
+ * # Returns
294
+ * - A boolean value indicating if the position is in range
295
+ */
296
+ export function isPositionInRange(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): boolean;
297
+ /**
298
+ * Calculate the status of a position
299
+ * The status can be one of three values:
300
+ * - InRange: The position is in range
301
+ * - BelowRange: The position is below the range
302
+ * - AboveRange: The position is above the range
303
+ *
304
+ * # Parameters
305
+ * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
306
+ * - `tick_index_1` - A i32 integer representing the first tick index of the position
307
+ * - `tick_index_2` - A i32 integer representing the second tick index of the position
308
+ *
309
+ * # Returns
310
+ * - A PositionStatus enum value indicating the status of the position
311
+ */
312
+ export function positionStatus(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionStatus;
313
+ /**
314
+ * Calculate the token_a / token_b ratio of a (ficticious) position
315
+ *
316
+ * # Parameters
317
+ * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
318
+ * - `tick_index_1` - A i32 integer representing the first tick index of the position
319
+ * - `tick_index_2` - A i32 integer representing the second tick index of the position
320
+ *
321
+ * # Returns
322
+ * - A PositionRatio struct containing the ratio of token_a and token_b
323
+ */
324
+ export function positionRatio(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionRatio;
255
325
  /**
256
326
  * Calculate the amount A delta between two sqrt_prices
257
327
  *
@@ -412,76 +482,6 @@ export function swapQuoteByInputToken(token_in: bigint, specified_token_a: boole
412
482
  * The exact input or output amount for the swap transaction.
413
483
  */
414
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;
415
- /**
416
- * Convert a price into a sqrt priceX64
417
- * IMPORTANT: floating point operations can reduce the precision of the result.
418
- * Make sure to do these operations last and not to use the result for further calculations.
419
- *
420
- * # Parameters
421
- * * `price` - The price to convert
422
- * * `decimals_a` - The number of decimals of the base token
423
- * * `decimals_b` - The number of decimals of the quote token
424
- *
425
- * # Returns
426
- * * `u128` - The sqrt priceX64
427
- */
428
- export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
429
- /**
430
- * Convert a sqrt priceX64 into a tick index
431
- * IMPORTANT: floating point operations can reduce the precision of the result.
432
- * Make sure to do these operations last and not to use the result for further calculations.
433
- *
434
- * # Parameters
435
- * * `sqrt_price` - The sqrt priceX64 to convert
436
- * * `decimals_a` - The number of decimals of the base token
437
- * * `decimals_b` - The number of decimals of the quote token
438
- *
439
- * # Returns
440
- * * `f64` - The decimal price
441
- */
442
- export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
443
- /**
444
- * Invert a price
445
- * IMPORTANT: floating point operations can reduce the precision of the result.
446
- * Make sure to do these operations last and not to use the result for further calculations.
447
- *
448
- * # Parameters
449
- * * `price` - The price to invert
450
- * * `decimals_a` - The number of decimals of the base token
451
- * * `decimals_b` - The number of decimals of the quote token
452
- *
453
- * # Returns
454
- * * `f64` - The inverted price
455
- */
456
- export function invertPrice(price: number, decimals_a: number, decimals_b: number): number;
457
- /**
458
- * Convert a tick index into a price
459
- * IMPORTANT: floating point operations can reduce the precision of the result.
460
- * Make sure to do these operations last and not to use the result for further calculations.
461
- *
462
- * # Parameters
463
- * * `tick_index` - The tick index to convert
464
- * * `decimals_a` - The number of decimals of the base token
465
- * * `decimals_b` - The number of decimals of the quote token
466
- *
467
- * # Returns
468
- * * `f64` - The decimal price
469
- */
470
- export function tickIndexToPrice(tick_index: number, decimals_a: number, decimals_b: number): number;
471
- /**
472
- * Convert a price into a tick index
473
- * IMPORTANT: floating point operations can reduce the precision of the result.
474
- * Make sure to do these operations last and not to use the result for further calculations.
475
- *
476
- * # Parameters
477
- * * `price` - The price to convert
478
- * * `decimals_a` - The number of decimals of the base token
479
- * * `decimals_b` - The number of decimals of the quote token
480
- *
481
- * # Returns
482
- * * `i32` - The tick index
483
- */
484
- export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
485
485
  /**
486
486
  * Calculate fees owed for a position
487
487
  *
@@ -615,6 +615,27 @@ export interface TransferFee {
615
615
  maxFee: bigint;
616
616
  }
617
617
 
618
+ export interface IncreaseLiquidityQuote {
619
+ liquidityDelta: bigint;
620
+ tokenEstA: bigint;
621
+ tokenEstB: bigint;
622
+ tokenMaxA: bigint;
623
+ tokenMaxB: bigint;
624
+ }
625
+
626
+ export interface DecreaseLiquidityQuote {
627
+ liquidityDelta: bigint;
628
+ tokenEstA: bigint;
629
+ tokenEstB: bigint;
630
+ tokenMinA: bigint;
631
+ tokenMinB: bigint;
632
+ }
633
+
634
+ export interface CollectFeesQuote {
635
+ feeOwedA: bigint;
636
+ feeOwedB: bigint;
637
+ }
638
+
618
639
  export interface TickArrayFacade {
619
640
  startTickIndex: number;
620
641
  ticks: TickFacade[];
@@ -634,22 +655,6 @@ export interface TickRange {
634
655
  tickUpperIndex: number;
635
656
  }
636
657
 
637
- export interface IncreaseLiquidityQuote {
638
- liquidityDelta: bigint;
639
- tokenEstA: bigint;
640
- tokenEstB: bigint;
641
- tokenMaxA: bigint;
642
- tokenMaxB: bigint;
643
- }
644
-
645
- export interface DecreaseLiquidityQuote {
646
- liquidityDelta: bigint;
647
- tokenEstA: bigint;
648
- tokenEstB: bigint;
649
- tokenMinA: bigint;
650
- tokenMinB: bigint;
651
- }
652
-
653
658
  export interface ExactOutSwapQuote {
654
659
  tokenOut: bigint;
655
660
  tokenEstIn: bigint;
@@ -664,9 +669,22 @@ export interface ExactInSwapQuote {
664
669
  tradeFee: bigint;
665
670
  }
666
671
 
667
- export interface CollectFeesQuote {
668
- feeOwedA: bigint;
669
- feeOwedB: bigint;
672
+ export interface WhirlpoolRewardInfoFacade {
673
+ emissionsPerSecondX64: bigint;
674
+ growthGlobalX64: bigint;
675
+ }
676
+
677
+ export interface WhirlpoolFacade {
678
+ tickSpacing: number;
679
+ feeRate: number;
680
+ protocolFeeRate: number;
681
+ liquidity: bigint;
682
+ sqrtPrice: bigint;
683
+ tickCurrentIndex: number;
684
+ feeGrowthGlobalA: bigint;
685
+ feeGrowthGlobalB: bigint;
686
+ rewardLastUpdatedTimestamp: bigint;
687
+ rewardInfos: WhirlpoolRewardInfoFacade[];
670
688
  }
671
689
 
672
690
  export interface CollectRewardQuote {
@@ -700,21 +718,3 @@ export interface PositionRatio {
700
718
  ratioB: number;
701
719
  }
702
720
 
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
-