@crypticdot/defituna-core 3.4.8 → 3.5.1
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.
- package/dist/browser/defituna_core_js_bindings.d.ts +64 -69
- package/dist/browser/defituna_core_js_bindings_bg.js +97 -97
- package/dist/browser/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/browser/defituna_core_js_bindings_bg.wasm.d.ts +7 -7
- package/dist/nodejs/defituna_core_js_bindings.d.ts +64 -69
- package/dist/nodejs/defituna_core_js_bindings.js +97 -97
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm.d.ts +7 -7
- package/package.json +2 -2
|
@@ -633,8 +633,26 @@ export function swapQuoteByInputToken(token_in: bigint, specified_token_a: boole
|
|
|
633
633
|
* The exact input or output amount for the swap transaction.
|
|
634
634
|
*/
|
|
635
635
|
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;
|
|
636
|
-
|
|
637
|
-
|
|
636
|
+
/**
|
|
637
|
+
* Computes the liquidation prices for an existing position.
|
|
638
|
+
*
|
|
639
|
+
* # Parameters
|
|
640
|
+
* - `tick_lower_index`: The lower tick index of the position.
|
|
641
|
+
* - `tick_upper_index`: The upper tick index of the position.
|
|
642
|
+
* - `leftovers_a`: The amount of leftovers A in the position.
|
|
643
|
+
* - `leftovers_a`: The amount of leftovers B in the position.
|
|
644
|
+
* - `liquidity`: Liquidity of the position.
|
|
645
|
+
* - `debt_a`: The amount of tokens A borrowed.
|
|
646
|
+
* - `debt_b`: The amount of tokens B borrowed.
|
|
647
|
+
* - `liquidation_threshold`: The liquidation threshold of the market.
|
|
648
|
+
*
|
|
649
|
+
* # Returns
|
|
650
|
+
* - `LiquidationPrices`: An object containing lower/upper liquidation prices.
|
|
651
|
+
*/
|
|
652
|
+
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;
|
|
653
|
+
export function getIncreaseLpPositionQuote(args: IncreaseLpPositionQuoteArgs): IncreaseLpPositionQuoteResult;
|
|
654
|
+
export function getRepayLpPositionDebtQuote(args: RepayLpPositionDebtQuoteArgs): RepayLpPositionDebtQuoteResult;
|
|
655
|
+
export function computeLeverage(total_a: bigint, total_b: bigint, debt_a: bigint, debt_b: bigint, sqrt_price: bigint): number;
|
|
638
656
|
/**
|
|
639
657
|
* Spot position increase quote
|
|
640
658
|
*
|
|
@@ -708,29 +726,11 @@ export function calculateTunaSpotPositionProtocolFee(collateral_token: number, b
|
|
|
708
726
|
export function applyTunaProtocolFee(amount: bigint, protocol_fee_rate: number, round_up: boolean): bigint;
|
|
709
727
|
export function reverseApplyTunaProtocolFee(amount: bigint, protocol_fee_rate: number, round_up: boolean): bigint;
|
|
710
728
|
export function calculateTunaProtocolFee(collateral: bigint, borrow: bigint, protocol_fee_rate_on_collateral: number, protocol_fee_rate: number): bigint;
|
|
711
|
-
/**
|
|
712
|
-
* Computes the liquidation prices for an existing position.
|
|
713
|
-
*
|
|
714
|
-
* # Parameters
|
|
715
|
-
* - `tick_lower_index`: The lower tick index of the position.
|
|
716
|
-
* - `tick_upper_index`: The upper tick index of the position.
|
|
717
|
-
* - `leftovers_a`: The amount of leftovers A in the position.
|
|
718
|
-
* - `leftovers_a`: The amount of leftovers B in the position.
|
|
719
|
-
* - `liquidity`: Liquidity of the position.
|
|
720
|
-
* - `debt_a`: The amount of tokens A borrowed.
|
|
721
|
-
* - `debt_b`: The amount of tokens B borrowed.
|
|
722
|
-
* - `liquidation_threshold`: The liquidation threshold of the market.
|
|
723
|
-
*
|
|
724
|
-
* # Returns
|
|
725
|
-
* - `LiquidationPrices`: An object containing lower/upper liquidation prices.
|
|
726
|
-
*/
|
|
727
|
-
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;
|
|
728
|
-
export function getIncreaseLpPositionQuote(args: IncreaseLpPositionQuoteArgs): IncreaseLpPositionQuoteResult;
|
|
729
|
-
export function getRepayLpPositionDebtQuote(args: RepayLpPositionDebtQuoteArgs): RepayLpPositionDebtQuoteResult;
|
|
730
|
-
export function computeLeverage(total_a: bigint, total_b: bigint, debt_a: bigint, debt_b: bigint, sqrt_price: bigint): number;
|
|
731
729
|
export function _INVALID_ARGUMENTS(): string;
|
|
732
730
|
export function _JUPITER_QUOTE_REQUEST_ERROR(): string;
|
|
733
731
|
export function _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR(): string;
|
|
732
|
+
export function _HUNDRED_PERCENT(): number;
|
|
733
|
+
export function _COMPUTED_AMOUNT(): bigint;
|
|
734
734
|
/**
|
|
735
735
|
* Initialize Javascript logging and panic handler
|
|
736
736
|
*/
|
|
@@ -854,48 +854,6 @@ export interface TickRange {
|
|
|
854
854
|
tickUpperIndex: number;
|
|
855
855
|
}
|
|
856
856
|
|
|
857
|
-
export interface SwapInstruction {
|
|
858
|
-
data: number[];
|
|
859
|
-
accounts: AccountMeta[];
|
|
860
|
-
addressLookupTableAddresses: Pubkey[];
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
export interface IncreaseSpotPositionQuoteResult {
|
|
864
|
-
collateral: bigint;
|
|
865
|
-
borrow: bigint;
|
|
866
|
-
estimatedAmount: bigint;
|
|
867
|
-
swapInputAmount: bigint;
|
|
868
|
-
minSwapOutputAmount: bigint;
|
|
869
|
-
protocolFeeA: bigint;
|
|
870
|
-
protocolFeeB: bigint;
|
|
871
|
-
priceImpact: number;
|
|
872
|
-
jupiterSwapIx: SwapInstruction | undefined;
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
export interface DecreaseSpotPositionQuoteResult {
|
|
876
|
-
decreasePercent: number;
|
|
877
|
-
requiredSwapAmount: bigint;
|
|
878
|
-
estimatedAmount: bigint;
|
|
879
|
-
estimatedPayableDebt: bigint;
|
|
880
|
-
estimatedCollateralToBeWithdrawn: bigint;
|
|
881
|
-
priceImpact: number;
|
|
882
|
-
jupiterSwapIx: SwapInstruction | undefined;
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
export interface TunaSpotPositionFacade {
|
|
886
|
-
version: number;
|
|
887
|
-
marketMaker: number;
|
|
888
|
-
positionToken: number;
|
|
889
|
-
collateralToken: number;
|
|
890
|
-
flags: number;
|
|
891
|
-
amount: bigint;
|
|
892
|
-
loanShares: bigint;
|
|
893
|
-
loanFunds: bigint;
|
|
894
|
-
entrySqrtPrice: bigint;
|
|
895
|
-
lowerLimitOrderSqrtPrice: bigint;
|
|
896
|
-
upperLimitOrderSqrtPrice: bigint;
|
|
897
|
-
}
|
|
898
|
-
|
|
899
857
|
export interface RepayLpPositionDebtQuoteResult {
|
|
900
858
|
debtA: bigint;
|
|
901
859
|
debtB: bigint;
|
|
@@ -921,14 +879,10 @@ export interface RepayLpPositionDebtQuoteArgs {
|
|
|
921
879
|
export interface IncreaseLpPositionQuoteResult {
|
|
922
880
|
collateralA: bigint;
|
|
923
881
|
collateralB: bigint;
|
|
924
|
-
maxCollateralA: bigint;
|
|
925
|
-
maxCollateralB: bigint;
|
|
926
882
|
borrowA: bigint;
|
|
927
883
|
borrowB: bigint;
|
|
928
884
|
totalA: bigint;
|
|
929
885
|
totalB: bigint;
|
|
930
|
-
minTotalA: bigint;
|
|
931
|
-
minTotalB: bigint;
|
|
932
886
|
swapInput: bigint;
|
|
933
887
|
swapOutput: bigint;
|
|
934
888
|
swapAToB: boolean;
|
|
@@ -951,7 +905,6 @@ export interface IncreaseLpPositionQuoteArgs {
|
|
|
951
905
|
sqrtPrice: bigint;
|
|
952
906
|
tickLowerIndex: number;
|
|
953
907
|
tickUpperIndex: number;
|
|
954
|
-
maxAmountSlippage: number;
|
|
955
908
|
liquidationThreshold: number;
|
|
956
909
|
}
|
|
957
910
|
|
|
@@ -960,6 +913,48 @@ export interface LiquidationPrices {
|
|
|
960
913
|
upper: number;
|
|
961
914
|
}
|
|
962
915
|
|
|
916
|
+
export interface SwapInstruction {
|
|
917
|
+
data: number[];
|
|
918
|
+
accounts: AccountMeta[];
|
|
919
|
+
addressLookupTableAddresses: Pubkey[];
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
export interface IncreaseSpotPositionQuoteResult {
|
|
923
|
+
collateral: bigint;
|
|
924
|
+
borrow: bigint;
|
|
925
|
+
estimatedAmount: bigint;
|
|
926
|
+
swapInputAmount: bigint;
|
|
927
|
+
minSwapOutputAmount: bigint;
|
|
928
|
+
protocolFeeA: bigint;
|
|
929
|
+
protocolFeeB: bigint;
|
|
930
|
+
priceImpact: number;
|
|
931
|
+
jupiterSwapIx: SwapInstruction | undefined;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
export interface DecreaseSpotPositionQuoteResult {
|
|
935
|
+
decreasePercent: number;
|
|
936
|
+
requiredSwapAmount: bigint;
|
|
937
|
+
estimatedAmount: bigint;
|
|
938
|
+
estimatedPayableDebt: bigint;
|
|
939
|
+
estimatedCollateralToBeWithdrawn: bigint;
|
|
940
|
+
priceImpact: number;
|
|
941
|
+
jupiterSwapIx: SwapInstruction | undefined;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
export interface TunaSpotPositionFacade {
|
|
945
|
+
version: number;
|
|
946
|
+
marketMaker: number;
|
|
947
|
+
positionToken: number;
|
|
948
|
+
collateralToken: number;
|
|
949
|
+
flags: number;
|
|
950
|
+
amount: bigint;
|
|
951
|
+
loanShares: bigint;
|
|
952
|
+
loanFunds: bigint;
|
|
953
|
+
entrySqrtPrice: bigint;
|
|
954
|
+
lowerLimitOrderSqrtPrice: bigint;
|
|
955
|
+
upperLimitOrderSqrtPrice: bigint;
|
|
956
|
+
}
|
|
957
|
+
|
|
963
958
|
/**
|
|
964
959
|
* A hash; the 32-byte output of a hashing algorithm.
|
|
965
960
|
*
|
|
@@ -1708,14 +1708,84 @@ export function swapQuoteByOutputToken(token_out, specified_token_a, slippage_to
|
|
|
1708
1708
|
}
|
|
1709
1709
|
}
|
|
1710
1710
|
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1711
|
+
/**
|
|
1712
|
+
* Computes the liquidation prices for an existing position.
|
|
1713
|
+
*
|
|
1714
|
+
* # Parameters
|
|
1715
|
+
* - `tick_lower_index`: The lower tick index of the position.
|
|
1716
|
+
* - `tick_upper_index`: The upper tick index of the position.
|
|
1717
|
+
* - `leftovers_a`: The amount of leftovers A in the position.
|
|
1718
|
+
* - `leftovers_a`: The amount of leftovers B in the position.
|
|
1719
|
+
* - `liquidity`: Liquidity of the position.
|
|
1720
|
+
* - `debt_a`: The amount of tokens A borrowed.
|
|
1721
|
+
* - `debt_b`: The amount of tokens B borrowed.
|
|
1722
|
+
* - `liquidation_threshold`: The liquidation threshold of the market.
|
|
1723
|
+
*
|
|
1724
|
+
* # Returns
|
|
1725
|
+
* - `LiquidationPrices`: An object containing lower/upper liquidation prices.
|
|
1726
|
+
*/
|
|
1727
|
+
export function getLpPositionLiquidationPrices(tick_lower_index, tick_upper_index, liquidity, leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold) {
|
|
1728
|
+
try {
|
|
1729
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1730
|
+
wasm.getLpPositionLiquidationPrices(retptr, tick_lower_index, tick_upper_index, liquidity, liquidity >> BigInt(64), leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold);
|
|
1731
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1732
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1733
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1734
|
+
if (r2) {
|
|
1735
|
+
throw takeObject(r1);
|
|
1736
|
+
}
|
|
1737
|
+
return takeObject(r0);
|
|
1738
|
+
} finally {
|
|
1739
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1740
|
+
}
|
|
1714
1741
|
}
|
|
1715
1742
|
|
|
1716
|
-
export function
|
|
1717
|
-
|
|
1718
|
-
|
|
1743
|
+
export function getIncreaseLpPositionQuote(args) {
|
|
1744
|
+
try {
|
|
1745
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1746
|
+
wasm.getIncreaseLpPositionQuote(retptr, addHeapObject(args));
|
|
1747
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1748
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1749
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1750
|
+
if (r2) {
|
|
1751
|
+
throw takeObject(r1);
|
|
1752
|
+
}
|
|
1753
|
+
return takeObject(r0);
|
|
1754
|
+
} finally {
|
|
1755
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
export function getRepayLpPositionDebtQuote(args) {
|
|
1760
|
+
try {
|
|
1761
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1762
|
+
wasm.getRepayLpPositionDebtQuote(retptr, addHeapObject(args));
|
|
1763
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1764
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1765
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1766
|
+
if (r2) {
|
|
1767
|
+
throw takeObject(r1);
|
|
1768
|
+
}
|
|
1769
|
+
return takeObject(r0);
|
|
1770
|
+
} finally {
|
|
1771
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
export function computeLeverage(total_a, total_b, debt_a, debt_b, sqrt_price) {
|
|
1776
|
+
try {
|
|
1777
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1778
|
+
wasm.computeLeverage(retptr, total_a, total_b, debt_a, debt_b, sqrt_price, sqrt_price >> BigInt(64));
|
|
1779
|
+
var r0 = getDataViewMemory0().getFloat64(retptr + 8 * 0, true);
|
|
1780
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1781
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1782
|
+
if (r3) {
|
|
1783
|
+
throw takeObject(r2);
|
|
1784
|
+
}
|
|
1785
|
+
return r0;
|
|
1786
|
+
} finally {
|
|
1787
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1788
|
+
}
|
|
1719
1789
|
}
|
|
1720
1790
|
|
|
1721
1791
|
/**
|
|
@@ -1875,86 +1945,6 @@ export function calculateTunaProtocolFee(collateral, borrow, protocol_fee_rate_o
|
|
|
1875
1945
|
return BigInt.asUintN(64, ret);
|
|
1876
1946
|
}
|
|
1877
1947
|
|
|
1878
|
-
/**
|
|
1879
|
-
* Computes the liquidation prices for an existing position.
|
|
1880
|
-
*
|
|
1881
|
-
* # Parameters
|
|
1882
|
-
* - `tick_lower_index`: The lower tick index of the position.
|
|
1883
|
-
* - `tick_upper_index`: The upper tick index of the position.
|
|
1884
|
-
* - `leftovers_a`: The amount of leftovers A in the position.
|
|
1885
|
-
* - `leftovers_a`: The amount of leftovers B in the position.
|
|
1886
|
-
* - `liquidity`: Liquidity of the position.
|
|
1887
|
-
* - `debt_a`: The amount of tokens A borrowed.
|
|
1888
|
-
* - `debt_b`: The amount of tokens B borrowed.
|
|
1889
|
-
* - `liquidation_threshold`: The liquidation threshold of the market.
|
|
1890
|
-
*
|
|
1891
|
-
* # Returns
|
|
1892
|
-
* - `LiquidationPrices`: An object containing lower/upper liquidation prices.
|
|
1893
|
-
*/
|
|
1894
|
-
export function getLpPositionLiquidationPrices(tick_lower_index, tick_upper_index, liquidity, leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold) {
|
|
1895
|
-
try {
|
|
1896
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1897
|
-
wasm.getLpPositionLiquidationPrices(retptr, tick_lower_index, tick_upper_index, liquidity, liquidity >> BigInt(64), leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold);
|
|
1898
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1899
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1900
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1901
|
-
if (r2) {
|
|
1902
|
-
throw takeObject(r1);
|
|
1903
|
-
}
|
|
1904
|
-
return takeObject(r0);
|
|
1905
|
-
} finally {
|
|
1906
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1907
|
-
}
|
|
1908
|
-
}
|
|
1909
|
-
|
|
1910
|
-
export function getIncreaseLpPositionQuote(args) {
|
|
1911
|
-
try {
|
|
1912
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1913
|
-
wasm.getIncreaseLpPositionQuote(retptr, addHeapObject(args));
|
|
1914
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1915
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1916
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1917
|
-
if (r2) {
|
|
1918
|
-
throw takeObject(r1);
|
|
1919
|
-
}
|
|
1920
|
-
return takeObject(r0);
|
|
1921
|
-
} finally {
|
|
1922
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1923
|
-
}
|
|
1924
|
-
}
|
|
1925
|
-
|
|
1926
|
-
export function getRepayLpPositionDebtQuote(args) {
|
|
1927
|
-
try {
|
|
1928
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1929
|
-
wasm.getRepayLpPositionDebtQuote(retptr, addHeapObject(args));
|
|
1930
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1931
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1932
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1933
|
-
if (r2) {
|
|
1934
|
-
throw takeObject(r1);
|
|
1935
|
-
}
|
|
1936
|
-
return takeObject(r0);
|
|
1937
|
-
} finally {
|
|
1938
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1939
|
-
}
|
|
1940
|
-
}
|
|
1941
|
-
|
|
1942
|
-
export function computeLeverage(total_a, total_b, debt_a, debt_b, sqrt_price) {
|
|
1943
|
-
try {
|
|
1944
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1945
|
-
wasm.computeLeverage(retptr, total_a, total_b, debt_a, debt_b, sqrt_price, sqrt_price >> BigInt(64));
|
|
1946
|
-
var r0 = getDataViewMemory0().getFloat64(retptr + 8 * 0, true);
|
|
1947
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1948
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1949
|
-
if (r3) {
|
|
1950
|
-
throw takeObject(r2);
|
|
1951
|
-
}
|
|
1952
|
-
return r0;
|
|
1953
|
-
} finally {
|
|
1954
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1955
|
-
}
|
|
1956
|
-
}
|
|
1957
|
-
|
|
1958
1948
|
export function _INVALID_ARGUMENTS() {
|
|
1959
1949
|
try {
|
|
1960
1950
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
@@ -1991,6 +1981,16 @@ export function _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR() {
|
|
|
1991
1981
|
}
|
|
1992
1982
|
}
|
|
1993
1983
|
|
|
1984
|
+
export function _HUNDRED_PERCENT() {
|
|
1985
|
+
const ret = wasm._HUNDRED_PERCENT();
|
|
1986
|
+
return ret >>> 0;
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
export function _COMPUTED_AMOUNT() {
|
|
1990
|
+
const ret = wasm._COMPUTED_AMOUNT();
|
|
1991
|
+
return BigInt.asUintN(64, ret);
|
|
1992
|
+
}
|
|
1993
|
+
|
|
1994
1994
|
/**
|
|
1995
1995
|
* Initialize Javascript logging and panic handler
|
|
1996
1996
|
*/
|
|
@@ -1998,12 +1998,12 @@ export function solana_program_init() {
|
|
|
1998
1998
|
wasm.solana_program_init();
|
|
1999
1999
|
}
|
|
2000
2000
|
|
|
2001
|
-
function
|
|
2002
|
-
wasm.
|
|
2001
|
+
function __wasm_bindgen_func_elem_3155(arg0, arg1) {
|
|
2002
|
+
wasm.__wasm_bindgen_func_elem_3155(arg0, arg1);
|
|
2003
2003
|
}
|
|
2004
2004
|
|
|
2005
|
-
function
|
|
2006
|
-
wasm.
|
|
2005
|
+
function __wasm_bindgen_func_elem_3254(arg0, arg1, arg2) {
|
|
2006
|
+
wasm.__wasm_bindgen_func_elem_3254(arg0, arg1, addHeapObject(arg2));
|
|
2007
2007
|
}
|
|
2008
2008
|
|
|
2009
2009
|
function __wasm_bindgen_func_elem_494(arg0, arg1, arg2, arg3) {
|
|
@@ -3414,6 +3414,12 @@ export function __wbg_warn_1d74dddbe2fd1dbb(arg0) {
|
|
|
3414
3414
|
console.warn(getObject(arg0));
|
|
3415
3415
|
};
|
|
3416
3416
|
|
|
3417
|
+
export function __wbindgen_cast_1ce0818a4204304c(arg0, arg1) {
|
|
3418
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 361, function: Function { arguments: [Externref], shim_idx: 356, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3419
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3273, __wasm_bindgen_func_elem_3254);
|
|
3420
|
+
return addHeapObject(ret);
|
|
3421
|
+
};
|
|
3422
|
+
|
|
3417
3423
|
export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
|
|
3418
3424
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
3419
3425
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
@@ -3428,7 +3434,7 @@ export function __wbindgen_cast_4625c577ab2ec9ee(arg0) {
|
|
|
3428
3434
|
|
|
3429
3435
|
export function __wbindgen_cast_7879599246031d81(arg0, arg1) {
|
|
3430
3436
|
// 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.
|
|
3437
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3151, __wasm_bindgen_func_elem_3155);
|
|
3432
3438
|
return addHeapObject(ret);
|
|
3433
3439
|
};
|
|
3434
3440
|
|
|
@@ -3444,12 +3450,6 @@ export function __wbindgen_cast_d6cd19b81560fd6e(arg0) {
|
|
|
3444
3450
|
return addHeapObject(ret);
|
|
3445
3451
|
};
|
|
3446
3452
|
|
|
3447
|
-
export function __wbindgen_cast_e346b65485039441(arg0, arg1) {
|
|
3448
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx: 355, function: Function { arguments: [Externref], shim_idx: 366, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3449
|
-
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3232, __wasm_bindgen_func_elem_3259);
|
|
3450
|
-
return addHeapObject(ret);
|
|
3451
|
-
};
|
|
3452
|
-
|
|
3453
3453
|
export function __wbindgen_cast_e7b45dd881f38ce3(arg0, arg1) {
|
|
3454
3454
|
// Cast intrinsic for `U128 -> Externref`.
|
|
3455
3455
|
const ret = (BigInt.asUintN(64, arg0) | (BigInt.asUintN(64, arg1) << BigInt(64)));
|
|
Binary file
|
|
@@ -5,6 +5,9 @@ export const getLpPositionLiquidationPrices: (a: number, b: number, c: number, d
|
|
|
5
5
|
export const getIncreaseLpPositionQuote: (a: number, b: number) => void;
|
|
6
6
|
export const getRepayLpPositionDebtQuote: (a: number, b: number) => void;
|
|
7
7
|
export const computeLeverage: (a: number, b: bigint, c: bigint, d: bigint, e: bigint, f: bigint, g: bigint) => void;
|
|
8
|
+
export const _INVALID_ARGUMENTS: (a: number) => void;
|
|
9
|
+
export const _JUPITER_QUOTE_REQUEST_ERROR: (a: number) => void;
|
|
10
|
+
export const _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR: (a: number) => void;
|
|
8
11
|
export const _HUNDRED_PERCENT: () => number;
|
|
9
12
|
export const _COMPUTED_AMOUNT: () => bigint;
|
|
10
13
|
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;
|
|
@@ -15,9 +18,6 @@ export const calculateTunaSpotPositionProtocolFee: (a: number, b: number, c: big
|
|
|
15
18
|
export const applyTunaProtocolFee: (a: number, b: bigint, c: number, d: number) => void;
|
|
16
19
|
export const reverseApplyTunaProtocolFee: (a: number, b: bigint, c: number, d: number) => void;
|
|
17
20
|
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;
|
|
21
21
|
export const __wbg_transaction_free: (a: number, b: number) => void;
|
|
22
22
|
export const transaction_constructor: (a: number, b: number) => number;
|
|
23
23
|
export const transaction_message: (a: number) => number;
|
|
@@ -147,10 +147,10 @@ export const limitOrderRewardByOutputToken: (a: number, b: bigint, c: number, d:
|
|
|
147
147
|
export const decreaseLimitOrderQuote: (a: number, b: number, c: number, d: number, e: bigint, f: number, g: number) => void;
|
|
148
148
|
export const collectFeesQuote: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
149
149
|
export const limitOrderFee: (a: number) => number;
|
|
150
|
-
export const
|
|
151
|
-
export const
|
|
152
|
-
export const
|
|
153
|
-
export const
|
|
150
|
+
export const __wasm_bindgen_func_elem_3155: (a: number, b: number) => void;
|
|
151
|
+
export const __wasm_bindgen_func_elem_3151: (a: number, b: number) => void;
|
|
152
|
+
export const __wasm_bindgen_func_elem_3254: (a: number, b: number, c: number) => void;
|
|
153
|
+
export const __wasm_bindgen_func_elem_3273: (a: number, b: number) => void;
|
|
154
154
|
export const __wasm_bindgen_func_elem_494: (a: number, b: number, c: number, d: number) => void;
|
|
155
155
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
156
156
|
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
@@ -633,8 +633,26 @@ export function swapQuoteByInputToken(token_in: bigint, specified_token_a: boole
|
|
|
633
633
|
* The exact input or output amount for the swap transaction.
|
|
634
634
|
*/
|
|
635
635
|
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;
|
|
636
|
-
|
|
637
|
-
|
|
636
|
+
/**
|
|
637
|
+
* Computes the liquidation prices for an existing position.
|
|
638
|
+
*
|
|
639
|
+
* # Parameters
|
|
640
|
+
* - `tick_lower_index`: The lower tick index of the position.
|
|
641
|
+
* - `tick_upper_index`: The upper tick index of the position.
|
|
642
|
+
* - `leftovers_a`: The amount of leftovers A in the position.
|
|
643
|
+
* - `leftovers_a`: The amount of leftovers B in the position.
|
|
644
|
+
* - `liquidity`: Liquidity of the position.
|
|
645
|
+
* - `debt_a`: The amount of tokens A borrowed.
|
|
646
|
+
* - `debt_b`: The amount of tokens B borrowed.
|
|
647
|
+
* - `liquidation_threshold`: The liquidation threshold of the market.
|
|
648
|
+
*
|
|
649
|
+
* # Returns
|
|
650
|
+
* - `LiquidationPrices`: An object containing lower/upper liquidation prices.
|
|
651
|
+
*/
|
|
652
|
+
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;
|
|
653
|
+
export function getIncreaseLpPositionQuote(args: IncreaseLpPositionQuoteArgs): IncreaseLpPositionQuoteResult;
|
|
654
|
+
export function getRepayLpPositionDebtQuote(args: RepayLpPositionDebtQuoteArgs): RepayLpPositionDebtQuoteResult;
|
|
655
|
+
export function computeLeverage(total_a: bigint, total_b: bigint, debt_a: bigint, debt_b: bigint, sqrt_price: bigint): number;
|
|
638
656
|
/**
|
|
639
657
|
* Spot position increase quote
|
|
640
658
|
*
|
|
@@ -708,29 +726,11 @@ export function calculateTunaSpotPositionProtocolFee(collateral_token: number, b
|
|
|
708
726
|
export function applyTunaProtocolFee(amount: bigint, protocol_fee_rate: number, round_up: boolean): bigint;
|
|
709
727
|
export function reverseApplyTunaProtocolFee(amount: bigint, protocol_fee_rate: number, round_up: boolean): bigint;
|
|
710
728
|
export function calculateTunaProtocolFee(collateral: bigint, borrow: bigint, protocol_fee_rate_on_collateral: number, protocol_fee_rate: number): bigint;
|
|
711
|
-
/**
|
|
712
|
-
* Computes the liquidation prices for an existing position.
|
|
713
|
-
*
|
|
714
|
-
* # Parameters
|
|
715
|
-
* - `tick_lower_index`: The lower tick index of the position.
|
|
716
|
-
* - `tick_upper_index`: The upper tick index of the position.
|
|
717
|
-
* - `leftovers_a`: The amount of leftovers A in the position.
|
|
718
|
-
* - `leftovers_a`: The amount of leftovers B in the position.
|
|
719
|
-
* - `liquidity`: Liquidity of the position.
|
|
720
|
-
* - `debt_a`: The amount of tokens A borrowed.
|
|
721
|
-
* - `debt_b`: The amount of tokens B borrowed.
|
|
722
|
-
* - `liquidation_threshold`: The liquidation threshold of the market.
|
|
723
|
-
*
|
|
724
|
-
* # Returns
|
|
725
|
-
* - `LiquidationPrices`: An object containing lower/upper liquidation prices.
|
|
726
|
-
*/
|
|
727
|
-
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;
|
|
728
|
-
export function getIncreaseLpPositionQuote(args: IncreaseLpPositionQuoteArgs): IncreaseLpPositionQuoteResult;
|
|
729
|
-
export function getRepayLpPositionDebtQuote(args: RepayLpPositionDebtQuoteArgs): RepayLpPositionDebtQuoteResult;
|
|
730
|
-
export function computeLeverage(total_a: bigint, total_b: bigint, debt_a: bigint, debt_b: bigint, sqrt_price: bigint): number;
|
|
731
729
|
export function _INVALID_ARGUMENTS(): string;
|
|
732
730
|
export function _JUPITER_QUOTE_REQUEST_ERROR(): string;
|
|
733
731
|
export function _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR(): string;
|
|
732
|
+
export function _HUNDRED_PERCENT(): number;
|
|
733
|
+
export function _COMPUTED_AMOUNT(): bigint;
|
|
734
734
|
/**
|
|
735
735
|
* Initialize Javascript logging and panic handler
|
|
736
736
|
*/
|
|
@@ -854,48 +854,6 @@ export interface TickRange {
|
|
|
854
854
|
tickUpperIndex: number;
|
|
855
855
|
}
|
|
856
856
|
|
|
857
|
-
export interface SwapInstruction {
|
|
858
|
-
data: number[];
|
|
859
|
-
accounts: AccountMeta[];
|
|
860
|
-
addressLookupTableAddresses: Pubkey[];
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
export interface IncreaseSpotPositionQuoteResult {
|
|
864
|
-
collateral: bigint;
|
|
865
|
-
borrow: bigint;
|
|
866
|
-
estimatedAmount: bigint;
|
|
867
|
-
swapInputAmount: bigint;
|
|
868
|
-
minSwapOutputAmount: bigint;
|
|
869
|
-
protocolFeeA: bigint;
|
|
870
|
-
protocolFeeB: bigint;
|
|
871
|
-
priceImpact: number;
|
|
872
|
-
jupiterSwapIx: SwapInstruction | undefined;
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
export interface DecreaseSpotPositionQuoteResult {
|
|
876
|
-
decreasePercent: number;
|
|
877
|
-
requiredSwapAmount: bigint;
|
|
878
|
-
estimatedAmount: bigint;
|
|
879
|
-
estimatedPayableDebt: bigint;
|
|
880
|
-
estimatedCollateralToBeWithdrawn: bigint;
|
|
881
|
-
priceImpact: number;
|
|
882
|
-
jupiterSwapIx: SwapInstruction | undefined;
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
export interface TunaSpotPositionFacade {
|
|
886
|
-
version: number;
|
|
887
|
-
marketMaker: number;
|
|
888
|
-
positionToken: number;
|
|
889
|
-
collateralToken: number;
|
|
890
|
-
flags: number;
|
|
891
|
-
amount: bigint;
|
|
892
|
-
loanShares: bigint;
|
|
893
|
-
loanFunds: bigint;
|
|
894
|
-
entrySqrtPrice: bigint;
|
|
895
|
-
lowerLimitOrderSqrtPrice: bigint;
|
|
896
|
-
upperLimitOrderSqrtPrice: bigint;
|
|
897
|
-
}
|
|
898
|
-
|
|
899
857
|
export interface RepayLpPositionDebtQuoteResult {
|
|
900
858
|
debtA: bigint;
|
|
901
859
|
debtB: bigint;
|
|
@@ -921,14 +879,10 @@ export interface RepayLpPositionDebtQuoteArgs {
|
|
|
921
879
|
export interface IncreaseLpPositionQuoteResult {
|
|
922
880
|
collateralA: bigint;
|
|
923
881
|
collateralB: bigint;
|
|
924
|
-
maxCollateralA: bigint;
|
|
925
|
-
maxCollateralB: bigint;
|
|
926
882
|
borrowA: bigint;
|
|
927
883
|
borrowB: bigint;
|
|
928
884
|
totalA: bigint;
|
|
929
885
|
totalB: bigint;
|
|
930
|
-
minTotalA: bigint;
|
|
931
|
-
minTotalB: bigint;
|
|
932
886
|
swapInput: bigint;
|
|
933
887
|
swapOutput: bigint;
|
|
934
888
|
swapAToB: boolean;
|
|
@@ -951,7 +905,6 @@ export interface IncreaseLpPositionQuoteArgs {
|
|
|
951
905
|
sqrtPrice: bigint;
|
|
952
906
|
tickLowerIndex: number;
|
|
953
907
|
tickUpperIndex: number;
|
|
954
|
-
maxAmountSlippage: number;
|
|
955
908
|
liquidationThreshold: number;
|
|
956
909
|
}
|
|
957
910
|
|
|
@@ -960,6 +913,48 @@ export interface LiquidationPrices {
|
|
|
960
913
|
upper: number;
|
|
961
914
|
}
|
|
962
915
|
|
|
916
|
+
export interface SwapInstruction {
|
|
917
|
+
data: number[];
|
|
918
|
+
accounts: AccountMeta[];
|
|
919
|
+
addressLookupTableAddresses: Pubkey[];
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
export interface IncreaseSpotPositionQuoteResult {
|
|
923
|
+
collateral: bigint;
|
|
924
|
+
borrow: bigint;
|
|
925
|
+
estimatedAmount: bigint;
|
|
926
|
+
swapInputAmount: bigint;
|
|
927
|
+
minSwapOutputAmount: bigint;
|
|
928
|
+
protocolFeeA: bigint;
|
|
929
|
+
protocolFeeB: bigint;
|
|
930
|
+
priceImpact: number;
|
|
931
|
+
jupiterSwapIx: SwapInstruction | undefined;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
export interface DecreaseSpotPositionQuoteResult {
|
|
935
|
+
decreasePercent: number;
|
|
936
|
+
requiredSwapAmount: bigint;
|
|
937
|
+
estimatedAmount: bigint;
|
|
938
|
+
estimatedPayableDebt: bigint;
|
|
939
|
+
estimatedCollateralToBeWithdrawn: bigint;
|
|
940
|
+
priceImpact: number;
|
|
941
|
+
jupiterSwapIx: SwapInstruction | undefined;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
export interface TunaSpotPositionFacade {
|
|
945
|
+
version: number;
|
|
946
|
+
marketMaker: number;
|
|
947
|
+
positionToken: number;
|
|
948
|
+
collateralToken: number;
|
|
949
|
+
flags: number;
|
|
950
|
+
amount: bigint;
|
|
951
|
+
loanShares: bigint;
|
|
952
|
+
loanFunds: bigint;
|
|
953
|
+
entrySqrtPrice: bigint;
|
|
954
|
+
lowerLimitOrderSqrtPrice: bigint;
|
|
955
|
+
upperLimitOrderSqrtPrice: bigint;
|
|
956
|
+
}
|
|
957
|
+
|
|
963
958
|
/**
|
|
964
959
|
* A hash; the 32-byte output of a hashing algorithm.
|
|
965
960
|
*
|
|
@@ -1698,14 +1698,84 @@ exports.swapQuoteByOutputToken = function(token_out, specified_token_a, slippage
|
|
|
1698
1698
|
}
|
|
1699
1699
|
};
|
|
1700
1700
|
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1701
|
+
/**
|
|
1702
|
+
* Computes the liquidation prices for an existing position.
|
|
1703
|
+
*
|
|
1704
|
+
* # Parameters
|
|
1705
|
+
* - `tick_lower_index`: The lower tick index of the position.
|
|
1706
|
+
* - `tick_upper_index`: The upper tick index of the position.
|
|
1707
|
+
* - `leftovers_a`: The amount of leftovers A in the position.
|
|
1708
|
+
* - `leftovers_a`: The amount of leftovers B in the position.
|
|
1709
|
+
* - `liquidity`: Liquidity of the position.
|
|
1710
|
+
* - `debt_a`: The amount of tokens A borrowed.
|
|
1711
|
+
* - `debt_b`: The amount of tokens B borrowed.
|
|
1712
|
+
* - `liquidation_threshold`: The liquidation threshold of the market.
|
|
1713
|
+
*
|
|
1714
|
+
* # Returns
|
|
1715
|
+
* - `LiquidationPrices`: An object containing lower/upper liquidation prices.
|
|
1716
|
+
*/
|
|
1717
|
+
exports.getLpPositionLiquidationPrices = function(tick_lower_index, tick_upper_index, liquidity, leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold) {
|
|
1718
|
+
try {
|
|
1719
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1720
|
+
wasm.getLpPositionLiquidationPrices(retptr, tick_lower_index, tick_upper_index, liquidity, liquidity >> BigInt(64), leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold);
|
|
1721
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1722
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1723
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1724
|
+
if (r2) {
|
|
1725
|
+
throw takeObject(r1);
|
|
1726
|
+
}
|
|
1727
|
+
return takeObject(r0);
|
|
1728
|
+
} finally {
|
|
1729
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1730
|
+
}
|
|
1704
1731
|
};
|
|
1705
1732
|
|
|
1706
|
-
exports.
|
|
1707
|
-
|
|
1708
|
-
|
|
1733
|
+
exports.getIncreaseLpPositionQuote = function(args) {
|
|
1734
|
+
try {
|
|
1735
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1736
|
+
wasm.getIncreaseLpPositionQuote(retptr, addHeapObject(args));
|
|
1737
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1738
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1739
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1740
|
+
if (r2) {
|
|
1741
|
+
throw takeObject(r1);
|
|
1742
|
+
}
|
|
1743
|
+
return takeObject(r0);
|
|
1744
|
+
} finally {
|
|
1745
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1746
|
+
}
|
|
1747
|
+
};
|
|
1748
|
+
|
|
1749
|
+
exports.getRepayLpPositionDebtQuote = function(args) {
|
|
1750
|
+
try {
|
|
1751
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1752
|
+
wasm.getRepayLpPositionDebtQuote(retptr, addHeapObject(args));
|
|
1753
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1754
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1755
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1756
|
+
if (r2) {
|
|
1757
|
+
throw takeObject(r1);
|
|
1758
|
+
}
|
|
1759
|
+
return takeObject(r0);
|
|
1760
|
+
} finally {
|
|
1761
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1762
|
+
}
|
|
1763
|
+
};
|
|
1764
|
+
|
|
1765
|
+
exports.computeLeverage = function(total_a, total_b, debt_a, debt_b, sqrt_price) {
|
|
1766
|
+
try {
|
|
1767
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1768
|
+
wasm.computeLeverage(retptr, total_a, total_b, debt_a, debt_b, sqrt_price, sqrt_price >> BigInt(64));
|
|
1769
|
+
var r0 = getDataViewMemory0().getFloat64(retptr + 8 * 0, true);
|
|
1770
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1771
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1772
|
+
if (r3) {
|
|
1773
|
+
throw takeObject(r2);
|
|
1774
|
+
}
|
|
1775
|
+
return r0;
|
|
1776
|
+
} finally {
|
|
1777
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1778
|
+
}
|
|
1709
1779
|
};
|
|
1710
1780
|
|
|
1711
1781
|
/**
|
|
@@ -1865,86 +1935,6 @@ exports.calculateTunaProtocolFee = function(collateral, borrow, protocol_fee_rat
|
|
|
1865
1935
|
return BigInt.asUintN(64, ret);
|
|
1866
1936
|
};
|
|
1867
1937
|
|
|
1868
|
-
/**
|
|
1869
|
-
* Computes the liquidation prices for an existing position.
|
|
1870
|
-
*
|
|
1871
|
-
* # Parameters
|
|
1872
|
-
* - `tick_lower_index`: The lower tick index of the position.
|
|
1873
|
-
* - `tick_upper_index`: The upper tick index of the position.
|
|
1874
|
-
* - `leftovers_a`: The amount of leftovers A in the position.
|
|
1875
|
-
* - `leftovers_a`: The amount of leftovers B in the position.
|
|
1876
|
-
* - `liquidity`: Liquidity of the position.
|
|
1877
|
-
* - `debt_a`: The amount of tokens A borrowed.
|
|
1878
|
-
* - `debt_b`: The amount of tokens B borrowed.
|
|
1879
|
-
* - `liquidation_threshold`: The liquidation threshold of the market.
|
|
1880
|
-
*
|
|
1881
|
-
* # Returns
|
|
1882
|
-
* - `LiquidationPrices`: An object containing lower/upper liquidation prices.
|
|
1883
|
-
*/
|
|
1884
|
-
exports.getLpPositionLiquidationPrices = function(tick_lower_index, tick_upper_index, liquidity, leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold) {
|
|
1885
|
-
try {
|
|
1886
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1887
|
-
wasm.getLpPositionLiquidationPrices(retptr, tick_lower_index, tick_upper_index, liquidity, liquidity >> BigInt(64), leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold);
|
|
1888
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1889
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1890
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1891
|
-
if (r2) {
|
|
1892
|
-
throw takeObject(r1);
|
|
1893
|
-
}
|
|
1894
|
-
return takeObject(r0);
|
|
1895
|
-
} finally {
|
|
1896
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1897
|
-
}
|
|
1898
|
-
};
|
|
1899
|
-
|
|
1900
|
-
exports.getIncreaseLpPositionQuote = function(args) {
|
|
1901
|
-
try {
|
|
1902
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1903
|
-
wasm.getIncreaseLpPositionQuote(retptr, addHeapObject(args));
|
|
1904
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1905
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1906
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1907
|
-
if (r2) {
|
|
1908
|
-
throw takeObject(r1);
|
|
1909
|
-
}
|
|
1910
|
-
return takeObject(r0);
|
|
1911
|
-
} finally {
|
|
1912
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1913
|
-
}
|
|
1914
|
-
};
|
|
1915
|
-
|
|
1916
|
-
exports.getRepayLpPositionDebtQuote = function(args) {
|
|
1917
|
-
try {
|
|
1918
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1919
|
-
wasm.getRepayLpPositionDebtQuote(retptr, addHeapObject(args));
|
|
1920
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1921
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1922
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1923
|
-
if (r2) {
|
|
1924
|
-
throw takeObject(r1);
|
|
1925
|
-
}
|
|
1926
|
-
return takeObject(r0);
|
|
1927
|
-
} finally {
|
|
1928
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1929
|
-
}
|
|
1930
|
-
};
|
|
1931
|
-
|
|
1932
|
-
exports.computeLeverage = function(total_a, total_b, debt_a, debt_b, sqrt_price) {
|
|
1933
|
-
try {
|
|
1934
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1935
|
-
wasm.computeLeverage(retptr, total_a, total_b, debt_a, debt_b, sqrt_price, sqrt_price >> BigInt(64));
|
|
1936
|
-
var r0 = getDataViewMemory0().getFloat64(retptr + 8 * 0, true);
|
|
1937
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1938
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1939
|
-
if (r3) {
|
|
1940
|
-
throw takeObject(r2);
|
|
1941
|
-
}
|
|
1942
|
-
return r0;
|
|
1943
|
-
} finally {
|
|
1944
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1945
|
-
}
|
|
1946
|
-
};
|
|
1947
|
-
|
|
1948
1938
|
exports._INVALID_ARGUMENTS = function() {
|
|
1949
1939
|
try {
|
|
1950
1940
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
@@ -1981,6 +1971,16 @@ exports._JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR = function() {
|
|
|
1981
1971
|
}
|
|
1982
1972
|
};
|
|
1983
1973
|
|
|
1974
|
+
exports._HUNDRED_PERCENT = function() {
|
|
1975
|
+
const ret = wasm._HUNDRED_PERCENT();
|
|
1976
|
+
return ret >>> 0;
|
|
1977
|
+
};
|
|
1978
|
+
|
|
1979
|
+
exports._COMPUTED_AMOUNT = function() {
|
|
1980
|
+
const ret = wasm._COMPUTED_AMOUNT();
|
|
1981
|
+
return BigInt.asUintN(64, ret);
|
|
1982
|
+
};
|
|
1983
|
+
|
|
1984
1984
|
/**
|
|
1985
1985
|
* Initialize Javascript logging and panic handler
|
|
1986
1986
|
*/
|
|
@@ -1988,12 +1988,12 @@ exports.solana_program_init = function() {
|
|
|
1988
1988
|
wasm.solana_program_init();
|
|
1989
1989
|
};
|
|
1990
1990
|
|
|
1991
|
-
function
|
|
1992
|
-
wasm.
|
|
1991
|
+
function __wasm_bindgen_func_elem_3155(arg0, arg1) {
|
|
1992
|
+
wasm.__wasm_bindgen_func_elem_3155(arg0, arg1);
|
|
1993
1993
|
}
|
|
1994
1994
|
|
|
1995
|
-
function
|
|
1996
|
-
wasm.
|
|
1995
|
+
function __wasm_bindgen_func_elem_3254(arg0, arg1, arg2) {
|
|
1996
|
+
wasm.__wasm_bindgen_func_elem_3254(arg0, arg1, addHeapObject(arg2));
|
|
1997
1997
|
}
|
|
1998
1998
|
|
|
1999
1999
|
function __wasm_bindgen_func_elem_494(arg0, arg1, arg2, arg3) {
|
|
@@ -3420,6 +3420,12 @@ exports.__wbg_warn_1d74dddbe2fd1dbb = function(arg0) {
|
|
|
3420
3420
|
console.warn(getObject(arg0));
|
|
3421
3421
|
};
|
|
3422
3422
|
|
|
3423
|
+
exports.__wbindgen_cast_1ce0818a4204304c = function(arg0, arg1) {
|
|
3424
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 361, function: Function { arguments: [Externref], shim_idx: 356, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3425
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3273, __wasm_bindgen_func_elem_3254);
|
|
3426
|
+
return addHeapObject(ret);
|
|
3427
|
+
};
|
|
3428
|
+
|
|
3423
3429
|
exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
3424
3430
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
3425
3431
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
@@ -3434,7 +3440,7 @@ exports.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
|
|
|
3434
3440
|
|
|
3435
3441
|
exports.__wbindgen_cast_7879599246031d81 = function(arg0, arg1) {
|
|
3436
3442
|
// Cast intrinsic for `Closure(Closure { dtor_idx: 343, function: Function { arguments: [], shim_idx: 344, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3437
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
3443
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3151, __wasm_bindgen_func_elem_3155);
|
|
3438
3444
|
return addHeapObject(ret);
|
|
3439
3445
|
};
|
|
3440
3446
|
|
|
@@ -3450,12 +3456,6 @@ exports.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
|
3450
3456
|
return addHeapObject(ret);
|
|
3451
3457
|
};
|
|
3452
3458
|
|
|
3453
|
-
exports.__wbindgen_cast_e346b65485039441 = function(arg0, arg1) {
|
|
3454
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx: 355, function: Function { arguments: [Externref], shim_idx: 366, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3455
|
-
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3232, __wasm_bindgen_func_elem_3259);
|
|
3456
|
-
return addHeapObject(ret);
|
|
3457
|
-
};
|
|
3458
|
-
|
|
3459
3459
|
exports.__wbindgen_cast_e7b45dd881f38ce3 = function(arg0, arg1) {
|
|
3460
3460
|
// Cast intrinsic for `U128 -> Externref`.
|
|
3461
3461
|
const ret = (BigInt.asUintN(64, arg0) | (BigInt.asUintN(64, arg1) << BigInt(64)));
|
|
Binary file
|
|
@@ -5,6 +5,9 @@ export const getLpPositionLiquidationPrices: (a: number, b: number, c: number, d
|
|
|
5
5
|
export const getIncreaseLpPositionQuote: (a: number, b: number) => void;
|
|
6
6
|
export const getRepayLpPositionDebtQuote: (a: number, b: number) => void;
|
|
7
7
|
export const computeLeverage: (a: number, b: bigint, c: bigint, d: bigint, e: bigint, f: bigint, g: bigint) => void;
|
|
8
|
+
export const _INVALID_ARGUMENTS: (a: number) => void;
|
|
9
|
+
export const _JUPITER_QUOTE_REQUEST_ERROR: (a: number) => void;
|
|
10
|
+
export const _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR: (a: number) => void;
|
|
8
11
|
export const _HUNDRED_PERCENT: () => number;
|
|
9
12
|
export const _COMPUTED_AMOUNT: () => bigint;
|
|
10
13
|
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;
|
|
@@ -15,9 +18,6 @@ export const calculateTunaSpotPositionProtocolFee: (a: number, b: number, c: big
|
|
|
15
18
|
export const applyTunaProtocolFee: (a: number, b: bigint, c: number, d: number) => void;
|
|
16
19
|
export const reverseApplyTunaProtocolFee: (a: number, b: bigint, c: number, d: number) => void;
|
|
17
20
|
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;
|
|
21
21
|
export const __wbg_transaction_free: (a: number, b: number) => void;
|
|
22
22
|
export const transaction_constructor: (a: number, b: number) => number;
|
|
23
23
|
export const transaction_message: (a: number) => number;
|
|
@@ -147,10 +147,10 @@ export const limitOrderRewardByOutputToken: (a: number, b: bigint, c: number, d:
|
|
|
147
147
|
export const decreaseLimitOrderQuote: (a: number, b: number, c: number, d: number, e: bigint, f: number, g: number) => void;
|
|
148
148
|
export const collectFeesQuote: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
149
149
|
export const limitOrderFee: (a: number) => number;
|
|
150
|
-
export const
|
|
151
|
-
export const
|
|
152
|
-
export const
|
|
153
|
-
export const
|
|
150
|
+
export const __wasm_bindgen_func_elem_3155: (a: number, b: number) => void;
|
|
151
|
+
export const __wasm_bindgen_func_elem_3151: (a: number, b: number) => void;
|
|
152
|
+
export const __wasm_bindgen_func_elem_3254: (a: number, b: number, c: number) => void;
|
|
153
|
+
export const __wasm_bindgen_func_elem_3273: (a: number, b: number) => void;
|
|
154
154
|
export const __wasm_bindgen_func_elem_494: (a: number, b: number, c: number, d: number) => void;
|
|
155
155
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
156
156
|
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
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
|
+
"version": "3.5.1",
|
|
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.
|
|
26
|
+
"@crypticdot/defituna-rust-core": "3.5.1"
|
|
27
27
|
},
|
|
28
28
|
"license": "SEE LICENSE IN LICENSE",
|
|
29
29
|
"keywords": [
|