@crypticdot/defituna-core 3.4.3 → 3.4.5

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.
@@ -632,24 +632,6 @@ export function swapQuoteByInputToken(token_in: bigint, specified_token_a: boole
632
632
  * The exact input or output amount for the swap transaction.
633
633
  */
634
634
  export function swapQuoteByOutputToken(token_out: bigint, specified_token_a: boolean, slippage_tolerance_bps: number, fusion_pool: FusionPoolFacade, tick_arrays: TickArrayFacade[], transfer_fee_a?: TransferFee | null, transfer_fee_b?: TransferFee | null): ExactOutSwapQuote;
635
- /**
636
- * Computes the liquidation prices for an existing position.
637
- *
638
- * # Parameters
639
- * - `tick_lower_index`: The lower tick index of the position.
640
- * - `tick_upper_index`: The upper tick index of the position.
641
- * - `leftovers_a`: The amount of leftovers A in the position.
642
- * - `leftovers_a`: The amount of leftovers B in the position.
643
- * - `liquidity`: Liquidity of the position.
644
- * - `debt_a`: The amount of tokens A borrowed.
645
- * - `debt_b`: The amount of tokens B borrowed.
646
- * - `liquidation_threshold`: The liquidation threshold of the market.
647
- *
648
- * # Returns
649
- * - `LiquidationPrices`: An object containing lower/upper liquidation prices.
650
- */
651
- export function getLpPositionLiquidationPrices(tick_lower_index: number, tick_upper_index: number, liquidity: bigint, leftovers_a: bigint, leftovers_b: bigint, debt_a: bigint, debt_b: bigint, liquidation_threshold: number): LiquidationPrices;
652
- export function getIncreaseLpPositionQuote(args: IncreaseLpPositionQuoteArgs): IncreaseLpPositionQuoteResult;
653
635
  export function _HUNDRED_PERCENT(): number;
654
636
  export function _COMPUTED_AMOUNT(): bigint;
655
637
  /**
@@ -695,14 +677,14 @@ export function getDecreaseSpotPositionQuote(decrease_amount: bigint, collateral
695
677
  *
696
678
  * # Parameters
697
679
  * - `position_token`: Token of the position
698
- * - `amount`: Position total size (decimal)
699
- * - `debt`: Position total debt (decimal)
700
- * - `liquidation_threshold`: Liquidation threshold of the market (decimal)
680
+ * - `amount`: Position total size
681
+ * - `debt`: Position total debt
682
+ * - `liquidation_threshold`: Liquidation threshold of a market
701
683
  *
702
684
  * # Returns
703
685
  * - `f64`: Decimal liquidation price
704
686
  */
705
- export function getSpotPositionLiquidationPrice(position_token: number, amount: number, debt: number, liquidation_threshold: number): number;
687
+ export function getSpotPositionLiquidationPrice(position_token: number, amount: bigint, debt: bigint, liquidation_threshold: number): number;
706
688
  /**
707
689
  * Calculates the maximum tradable amount in the collateral token.
708
690
  *
@@ -722,7 +704,29 @@ export function getSpotPositionLiquidationPrice(position_token: number, amount:
722
704
  */
723
705
  export function getTradableAmount(collateral_token: number, available_balance: bigint, leverage: number, position_token: number, position_amount: bigint, protocol_fee_rate: number, protocol_fee_rate_on_collateral: number, fusion_pool: FusionPoolFacade, increase: boolean): bigint;
724
706
  export function calculateTunaSpotPositionProtocolFee(collateral_token: number, borrowed_token: number, collateral: bigint, borrow: bigint, protocol_fee_rate_on_collateral: number, protocol_fee_rate: number): TokenPair;
707
+ export function applyTunaProtocolFee(amount: bigint, protocol_fee_rate: number, round_up: boolean): bigint;
708
+ export function reverseApplyTunaProtocolFee(amount: bigint, protocol_fee_rate: number, round_up: boolean): bigint;
725
709
  export function calculateTunaProtocolFee(collateral: bigint, borrow: bigint, protocol_fee_rate_on_collateral: number, protocol_fee_rate: number): bigint;
710
+ /**
711
+ * Computes the liquidation prices for an existing position.
712
+ *
713
+ * # Parameters
714
+ * - `tick_lower_index`: The lower tick index of the position.
715
+ * - `tick_upper_index`: The upper tick index of the position.
716
+ * - `leftovers_a`: The amount of leftovers A in the position.
717
+ * - `leftovers_a`: The amount of leftovers B in the position.
718
+ * - `liquidity`: Liquidity of the position.
719
+ * - `debt_a`: The amount of tokens A borrowed.
720
+ * - `debt_b`: The amount of tokens B borrowed.
721
+ * - `liquidation_threshold`: The liquidation threshold of the market.
722
+ *
723
+ * # Returns
724
+ * - `LiquidationPrices`: An object containing lower/upper liquidation prices.
725
+ */
726
+ export function getLpPositionLiquidationPrices(tick_lower_index: number, tick_upper_index: number, liquidity: bigint, leftovers_a: bigint, leftovers_b: bigint, debt_a: bigint, debt_b: bigint, liquidation_threshold: number): LiquidationPrices;
727
+ export function getIncreaseLpPositionQuote(args: IncreaseLpPositionQuoteArgs): IncreaseLpPositionQuoteResult;
728
+ export function getRepayLpPositionDebtQuote(args: RepayLpPositionDebtQuoteArgs): RepayLpPositionDebtQuoteResult;
729
+ export function computeLeverage(total_a: bigint, total_b: bigint, debt_a: bigint, debt_b: bigint, sqrt_price: bigint): number;
726
730
  export function _INVALID_ARGUMENTS(): string;
727
731
  export function _JUPITER_QUOTE_REQUEST_ERROR(): string;
728
732
  export function _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR(): string;
@@ -849,46 +853,6 @@ export interface TickRange {
849
853
  tickUpperIndex: number;
850
854
  }
851
855
 
852
- export interface IncreaseLpPositionQuoteResult {
853
- collateralA: bigint;
854
- collateralB: bigint;
855
- maxCollateralA: bigint;
856
- maxCollateralB: bigint;
857
- borrowA: bigint;
858
- borrowB: bigint;
859
- totalA: bigint;
860
- totalB: bigint;
861
- minTotalA: bigint;
862
- minTotalB: bigint;
863
- swapInput: bigint;
864
- swapOutput: bigint;
865
- swapAToB: boolean;
866
- protocolFeeA: bigint;
867
- protocolFeeB: bigint;
868
- liquidationLowerPrice: number;
869
- liquidationUpperPrice: number;
870
- }
871
-
872
- export interface IncreaseLpPositionQuoteArgs {
873
- collateralA: bigint;
874
- collateralB: bigint;
875
- borrowA: bigint;
876
- borrowB: bigint;
877
- protocolFeeRate: number;
878
- protocolFeeRateOnCollateral: number;
879
- swapFeeRate: number;
880
- sqrtPrice: bigint;
881
- tickLowerIndex: number;
882
- tickUpperIndex: number;
883
- maxAmountSlippage: number;
884
- liquidationThreshold: number;
885
- }
886
-
887
- export interface LiquidationPrices {
888
- lower: number;
889
- upper: number;
890
- }
891
-
892
856
  export interface SwapInstruction {
893
857
  data: number[];
894
858
  accounts: AccountMeta[];
@@ -931,6 +895,70 @@ export interface TunaSpotPositionFacade {
931
895
  upperLimitOrderSqrtPrice: bigint;
932
896
  }
933
897
 
898
+ export interface RepayLpPositionDebtQuoteResult {
899
+ debtA: bigint;
900
+ debtB: bigint;
901
+ leverage: number;
902
+ liquidationLowerPrice: number;
903
+ liquidationUpperPrice: number;
904
+ }
905
+
906
+ export interface RepayLpPositionDebtQuoteArgs {
907
+ liquidity: bigint;
908
+ debtA: bigint;
909
+ debtB: bigint;
910
+ leftoversA: bigint;
911
+ leftoversB: bigint;
912
+ tickLowerIndex: number;
913
+ tickUpperIndex: number;
914
+ repayA: bigint;
915
+ repayB: bigint;
916
+ sqrtPrice: bigint;
917
+ liquidationThreshold: number;
918
+ }
919
+
920
+ export interface IncreaseLpPositionQuoteResult {
921
+ collateralA: bigint;
922
+ collateralB: bigint;
923
+ maxCollateralA: bigint;
924
+ maxCollateralB: bigint;
925
+ borrowA: bigint;
926
+ borrowB: bigint;
927
+ totalA: bigint;
928
+ totalB: bigint;
929
+ minTotalA: bigint;
930
+ minTotalB: bigint;
931
+ swapInput: bigint;
932
+ swapOutput: bigint;
933
+ swapAToB: boolean;
934
+ protocolFeeA: bigint;
935
+ protocolFeeB: bigint;
936
+ liquidity: bigint;
937
+ leverage: number;
938
+ liquidationLowerPrice: number;
939
+ liquidationUpperPrice: number;
940
+ }
941
+
942
+ export interface IncreaseLpPositionQuoteArgs {
943
+ collateralA: bigint;
944
+ collateralB: bigint;
945
+ borrowA: bigint;
946
+ borrowB: bigint;
947
+ protocolFeeRate: number;
948
+ protocolFeeRateOnCollateral: number;
949
+ swapFeeRate: number;
950
+ sqrtPrice: bigint;
951
+ tickLowerIndex: number;
952
+ tickUpperIndex: number;
953
+ maxAmountSlippage: number;
954
+ liquidationThreshold: number;
955
+ }
956
+
957
+ export interface LiquidationPrices {
958
+ lower: number;
959
+ upper: number;
960
+ }
961
+
934
962
  /**
935
963
  * A hash; the 32-byte output of a hashing algorithm.
936
964
  *
@@ -1696,54 +1696,6 @@ export function swapQuoteByOutputToken(token_out, specified_token_a, slippage_to
1696
1696
  }
1697
1697
  }
1698
1698
 
1699
- /**
1700
- * Computes the liquidation prices for an existing position.
1701
- *
1702
- * # Parameters
1703
- * - `tick_lower_index`: The lower tick index of the position.
1704
- * - `tick_upper_index`: The upper tick index of the position.
1705
- * - `leftovers_a`: The amount of leftovers A in the position.
1706
- * - `leftovers_a`: The amount of leftovers B in the position.
1707
- * - `liquidity`: Liquidity of the position.
1708
- * - `debt_a`: The amount of tokens A borrowed.
1709
- * - `debt_b`: The amount of tokens B borrowed.
1710
- * - `liquidation_threshold`: The liquidation threshold of the market.
1711
- *
1712
- * # Returns
1713
- * - `LiquidationPrices`: An object containing lower/upper liquidation prices.
1714
- */
1715
- export function getLpPositionLiquidationPrices(tick_lower_index, tick_upper_index, liquidity, leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold) {
1716
- try {
1717
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1718
- wasm.getLpPositionLiquidationPrices(retptr, tick_lower_index, tick_upper_index, liquidity, liquidity >> BigInt(64), leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold);
1719
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1720
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1721
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1722
- if (r2) {
1723
- throw takeObject(r1);
1724
- }
1725
- return takeObject(r0);
1726
- } finally {
1727
- wasm.__wbindgen_add_to_stack_pointer(16);
1728
- }
1729
- }
1730
-
1731
- export function getIncreaseLpPositionQuote(args) {
1732
- try {
1733
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1734
- wasm.getIncreaseLpPositionQuote(retptr, addHeapObject(args));
1735
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1736
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1737
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1738
- if (r2) {
1739
- throw takeObject(r1);
1740
- }
1741
- return takeObject(r0);
1742
- } finally {
1743
- wasm.__wbindgen_add_to_stack_pointer(16);
1744
- }
1745
- }
1746
-
1747
1699
  export function _HUNDRED_PERCENT() {
1748
1700
  const ret = wasm._HUNDRED_PERCENT();
1749
1701
  return ret >>> 0;
@@ -1813,9 +1765,9 @@ export function getDecreaseSpotPositionQuote(decrease_amount, collateral_token,
1813
1765
  *
1814
1766
  * # Parameters
1815
1767
  * - `position_token`: Token of the position
1816
- * - `amount`: Position total size (decimal)
1817
- * - `debt`: Position total debt (decimal)
1818
- * - `liquidation_threshold`: Liquidation threshold of the market (decimal)
1768
+ * - `amount`: Position total size
1769
+ * - `debt`: Position total debt
1770
+ * - `liquidation_threshold`: Liquidation threshold of a market
1819
1771
  *
1820
1772
  * # Returns
1821
1773
  * - `f64`: Decimal liquidation price
@@ -1874,11 +1826,123 @@ export function calculateTunaSpotPositionProtocolFee(collateral_token, borrowed_
1874
1826
  return takeObject(ret);
1875
1827
  }
1876
1828
 
1829
+ export function applyTunaProtocolFee(amount, protocol_fee_rate, round_up) {
1830
+ try {
1831
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1832
+ wasm.applyTunaProtocolFee(retptr, amount, protocol_fee_rate, round_up);
1833
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1834
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1835
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1836
+ if (r3) {
1837
+ throw takeObject(r2);
1838
+ }
1839
+ return BigInt.asUintN(64, r0);
1840
+ } finally {
1841
+ wasm.__wbindgen_add_to_stack_pointer(16);
1842
+ }
1843
+ }
1844
+
1845
+ export function reverseApplyTunaProtocolFee(amount, protocol_fee_rate, round_up) {
1846
+ try {
1847
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1848
+ wasm.reverseApplyTunaProtocolFee(retptr, amount, protocol_fee_rate, round_up);
1849
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1850
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1851
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1852
+ if (r3) {
1853
+ throw takeObject(r2);
1854
+ }
1855
+ return BigInt.asUintN(64, r0);
1856
+ } finally {
1857
+ wasm.__wbindgen_add_to_stack_pointer(16);
1858
+ }
1859
+ }
1860
+
1877
1861
  export function calculateTunaProtocolFee(collateral, borrow, protocol_fee_rate_on_collateral, protocol_fee_rate) {
1878
1862
  const ret = wasm.calculateTunaProtocolFee(collateral, borrow, protocol_fee_rate_on_collateral, protocol_fee_rate);
1879
1863
  return BigInt.asUintN(64, ret);
1880
1864
  }
1881
1865
 
1866
+ /**
1867
+ * Computes the liquidation prices for an existing position.
1868
+ *
1869
+ * # Parameters
1870
+ * - `tick_lower_index`: The lower tick index of the position.
1871
+ * - `tick_upper_index`: The upper tick index of the position.
1872
+ * - `leftovers_a`: The amount of leftovers A in the position.
1873
+ * - `leftovers_a`: The amount of leftovers B in the position.
1874
+ * - `liquidity`: Liquidity of the position.
1875
+ * - `debt_a`: The amount of tokens A borrowed.
1876
+ * - `debt_b`: The amount of tokens B borrowed.
1877
+ * - `liquidation_threshold`: The liquidation threshold of the market.
1878
+ *
1879
+ * # Returns
1880
+ * - `LiquidationPrices`: An object containing lower/upper liquidation prices.
1881
+ */
1882
+ export function getLpPositionLiquidationPrices(tick_lower_index, tick_upper_index, liquidity, leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold) {
1883
+ try {
1884
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1885
+ wasm.getLpPositionLiquidationPrices(retptr, tick_lower_index, tick_upper_index, liquidity, liquidity >> BigInt(64), leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold);
1886
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1887
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1888
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1889
+ if (r2) {
1890
+ throw takeObject(r1);
1891
+ }
1892
+ return takeObject(r0);
1893
+ } finally {
1894
+ wasm.__wbindgen_add_to_stack_pointer(16);
1895
+ }
1896
+ }
1897
+
1898
+ export function getIncreaseLpPositionQuote(args) {
1899
+ try {
1900
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1901
+ wasm.getIncreaseLpPositionQuote(retptr, addHeapObject(args));
1902
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1903
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1904
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1905
+ if (r2) {
1906
+ throw takeObject(r1);
1907
+ }
1908
+ return takeObject(r0);
1909
+ } finally {
1910
+ wasm.__wbindgen_add_to_stack_pointer(16);
1911
+ }
1912
+ }
1913
+
1914
+ export function getRepayLpPositionDebtQuote(args) {
1915
+ try {
1916
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1917
+ wasm.getRepayLpPositionDebtQuote(retptr, addHeapObject(args));
1918
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1919
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1920
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1921
+ if (r2) {
1922
+ throw takeObject(r1);
1923
+ }
1924
+ return takeObject(r0);
1925
+ } finally {
1926
+ wasm.__wbindgen_add_to_stack_pointer(16);
1927
+ }
1928
+ }
1929
+
1930
+ export function computeLeverage(total_a, total_b, debt_a, debt_b, sqrt_price) {
1931
+ try {
1932
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1933
+ wasm.computeLeverage(retptr, total_a, total_b, debt_a, debt_b, sqrt_price, sqrt_price >> BigInt(64));
1934
+ var r0 = getDataViewMemory0().getFloat64(retptr + 8 * 0, true);
1935
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1936
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1937
+ if (r3) {
1938
+ throw takeObject(r2);
1939
+ }
1940
+ return r0;
1941
+ } finally {
1942
+ wasm.__wbindgen_add_to_stack_pointer(16);
1943
+ }
1944
+ }
1945
+
1882
1946
  export function _INVALID_ARGUMENTS() {
1883
1947
  try {
1884
1948
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
@@ -1922,16 +1986,16 @@ export function solana_program_init() {
1922
1986
  wasm.solana_program_init();
1923
1987
  }
1924
1988
 
1925
- function __wasm_bindgen_func_elem_3207(arg0, arg1) {
1926
- wasm.__wasm_bindgen_func_elem_3207(arg0, arg1);
1989
+ function __wasm_bindgen_func_elem_3154(arg0, arg1) {
1990
+ wasm.__wasm_bindgen_func_elem_3154(arg0, arg1);
1927
1991
  }
1928
1992
 
1929
- function __wasm_bindgen_func_elem_2634(arg0, arg1, arg2) {
1930
- wasm.__wasm_bindgen_func_elem_2634(arg0, arg1, addHeapObject(arg2));
1993
+ function __wasm_bindgen_func_elem_3288(arg0, arg1, arg2) {
1994
+ wasm.__wasm_bindgen_func_elem_3288(arg0, arg1, addHeapObject(arg2));
1931
1995
  }
1932
1996
 
1933
- function __wasm_bindgen_func_elem_495(arg0, arg1, arg2, arg3) {
1934
- wasm.__wasm_bindgen_func_elem_495(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1997
+ function __wasm_bindgen_func_elem_494(arg0, arg1, arg2, arg3) {
1998
+ wasm.__wasm_bindgen_func_elem_494(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1935
1999
  }
1936
2000
 
1937
2001
  const __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
@@ -3094,7 +3158,7 @@ export function __wbg_new_3c3d849046688a66(arg0, arg1) {
3094
3158
  const a = state0.a;
3095
3159
  state0.a = 0;
3096
3160
  try {
3097
- return __wasm_bindgen_func_elem_495(a, state0.b, arg0, arg1);
3161
+ return __wasm_bindgen_func_elem_494(a, state0.b, arg0, arg1);
3098
3162
  } finally {
3099
3163
  state0.a = a;
3100
3164
  }
@@ -3338,30 +3402,30 @@ export function __wbg_warn_1d74dddbe2fd1dbb(arg0) {
3338
3402
  console.warn(getObject(arg0));
3339
3403
  };
3340
3404
 
3341
- export function __wbindgen_cast_0660a350899916ec(arg0, arg1) {
3342
- // Cast intrinsic for `Closure(Closure { dtor_idx: 360, function: Function { arguments: [], shim_idx: 361, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3343
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3203, __wasm_bindgen_func_elem_3207);
3344
- return addHeapObject(ret);
3345
- };
3346
-
3347
3405
  export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
3348
3406
  // Cast intrinsic for `Ref(String) -> Externref`.
3349
3407
  const ret = getStringFromWasm0(arg0, arg1);
3350
3408
  return addHeapObject(ret);
3351
3409
  };
3352
3410
 
3353
- export function __wbindgen_cast_2e5f7f1574aa20c6(arg0, arg1) {
3354
- // Cast intrinsic for `Closure(Closure { dtor_idx: 232, function: Function { arguments: [Externref], shim_idx: 227, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3355
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_2653, __wasm_bindgen_func_elem_2634);
3356
- return addHeapObject(ret);
3357
- };
3358
-
3359
3411
  export function __wbindgen_cast_4625c577ab2ec9ee(arg0) {
3360
3412
  // Cast intrinsic for `U64 -> Externref`.
3361
3413
  const ret = BigInt.asUintN(64, arg0);
3362
3414
  return addHeapObject(ret);
3363
3415
  };
3364
3416
 
3417
+ export function __wbindgen_cast_49dae81bf02b4884(arg0, arg1) {
3418
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 369, function: Function { arguments: [Externref], shim_idx: 380, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3419
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3261, __wasm_bindgen_func_elem_3288);
3420
+ return addHeapObject(ret);
3421
+ };
3422
+
3423
+ export function __wbindgen_cast_7879599246031d81(arg0, arg1) {
3424
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 343, function: Function { arguments: [], shim_idx: 344, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3425
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3150, __wasm_bindgen_func_elem_3154);
3426
+ return addHeapObject(ret);
3427
+ };
3428
+
3365
3429
  export function __wbindgen_cast_9ae0607507abb057(arg0) {
3366
3430
  // Cast intrinsic for `I64 -> Externref`.
3367
3431
  const ret = arg0;
@@ -3,17 +3,21 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const getLpPositionLiquidationPrices: (a: number, b: number, c: number, d: bigint, e: bigint, f: bigint, g: bigint, h: bigint, i: bigint, j: number) => void;
5
5
  export const getIncreaseLpPositionQuote: (a: number, b: number) => void;
6
- export const _INVALID_ARGUMENTS: (a: number) => void;
7
- export const _JUPITER_QUOTE_REQUEST_ERROR: (a: number) => void;
8
- export const _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR: (a: number) => void;
6
+ export const getRepayLpPositionDebtQuote: (a: number, b: number) => void;
7
+ export const computeLeverage: (a: number, b: bigint, c: bigint, d: bigint, e: bigint, f: bigint, g: bigint) => void;
9
8
  export const _HUNDRED_PERCENT: () => number;
10
9
  export const _COMPUTED_AMOUNT: () => bigint;
11
10
  export const getIncreaseSpotPositionQuote: (a: bigint, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => number;
12
11
  export const getDecreaseSpotPositionQuote: (a: bigint, b: number, c: number, d: number, e: number, f: bigint, g: bigint, h: number, i: number, j: number, k: number) => number;
13
- export const getSpotPositionLiquidationPrice: (a: number, b: number, c: number, d: number, e: number) => void;
12
+ export const getSpotPositionLiquidationPrice: (a: number, b: number, c: bigint, d: bigint, e: number) => void;
14
13
  export const getTradableAmount: (a: number, b: number, c: bigint, d: number, e: number, f: bigint, g: number, h: number, i: number, j: number) => void;
15
14
  export const calculateTunaSpotPositionProtocolFee: (a: number, b: number, c: bigint, d: bigint, e: number, f: number) => number;
15
+ export const applyTunaProtocolFee: (a: number, b: bigint, c: number, d: number) => void;
16
+ export const reverseApplyTunaProtocolFee: (a: number, b: bigint, c: number, d: number) => void;
16
17
  export const calculateTunaProtocolFee: (a: bigint, b: bigint, c: number, d: number) => bigint;
18
+ export const _INVALID_ARGUMENTS: (a: number) => void;
19
+ export const _JUPITER_QUOTE_REQUEST_ERROR: (a: number) => void;
20
+ export const _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR: (a: number) => void;
17
21
  export const __wbg_transaction_free: (a: number, b: number) => void;
18
22
  export const transaction_constructor: (a: number, b: number) => number;
19
23
  export const transaction_message: (a: number) => number;
@@ -142,11 +146,11 @@ export const limitOrderQuoteByInputToken: (a: number, b: bigint, c: number, d: n
142
146
  export const limitOrderQuoteByOutputToken: (a: number, b: bigint, c: number, d: number, e: number) => void;
143
147
  export const limitOrderRewardByOutputToken: (a: number, b: bigint, c: number, d: number) => void;
144
148
  export const decreaseLimitOrderQuote: (a: number, b: number, c: number, d: number, e: bigint, f: number, g: number) => void;
145
- export const __wasm_bindgen_func_elem_3207: (a: number, b: number) => void;
146
- export const __wasm_bindgen_func_elem_3203: (a: number, b: number) => void;
147
- export const __wasm_bindgen_func_elem_2634: (a: number, b: number, c: number) => void;
148
- export const __wasm_bindgen_func_elem_2653: (a: number, b: number) => void;
149
- export const __wasm_bindgen_func_elem_495: (a: number, b: number, c: number, d: number) => void;
149
+ export const __wasm_bindgen_func_elem_3154: (a: number, b: number) => void;
150
+ export const __wasm_bindgen_func_elem_3150: (a: number, b: number) => void;
151
+ export const __wasm_bindgen_func_elem_3288: (a: number, b: number, c: number) => void;
152
+ export const __wasm_bindgen_func_elem_3261: (a: number, b: number) => void;
153
+ export const __wasm_bindgen_func_elem_494: (a: number, b: number, c: number, d: number) => void;
150
154
  export const __wbindgen_export: (a: number, b: number) => number;
151
155
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
152
156
  export const __wbindgen_export3: (a: number) => void;
@@ -632,24 +632,6 @@ export function swapQuoteByInputToken(token_in: bigint, specified_token_a: boole
632
632
  * The exact input or output amount for the swap transaction.
633
633
  */
634
634
  export function swapQuoteByOutputToken(token_out: bigint, specified_token_a: boolean, slippage_tolerance_bps: number, fusion_pool: FusionPoolFacade, tick_arrays: TickArrayFacade[], transfer_fee_a?: TransferFee | null, transfer_fee_b?: TransferFee | null): ExactOutSwapQuote;
635
- /**
636
- * Computes the liquidation prices for an existing position.
637
- *
638
- * # Parameters
639
- * - `tick_lower_index`: The lower tick index of the position.
640
- * - `tick_upper_index`: The upper tick index of the position.
641
- * - `leftovers_a`: The amount of leftovers A in the position.
642
- * - `leftovers_a`: The amount of leftovers B in the position.
643
- * - `liquidity`: Liquidity of the position.
644
- * - `debt_a`: The amount of tokens A borrowed.
645
- * - `debt_b`: The amount of tokens B borrowed.
646
- * - `liquidation_threshold`: The liquidation threshold of the market.
647
- *
648
- * # Returns
649
- * - `LiquidationPrices`: An object containing lower/upper liquidation prices.
650
- */
651
- export function getLpPositionLiquidationPrices(tick_lower_index: number, tick_upper_index: number, liquidity: bigint, leftovers_a: bigint, leftovers_b: bigint, debt_a: bigint, debt_b: bigint, liquidation_threshold: number): LiquidationPrices;
652
- export function getIncreaseLpPositionQuote(args: IncreaseLpPositionQuoteArgs): IncreaseLpPositionQuoteResult;
653
635
  export function _HUNDRED_PERCENT(): number;
654
636
  export function _COMPUTED_AMOUNT(): bigint;
655
637
  /**
@@ -695,14 +677,14 @@ export function getDecreaseSpotPositionQuote(decrease_amount: bigint, collateral
695
677
  *
696
678
  * # Parameters
697
679
  * - `position_token`: Token of the position
698
- * - `amount`: Position total size (decimal)
699
- * - `debt`: Position total debt (decimal)
700
- * - `liquidation_threshold`: Liquidation threshold of the market (decimal)
680
+ * - `amount`: Position total size
681
+ * - `debt`: Position total debt
682
+ * - `liquidation_threshold`: Liquidation threshold of a market
701
683
  *
702
684
  * # Returns
703
685
  * - `f64`: Decimal liquidation price
704
686
  */
705
- export function getSpotPositionLiquidationPrice(position_token: number, amount: number, debt: number, liquidation_threshold: number): number;
687
+ export function getSpotPositionLiquidationPrice(position_token: number, amount: bigint, debt: bigint, liquidation_threshold: number): number;
706
688
  /**
707
689
  * Calculates the maximum tradable amount in the collateral token.
708
690
  *
@@ -722,7 +704,29 @@ export function getSpotPositionLiquidationPrice(position_token: number, amount:
722
704
  */
723
705
  export function getTradableAmount(collateral_token: number, available_balance: bigint, leverage: number, position_token: number, position_amount: bigint, protocol_fee_rate: number, protocol_fee_rate_on_collateral: number, fusion_pool: FusionPoolFacade, increase: boolean): bigint;
724
706
  export function calculateTunaSpotPositionProtocolFee(collateral_token: number, borrowed_token: number, collateral: bigint, borrow: bigint, protocol_fee_rate_on_collateral: number, protocol_fee_rate: number): TokenPair;
707
+ export function applyTunaProtocolFee(amount: bigint, protocol_fee_rate: number, round_up: boolean): bigint;
708
+ export function reverseApplyTunaProtocolFee(amount: bigint, protocol_fee_rate: number, round_up: boolean): bigint;
725
709
  export function calculateTunaProtocolFee(collateral: bigint, borrow: bigint, protocol_fee_rate_on_collateral: number, protocol_fee_rate: number): bigint;
710
+ /**
711
+ * Computes the liquidation prices for an existing position.
712
+ *
713
+ * # Parameters
714
+ * - `tick_lower_index`: The lower tick index of the position.
715
+ * - `tick_upper_index`: The upper tick index of the position.
716
+ * - `leftovers_a`: The amount of leftovers A in the position.
717
+ * - `leftovers_a`: The amount of leftovers B in the position.
718
+ * - `liquidity`: Liquidity of the position.
719
+ * - `debt_a`: The amount of tokens A borrowed.
720
+ * - `debt_b`: The amount of tokens B borrowed.
721
+ * - `liquidation_threshold`: The liquidation threshold of the market.
722
+ *
723
+ * # Returns
724
+ * - `LiquidationPrices`: An object containing lower/upper liquidation prices.
725
+ */
726
+ export function getLpPositionLiquidationPrices(tick_lower_index: number, tick_upper_index: number, liquidity: bigint, leftovers_a: bigint, leftovers_b: bigint, debt_a: bigint, debt_b: bigint, liquidation_threshold: number): LiquidationPrices;
727
+ export function getIncreaseLpPositionQuote(args: IncreaseLpPositionQuoteArgs): IncreaseLpPositionQuoteResult;
728
+ export function getRepayLpPositionDebtQuote(args: RepayLpPositionDebtQuoteArgs): RepayLpPositionDebtQuoteResult;
729
+ export function computeLeverage(total_a: bigint, total_b: bigint, debt_a: bigint, debt_b: bigint, sqrt_price: bigint): number;
726
730
  export function _INVALID_ARGUMENTS(): string;
727
731
  export function _JUPITER_QUOTE_REQUEST_ERROR(): string;
728
732
  export function _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR(): string;
@@ -849,46 +853,6 @@ export interface TickRange {
849
853
  tickUpperIndex: number;
850
854
  }
851
855
 
852
- export interface IncreaseLpPositionQuoteResult {
853
- collateralA: bigint;
854
- collateralB: bigint;
855
- maxCollateralA: bigint;
856
- maxCollateralB: bigint;
857
- borrowA: bigint;
858
- borrowB: bigint;
859
- totalA: bigint;
860
- totalB: bigint;
861
- minTotalA: bigint;
862
- minTotalB: bigint;
863
- swapInput: bigint;
864
- swapOutput: bigint;
865
- swapAToB: boolean;
866
- protocolFeeA: bigint;
867
- protocolFeeB: bigint;
868
- liquidationLowerPrice: number;
869
- liquidationUpperPrice: number;
870
- }
871
-
872
- export interface IncreaseLpPositionQuoteArgs {
873
- collateralA: bigint;
874
- collateralB: bigint;
875
- borrowA: bigint;
876
- borrowB: bigint;
877
- protocolFeeRate: number;
878
- protocolFeeRateOnCollateral: number;
879
- swapFeeRate: number;
880
- sqrtPrice: bigint;
881
- tickLowerIndex: number;
882
- tickUpperIndex: number;
883
- maxAmountSlippage: number;
884
- liquidationThreshold: number;
885
- }
886
-
887
- export interface LiquidationPrices {
888
- lower: number;
889
- upper: number;
890
- }
891
-
892
856
  export interface SwapInstruction {
893
857
  data: number[];
894
858
  accounts: AccountMeta[];
@@ -931,6 +895,70 @@ export interface TunaSpotPositionFacade {
931
895
  upperLimitOrderSqrtPrice: bigint;
932
896
  }
933
897
 
898
+ export interface RepayLpPositionDebtQuoteResult {
899
+ debtA: bigint;
900
+ debtB: bigint;
901
+ leverage: number;
902
+ liquidationLowerPrice: number;
903
+ liquidationUpperPrice: number;
904
+ }
905
+
906
+ export interface RepayLpPositionDebtQuoteArgs {
907
+ liquidity: bigint;
908
+ debtA: bigint;
909
+ debtB: bigint;
910
+ leftoversA: bigint;
911
+ leftoversB: bigint;
912
+ tickLowerIndex: number;
913
+ tickUpperIndex: number;
914
+ repayA: bigint;
915
+ repayB: bigint;
916
+ sqrtPrice: bigint;
917
+ liquidationThreshold: number;
918
+ }
919
+
920
+ export interface IncreaseLpPositionQuoteResult {
921
+ collateralA: bigint;
922
+ collateralB: bigint;
923
+ maxCollateralA: bigint;
924
+ maxCollateralB: bigint;
925
+ borrowA: bigint;
926
+ borrowB: bigint;
927
+ totalA: bigint;
928
+ totalB: bigint;
929
+ minTotalA: bigint;
930
+ minTotalB: bigint;
931
+ swapInput: bigint;
932
+ swapOutput: bigint;
933
+ swapAToB: boolean;
934
+ protocolFeeA: bigint;
935
+ protocolFeeB: bigint;
936
+ liquidity: bigint;
937
+ leverage: number;
938
+ liquidationLowerPrice: number;
939
+ liquidationUpperPrice: number;
940
+ }
941
+
942
+ export interface IncreaseLpPositionQuoteArgs {
943
+ collateralA: bigint;
944
+ collateralB: bigint;
945
+ borrowA: bigint;
946
+ borrowB: bigint;
947
+ protocolFeeRate: number;
948
+ protocolFeeRateOnCollateral: number;
949
+ swapFeeRate: number;
950
+ sqrtPrice: bigint;
951
+ tickLowerIndex: number;
952
+ tickUpperIndex: number;
953
+ maxAmountSlippage: number;
954
+ liquidationThreshold: number;
955
+ }
956
+
957
+ export interface LiquidationPrices {
958
+ lower: number;
959
+ upper: number;
960
+ }
961
+
934
962
  /**
935
963
  * A hash; the 32-byte output of a hashing algorithm.
936
964
  *
@@ -1686,54 +1686,6 @@ exports.swapQuoteByOutputToken = function(token_out, specified_token_a, slippage
1686
1686
  }
1687
1687
  };
1688
1688
 
1689
- /**
1690
- * Computes the liquidation prices for an existing position.
1691
- *
1692
- * # Parameters
1693
- * - `tick_lower_index`: The lower tick index of the position.
1694
- * - `tick_upper_index`: The upper tick index of the position.
1695
- * - `leftovers_a`: The amount of leftovers A in the position.
1696
- * - `leftovers_a`: The amount of leftovers B in the position.
1697
- * - `liquidity`: Liquidity of the position.
1698
- * - `debt_a`: The amount of tokens A borrowed.
1699
- * - `debt_b`: The amount of tokens B borrowed.
1700
- * - `liquidation_threshold`: The liquidation threshold of the market.
1701
- *
1702
- * # Returns
1703
- * - `LiquidationPrices`: An object containing lower/upper liquidation prices.
1704
- */
1705
- exports.getLpPositionLiquidationPrices = function(tick_lower_index, tick_upper_index, liquidity, leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold) {
1706
- try {
1707
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1708
- wasm.getLpPositionLiquidationPrices(retptr, tick_lower_index, tick_upper_index, liquidity, liquidity >> BigInt(64), leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold);
1709
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1710
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1711
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1712
- if (r2) {
1713
- throw takeObject(r1);
1714
- }
1715
- return takeObject(r0);
1716
- } finally {
1717
- wasm.__wbindgen_add_to_stack_pointer(16);
1718
- }
1719
- };
1720
-
1721
- exports.getIncreaseLpPositionQuote = function(args) {
1722
- try {
1723
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1724
- wasm.getIncreaseLpPositionQuote(retptr, addHeapObject(args));
1725
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1726
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1727
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1728
- if (r2) {
1729
- throw takeObject(r1);
1730
- }
1731
- return takeObject(r0);
1732
- } finally {
1733
- wasm.__wbindgen_add_to_stack_pointer(16);
1734
- }
1735
- };
1736
-
1737
1689
  exports._HUNDRED_PERCENT = function() {
1738
1690
  const ret = wasm._HUNDRED_PERCENT();
1739
1691
  return ret >>> 0;
@@ -1803,9 +1755,9 @@ exports.getDecreaseSpotPositionQuote = function(decrease_amount, collateral_toke
1803
1755
  *
1804
1756
  * # Parameters
1805
1757
  * - `position_token`: Token of the position
1806
- * - `amount`: Position total size (decimal)
1807
- * - `debt`: Position total debt (decimal)
1808
- * - `liquidation_threshold`: Liquidation threshold of the market (decimal)
1758
+ * - `amount`: Position total size
1759
+ * - `debt`: Position total debt
1760
+ * - `liquidation_threshold`: Liquidation threshold of a market
1809
1761
  *
1810
1762
  * # Returns
1811
1763
  * - `f64`: Decimal liquidation price
@@ -1864,11 +1816,123 @@ exports.calculateTunaSpotPositionProtocolFee = function(collateral_token, borrow
1864
1816
  return takeObject(ret);
1865
1817
  };
1866
1818
 
1819
+ exports.applyTunaProtocolFee = function(amount, protocol_fee_rate, round_up) {
1820
+ try {
1821
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1822
+ wasm.applyTunaProtocolFee(retptr, amount, protocol_fee_rate, round_up);
1823
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1824
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1825
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1826
+ if (r3) {
1827
+ throw takeObject(r2);
1828
+ }
1829
+ return BigInt.asUintN(64, r0);
1830
+ } finally {
1831
+ wasm.__wbindgen_add_to_stack_pointer(16);
1832
+ }
1833
+ };
1834
+
1835
+ exports.reverseApplyTunaProtocolFee = function(amount, protocol_fee_rate, round_up) {
1836
+ try {
1837
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1838
+ wasm.reverseApplyTunaProtocolFee(retptr, amount, protocol_fee_rate, round_up);
1839
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1840
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1841
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1842
+ if (r3) {
1843
+ throw takeObject(r2);
1844
+ }
1845
+ return BigInt.asUintN(64, r0);
1846
+ } finally {
1847
+ wasm.__wbindgen_add_to_stack_pointer(16);
1848
+ }
1849
+ };
1850
+
1867
1851
  exports.calculateTunaProtocolFee = function(collateral, borrow, protocol_fee_rate_on_collateral, protocol_fee_rate) {
1868
1852
  const ret = wasm.calculateTunaProtocolFee(collateral, borrow, protocol_fee_rate_on_collateral, protocol_fee_rate);
1869
1853
  return BigInt.asUintN(64, ret);
1870
1854
  };
1871
1855
 
1856
+ /**
1857
+ * Computes the liquidation prices for an existing position.
1858
+ *
1859
+ * # Parameters
1860
+ * - `tick_lower_index`: The lower tick index of the position.
1861
+ * - `tick_upper_index`: The upper tick index of the position.
1862
+ * - `leftovers_a`: The amount of leftovers A in the position.
1863
+ * - `leftovers_a`: The amount of leftovers B in the position.
1864
+ * - `liquidity`: Liquidity of the position.
1865
+ * - `debt_a`: The amount of tokens A borrowed.
1866
+ * - `debt_b`: The amount of tokens B borrowed.
1867
+ * - `liquidation_threshold`: The liquidation threshold of the market.
1868
+ *
1869
+ * # Returns
1870
+ * - `LiquidationPrices`: An object containing lower/upper liquidation prices.
1871
+ */
1872
+ exports.getLpPositionLiquidationPrices = function(tick_lower_index, tick_upper_index, liquidity, leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold) {
1873
+ try {
1874
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1875
+ wasm.getLpPositionLiquidationPrices(retptr, tick_lower_index, tick_upper_index, liquidity, liquidity >> BigInt(64), leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold);
1876
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1877
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1878
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1879
+ if (r2) {
1880
+ throw takeObject(r1);
1881
+ }
1882
+ return takeObject(r0);
1883
+ } finally {
1884
+ wasm.__wbindgen_add_to_stack_pointer(16);
1885
+ }
1886
+ };
1887
+
1888
+ exports.getIncreaseLpPositionQuote = function(args) {
1889
+ try {
1890
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1891
+ wasm.getIncreaseLpPositionQuote(retptr, addHeapObject(args));
1892
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1893
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1894
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1895
+ if (r2) {
1896
+ throw takeObject(r1);
1897
+ }
1898
+ return takeObject(r0);
1899
+ } finally {
1900
+ wasm.__wbindgen_add_to_stack_pointer(16);
1901
+ }
1902
+ };
1903
+
1904
+ exports.getRepayLpPositionDebtQuote = function(args) {
1905
+ try {
1906
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1907
+ wasm.getRepayLpPositionDebtQuote(retptr, addHeapObject(args));
1908
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1909
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1910
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1911
+ if (r2) {
1912
+ throw takeObject(r1);
1913
+ }
1914
+ return takeObject(r0);
1915
+ } finally {
1916
+ wasm.__wbindgen_add_to_stack_pointer(16);
1917
+ }
1918
+ };
1919
+
1920
+ exports.computeLeverage = function(total_a, total_b, debt_a, debt_b, sqrt_price) {
1921
+ try {
1922
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1923
+ wasm.computeLeverage(retptr, total_a, total_b, debt_a, debt_b, sqrt_price, sqrt_price >> BigInt(64));
1924
+ var r0 = getDataViewMemory0().getFloat64(retptr + 8 * 0, true);
1925
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1926
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1927
+ if (r3) {
1928
+ throw takeObject(r2);
1929
+ }
1930
+ return r0;
1931
+ } finally {
1932
+ wasm.__wbindgen_add_to_stack_pointer(16);
1933
+ }
1934
+ };
1935
+
1872
1936
  exports._INVALID_ARGUMENTS = function() {
1873
1937
  try {
1874
1938
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
@@ -1912,16 +1976,16 @@ exports.solana_program_init = function() {
1912
1976
  wasm.solana_program_init();
1913
1977
  };
1914
1978
 
1915
- function __wasm_bindgen_func_elem_2634(arg0, arg1, arg2) {
1916
- wasm.__wasm_bindgen_func_elem_2634(arg0, arg1, addHeapObject(arg2));
1979
+ function __wasm_bindgen_func_elem_3154(arg0, arg1) {
1980
+ wasm.__wasm_bindgen_func_elem_3154(arg0, arg1);
1917
1981
  }
1918
1982
 
1919
- function __wasm_bindgen_func_elem_3207(arg0, arg1) {
1920
- wasm.__wasm_bindgen_func_elem_3207(arg0, arg1);
1983
+ function __wasm_bindgen_func_elem_3288(arg0, arg1, arg2) {
1984
+ wasm.__wasm_bindgen_func_elem_3288(arg0, arg1, addHeapObject(arg2));
1921
1985
  }
1922
1986
 
1923
- function __wasm_bindgen_func_elem_495(arg0, arg1, arg2, arg3) {
1924
- wasm.__wasm_bindgen_func_elem_495(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1987
+ function __wasm_bindgen_func_elem_494(arg0, arg1, arg2, arg3) {
1988
+ wasm.__wasm_bindgen_func_elem_494(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1925
1989
  }
1926
1990
 
1927
1991
  const __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
@@ -3100,7 +3164,7 @@ exports.__wbg_new_3c3d849046688a66 = function(arg0, arg1) {
3100
3164
  const a = state0.a;
3101
3165
  state0.a = 0;
3102
3166
  try {
3103
- return __wasm_bindgen_func_elem_495(a, state0.b, arg0, arg1);
3167
+ return __wasm_bindgen_func_elem_494(a, state0.b, arg0, arg1);
3104
3168
  } finally {
3105
3169
  state0.a = a;
3106
3170
  }
@@ -3344,30 +3408,30 @@ exports.__wbg_warn_1d74dddbe2fd1dbb = function(arg0) {
3344
3408
  console.warn(getObject(arg0));
3345
3409
  };
3346
3410
 
3347
- exports.__wbindgen_cast_0660a350899916ec = function(arg0, arg1) {
3348
- // Cast intrinsic for `Closure(Closure { dtor_idx: 360, function: Function { arguments: [], shim_idx: 361, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3349
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3203, __wasm_bindgen_func_elem_3207);
3350
- return addHeapObject(ret);
3351
- };
3352
-
3353
3411
  exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
3354
3412
  // Cast intrinsic for `Ref(String) -> Externref`.
3355
3413
  const ret = getStringFromWasm0(arg0, arg1);
3356
3414
  return addHeapObject(ret);
3357
3415
  };
3358
3416
 
3359
- exports.__wbindgen_cast_2e5f7f1574aa20c6 = function(arg0, arg1) {
3360
- // Cast intrinsic for `Closure(Closure { dtor_idx: 232, function: Function { arguments: [Externref], shim_idx: 227, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3361
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_2653, __wasm_bindgen_func_elem_2634);
3362
- return addHeapObject(ret);
3363
- };
3364
-
3365
3417
  exports.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
3366
3418
  // Cast intrinsic for `U64 -> Externref`.
3367
3419
  const ret = BigInt.asUintN(64, arg0);
3368
3420
  return addHeapObject(ret);
3369
3421
  };
3370
3422
 
3423
+ exports.__wbindgen_cast_49dae81bf02b4884 = function(arg0, arg1) {
3424
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 369, function: Function { arguments: [Externref], shim_idx: 380, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3425
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3261, __wasm_bindgen_func_elem_3288);
3426
+ return addHeapObject(ret);
3427
+ };
3428
+
3429
+ exports.__wbindgen_cast_7879599246031d81 = function(arg0, arg1) {
3430
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 343, function: Function { arguments: [], shim_idx: 344, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3431
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3150, __wasm_bindgen_func_elem_3154);
3432
+ return addHeapObject(ret);
3433
+ };
3434
+
3371
3435
  exports.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
3372
3436
  // Cast intrinsic for `I64 -> Externref`.
3373
3437
  const ret = arg0;
@@ -3,17 +3,21 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const getLpPositionLiquidationPrices: (a: number, b: number, c: number, d: bigint, e: bigint, f: bigint, g: bigint, h: bigint, i: bigint, j: number) => void;
5
5
  export const getIncreaseLpPositionQuote: (a: number, b: number) => void;
6
- export const _INVALID_ARGUMENTS: (a: number) => void;
7
- export const _JUPITER_QUOTE_REQUEST_ERROR: (a: number) => void;
8
- export const _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR: (a: number) => void;
6
+ export const getRepayLpPositionDebtQuote: (a: number, b: number) => void;
7
+ export const computeLeverage: (a: number, b: bigint, c: bigint, d: bigint, e: bigint, f: bigint, g: bigint) => void;
9
8
  export const _HUNDRED_PERCENT: () => number;
10
9
  export const _COMPUTED_AMOUNT: () => bigint;
11
10
  export const getIncreaseSpotPositionQuote: (a: bigint, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => number;
12
11
  export const getDecreaseSpotPositionQuote: (a: bigint, b: number, c: number, d: number, e: number, f: bigint, g: bigint, h: number, i: number, j: number, k: number) => number;
13
- export const getSpotPositionLiquidationPrice: (a: number, b: number, c: number, d: number, e: number) => void;
12
+ export const getSpotPositionLiquidationPrice: (a: number, b: number, c: bigint, d: bigint, e: number) => void;
14
13
  export const getTradableAmount: (a: number, b: number, c: bigint, d: number, e: number, f: bigint, g: number, h: number, i: number, j: number) => void;
15
14
  export const calculateTunaSpotPositionProtocolFee: (a: number, b: number, c: bigint, d: bigint, e: number, f: number) => number;
15
+ export const applyTunaProtocolFee: (a: number, b: bigint, c: number, d: number) => void;
16
+ export const reverseApplyTunaProtocolFee: (a: number, b: bigint, c: number, d: number) => void;
16
17
  export const calculateTunaProtocolFee: (a: bigint, b: bigint, c: number, d: number) => bigint;
18
+ export const _INVALID_ARGUMENTS: (a: number) => void;
19
+ export const _JUPITER_QUOTE_REQUEST_ERROR: (a: number) => void;
20
+ export const _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR: (a: number) => void;
17
21
  export const __wbg_transaction_free: (a: number, b: number) => void;
18
22
  export const transaction_constructor: (a: number, b: number) => number;
19
23
  export const transaction_message: (a: number) => number;
@@ -142,11 +146,11 @@ export const limitOrderQuoteByInputToken: (a: number, b: bigint, c: number, d: n
142
146
  export const limitOrderQuoteByOutputToken: (a: number, b: bigint, c: number, d: number, e: number) => void;
143
147
  export const limitOrderRewardByOutputToken: (a: number, b: bigint, c: number, d: number) => void;
144
148
  export const decreaseLimitOrderQuote: (a: number, b: number, c: number, d: number, e: bigint, f: number, g: number) => void;
145
- export const __wasm_bindgen_func_elem_2634: (a: number, b: number, c: number) => void;
146
- export const __wasm_bindgen_func_elem_2653: (a: number, b: number) => void;
147
- export const __wasm_bindgen_func_elem_3207: (a: number, b: number) => void;
148
- export const __wasm_bindgen_func_elem_3203: (a: number, b: number) => void;
149
- export const __wasm_bindgen_func_elem_495: (a: number, b: number, c: number, d: number) => void;
149
+ export const __wasm_bindgen_func_elem_3154: (a: number, b: number) => void;
150
+ export const __wasm_bindgen_func_elem_3150: (a: number, b: number) => void;
151
+ export const __wasm_bindgen_func_elem_3288: (a: number, b: number, c: number) => void;
152
+ export const __wasm_bindgen_func_elem_3261: (a: number, b: number) => void;
153
+ export const __wasm_bindgen_func_elem_494: (a: number, b: number, c: number, d: number) => void;
150
154
  export const __wbindgen_export: (a: number, b: number) => number;
151
155
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
152
156
  export const __wbindgen_export3: (a: number) => void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@crypticdot/defituna-core",
3
3
  "description": "DefiTuna core typescript package.",
4
- "version": "3.4.3",
4
+ "version": "3.4.5",
5
5
  "main": "./dist/nodejs/defituna_core_js_bindings.js",
6
6
  "types": "./dist/nodejs/defituna_core_js_bindings.d.ts",
7
7
  "browser": "./dist/browser/defituna_core_js_bindings.js",
@@ -23,7 +23,7 @@
23
23
  "@crypticdot/typescript-config": "^1.0.0",
24
24
  "typescript": "^5.8.3",
25
25
  "wasm-pack": "^0.13.1",
26
- "@crypticdot/defituna-rust-core": "3.4.3"
26
+ "@crypticdot/defituna-rust-core": "3.4.5"
27
27
  },
28
28
  "license": "SEE LICENSE IN LICENSE",
29
29
  "keywords": [