@crypticdot/defituna-core 3.5.3 → 3.5.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.
- package/dist/browser/defituna_core_js_bindings.d.ts +37 -37
- package/dist/browser/defituna_core_js_bindings_bg.js +65 -65
- package/dist/browser/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/browser/defituna_core_js_bindings_bg.wasm.d.ts +2 -2
- package/dist/nodejs/defituna_core_js_bindings.d.ts +37 -37
- package/dist/nodejs/defituna_core_js_bindings.js +65 -65
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm.d.ts +2 -2
- package/package.json +3 -3
|
@@ -601,6 +601,26 @@ export function _INVALID_SLIPPAGE_TOLERANCE(): string;
|
|
|
601
601
|
export function _TICK_INDEX_NOT_IN_ARRAY(): string;
|
|
602
602
|
export function _INVALID_TICK_ARRAY_SEQUENCE(): string;
|
|
603
603
|
export function _LIMIT_ORDER_AND_POOL_ARE_OUT_OF_SYNC(): string;
|
|
604
|
+
/**
|
|
605
|
+
* Computes the liquidation prices for an existing position.
|
|
606
|
+
*
|
|
607
|
+
* # Parameters
|
|
608
|
+
* - `tick_lower_index`: The lower tick index of the position.
|
|
609
|
+
* - `tick_upper_index`: The upper tick index of the position.
|
|
610
|
+
* - `leftovers_a`: The amount of leftovers A in the position.
|
|
611
|
+
* - `leftovers_a`: The amount of leftovers B in the position.
|
|
612
|
+
* - `liquidity`: Liquidity of the position.
|
|
613
|
+
* - `debt_a`: The amount of tokens A borrowed.
|
|
614
|
+
* - `debt_b`: The amount of tokens B borrowed.
|
|
615
|
+
* - `liquidation_threshold`: The liquidation threshold of the market.
|
|
616
|
+
*
|
|
617
|
+
* # Returns
|
|
618
|
+
* - `LiquidationPrices`: An object containing lower/upper liquidation prices.
|
|
619
|
+
*/
|
|
620
|
+
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;
|
|
621
|
+
export function getIncreaseLpPositionQuote(args: IncreaseLpPositionQuoteArgs): IncreaseLpPositionQuoteResult;
|
|
622
|
+
export function getRepayLpPositionDebtQuote(args: RepayLpPositionDebtQuoteArgs): RepayLpPositionDebtQuoteResult;
|
|
623
|
+
export function computeLeverage(total_a: bigint, total_b: bigint, debt_a: bigint, debt_b: bigint, sqrt_price: bigint): number;
|
|
604
624
|
/**
|
|
605
625
|
* Computes the exact input or output amount for a swap transaction.
|
|
606
626
|
*
|
|
@@ -633,26 +653,6 @@ export function swapQuoteByInputToken(token_in: bigint, specified_token_a: boole
|
|
|
633
653
|
* The exact input or output amount for the swap transaction.
|
|
634
654
|
*/
|
|
635
655
|
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
|
-
* 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;
|
|
656
656
|
/**
|
|
657
657
|
* Spot position increase quote
|
|
658
658
|
*
|
|
@@ -735,6 +735,23 @@ export function _COMPUTED_AMOUNT(): bigint;
|
|
|
735
735
|
* Initialize Javascript logging and panic handler
|
|
736
736
|
*/
|
|
737
737
|
export function solana_program_init(): void;
|
|
738
|
+
export interface PositionFacade {
|
|
739
|
+
liquidity: bigint;
|
|
740
|
+
tickLowerIndex: number;
|
|
741
|
+
tickUpperIndex: number;
|
|
742
|
+
feeGrowthCheckpointA: bigint;
|
|
743
|
+
feeOwedA: bigint;
|
|
744
|
+
feeGrowthCheckpointB: bigint;
|
|
745
|
+
feeOwedB: bigint;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
export type PositionStatus = "priceInRange" | "priceBelowRange" | "priceAboveRange" | "invalid";
|
|
749
|
+
|
|
750
|
+
export interface PositionRatio {
|
|
751
|
+
ratioA: bigint;
|
|
752
|
+
ratioB: bigint;
|
|
753
|
+
}
|
|
754
|
+
|
|
738
755
|
export interface LimitOrderDecreaseQuote {
|
|
739
756
|
amountOutA: bigint;
|
|
740
757
|
amountOutB: bigint;
|
|
@@ -797,23 +814,6 @@ export interface TokenPair {
|
|
|
797
814
|
b: bigint;
|
|
798
815
|
}
|
|
799
816
|
|
|
800
|
-
export interface PositionFacade {
|
|
801
|
-
liquidity: bigint;
|
|
802
|
-
tickLowerIndex: number;
|
|
803
|
-
tickUpperIndex: number;
|
|
804
|
-
feeGrowthCheckpointA: bigint;
|
|
805
|
-
feeOwedA: bigint;
|
|
806
|
-
feeGrowthCheckpointB: bigint;
|
|
807
|
-
feeOwedB: bigint;
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
export type PositionStatus = "priceInRange" | "priceBelowRange" | "priceAboveRange" | "invalid";
|
|
811
|
-
|
|
812
|
-
export interface PositionRatio {
|
|
813
|
-
ratioA: bigint;
|
|
814
|
-
ratioB: bigint;
|
|
815
|
-
}
|
|
816
|
-
|
|
817
817
|
export interface ExactOutSwapQuote {
|
|
818
818
|
tokenOut: bigint;
|
|
819
819
|
tokenEstIn: bigint;
|
|
@@ -1646,68 +1646,6 @@ export function _LIMIT_ORDER_AND_POOL_ARE_OUT_OF_SYNC() {
|
|
|
1646
1646
|
}
|
|
1647
1647
|
}
|
|
1648
1648
|
|
|
1649
|
-
/**
|
|
1650
|
-
* Computes the exact input or output amount for a swap transaction.
|
|
1651
|
-
*
|
|
1652
|
-
* # Arguments
|
|
1653
|
-
* - `token_in`: The input token amount.
|
|
1654
|
-
* - `specified_token_a`: If `true`, the input token is token A. Otherwise, it is token B.
|
|
1655
|
-
* - `slippage_tolerance`: The slippage tolerance in basis points.
|
|
1656
|
-
* - `fusion_pool`: The fusion_pool state.
|
|
1657
|
-
* - `tick_arrays`: The tick arrays needed for the swap.
|
|
1658
|
-
* - `transfer_fee_a`: The transfer fee for token A.
|
|
1659
|
-
* - `transfer_fee_b`: The transfer fee for token B.
|
|
1660
|
-
*
|
|
1661
|
-
* # Returns
|
|
1662
|
-
* The exact input or output amount for the swap transaction.
|
|
1663
|
-
*/
|
|
1664
|
-
export function swapQuoteByInputToken(token_in, specified_token_a, slippage_tolerance_bps, fusion_pool, tick_arrays, transfer_fee_a, transfer_fee_b) {
|
|
1665
|
-
try {
|
|
1666
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1667
|
-
wasm.swapQuoteByInputToken(retptr, token_in, specified_token_a, slippage_tolerance_bps, addHeapObject(fusion_pool), addHeapObject(tick_arrays), isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
1668
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1669
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1670
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1671
|
-
if (r2) {
|
|
1672
|
-
throw takeObject(r1);
|
|
1673
|
-
}
|
|
1674
|
-
return takeObject(r0);
|
|
1675
|
-
} finally {
|
|
1676
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1677
|
-
}
|
|
1678
|
-
}
|
|
1679
|
-
|
|
1680
|
-
/**
|
|
1681
|
-
* Computes the exact input or output amount for a swap transaction.
|
|
1682
|
-
*
|
|
1683
|
-
* # Arguments
|
|
1684
|
-
* - `token_out`: The output token amount.
|
|
1685
|
-
* - `specified_token_a`: If `true`, the output token is token A. Otherwise, it is token B.
|
|
1686
|
-
* - `slippage_tolerance`: The slippage tolerance in basis points.
|
|
1687
|
-
* - `fusion_pool`: The fusion_pool state.
|
|
1688
|
-
* - `tick_arrays`: The tick arrays needed for the swap.
|
|
1689
|
-
* - `transfer_fee_a`: The transfer fee for token A.
|
|
1690
|
-
* - `transfer_fee_b`: The transfer fee for token B.
|
|
1691
|
-
*
|
|
1692
|
-
* # Returns
|
|
1693
|
-
* The exact input or output amount for the swap transaction.
|
|
1694
|
-
*/
|
|
1695
|
-
export function swapQuoteByOutputToken(token_out, specified_token_a, slippage_tolerance_bps, fusion_pool, tick_arrays, transfer_fee_a, transfer_fee_b) {
|
|
1696
|
-
try {
|
|
1697
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1698
|
-
wasm.swapQuoteByOutputToken(retptr, token_out, specified_token_a, slippage_tolerance_bps, addHeapObject(fusion_pool), addHeapObject(tick_arrays), isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
1699
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1700
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1701
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1702
|
-
if (r2) {
|
|
1703
|
-
throw takeObject(r1);
|
|
1704
|
-
}
|
|
1705
|
-
return takeObject(r0);
|
|
1706
|
-
} finally {
|
|
1707
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1708
|
-
}
|
|
1709
|
-
}
|
|
1710
|
-
|
|
1711
1649
|
/**
|
|
1712
1650
|
* Computes the liquidation prices for an existing position.
|
|
1713
1651
|
*
|
|
@@ -1788,6 +1726,68 @@ export function computeLeverage(total_a, total_b, debt_a, debt_b, sqrt_price) {
|
|
|
1788
1726
|
}
|
|
1789
1727
|
}
|
|
1790
1728
|
|
|
1729
|
+
/**
|
|
1730
|
+
* Computes the exact input or output amount for a swap transaction.
|
|
1731
|
+
*
|
|
1732
|
+
* # Arguments
|
|
1733
|
+
* - `token_in`: The input token amount.
|
|
1734
|
+
* - `specified_token_a`: If `true`, the input token is token A. Otherwise, it is token B.
|
|
1735
|
+
* - `slippage_tolerance`: The slippage tolerance in basis points.
|
|
1736
|
+
* - `fusion_pool`: The fusion_pool state.
|
|
1737
|
+
* - `tick_arrays`: The tick arrays needed for the swap.
|
|
1738
|
+
* - `transfer_fee_a`: The transfer fee for token A.
|
|
1739
|
+
* - `transfer_fee_b`: The transfer fee for token B.
|
|
1740
|
+
*
|
|
1741
|
+
* # Returns
|
|
1742
|
+
* The exact input or output amount for the swap transaction.
|
|
1743
|
+
*/
|
|
1744
|
+
export function swapQuoteByInputToken(token_in, specified_token_a, slippage_tolerance_bps, fusion_pool, tick_arrays, transfer_fee_a, transfer_fee_b) {
|
|
1745
|
+
try {
|
|
1746
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1747
|
+
wasm.swapQuoteByInputToken(retptr, token_in, specified_token_a, slippage_tolerance_bps, addHeapObject(fusion_pool), addHeapObject(tick_arrays), isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
1748
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1749
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1750
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1751
|
+
if (r2) {
|
|
1752
|
+
throw takeObject(r1);
|
|
1753
|
+
}
|
|
1754
|
+
return takeObject(r0);
|
|
1755
|
+
} finally {
|
|
1756
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
/**
|
|
1761
|
+
* Computes the exact input or output amount for a swap transaction.
|
|
1762
|
+
*
|
|
1763
|
+
* # Arguments
|
|
1764
|
+
* - `token_out`: The output token amount.
|
|
1765
|
+
* - `specified_token_a`: If `true`, the output token is token A. Otherwise, it is token B.
|
|
1766
|
+
* - `slippage_tolerance`: The slippage tolerance in basis points.
|
|
1767
|
+
* - `fusion_pool`: The fusion_pool state.
|
|
1768
|
+
* - `tick_arrays`: The tick arrays needed for the swap.
|
|
1769
|
+
* - `transfer_fee_a`: The transfer fee for token A.
|
|
1770
|
+
* - `transfer_fee_b`: The transfer fee for token B.
|
|
1771
|
+
*
|
|
1772
|
+
* # Returns
|
|
1773
|
+
* The exact input or output amount for the swap transaction.
|
|
1774
|
+
*/
|
|
1775
|
+
export function swapQuoteByOutputToken(token_out, specified_token_a, slippage_tolerance_bps, fusion_pool, tick_arrays, transfer_fee_a, transfer_fee_b) {
|
|
1776
|
+
try {
|
|
1777
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1778
|
+
wasm.swapQuoteByOutputToken(retptr, token_out, specified_token_a, slippage_tolerance_bps, addHeapObject(fusion_pool), addHeapObject(tick_arrays), isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
1779
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1780
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1781
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1782
|
+
if (r2) {
|
|
1783
|
+
throw takeObject(r1);
|
|
1784
|
+
}
|
|
1785
|
+
return takeObject(r0);
|
|
1786
|
+
} finally {
|
|
1787
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
1791
|
/**
|
|
1792
1792
|
* Spot position increase quote
|
|
1793
1793
|
*
|
|
@@ -1998,8 +1998,8 @@ 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_3236(arg0, arg1, arg2) {
|
|
2002
|
+
wasm.__wasm_bindgen_func_elem_3236(arg0, arg1, addHeapObject(arg2));
|
|
2003
2003
|
}
|
|
2004
2004
|
|
|
2005
2005
|
function __wasm_bindgen_func_elem_3155(arg0, arg1) {
|
|
@@ -3416,7 +3416,7 @@ export function __wbg_warn_1d74dddbe2fd1dbb(arg0) {
|
|
|
3416
3416
|
|
|
3417
3417
|
export function __wbindgen_cast_1ce0818a4204304c(arg0, arg1) {
|
|
3418
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.
|
|
3419
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3255, __wasm_bindgen_func_elem_3236);
|
|
3420
3420
|
return addHeapObject(ret);
|
|
3421
3421
|
};
|
|
3422
3422
|
|
|
Binary file
|
|
@@ -147,8 +147,8 @@ 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
|
|
150
|
+
export const __wasm_bindgen_func_elem_3236: (a: number, b: number, c: number) => void;
|
|
151
|
+
export const __wasm_bindgen_func_elem_3255: (a: number, b: number) => void;
|
|
152
152
|
export const __wasm_bindgen_func_elem_3155: (a: number, b: number) => void;
|
|
153
153
|
export const __wasm_bindgen_func_elem_3151: (a: number, b: number) => void;
|
|
154
154
|
export const __wasm_bindgen_func_elem_494: (a: number, b: number, c: number, d: number) => void;
|
|
@@ -601,6 +601,26 @@ export function _INVALID_SLIPPAGE_TOLERANCE(): string;
|
|
|
601
601
|
export function _TICK_INDEX_NOT_IN_ARRAY(): string;
|
|
602
602
|
export function _INVALID_TICK_ARRAY_SEQUENCE(): string;
|
|
603
603
|
export function _LIMIT_ORDER_AND_POOL_ARE_OUT_OF_SYNC(): string;
|
|
604
|
+
/**
|
|
605
|
+
* Computes the liquidation prices for an existing position.
|
|
606
|
+
*
|
|
607
|
+
* # Parameters
|
|
608
|
+
* - `tick_lower_index`: The lower tick index of the position.
|
|
609
|
+
* - `tick_upper_index`: The upper tick index of the position.
|
|
610
|
+
* - `leftovers_a`: The amount of leftovers A in the position.
|
|
611
|
+
* - `leftovers_a`: The amount of leftovers B in the position.
|
|
612
|
+
* - `liquidity`: Liquidity of the position.
|
|
613
|
+
* - `debt_a`: The amount of tokens A borrowed.
|
|
614
|
+
* - `debt_b`: The amount of tokens B borrowed.
|
|
615
|
+
* - `liquidation_threshold`: The liquidation threshold of the market.
|
|
616
|
+
*
|
|
617
|
+
* # Returns
|
|
618
|
+
* - `LiquidationPrices`: An object containing lower/upper liquidation prices.
|
|
619
|
+
*/
|
|
620
|
+
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;
|
|
621
|
+
export function getIncreaseLpPositionQuote(args: IncreaseLpPositionQuoteArgs): IncreaseLpPositionQuoteResult;
|
|
622
|
+
export function getRepayLpPositionDebtQuote(args: RepayLpPositionDebtQuoteArgs): RepayLpPositionDebtQuoteResult;
|
|
623
|
+
export function computeLeverage(total_a: bigint, total_b: bigint, debt_a: bigint, debt_b: bigint, sqrt_price: bigint): number;
|
|
604
624
|
/**
|
|
605
625
|
* Computes the exact input or output amount for a swap transaction.
|
|
606
626
|
*
|
|
@@ -633,26 +653,6 @@ export function swapQuoteByInputToken(token_in: bigint, specified_token_a: boole
|
|
|
633
653
|
* The exact input or output amount for the swap transaction.
|
|
634
654
|
*/
|
|
635
655
|
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
|
-
* 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;
|
|
656
656
|
/**
|
|
657
657
|
* Spot position increase quote
|
|
658
658
|
*
|
|
@@ -735,6 +735,23 @@ export function _COMPUTED_AMOUNT(): bigint;
|
|
|
735
735
|
* Initialize Javascript logging and panic handler
|
|
736
736
|
*/
|
|
737
737
|
export function solana_program_init(): void;
|
|
738
|
+
export interface PositionFacade {
|
|
739
|
+
liquidity: bigint;
|
|
740
|
+
tickLowerIndex: number;
|
|
741
|
+
tickUpperIndex: number;
|
|
742
|
+
feeGrowthCheckpointA: bigint;
|
|
743
|
+
feeOwedA: bigint;
|
|
744
|
+
feeGrowthCheckpointB: bigint;
|
|
745
|
+
feeOwedB: bigint;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
export type PositionStatus = "priceInRange" | "priceBelowRange" | "priceAboveRange" | "invalid";
|
|
749
|
+
|
|
750
|
+
export interface PositionRatio {
|
|
751
|
+
ratioA: bigint;
|
|
752
|
+
ratioB: bigint;
|
|
753
|
+
}
|
|
754
|
+
|
|
738
755
|
export interface LimitOrderDecreaseQuote {
|
|
739
756
|
amountOutA: bigint;
|
|
740
757
|
amountOutB: bigint;
|
|
@@ -797,23 +814,6 @@ export interface TokenPair {
|
|
|
797
814
|
b: bigint;
|
|
798
815
|
}
|
|
799
816
|
|
|
800
|
-
export interface PositionFacade {
|
|
801
|
-
liquidity: bigint;
|
|
802
|
-
tickLowerIndex: number;
|
|
803
|
-
tickUpperIndex: number;
|
|
804
|
-
feeGrowthCheckpointA: bigint;
|
|
805
|
-
feeOwedA: bigint;
|
|
806
|
-
feeGrowthCheckpointB: bigint;
|
|
807
|
-
feeOwedB: bigint;
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
export type PositionStatus = "priceInRange" | "priceBelowRange" | "priceAboveRange" | "invalid";
|
|
811
|
-
|
|
812
|
-
export interface PositionRatio {
|
|
813
|
-
ratioA: bigint;
|
|
814
|
-
ratioB: bigint;
|
|
815
|
-
}
|
|
816
|
-
|
|
817
817
|
export interface ExactOutSwapQuote {
|
|
818
818
|
tokenOut: bigint;
|
|
819
819
|
tokenEstIn: bigint;
|
|
@@ -1636,68 +1636,6 @@ exports._LIMIT_ORDER_AND_POOL_ARE_OUT_OF_SYNC = function() {
|
|
|
1636
1636
|
}
|
|
1637
1637
|
};
|
|
1638
1638
|
|
|
1639
|
-
/**
|
|
1640
|
-
* Computes the exact input or output amount for a swap transaction.
|
|
1641
|
-
*
|
|
1642
|
-
* # Arguments
|
|
1643
|
-
* - `token_in`: The input token amount.
|
|
1644
|
-
* - `specified_token_a`: If `true`, the input token is token A. Otherwise, it is token B.
|
|
1645
|
-
* - `slippage_tolerance`: The slippage tolerance in basis points.
|
|
1646
|
-
* - `fusion_pool`: The fusion_pool state.
|
|
1647
|
-
* - `tick_arrays`: The tick arrays needed for the swap.
|
|
1648
|
-
* - `transfer_fee_a`: The transfer fee for token A.
|
|
1649
|
-
* - `transfer_fee_b`: The transfer fee for token B.
|
|
1650
|
-
*
|
|
1651
|
-
* # Returns
|
|
1652
|
-
* The exact input or output amount for the swap transaction.
|
|
1653
|
-
*/
|
|
1654
|
-
exports.swapQuoteByInputToken = function(token_in, specified_token_a, slippage_tolerance_bps, fusion_pool, tick_arrays, transfer_fee_a, transfer_fee_b) {
|
|
1655
|
-
try {
|
|
1656
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1657
|
-
wasm.swapQuoteByInputToken(retptr, token_in, specified_token_a, slippage_tolerance_bps, addHeapObject(fusion_pool), addHeapObject(tick_arrays), isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
1658
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1659
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1660
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1661
|
-
if (r2) {
|
|
1662
|
-
throw takeObject(r1);
|
|
1663
|
-
}
|
|
1664
|
-
return takeObject(r0);
|
|
1665
|
-
} finally {
|
|
1666
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1667
|
-
}
|
|
1668
|
-
};
|
|
1669
|
-
|
|
1670
|
-
/**
|
|
1671
|
-
* Computes the exact input or output amount for a swap transaction.
|
|
1672
|
-
*
|
|
1673
|
-
* # Arguments
|
|
1674
|
-
* - `token_out`: The output token amount.
|
|
1675
|
-
* - `specified_token_a`: If `true`, the output token is token A. Otherwise, it is token B.
|
|
1676
|
-
* - `slippage_tolerance`: The slippage tolerance in basis points.
|
|
1677
|
-
* - `fusion_pool`: The fusion_pool state.
|
|
1678
|
-
* - `tick_arrays`: The tick arrays needed for the swap.
|
|
1679
|
-
* - `transfer_fee_a`: The transfer fee for token A.
|
|
1680
|
-
* - `transfer_fee_b`: The transfer fee for token B.
|
|
1681
|
-
*
|
|
1682
|
-
* # Returns
|
|
1683
|
-
* The exact input or output amount for the swap transaction.
|
|
1684
|
-
*/
|
|
1685
|
-
exports.swapQuoteByOutputToken = function(token_out, specified_token_a, slippage_tolerance_bps, fusion_pool, tick_arrays, transfer_fee_a, transfer_fee_b) {
|
|
1686
|
-
try {
|
|
1687
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1688
|
-
wasm.swapQuoteByOutputToken(retptr, token_out, specified_token_a, slippage_tolerance_bps, addHeapObject(fusion_pool), addHeapObject(tick_arrays), isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
1689
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1690
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1691
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1692
|
-
if (r2) {
|
|
1693
|
-
throw takeObject(r1);
|
|
1694
|
-
}
|
|
1695
|
-
return takeObject(r0);
|
|
1696
|
-
} finally {
|
|
1697
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1698
|
-
}
|
|
1699
|
-
};
|
|
1700
|
-
|
|
1701
1639
|
/**
|
|
1702
1640
|
* Computes the liquidation prices for an existing position.
|
|
1703
1641
|
*
|
|
@@ -1778,6 +1716,68 @@ exports.computeLeverage = function(total_a, total_b, debt_a, debt_b, sqrt_price)
|
|
|
1778
1716
|
}
|
|
1779
1717
|
};
|
|
1780
1718
|
|
|
1719
|
+
/**
|
|
1720
|
+
* Computes the exact input or output amount for a swap transaction.
|
|
1721
|
+
*
|
|
1722
|
+
* # Arguments
|
|
1723
|
+
* - `token_in`: The input token amount.
|
|
1724
|
+
* - `specified_token_a`: If `true`, the input token is token A. Otherwise, it is token B.
|
|
1725
|
+
* - `slippage_tolerance`: The slippage tolerance in basis points.
|
|
1726
|
+
* - `fusion_pool`: The fusion_pool state.
|
|
1727
|
+
* - `tick_arrays`: The tick arrays needed for the swap.
|
|
1728
|
+
* - `transfer_fee_a`: The transfer fee for token A.
|
|
1729
|
+
* - `transfer_fee_b`: The transfer fee for token B.
|
|
1730
|
+
*
|
|
1731
|
+
* # Returns
|
|
1732
|
+
* The exact input or output amount for the swap transaction.
|
|
1733
|
+
*/
|
|
1734
|
+
exports.swapQuoteByInputToken = function(token_in, specified_token_a, slippage_tolerance_bps, fusion_pool, tick_arrays, transfer_fee_a, transfer_fee_b) {
|
|
1735
|
+
try {
|
|
1736
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1737
|
+
wasm.swapQuoteByInputToken(retptr, token_in, specified_token_a, slippage_tolerance_bps, addHeapObject(fusion_pool), addHeapObject(tick_arrays), isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
1738
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1739
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1740
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1741
|
+
if (r2) {
|
|
1742
|
+
throw takeObject(r1);
|
|
1743
|
+
}
|
|
1744
|
+
return takeObject(r0);
|
|
1745
|
+
} finally {
|
|
1746
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1747
|
+
}
|
|
1748
|
+
};
|
|
1749
|
+
|
|
1750
|
+
/**
|
|
1751
|
+
* Computes the exact input or output amount for a swap transaction.
|
|
1752
|
+
*
|
|
1753
|
+
* # Arguments
|
|
1754
|
+
* - `token_out`: The output token amount.
|
|
1755
|
+
* - `specified_token_a`: If `true`, the output token is token A. Otherwise, it is token B.
|
|
1756
|
+
* - `slippage_tolerance`: The slippage tolerance in basis points.
|
|
1757
|
+
* - `fusion_pool`: The fusion_pool state.
|
|
1758
|
+
* - `tick_arrays`: The tick arrays needed for the swap.
|
|
1759
|
+
* - `transfer_fee_a`: The transfer fee for token A.
|
|
1760
|
+
* - `transfer_fee_b`: The transfer fee for token B.
|
|
1761
|
+
*
|
|
1762
|
+
* # Returns
|
|
1763
|
+
* The exact input or output amount for the swap transaction.
|
|
1764
|
+
*/
|
|
1765
|
+
exports.swapQuoteByOutputToken = function(token_out, specified_token_a, slippage_tolerance_bps, fusion_pool, tick_arrays, transfer_fee_a, transfer_fee_b) {
|
|
1766
|
+
try {
|
|
1767
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1768
|
+
wasm.swapQuoteByOutputToken(retptr, token_out, specified_token_a, slippage_tolerance_bps, addHeapObject(fusion_pool), addHeapObject(tick_arrays), isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
1769
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1770
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1771
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1772
|
+
if (r2) {
|
|
1773
|
+
throw takeObject(r1);
|
|
1774
|
+
}
|
|
1775
|
+
return takeObject(r0);
|
|
1776
|
+
} finally {
|
|
1777
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1778
|
+
}
|
|
1779
|
+
};
|
|
1780
|
+
|
|
1781
1781
|
/**
|
|
1782
1782
|
* Spot position increase quote
|
|
1783
1783
|
*
|
|
@@ -1988,8 +1988,8 @@ 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_3236(arg0, arg1, arg2) {
|
|
1992
|
+
wasm.__wasm_bindgen_func_elem_3236(arg0, arg1, addHeapObject(arg2));
|
|
1993
1993
|
}
|
|
1994
1994
|
|
|
1995
1995
|
function __wasm_bindgen_func_elem_3155(arg0, arg1) {
|
|
@@ -3422,7 +3422,7 @@ exports.__wbg_warn_1d74dddbe2fd1dbb = function(arg0) {
|
|
|
3422
3422
|
|
|
3423
3423
|
exports.__wbindgen_cast_1ce0818a4204304c = function(arg0, arg1) {
|
|
3424
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.
|
|
3425
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3255, __wasm_bindgen_func_elem_3236);
|
|
3426
3426
|
return addHeapObject(ret);
|
|
3427
3427
|
};
|
|
3428
3428
|
|
|
Binary file
|
|
@@ -147,8 +147,8 @@ 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
|
|
150
|
+
export const __wasm_bindgen_func_elem_3236: (a: number, b: number, c: number) => void;
|
|
151
|
+
export const __wasm_bindgen_func_elem_3255: (a: number, b: number) => void;
|
|
152
152
|
export const __wasm_bindgen_func_elem_3155: (a: number, b: number) => void;
|
|
153
153
|
export const __wasm_bindgen_func_elem_3151: (a: number, b: number) => void;
|
|
154
154
|
export const __wasm_bindgen_func_elem_494: (a: number, b: number, c: number, d: number) => void;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crypticdot/defituna-core",
|
|
3
3
|
"description": "DefiTuna core typescript package.",
|
|
4
|
-
"version": "3.5.
|
|
4
|
+
"version": "3.5.5",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "./dist/nodejs/defituna_core_js_bindings.js",
|
|
6
7
|
"types": "./dist/nodejs/defituna_core_js_bindings.d.ts",
|
|
7
8
|
"browser": "./dist/browser/defituna_core_js_bindings.js",
|
|
8
|
-
"type": "module",
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
@@ -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.5.
|
|
26
|
+
"@crypticdot/defituna-rust-core": "3.5.5"
|
|
27
27
|
},
|
|
28
28
|
"license": "SEE LICENSE IN LICENSE",
|
|
29
29
|
"keywords": [
|