@crypticdot/defituna-core 3.3.6 → 3.4.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.
@@ -262,232 +262,6 @@ function passArray8ToWasm0(arg, malloc) {
262
262
  WASM_VECTOR_LEN = arg.length;
263
263
  return ptr;
264
264
  }
265
- /**
266
- * Get the first tick index in the tick array that contains the specified tick index.
267
- *
268
- * # Parameters
269
- * - `tick_index` - A i32 integer representing the tick integer
270
- * - `tick_spacing` - A i32 integer representing the tick spacing
271
- *
272
- * # Returns
273
- * - A i32 integer representing the first tick index in the tick array
274
- */
275
- export function getTickArrayStartTickIndex(tick_index, tick_spacing) {
276
- const ret = wasm.getTickArrayStartTickIndex(tick_index, tick_spacing);
277
- return ret;
278
- }
279
-
280
- /**
281
- * Derive the sqrt-price from a tick index. The precision of this method is only guarranted
282
- * if tick is within the bounds of {max, min} tick-index.
283
- *
284
- * # Parameters
285
- * - `tick_index` - A i32 integer representing the tick integer
286
- *
287
- * # Returns
288
- * - `Ok`: A u128 Q32.64 representing the sqrt_price
289
- */
290
- export function tickIndexToSqrtPrice(tick_index) {
291
- const ret = wasm.tickIndexToSqrtPrice(tick_index);
292
- return takeObject(ret);
293
- }
294
-
295
- /**
296
- * Derive the tick index from a sqrt price. The precision of this method is only guarranted
297
- * if tick is within the bounds of {max, min} tick-index.
298
- *
299
- * # Parameters
300
- * - `sqrt_price` - A u128 integer representing the sqrt price
301
- *
302
- * # Returns
303
- * - `Ok`: A i32 integer representing the tick integer
304
- */
305
- export function sqrtPriceToTickIndex(sqrt_price) {
306
- const ret = wasm.sqrtPriceToTickIndex(addHeapObject(sqrt_price));
307
- return ret;
308
- }
309
-
310
- /**
311
- * Get the initializable tick index.
312
- * If the tick index is already initializable, it is returned as is.
313
- *
314
- * # Parameters
315
- * - `tick_index` - A i32 integer representing the tick integer
316
- * - `tick_spacing` - A i32 integer representing the tick spacing
317
- * - `round_up` - A boolean value indicating if the supplied tick index should be rounded up. None will round to the nearest.
318
- *
319
- * # Returns
320
- * - A i32 integer representing the previous initializable tick index
321
- */
322
- export function getInitializableTickIndex(tick_index, tick_spacing, round_up) {
323
- const ret = wasm.getInitializableTickIndex(tick_index, tick_spacing, isLikeNone(round_up) ? 0xFFFFFF : round_up ? 1 : 0);
324
- return ret;
325
- }
326
-
327
- /**
328
- * Get the previous initializable tick index.
329
- *
330
- * # Parameters
331
- * - `tick_index` - A i32 integer representing the tick integer
332
- * - `tick_spacing` - A i32 integer representing the tick spacing
333
- *
334
- * # Returns
335
- * - A i32 integer representing the previous initializable tick index
336
- */
337
- export function getPrevInitializableTickIndex(tick_index, tick_spacing) {
338
- const ret = wasm.getPrevInitializableTickIndex(tick_index, tick_spacing);
339
- return ret;
340
- }
341
-
342
- /**
343
- * Get the next initializable tick index.
344
- *
345
- * # Parameters
346
- * - `tick_index` - A i32 integer representing the tick integer
347
- * - `tick_spacing` - A i32 integer representing the tick spacing
348
- *
349
- * # Returns
350
- * - A i32 integer representing the next initializable tick index
351
- */
352
- export function getNextInitializableTickIndex(tick_index, tick_spacing) {
353
- const ret = wasm.getNextInitializableTickIndex(tick_index, tick_spacing);
354
- return ret;
355
- }
356
-
357
- /**
358
- * Check if a tick is in-bounds.
359
- *
360
- * # Parameters
361
- * - `tick_index` - A i32 integer representing the tick integer
362
- *
363
- * # Returns
364
- * - A boolean value indicating if the tick is in-bounds
365
- */
366
- export function isTickIndexInBounds(tick_index) {
367
- const ret = wasm.isTickIndexInBounds(tick_index);
368
- return ret !== 0;
369
- }
370
-
371
- /**
372
- * Check if a tick is initializable.
373
- * A tick is initializable if it is divisible by the tick spacing.
374
- *
375
- * # Parameters
376
- * - `tick_index` - A i32 integer representing the tick integer
377
- * - `tick_spacing` - A i32 integer representing the tick spacing
378
- *
379
- * # Returns
380
- * - A boolean value indicating if the tick is initializable
381
- */
382
- export function isTickInitializable(tick_index, tick_spacing) {
383
- const ret = wasm.isTickInitializable(tick_index, tick_spacing);
384
- return ret !== 0;
385
- }
386
-
387
- /**
388
- * Get the tick index for the inverse of the price that this tick represents.
389
- * Eg: Consider tick i where Pb/Pa = 1.0001 ^ i
390
- * inverse of this, i.e. Pa/Pb = 1 / (1.0001 ^ i) = 1.0001^-i
391
- *
392
- * # Parameters
393
- * - `tick_index` - A i32 integer representing the tick integer
394
- *
395
- * # Returns
396
- * - A i32 integer representing the tick index for the inverse of the price
397
- */
398
- export function invertTickIndex(tick_index) {
399
- const ret = wasm.invertTickIndex(tick_index);
400
- return ret;
401
- }
402
-
403
- /**
404
- * Get the sqrt price for the inverse of the price that this tick represents.
405
- * Because converting to a tick index and then back to a sqrt price is lossy,
406
- * this function is clamped to the nearest tick index.
407
- *
408
- * # Parameters
409
- * - `sqrt_price` - A u128 integer representing the sqrt price
410
- *
411
- * # Returns
412
- * - A u128 integer representing the sqrt price for the inverse of the price
413
- */
414
- export function invertSqrtPrice(sqrt_price) {
415
- const ret = wasm.invertSqrtPrice(addHeapObject(sqrt_price));
416
- return takeObject(ret);
417
- }
418
-
419
- /**
420
- * Get the minimum and maximum tick index that can be initialized.
421
- *
422
- * # Parameters
423
- * - `tick_spacing` - A i32 integer representing the tick spacing
424
- *
425
- * # Returns
426
- * - A TickRange struct containing the lower and upper tick index
427
- */
428
- export function getFullRangeTickIndexes(tick_spacing) {
429
- const ret = wasm.getFullRangeTickIndexes(tick_spacing);
430
- return takeObject(ret);
431
- }
432
-
433
- /**
434
- * Order tick indexes in ascending order.
435
- * If the lower tick index is greater than the upper tick index, the indexes are swapped.
436
- * This is useful for ensuring that the lower tick index is always less than the upper tick index.
437
- *
438
- * # Parameters
439
- * - `tick_index_1` - A i32 integer representing the first tick index
440
- * - `tick_index_2` - A i32 integer representing the second tick index
441
- *
442
- * # Returns
443
- * - A TickRange struct containing the lower and upper tick index
444
- */
445
- export function orderTickIndexes(tick_index_1, tick_index_2) {
446
- const ret = wasm.orderTickIndexes(tick_index_1, tick_index_2);
447
- return takeObject(ret);
448
- }
449
-
450
- /**
451
- * Check if a fusion_pool is a full-range only pool.
452
- *
453
- * # Parameters
454
- * - `tick_spacing` - A u16 integer representing the tick spacing
455
- *
456
- * # Returns
457
- * - A boolean value indicating if the fusion_pool is a full-range only pool
458
- */
459
- export function isFullRangeOnly(tick_spacing) {
460
- const ret = wasm.isFullRangeOnly(tick_spacing);
461
- return ret !== 0;
462
- }
463
-
464
- /**
465
- * Get the index of a tick in a tick array.
466
- *
467
- * # Parameters
468
- * - `tick_index` - A i32 integer representing the tick index
469
- * - `tick_array_start_index` - A i32 integer representing the start tick index of the tick array
470
- * - `tick_spacing` - A u16 integer representing the tick spacing
471
- *
472
- * # Returns
473
- * - A u32 integer representing the tick index in the tick array
474
- */
475
- export function getTickIndexInArray(tick_index, tick_array_start_index, tick_spacing) {
476
- try {
477
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
478
- wasm.getTickIndexInArray(retptr, tick_index, tick_array_start_index, tick_spacing);
479
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
480
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
481
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
482
- if (r2) {
483
- throw takeObject(r1);
484
- }
485
- return r0 >>> 0;
486
- } finally {
487
- wasm.__wbindgen_add_to_stack_pointer(16);
488
- }
489
- }
490
-
491
265
  /**
492
266
  * Calculate the amount A delta between two sqrt_prices
493
267
  *
@@ -684,171 +458,344 @@ export function tryGetMaxAmountWithSlippageTolerance(amount, slippage_tolerance_
684
458
  }
685
459
 
686
460
  /**
687
- * Get the minimum amount with a slippage tolerance
688
- * e.g. Your estimated amount you receive is 10000 with 100 slippage tolerance. The min amount you receive will be 9900.
461
+ * Get the minimum amount with a slippage tolerance
462
+ * e.g. Your estimated amount you receive is 10000 with 100 slippage tolerance. The min amount you receive will be 9900.
463
+ *
464
+ * # Parameters
465
+ * - `amount`: The amount to apply the fee to
466
+ * - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
467
+ *
468
+ * # Returns
469
+ * - `u64`: The minimum amount
470
+ */
471
+ export function tryGetMinAmountWithSlippageTolerance(amount, slippage_tolerance_bps) {
472
+ try {
473
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
474
+ wasm.tryGetMinAmountWithSlippageTolerance(retptr, amount, slippage_tolerance_bps);
475
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
476
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
477
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
478
+ if (r3) {
479
+ throw takeObject(r2);
480
+ }
481
+ return BigInt.asUintN(64, r0);
482
+ } finally {
483
+ wasm.__wbindgen_add_to_stack_pointer(16);
484
+ }
485
+ }
486
+
487
+ /**
488
+ * Apply a swap fee to an amount
489
+ * e.g. You send 10000 amount with 10000 fee rate. The fee amount will be 100.
490
+ * So the amount after fee will be 9900.
491
+ *
492
+ * # Parameters
493
+ * - `amount`: The amount to apply the fee to
494
+ * - `fee_rate`: The fee rate to apply denominated in 1e6
495
+ *
496
+ * # Returns
497
+ * - `u64`: The amount after the fee has been applied
498
+ */
499
+ export function tryApplySwapFee(amount, fee_rate) {
500
+ try {
501
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
502
+ wasm.tryApplySwapFee(retptr, amount, fee_rate);
503
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
504
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
505
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
506
+ if (r3) {
507
+ throw takeObject(r2);
508
+ }
509
+ return BigInt.asUintN(64, r0);
510
+ } finally {
511
+ wasm.__wbindgen_add_to_stack_pointer(16);
512
+ }
513
+ }
514
+
515
+ /**
516
+ * Reverse the application of a swap fee to an amount
517
+ * e.g. You received 9900 amount with 10000 fee rate. The fee amount will be 100.
518
+ * So the amount before fee will be 10000.
519
+ *
520
+ * # Parameters
521
+ * - `amount`: The amount to reverse the fee from
522
+ * - `fee_rate`: The fee rate to reverse denominated in 1e6
523
+ *
524
+ * # Returns
525
+ * - `u64`: The amount before the fee has been applied
526
+ */
527
+ export function tryReverseApplySwapFee(amount, fee_rate) {
528
+ try {
529
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
530
+ wasm.tryReverseApplySwapFee(retptr, amount, fee_rate);
531
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
532
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
533
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
534
+ if (r3) {
535
+ throw takeObject(r2);
536
+ }
537
+ return BigInt.asUintN(64, r0);
538
+ } finally {
539
+ wasm.__wbindgen_add_to_stack_pointer(16);
540
+ }
541
+ }
542
+
543
+ export function _FEE_RATE_MUL_VALUE() {
544
+ const ret = wasm._FEE_RATE_MUL_VALUE();
545
+ return ret >>> 0;
546
+ }
547
+
548
+ export function _MAX_PROTOCOL_FEE_RATE() {
549
+ const ret = wasm._MAX_PROTOCOL_FEE_RATE();
550
+ return ret;
551
+ }
552
+
553
+ export function _PROTOCOL_FEE_RATE_MUL_VALUE() {
554
+ const ret = wasm._PROTOCOL_FEE_RATE_MUL_VALUE();
555
+ return ret;
556
+ }
557
+
558
+ export function _TICK_ARRAY_SIZE() {
559
+ const ret = wasm._TICK_ARRAY_SIZE();
560
+ return ret >>> 0;
561
+ }
562
+
563
+ export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD() {
564
+ const ret = wasm._FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD();
565
+ return ret;
566
+ }
567
+
568
+ export function _MIN_TICK_INDEX() {
569
+ const ret = wasm._MIN_TICK_INDEX();
570
+ return ret;
571
+ }
572
+
573
+ export function _MAX_TICK_INDEX() {
574
+ const ret = wasm._MAX_TICK_INDEX();
575
+ return ret;
576
+ }
577
+
578
+ /**
579
+ * Get the first tick index in the tick array that contains the specified tick index.
580
+ *
581
+ * # Parameters
582
+ * - `tick_index` - A i32 integer representing the tick integer
583
+ * - `tick_spacing` - A i32 integer representing the tick spacing
584
+ *
585
+ * # Returns
586
+ * - A i32 integer representing the first tick index in the tick array
587
+ */
588
+ export function getTickArrayStartTickIndex(tick_index, tick_spacing) {
589
+ const ret = wasm.getTickArrayStartTickIndex(tick_index, tick_spacing);
590
+ return ret;
591
+ }
592
+
593
+ /**
594
+ * Derive the sqrt-price from a tick index. The precision of this method is only guarranted
595
+ * if tick is within the bounds of {max, min} tick-index.
596
+ *
597
+ * # Parameters
598
+ * - `tick_index` - A i32 integer representing the tick integer
599
+ *
600
+ * # Returns
601
+ * - `Ok`: A u128 Q32.64 representing the sqrt_price
602
+ */
603
+ export function tickIndexToSqrtPrice(tick_index) {
604
+ const ret = wasm.tickIndexToSqrtPrice(tick_index);
605
+ return takeObject(ret);
606
+ }
607
+
608
+ /**
609
+ * Derive the tick index from a sqrt price. The precision of this method is only guarranted
610
+ * if tick is within the bounds of {max, min} tick-index.
611
+ *
612
+ * # Parameters
613
+ * - `sqrt_price` - A u128 integer representing the sqrt price
614
+ *
615
+ * # Returns
616
+ * - `Ok`: A i32 integer representing the tick integer
617
+ */
618
+ export function sqrtPriceToTickIndex(sqrt_price) {
619
+ const ret = wasm.sqrtPriceToTickIndex(addHeapObject(sqrt_price));
620
+ return ret;
621
+ }
622
+
623
+ /**
624
+ * Get the initializable tick index.
625
+ * If the tick index is already initializable, it is returned as is.
626
+ *
627
+ * # Parameters
628
+ * - `tick_index` - A i32 integer representing the tick integer
629
+ * - `tick_spacing` - A i32 integer representing the tick spacing
630
+ * - `round_up` - A boolean value indicating if the supplied tick index should be rounded up. None will round to the nearest.
631
+ *
632
+ * # Returns
633
+ * - A i32 integer representing the previous initializable tick index
634
+ */
635
+ export function getInitializableTickIndex(tick_index, tick_spacing, round_up) {
636
+ const ret = wasm.getInitializableTickIndex(tick_index, tick_spacing, isLikeNone(round_up) ? 0xFFFFFF : round_up ? 1 : 0);
637
+ return ret;
638
+ }
639
+
640
+ /**
641
+ * Get the previous initializable tick index.
642
+ *
643
+ * # Parameters
644
+ * - `tick_index` - A i32 integer representing the tick integer
645
+ * - `tick_spacing` - A i32 integer representing the tick spacing
646
+ *
647
+ * # Returns
648
+ * - A i32 integer representing the previous initializable tick index
649
+ */
650
+ export function getPrevInitializableTickIndex(tick_index, tick_spacing) {
651
+ const ret = wasm.getPrevInitializableTickIndex(tick_index, tick_spacing);
652
+ return ret;
653
+ }
654
+
655
+ /**
656
+ * Get the next initializable tick index.
657
+ *
658
+ * # Parameters
659
+ * - `tick_index` - A i32 integer representing the tick integer
660
+ * - `tick_spacing` - A i32 integer representing the tick spacing
661
+ *
662
+ * # Returns
663
+ * - A i32 integer representing the next initializable tick index
664
+ */
665
+ export function getNextInitializableTickIndex(tick_index, tick_spacing) {
666
+ const ret = wasm.getNextInitializableTickIndex(tick_index, tick_spacing);
667
+ return ret;
668
+ }
669
+
670
+ /**
671
+ * Check if a tick is in-bounds.
672
+ *
673
+ * # Parameters
674
+ * - `tick_index` - A i32 integer representing the tick integer
675
+ *
676
+ * # Returns
677
+ * - A boolean value indicating if the tick is in-bounds
678
+ */
679
+ export function isTickIndexInBounds(tick_index) {
680
+ const ret = wasm.isTickIndexInBounds(tick_index);
681
+ return ret !== 0;
682
+ }
683
+
684
+ /**
685
+ * Check if a tick is initializable.
686
+ * A tick is initializable if it is divisible by the tick spacing.
687
+ *
688
+ * # Parameters
689
+ * - `tick_index` - A i32 integer representing the tick integer
690
+ * - `tick_spacing` - A i32 integer representing the tick spacing
691
+ *
692
+ * # Returns
693
+ * - A boolean value indicating if the tick is initializable
694
+ */
695
+ export function isTickInitializable(tick_index, tick_spacing) {
696
+ const ret = wasm.isTickInitializable(tick_index, tick_spacing);
697
+ return ret !== 0;
698
+ }
699
+
700
+ /**
701
+ * Get the tick index for the inverse of the price that this tick represents.
702
+ * Eg: Consider tick i where Pb/Pa = 1.0001 ^ i
703
+ * inverse of this, i.e. Pa/Pb = 1 / (1.0001 ^ i) = 1.0001^-i
689
704
  *
690
705
  * # Parameters
691
- * - `amount`: The amount to apply the fee to
692
- * - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
706
+ * - `tick_index` - A i32 integer representing the tick integer
693
707
  *
694
708
  * # Returns
695
- * - `u64`: The minimum amount
709
+ * - A i32 integer representing the tick index for the inverse of the price
696
710
  */
