@crypticdot/defituna-core 3.4.5 → 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.
@@ -263,28 +263,154 @@ export function increaseLiquidityQuoteA(token_amount_a: bigint, slippage_toleran
263
263
  * - An IncreaseLiquidityQuote struct containing the estimated token amounts
264
264
  */
265
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
- 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
266
  /**
273
- * Calculate fees owed for a position
267
+ * Get the first unoccupied position in a bundle
274
268
  *
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
269
+ * # Arguments
270
+ * * `bundle` - The bundle to check
282
271
  *
283
272
  * # Returns
284
- * - `CollectFeesQuote`: The fees owed for token A and token B
273
+ * * `u32` - The first unoccupied position (None if full)
285
274
  */
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;
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;
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,44 @@ 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 LimitOrderDecreaseQuote {
739
+ amountOutA: bigint;
740
+ amountOutB: bigint;
741
+ rewardA: bigint;
742
+ rewardB: bigint;
743
743
  }
744
744
 
745
- export interface ExactInSwapQuote {
746
- tokenIn: bigint;
747
- tokenEstOut: bigint;
748
- tokenMinOut: bigint;
749
- tradeFee: bigint;
750
- nextSqrtPrice: bigint;
745
+ export interface LimitOrderFacade {
746
+ tickIndex: number;
747
+ amount: bigint;
748
+ aToB: boolean;
749
+ age: bigint;
750
+ }
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;
751
776
  }
752
777
 
753
778
  export interface FusionPoolFacade {
@@ -767,35 +792,11 @@ export interface FusionPoolFacade {
767
792
  olpFeeOwedB: bigint;
768
793
  }
769
794
 
770
- export interface CollectFeesQuote {
771
- feeOwedA: bigint;
772
- feeOwedB: bigint;
773
- }
774
-
775
795
  export interface TokenPair {
776
796
  a: bigint;
777
797
  b: bigint;
778
798
  }
779
799
 
780
- export interface LimitOrderDecreaseQuote {
781
- amountOutA: bigint;
782
- amountOutB: bigint;
783
- rewardA: bigint;
784
- rewardB: bigint;
785
- }
786
-
787
- export interface LimitOrderFacade {
788
- tickIndex: number;
789
- amount: bigint;
790
- aToB: boolean;
791
- age: bigint;
792
- }
793
-
794
- export interface TransferFee {
795
- feeBps: number;
796
- maxFee: bigint;
797
- }
798
-
799
800
  export interface PositionFacade {
800
801
  liquidity: bigint;
801
802
  tickLowerIndex: number;
@@ -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 {