697
- export function tryGetMinAmountWithSlippageTolerance(amount, slippage_tolerance_bps) {
698
- try {
699
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
700
- wasm.tryGetMinAmountWithSlippageTolerance(retptr, amount, slippage_tolerance_bps);
701
- var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
702
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
703
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
704
- if (r3) {
705
- throw takeObject(r2);
706
- }
707
- return BigInt.asUintN(64, r0);
708
- } finally {
709
- wasm.__wbindgen_add_to_stack_pointer(16);
710
- }
711
+ export function invertTickIndex(tick_index) {
712
+ const ret = wasm.invertTickIndex(tick_index);
713
+ return ret;
711
714
  }
712
715
 
713
716
  /**
714
- * Apply a swap fee to an amount
715
- * e.g. You send 10000 amount with 10000 fee rate. The fee amount will be 100.
716
- * So the amount after fee will be 9900.
717
+ * Get the sqrt price for the inverse of the price that this tick represents.
718
+ * Because converting to a tick index and then back to a sqrt price is lossy,
719
+ * this function is clamped to the nearest tick index.
717
720
  *
718
721
  * # Parameters
719
- * - `amount`: The amount to apply the fee to
720
- * - `fee_rate`: The fee rate to apply denominated in 1e6
722
+ * - `sqrt_price` - A u128 integer representing the sqrt price
721
723
  *
722
724
  * # Returns
723
- * - `u64`: The amount after the fee has been applied
725
+ * - A u128 integer representing the sqrt price for the inverse of the price
724
726
  */
725
- export function tryApplySwapFee(amount, fee_rate) {
726
- try {
727
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
728
- wasm.tryApplySwapFee(retptr, amount, fee_rate);
729
- var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
730
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
731
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
732
- if (r3) {
733
- throw takeObject(r2);
734
- }
735
- return BigInt.asUintN(64, r0);
736
- } finally {
737
- wasm.__wbindgen_add_to_stack_pointer(16);
738
- }
727
+ export function invertSqrtPrice(sqrt_price) {
728
+ const ret = wasm.invertSqrtPrice(addHeapObject(sqrt_price));
729
+ return takeObject(ret);
739
730
  }
740
731
 
741
732
  /**
742
- * Reverse the application of a swap fee to an amount
743
- * e.g. You received 9900 amount with 10000 fee rate. The fee amount will be 100.
744
- * So the amount before fee will be 10000.
733
+ * Get the minimum and maximum tick index that can be initialized.
745
734
  *
746
735
  * # Parameters
747
- * - `amount`: The amount to reverse the fee from
748
- * - `fee_rate`: The fee rate to reverse denominated in 1e6
736
+ * - `tick_spacing` - A i32 integer representing the tick spacing
749
737
  *
750
738
  * # Returns
751
- * - `u64`: The amount before the fee has been applied
739
+ * - A TickRange struct containing the lower and upper tick index
752
740
  */
753
- export function tryReverseApplySwapFee(amount, fee_rate) {
754
- try {
755
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
756
- wasm.tryReverseApplySwapFee(retptr, amount, fee_rate);
757
- var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
758
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
759
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
760
- if (r3) {
761
- throw takeObject(r2);
762
- }
763
- return BigInt.asUintN(64, r0);
764
- } finally {
765
- wasm.__wbindgen_add_to_stack_pointer(16);
766
- }
741
+ export function getFullRangeTickIndexes(tick_spacing) {
742
+ const ret = wasm.getFullRangeTickIndexes(tick_spacing);
743
+ return takeObject(ret);
767
744
  }
768
745
 
769
746
  /**
770
- * Computes the limit order output amount by input amount.
771
- * ### Parameters
772
- * - `amount_in` - The input token amount of a limit order.
773
- * - `a_to_b_order` - The limit order direction.
774
- * - `tick_index` - The tick index of an order.
775
- * - `fusion_pool` - The fusion_pool state.
747
+ * Order tick indexes in ascending order.
748
+ * If the lower tick index is greater than the upper tick index, the indexes are swapped.
749
+ * This is useful for ensuring that the lower tick index is always less than the upper tick index.
750
+ *
751
+ * # Parameters
752
+ * - `tick_index_1` - A i32 integer representing the first tick index
753
+ * - `tick_index_2` - A i32 integer representing the second tick index
754
+ *
755
+ * # Returns
756
+ * - A TickRange struct containing the lower and upper tick index
776
757
  */
777
- export function limitOrderQuoteByInputToken(amount_in, a_to_b_order, tick_index, fusion_pool) {
778
- try {
779
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
780
- wasm.limitOrderQuoteByInputToken(retptr, amount_in, a_to_b_order, tick_index, addHeapObject(fusion_pool));
781
- var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
782
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
783
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
784
- if (r3) {
785
- throw takeObject(r2);
786
- }
787
- return BigInt.asUintN(64, r0);
788
- } finally {
789
- wasm.__wbindgen_add_to_stack_pointer(16);
790
- }
758
+ export function orderTickIndexes(tick_index_1, tick_index_2) {
759
+ const ret = wasm.orderTickIndexes(tick_index_1, tick_index_2);
760
+ return takeObject(ret);
791
761
  }
792
762
 
793
763
  /**
794
- * Computes the limit order input amount by output amount.
795
- * ### Parameters
796
- * - `amount_out` - The output token amount of a limit order.
797
- * - `a_to_b_order` - The limit order direction.
798
- * - `tick_index` - The tick index of an order.
799
- * - `fusion_pool` - The fusion_pool state.
764
+ * Check if a fusion_pool is a full-range only pool.
765
+ *
766
+ * # Parameters
767
+ * - `tick_spacing` - A u16 integer representing the tick spacing
768
+ *
769
+ * # Returns
770
+ * - A boolean value indicating if the fusion_pool is a full-range only pool
800
771
  */
801
- export function limitOrderQuoteByOutputToken(amount_out, a_to_b_order, tick_index, fusion_pool) {
802
- try {
803
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
804
- wasm.limitOrderQuoteByOutputToken(retptr, amount_out, a_to_b_order, tick_index, addHeapObject(fusion_pool));
805
- var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
806
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
807
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
808
- if (r3) {
809
- throw takeObject(r2);
810
- }
811
- return BigInt.asUintN(64, r0);
812
- } finally {
813
- wasm.__wbindgen_add_to_stack_pointer(16);
814
- }
772
+ export function isFullRangeOnly(tick_spacing) {
773
+ const ret = wasm.isFullRangeOnly(tick_spacing);
774
+ return ret !== 0;
815
775
  }
816
776
 
817
777
  /**
818
- * Computes the limit order reward by input amount.
819
- * ### Parameters
820
- * - `amount_out` - The output token amount of a limit order (swap input).
821
- * - `a_to_b_order` - The limit order direction.
822
- * - `tick_index` - The tick index of an order.
823
- * - `fusion_pool` - The fusion_pool state.
778
+ * Get the index of a tick in a tick array.
779
+ *
780
+ * # Parameters
781
+ * - `tick_index` - A i32 integer representing the tick index
782
+ * - `tick_array_start_index` - A i32 integer representing the start tick index of the tick array
783
+ * - `tick_spacing` - A u16 integer representing the tick spacing
784
+ *
785
+ * # Returns
786
+ * - A u32 integer representing the tick index in the tick array
824
787
  */
825
- export function limitOrderRewardByOutputToken(amount_out, fee_rate, protocol_fee_rate) {
826
- try {
827
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
828
- wasm.limitOrderRewardByOutputToken(retptr, amount_out, fee_rate, protocol_fee_rate);
829
- var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
830
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
831
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
832
- if (r3) {
833
- throw takeObject(r2);
834
- }
835
- return BigInt.asUintN(64, r0);
836
- } finally {
837
- wasm.__wbindgen_add_to_stack_pointer(16);
838
- }
839
- }
840
-
841
- export function decreaseLimitOrderQuote(fusion_pool, limit_order, tick, amount, transfer_fee_a, transfer_fee_b) {
788
+ export function getTickIndexInArray(tick_index, tick_array_start_index, tick_spacing) {
842
789
  try {
843
790
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
844
- wasm.decreaseLimitOrderQuote(retptr, addHeapObject(fusion_pool), addHeapObject(limit_order), addHeapObject(tick), amount, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
791
+ wasm.getTickIndexInArray(retptr, tick_index, tick_array_start_index, tick_spacing);
845
792
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
846
793
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
847
794
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
848
795
  if (r2) {
849
796
  throw takeObject(r1);
850
797
  }
851
- return takeObject(r0);
798
+ return r0 >>> 0;
852
799
  } finally {
853
800
  wasm.__wbindgen_add_to_stack_pointer(16);
854
801
  }
@@ -1157,114 +1104,92 @@ export function limitOrderFee(fusion_pool) {
1157
1104
  return ret;
1158
1105
  }
1159
1106
 
1160
- export function _TICK_ARRAY_SIZE() {
1161
- const ret = wasm._TICK_ARRAY_SIZE();
1162
- return ret >>> 0;
1163
- }
1164
-
1165
- export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD() {
1166
- const ret = wasm._FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD();
1167
- return ret;
1168
- }
1169
-
1170
- export function _MIN_TICK_INDEX() {
1171
- const ret = wasm._MIN_TICK_INDEX();
1172
- return ret;
1173
- }
1174
-
1175
- export function _MAX_TICK_INDEX() {
1176
- const ret = wasm._MAX_TICK_INDEX();
1177
- return ret;
1178
- }
1179
-
1180
- /**
1181
- * Convert a price into a sqrt priceX64
1182
- * IMPORTANT: floating point operations can reduce the precision of the result.
1183
- * Make sure to do these operations last and not to use the result for further calculations.
1184
- *
1185
- * # Parameters
1186
- * * `price` - The price to convert
1187
- * * `decimals_a` - The number of decimals of the base token
1188
- * * `decimals_b` - The number of decimals of the quote token
1189
- *
1190
- * # Returns
1191
- * * `u128` - The sqrt priceX64
1192
- */
1193
- export function priceToSqrtPrice(price, decimals_a, decimals_b) {
1194
- const ret = wasm.priceToSqrtPrice(price, decimals_a, decimals_b);
1195
- return takeObject(ret);
1196
- }
1197
-
1198
1107
  /**
1199
- * Convert a sqrt priceX64 into a tick index
1200
- * IMPORTANT: floating point operations can reduce the precision of the result.
1201
- * Make sure to do these operations last and not to use the result for further calculations.
1202
- *
1203
- * # Parameters
1204
- * * `sqrt_price` - The sqrt priceX64 to convert
1205
- * * `decimals_a` - The number of decimals of the base token
1206
- * * `decimals_b` - The number of decimals of the quote token
1207
- *
1208
- * # Returns
1209
- * * `f64` - The decimal price
1108
+ * Computes the limit order output amount by input amount.
1109
+ * ### Parameters
1110
+ * - `amount_in` - The input token amount of a limit order.
1111
+ * - `a_to_b_order` - The limit order direction.
1112
+ * - `tick_index` - The tick index of an order.
1113
+ * - `fusion_pool` - The fusion_pool state.
1210
1114
  */
1211
- export function sqrtPriceToPrice(sqrt_price, decimals_a, decimals_b) {
1212
- const ret = wasm.sqrtPriceToPrice(addHeapObject(sqrt_price), decimals_a, decimals_b);
1213
- return ret;
1115
+ export function limitOrderQuoteByInputToken(amount_in, a_to_b_order, tick_index, fusion_pool) {
1116
+ try {
1117
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1118
+ wasm.limitOrderQuoteByInputToken(retptr, amount_in, a_to_b_order, tick_index, addHeapObject(fusion_pool));
1119
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1120
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1121
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1122
+ if (r3) {
1123
+ throw takeObject(r2);
1124
+ }
1125
+ return BigInt.asUintN(64, r0);
1126
+ } finally {
1127
+ wasm.__wbindgen_add_to_stack_pointer(16);
1128
+ }
1214
1129
  }
1215
1130
 
1216
1131
  /**
1217
- * Invert a price
1218
- * IMPORTANT: floating point operations can reduce the precision of the result.
1219
- * Make sure to do these operations last and not to use the result for further calculations.
1220
- *
1221
- * # Parameters
1222
- * * `price` - The price to invert
1223
- * * `decimals_a` - The number of decimals of the base token
1224
- * * `decimals_b` - The number of decimals of the quote token
1225
- *
1226
- * # Returns
1227
- * * `f64` - The inverted price
1132
+ * Computes the limit order input amount by output amount.
1133
+ * ### Parameters
1134
+ * - `amount_out` - The output token amount of a limit order.
1135
+ * - `a_to_b_order` - The limit order direction.
1136
+ * - `tick_index` - The tick index of an order.
1137
+ * - `fusion_pool` - The fusion_pool state.
1228
1138
  */
1229
- export function invertPrice(price, decimals_a, decimals_b) {
1230
- const ret = wasm.invertPrice(price, decimals_a, decimals_b);
1231
- return ret;
1139
+ export function limitOrderQuoteByOutputToken(amount_out, a_to_b_order, tick_index, fusion_pool) {
1140
+ try {
1141
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1142
+ wasm.limitOrderQuoteByOutputToken(retptr, amount_out, a_to_b_order, tick_index, addHeapObject(fusion_pool));
1143
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1144
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1145
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1146
+ if (r3) {
1147
+ throw takeObject(r2);
1148
+ }
1149
+ return BigInt.asUintN(64, r0);
1150
+ } finally {
1151
+ wasm.__wbindgen_add_to_stack_pointer(16);
1152
+ }
1232
1153
  }
1233
1154
 
1234
1155
  /**
1235
- * Convert a tick index into a price
1236
- * IMPORTANT: floating point operations can reduce the precision of the result.
1237
- * Make sure to do these operations last and not to use the result for further calculations.
1238
- *
1239
- * # Parameters
1240
- * * `tick_index` - The tick index to convert
1241
- * * `decimals_a` - The number of decimals of the base token
1242
- * * `decimals_b` - The number of decimals of the quote token
1243
- *
1244
- * # Returns
1245
- * * `f64` - The decimal price
1156
+ * Computes the limit order reward by input amount.
1157
+ * ### Parameters
1158
+ * - `amount_out` - The output token amount of a limit order (swap input).
1159
+ * - `a_to_b_order` - The limit order direction.
1160
+ * - `tick_index` - The tick index of an order.
1161
+ * - `fusion_pool` - The fusion_pool state.
1246
1162
  */
1247
- export function tickIndexToPrice(tick_index, decimals_a, decimals_b) {
1248
- const ret = wasm.tickIndexToPrice(tick_index, decimals_a, decimals_b);
1249
- return ret;
1163
+ export function limitOrderRewardByOutputToken(amount_out, fee_rate, protocol_fee_rate) {
1164
+ try {
1165
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1166
+ wasm.limitOrderRewardByOutputToken(retptr, amount_out, fee_rate, protocol_fee_rate);
1167
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1168
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1169
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1170
+ if (r3) {
1171
+ throw takeObject(r2);
1172
+ }
1173
+ return BigInt.asUintN(64, r0);
1174
+ } finally {
1175
+ wasm.__wbindgen_add_to_stack_pointer(16);
1176
+ }
1250
1177
  }
1251
1178
 
1252
- /**
1253
- * Convert a price into a tick index
1254
- * IMPORTANT: floating point operations can reduce the precision of the result.
1255
- * Make sure to do these operations last and not to use the result for further calculations.
1256
- *
1257
- * # Parameters
1258
- * * `price` - The price to convert
1259
- * * `decimals_a` - The number of decimals of the base token
1260
- * * `decimals_b` - The number of decimals of the quote token
1261
- *
1262
- * # Returns
1263
- * * `i32` - The tick index
1264
- */
1265
- export function priceToTickIndex(price, decimals_a, decimals_b) {
1266
- const ret = wasm.priceToTickIndex(price, decimals_a, decimals_b);
1267
- return ret;
1179
+ export function decreaseLimitOrderQuote(fusion_pool, limit_order, tick, amount, transfer_fee_a, transfer_fee_b) {
1180
+ try {
1181
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1182
+ wasm.decreaseLimitOrderQuote(retptr, addHeapObject(fusion_pool), addHeapObject(limit_order), addHeapObject(tick), amount, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
1183
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1184
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1185
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1186
+ if (r2) {
1187
+ throw takeObject(r1);
1188
+ }
1189
+ return takeObject(r0);
1190
+ } finally {
1191
+ wasm.__wbindgen_add_to_stack_pointer(16);
1192
+ }
1268
1193
  }
1269
1194
 
1270
1195
  export function _POSITION_BUNDLE_SIZE() {
@@ -1476,21 +1401,6 @@ export function _LIMIT_ORDER_AND_POOL_ARE_OUT_OF_SYNC() {
1476
1401
  }
1477
1402
  }
1478
1403
 
1479
- export function _FEE_RATE_MUL_VALUE() {
1480
- const ret = wasm._FEE_RATE_MUL_VALUE();
1481
- return ret >>> 0;
1482
- }
1483
-
1484
- export function _MAX_PROTOCOL_FEE_RATE() {
1485
- const ret = wasm._MAX_PROTOCOL_FEE_RATE();
1486
- return ret;
1487
- }
1488
-
1489
- export function _PROTOCOL_FEE_RATE_MUL_VALUE() {
1490
- const ret = wasm._PROTOCOL_FEE_RATE_MUL_VALUE();
1491
- return ret;
1492
- }
1493
-
1494
1404
  /**
1495
1405
  * Get the first unoccupied position in a bundle
1496
1406
  *
@@ -1593,6 +1503,96 @@ export function positionRatioX64(current_sqrt_price, tick_index_1, tick_index_2)
1593
1503
  return takeObject(ret);
1594
1504
  }
1595
1505
 
1506
+ /**
1507
+ * Convert a price into a sqrt priceX64
1508
+ * IMPORTANT: floating point operations can reduce the precision of the result.
1509
+ * Make sure to do these operations last and not to use the result for further calculations.
1510
+ *
1511
+ * # Parameters
1512
+ * * `price` - The price to convert
1513
+ * * `decimals_a` - The number of decimals of the base token
1514
+ * * `decimals_b` - The number of decimals of the quote token
1515
+ *
1516
+ * # Returns
1517
+ * * `u128` - The sqrt priceX64
1518
+ */
1519
+ export function priceToSqrtPrice(price, decimals_a, decimals_b) {
1520
+ const ret = wasm.priceToSqrtPrice(price, decimals_a, decimals_b);
1521
+ return takeObject(ret);
1522
+ }
1523
+
1524
+ /**
1525
+ * Convert a sqrt priceX64 into a tick index
1526
+ * IMPORTANT: floating point operations can reduce the precision of the result.
1527
+ * Make sure to do these operations last and not to use the result for further calculations.
1528
+ *
1529
+ * # Parameters
1530
+ * * `sqrt_price` - The sqrt priceX64 to convert
1531
+ * * `decimals_a` - The number of decimals of the base token
1532
+ * * `decimals_b` - The number of decimals of the quote token
1533
+ *
1534
+ * # Returns
1535
+ * * `f64` - The decimal price
1536
+ */
1537
+ export function sqrtPriceToPrice(sqrt_price, decimals_a, decimals_b) {
1538
+ const ret = wasm.sqrtPriceToPrice(addHeapObject(sqrt_price), decimals_a, decimals_b);
1539
+ return ret;
1540
+ }
1541
+
1542
+ /**
1543
+ * Invert a price
1544
+ * IMPORTANT: floating point operations can reduce the precision of the result.
1545
+ * Make sure to do these operations last and not to use the result for further calculations.
1546
+ *
1547
+ * # Parameters
1548
+ * * `price` - The price to invert
1549
+ * * `decimals_a` - The number of decimals of the base token
1550
+ * * `decimals_b` - The number of decimals of the quote token
1551
+ *
1552
+ * # Returns
1553
+ * * `f64` - The inverted price
1554
+ */
1555
+ export function invertPrice(price, decimals_a, decimals_b) {
1556
+ const ret = wasm.invertPrice(price, decimals_a, decimals_b);
1557
+ return ret;
1558
+ }
1559
+
1560
+ /**
1561
+ * Convert a tick index into a price
1562
+ * IMPORTANT: floating point operations can reduce the precision of the result.
1563
+ * Make sure to do these operations last and not to use the result for further calculations.
1564
+ *
1565
+ * # Parameters
1566
+ * * `tick_index` - The tick index to convert
1567
+ * * `decimals_a` - The number of decimals of the base token
1568
+ * * `decimals_b` - The number of decimals of the quote token
1569
+ *
1570
+ * # Returns
1571
+ * * `f64` - The decimal price
1572
+ */
1573
+ export function tickIndexToPrice(tick_index, decimals_a, decimals_b) {
1574
+ const ret = wasm.tickIndexToPrice(tick_index, decimals_a, decimals_b);
1575
+ return ret;
1576
+ }
1577
+
1578
+ /**
1579
+ * Convert a price into a tick index
1580
+ * IMPORTANT: floating point operations can reduce the precision of the result.
1581
+ * Make sure to do these operations last and not to use the result for further calculations.
1582
+ *
1583
+ * # Parameters
1584
+ * * `price` - The price to convert
1585
+ * * `decimals_a` - The number of decimals of the base token
1586
+ * * `decimals_b` - The number of decimals of the quote token
1587
+ *
1588
+ * # Returns
1589
+ * * `i32` - The tick index
1590
+ */
1591
+ export function priceToTickIndex(price, decimals_a, decimals_b) {
1592
+ const ret = wasm.priceToTickIndex(price, decimals_a, decimals_b);
1593
+ return ret;
1594
+ }
1595
+
1596
1596
  /**
1597
1597
  * Computes the exact input or output amount for a swap transaction.
1598
1598
  *
@@ -1655,6 +1655,64 @@ export function swapQuoteByOutputToken(token_out, specified_token_a, slippage_to
1655
1655
  }
1656
1656
  }
1657
1657
 
1658
+ /**
1659
+ * Computes the liquidation prices for an existing position.
1660
+ *
1661
+ * # Parameters
1662
+ * - `tick_lower_index`: The lower tick index of the position.
1663
+ * - `tick_upper_index`: The upper tick index of the position.
1664
+ * - `leftovers_a`: The amount of leftovers A in the position.
1665
+ * - `leftovers_a`: The amount of leftovers B in the position.
1666
+ * - `liquidity`: Liquidity of the position.
1667
+ * - `debt_a`: The amount of tokens A borrowed.
1668
+ * - `debt_b`: The amount of tokens B borrowed.
1669
+ * - `liquidation_threshold`: The liquidation threshold of the market.
1670
+ *
1671
+ * # Returns
1672
+ * - `LiquidationPrices`: An object containing lower/upper liquidation prices.
1673
+ */
1674
+ export function getLpPositionLiquidationPrices(tick_lower_index, tick_upper_index, liquidity, leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold) {
1675
+ try {
1676
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1677
+ wasm.getLpPositionLiquidationPrices(retptr, tick_lower_index, tick_upper_index, addHeapObject(liquidity), leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold);
1678
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1679
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1680
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1681
+ if (r2) {
1682
+ throw takeObject(r1);
1683
+ }
1684
+ return takeObject(r0);
1685
+ } finally {
1686
+ wasm.__wbindgen_add_to_stack_pointer(16);
1687
+ }
1688
+ }
1689
+
1690
+ export function getIncreaseLpPositionQuote(args) {
1691
+ try {
1692
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1693
+ wasm.getIncreaseLpPositionQuote(retptr, addHeapObject(args));
1694
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1695
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1696
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1697
+ if (r2) {
1698
+ throw takeObject(r1);
1699
+ }
1700
+ return takeObject(r0);
1701
+ } finally {
1702
+ wasm.__wbindgen_add_to_stack_pointer(16);
1703
+ }
1704
+ }
1705
+
1706
+ export function _HUNDRED_PERCENT() {
1707
+ const ret = wasm._HUNDRED_PERCENT();
1708
+ return ret >>> 0;
1709
+ }
1710
+
1711
+ export function _COMPUTED_AMOUNT() {
1712
+ const ret = wasm._COMPUTED_AMOUNT();
1713
+ return BigInt.asUintN(64, ret);
1714
+ }
1715
+
1658
1716
  /**
1659
1717
  * Spot position increase quote
1660
1718
  *
@@ -1721,10 +1779,10 @@ export function getDecreaseSpotPositionQuote(decrease_amount, collateral_token,
1721
1779
  * # Returns
1722
1780
  * - `f64`: Decimal liquidation price
1723
1781
  */
1724
- export function getLiquidationPrice(position_token, amount, debt, liquidation_threshold) {
1782
+ export function getSpotPositionLiquidationPrice(position_token, amount, debt, liquidation_threshold) {
1725
1783
  try {
1726
1784
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1727
- wasm.getLiquidationPrice(retptr, position_token, amount, debt, liquidation_threshold);
1785
+ wasm.getSpotPositionLiquidationPrice(retptr, position_token, amount, debt, liquidation_threshold);
1728
1786
  var r0 = getDataViewMemory0().getFloat64(retptr + 8 * 0, true);
1729
1787
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1730
1788
  var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
@@ -1770,11 +1828,16 @@ export function getTradableAmount(collateral_token, available_balance, leverage,
1770
1828
  }
1771
1829
  }
1772
1830
 
1773
- export function calculateTunaProtocolFee(collateral_token, borrowed_token, collateral, borrow, protocol_fee_rate_on_collateral, protocol_fee_rate) {
1774
- const ret = wasm.calculateTunaProtocolFee(collateral_token, borrowed_token, collateral, borrow, protocol_fee_rate_on_collateral, protocol_fee_rate);
1831
+ export function calculateTunaSpotPositionProtocolFee(collateral_token, borrowed_token, collateral, borrow, protocol_fee_rate_on_collateral, protocol_fee_rate) {
1832
+ const ret = wasm.calculateTunaSpotPositionProtocolFee(collateral_token, borrowed_token, collateral, borrow, protocol_fee_rate_on_collateral, protocol_fee_rate);
1775
1833
  return takeObject(ret);
1776
1834
  }
1777
1835
 
1836
+ export function calculateTunaProtocolFee(collateral, borrow, protocol_fee_rate_on_collateral, protocol_fee_rate) {
1837
+ const ret = wasm.calculateTunaProtocolFee(collateral, borrow, protocol_fee_rate_on_collateral, protocol_fee_rate);
1838
+ return BigInt.asUintN(64, ret);
1839
+ }
1840
+
1778
1841
  export function _INVALID_ARGUMENTS() {
1779
1842
  try {
1780
1843
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
@@ -1818,16 +1881,16 @@ export function solana_program_init() {
1818
1881
  wasm.solana_program_init();
1819
1882
  }
1820
1883
 
1821
- function __wasm_bindgen_func_elem_3312(arg0, arg1, arg2) {
1822
- wasm.__wasm_bindgen_func_elem_3312(arg0, arg1, addHeapObject(arg2));
1884
+ function __wasm_bindgen_func_elem_2635(arg0, arg1, arg2) {
1885
+ wasm.__wasm_bindgen_func_elem_2635(arg0, arg1, addHeapObject(arg2));
1823
1886
  }
1824
1887
 
1825
- function __wasm_bindgen_func_elem_3103(arg0, arg1) {
1826
- wasm.__wasm_bindgen_func_elem_3103(arg0, arg1);
1888
+ function __wasm_bindgen_func_elem_3208(arg0, arg1) {
1889
+ wasm.__wasm_bindgen_func_elem_3208(arg0, arg1);
1827
1890
  }
1828
1891
 
1829
- function __wasm_bindgen_func_elem_480(arg0, arg1, arg2, arg3) {
1830
- wasm.__wasm_bindgen_func_elem_480(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1892
+ function __wasm_bindgen_func_elem_495(arg0, arg1, arg2, arg3) {
1893
+ wasm.__wasm_bindgen_func_elem_495(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1831
1894
  }
1832
1895
 
1833
1896
  const __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
@@ -2990,7 +3053,7 @@ export function __wbg_new_3c3d849046688a66(arg0, arg1) {
2990
3053
  const a = state0.a;
2991
3054
  state0.a = 0;
2992
3055
  try {
2993
- return __wasm_bindgen_func_elem_480(a, state0.b, arg0, arg1);
3056
+ return __wasm_bindgen_func_elem_495(a, state0.b, arg0, arg1);
2994
3057
  } finally {
2995
3058
  state0.a = a;
2996
3059
  }
@@ -3234,21 +3297,27 @@ export function __wbg_warn_1d74dddbe2fd1dbb(arg0) {
3234
3297
  console.warn(getObject(arg0));
3235
3298
  };
3236
3299
 
3300
+ export function __wbindgen_cast_0660a350899916ec(arg0, arg1) {
3301
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 360, function: Function { arguments: [], shim_idx: 361, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3302
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3204, __wasm_bindgen_func_elem_3208);
3303
+ return addHeapObject(ret);
3304
+ };
3305
+
3237
3306
  export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
3238
3307
  // Cast intrinsic for `Ref(String) -> Externref`.
3239
3308
  const ret = getStringFromWasm0(arg0, arg1);
3240
3309
  return addHeapObject(ret);
3241
3310
  };
3242
3311
 
3243
- export function __wbindgen_cast_4625c577ab2ec9ee(arg0) {
3244
- // Cast intrinsic for `U64 -> Externref`.
3245
- const ret = BigInt.asUintN(64, arg0);
3312
+ export function __wbindgen_cast_2e5f7f1574aa20c6(arg0, arg1) {
3313
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 232, function: Function { arguments: [Externref], shim_idx: 227, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3314
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_2654, __wasm_bindgen_func_elem_2635);
3246
3315
  return addHeapObject(ret);
3247
3316
  };
3248
3317
 
3249
- export function __wbindgen_cast_829978f7e672581b(arg0, arg1) {
3250
- // Cast intrinsic for `Closure(Closure { dtor_idx: 337, function: Function { arguments: [], shim_idx: 338, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3251
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3099, __wasm_bindgen_func_elem_3103);
3318
+ export function __wbindgen_cast_4625c577ab2ec9ee(arg0) {
3319
+ // Cast intrinsic for `U64 -> Externref`.
3320
+ const ret = BigInt.asUintN(64, arg0);
3252
3321
  return addHeapObject(ret);
3253
3322
  };
3254
3323
 
@@ -3270,12 +3339,6 @@ export function __wbindgen_cast_e7b45dd881f38ce3(arg0, arg1) {
3270
3339
  return addHeapObject(ret);
3271
3340
  };
3272
3341
 
3273
- export function __wbindgen_cast_e9643297b4d6a498(arg0, arg1) {
3274
- // Cast intrinsic for `Closure(Closure { dtor_idx: 372, function: Function { arguments: [Externref], shim_idx: 383, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3275
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3285, __wasm_bindgen_func_elem_3312);
3276
- return addHeapObject(ret);
3277
- };
3278
-
3279
3342
  export function __wbindgen_object_clone_ref(arg0) {
3280
3343
  const ret = getObject(arg0);
3281
3344
  return addHeapObject(ret);