@crypticdot/defituna-core 3.3.0 → 3.3.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 +18 -32
- package/dist/browser/defituna_core_js_bindings_bg.js +18 -36
- package/dist/browser/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/browser/defituna_core_js_bindings_bg.wasm.d.ts +6 -7
- package/dist/nodejs/defituna_core_js_bindings.d.ts +18 -32
- package/dist/nodejs/defituna_core_js_bindings.js +18 -36
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm.d.ts +6 -7
- package/package.json +2 -2
|
@@ -658,20 +658,17 @@ export function getIncreaseSpotPositionQuote(increase_amount: bigint, collateral
|
|
|
658
658
|
* - `decrease_amount`: Position total decrease size in the collateral_token.
|
|
659
659
|
* - `collateral_token`: Collateral token.
|
|
660
660
|
* - `leverage`: Leverage (1.0 or higher).
|
|
661
|
-
* - `reduce_only`: Only allow reducing the existing position.
|
|
662
661
|
* - `slippage_tolerance_bps`: An optional slippage tolerance in basis points. Defaults to the global slippage tolerance if not provided.
|
|
663
662
|
* - `position_token`: Token of the existing position.
|
|
664
663
|
* - `position_amount`: Existing position amount in the position_token.
|
|
665
664
|
* - `position_debt`: Existing position debt in the token opposite to the position_token.
|
|
666
|
-
* - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
667
|
-
* - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
668
665
|
* - `fusion_pool`: Fusion pool.
|
|
669
666
|
* - `tick_arrays`: Optional five tick arrays around the current pool price. If not provided, the quote will be calculated using the Jupiter Aggregator.
|
|
670
667
|
*
|
|
671
668
|
* # Returns
|
|
672
669
|
* - `DecreaseSpotPositionQuoteResult`: quote result
|
|
673
670
|
*/
|
|
674
|
-
export function getDecreaseSpotPositionQuote(decrease_amount: bigint, collateral_token: number, leverage: number,
|
|
671
|
+
export function getDecreaseSpotPositionQuote(decrease_amount: bigint, collateral_token: number, leverage: number, slippage_tolerance_bps: number | null | undefined, position_token: number, position_amount: bigint, position_debt: bigint, mint_a: Pubkey, mint_b: Pubkey, fusion_pool: FusionPoolFacade, tick_arrays?: TickArrayFacade[] | null): Promise<any>;
|
|
675
672
|
/**
|
|
676
673
|
* Returns the liquidation price
|
|
677
674
|
*
|
|
@@ -692,23 +689,19 @@ export function getLiquidationPrice(position_token: number, amount: number, debt
|
|
|
692
689
|
* - `collateral_token`: Collateral token.
|
|
693
690
|
* - `available_balance`: Available wallet balance in the collateral_token.
|
|
694
691
|
* - `leverage`: Leverage (1.0 or higher).
|
|
695
|
-
* - `new_position_token`: Token of the new position.
|
|
696
692
|
* - `position_token`: Token of the existing position. Should be set to new_position_token if position_amount is zero.
|
|
697
693
|
* - `position_amount`: Existing position amount in the position_token.
|
|
698
|
-
* - `position_debt`: Existing position debt in the token opposite to the position_token.
|
|
699
|
-
* - `reduce_only`: Only allow reducing the existing position.///
|
|
700
694
|
* - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
701
695
|
* - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
702
696
|
* - `fusion_pool`: Fusion pool.
|
|
703
|
-
* - `
|
|
697
|
+
* - `increase`: true if increasing the position
|
|
704
698
|
*
|
|
705
699
|
* # Returns
|
|
706
700
|
* - `u64`: the maximum tradable amount
|
|
707
701
|
*/
|
|
708
|
-
export function getTradableAmount(collateral_token: number, available_balance: bigint, leverage: number,
|
|
702
|
+
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;
|
|
709
703
|
export function calculateTunaProtocolFee(collateral_token: number, borrowed_token: number, collateral: bigint, borrow: bigint, protocol_fee_rate_on_collateral: number, protocol_fee_rate: number): TokenPair;
|
|
710
704
|
export function _INVALID_ARGUMENTS(): string;
|
|
711
|
-
export function _TICK_ARRAYS_NOT_PROVIDED(): string;
|
|
712
705
|
export function _JUPITER_QUOTE_REQUEST_ERROR(): string;
|
|
713
706
|
export function _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR(): string;
|
|
714
707
|
/**
|
|
@@ -834,20 +827,6 @@ export interface PositionRatio {
|
|
|
834
827
|
ratioB: bigint;
|
|
835
828
|
}
|
|
836
829
|
|
|
837
|
-
export interface TunaSpotPositionFacade {
|
|
838
|
-
version: number;
|
|
839
|
-
marketMaker: number;
|
|
840
|
-
positionToken: number;
|
|
841
|
-
collateralToken: number;
|
|
842
|
-
flags: number;
|
|
843
|
-
amount: bigint;
|
|
844
|
-
loanShares: bigint;
|
|
845
|
-
loanFunds: bigint;
|
|
846
|
-
entrySqrtPrice: bigint;
|
|
847
|
-
lowerLimitOrderSqrtPrice: bigint;
|
|
848
|
-
upperLimitOrderSqrtPrice: bigint;
|
|
849
|
-
}
|
|
850
|
-
|
|
851
830
|
export interface SwapInstruction {
|
|
852
831
|
data: number[];
|
|
853
832
|
accounts: AccountMeta[];
|
|
@@ -868,19 +847,26 @@ export interface IncreaseSpotPositionQuoteResult {
|
|
|
868
847
|
|
|
869
848
|
export interface DecreaseSpotPositionQuoteResult {
|
|
870
849
|
decreasePercent: number;
|
|
871
|
-
|
|
872
|
-
positionToken: number;
|
|
873
|
-
collateral: bigint;
|
|
874
|
-
borrow: bigint;
|
|
875
|
-
decreaseAcceptableSwapAmount: bigint;
|
|
876
|
-
increaseMinSwapOutputAmount: bigint;
|
|
850
|
+
requiredSwapAmount: bigint;
|
|
877
851
|
estimatedAmount: bigint;
|
|
878
|
-
protocolFeeA: bigint;
|
|
879
|
-
protocolFeeB: bigint;
|
|
880
852
|
priceImpact: number;
|
|
881
853
|
jupiterSwapIx: SwapInstruction | undefined;
|
|
882
854
|
}
|
|
883
855
|
|
|
856
|
+
export interface TunaSpotPositionFacade {
|
|
857
|
+
version: number;
|
|
858
|
+
marketMaker: number;
|
|
859
|
+
positionToken: number;
|
|
860
|
+
collateralToken: number;
|
|
861
|
+
flags: number;
|
|
862
|
+
amount: bigint;
|
|
863
|
+
loanShares: bigint;
|
|
864
|
+
loanFunds: bigint;
|
|
865
|
+
entrySqrtPrice: bigint;
|
|
866
|
+
lowerLimitOrderSqrtPrice: bigint;
|
|
867
|
+
upperLimitOrderSqrtPrice: bigint;
|
|
868
|
+
}
|
|
869
|
+
|
|
884
870
|
/**
|
|
885
871
|
* A hash; the 32-byte output of a hashing algorithm.
|
|
886
872
|
*
|
|
@@ -1690,25 +1690,22 @@ export function getIncreaseSpotPositionQuote(increase_amount, collateral_token,
|
|
|
1690
1690
|
* - `decrease_amount`: Position total decrease size in the collateral_token.
|
|
1691
1691
|
* - `collateral_token`: Collateral token.
|
|
1692
1692
|
* - `leverage`: Leverage (1.0 or higher).
|
|
1693
|
-
* - `reduce_only`: Only allow reducing the existing position.
|
|
1694
1693
|
* - `slippage_tolerance_bps`: An optional slippage tolerance in basis points. Defaults to the global slippage tolerance if not provided.
|
|
1695
1694
|
* - `position_token`: Token of the existing position.
|
|
1696
1695
|
* - `position_amount`: Existing position amount in the position_token.
|
|
1697
1696
|
* - `position_debt`: Existing position debt in the token opposite to the position_token.
|
|
1698
|
-
* - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1699
|
-
* - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1700
1697
|
* - `fusion_pool`: Fusion pool.
|
|
1701
1698
|
* - `tick_arrays`: Optional five tick arrays around the current pool price. If not provided, the quote will be calculated using the Jupiter Aggregator.
|
|
1702
1699
|
*
|
|
1703
1700
|
* # Returns
|
|
1704
1701
|
* - `DecreaseSpotPositionQuoteResult`: quote result
|
|
1705
1702
|
*/
|
|
1706
|
-
export function getDecreaseSpotPositionQuote(decrease_amount, collateral_token, leverage,
|
|
1703
|
+
export function getDecreaseSpotPositionQuote(decrease_amount, collateral_token, leverage, slippage_tolerance_bps, position_token, position_amount, position_debt, mint_a, mint_b, fusion_pool, tick_arrays) {
|
|
1707
1704
|
_assertClass(mint_a, Pubkey);
|
|
1708
1705
|
var ptr0 = mint_a.__destroy_into_raw();
|
|
1709
1706
|
_assertClass(mint_b, Pubkey);
|
|
1710
1707
|
var ptr1 = mint_b.__destroy_into_raw();
|
|
1711
|
-
const ret = wasm.getDecreaseSpotPositionQuote(decrease_amount, collateral_token, leverage,
|
|
1708
|
+
const ret = wasm.getDecreaseSpotPositionQuote(decrease_amount, collateral_token, leverage, isLikeNone(slippage_tolerance_bps) ? 0xFFFFFF : slippage_tolerance_bps, position_token, position_amount, position_debt, ptr0, ptr1, addHeapObject(fusion_pool), isLikeNone(tick_arrays) ? 0 : addHeapObject(tick_arrays));
|
|
1712
1709
|
return takeObject(ret);
|
|
1713
1710
|
}
|
|
1714
1711
|
|
|
@@ -1747,23 +1744,20 @@ export function getLiquidationPrice(position_token, amount, debt, liquidation_th
|
|
|
1747
1744
|
* - `collateral_token`: Collateral token.
|
|
1748
1745
|
* - `available_balance`: Available wallet balance in the collateral_token.
|
|
1749
1746
|
* - `leverage`: Leverage (1.0 or higher).
|
|
1750
|
-
* - `new_position_token`: Token of the new position.
|
|
1751
1747
|
* - `position_token`: Token of the existing position. Should be set to new_position_token if position_amount is zero.
|
|
1752
1748
|
* - `position_amount`: Existing position amount in the position_token.
|
|
1753
|
-
* - `position_debt`: Existing position debt in the token opposite to the position_token.
|
|
1754
|
-
* - `reduce_only`: Only allow reducing the existing position.///
|
|
1755
1749
|
* - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1756
1750
|
* - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1757
1751
|
* - `fusion_pool`: Fusion pool.
|
|
1758
|
-
* - `
|
|
1752
|
+
* - `increase`: true if increasing the position
|
|
1759
1753
|
*
|
|
1760
1754
|
* # Returns
|
|
1761
1755
|
* - `u64`: the maximum tradable amount
|
|
1762
1756
|
*/
|
|
1763
|
-
export function getTradableAmount(collateral_token, available_balance, leverage,
|
|
1757
|
+
export function getTradableAmount(collateral_token, available_balance, leverage, position_token, position_amount, protocol_fee_rate, protocol_fee_rate_on_collateral, fusion_pool, increase) {
|
|
1764
1758
|
try {
|
|
1765
1759
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1766
|
-
wasm.getTradableAmount(retptr, collateral_token, available_balance, leverage,
|
|
1760
|
+
wasm.getTradableAmount(retptr, collateral_token, available_balance, leverage, position_token, position_amount, protocol_fee_rate, protocol_fee_rate_on_collateral, addHeapObject(fusion_pool), increase);
|
|
1767
1761
|
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1768
1762
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1769
1763
|
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
@@ -1793,18 +1787,6 @@ export function _INVALID_ARGUMENTS() {
|
|
|
1793
1787
|
}
|
|
1794
1788
|
}
|
|
1795
1789
|
|
|
1796
|
-
export function _TICK_ARRAYS_NOT_PROVIDED() {
|
|
1797
|
-
try {
|
|
1798
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1799
|
-
wasm._TICK_ARRAYS_NOT_PROVIDED(retptr);
|
|
1800
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1801
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1802
|
-
return getStringFromWasm0(r0, r1);
|
|
1803
|
-
} finally {
|
|
1804
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
|
|
1808
1790
|
export function _JUPITER_QUOTE_REQUEST_ERROR() {
|
|
1809
1791
|
try {
|
|
1810
1792
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
@@ -1836,12 +1818,12 @@ export function solana_program_init() {
|
|
|
1836
1818
|
wasm.solana_program_init();
|
|
1837
1819
|
}
|
|
1838
1820
|
|
|
1839
|
-
function
|
|
1840
|
-
wasm.
|
|
1821
|
+
function __wasm_bindgen_func_elem_3203(arg0, arg1, arg2) {
|
|
1822
|
+
wasm.__wasm_bindgen_func_elem_3203(arg0, arg1, addHeapObject(arg2));
|
|
1841
1823
|
}
|
|
1842
1824
|
|
|
1843
|
-
function
|
|
1844
|
-
wasm.
|
|
1825
|
+
function __wasm_bindgen_func_elem_3097(arg0, arg1) {
|
|
1826
|
+
wasm.__wasm_bindgen_func_elem_3097(arg0, arg1);
|
|
1845
1827
|
}
|
|
1846
1828
|
|
|
1847
1829
|
function __wasm_bindgen_func_elem_480(arg0, arg1, arg2, arg3) {
|
|
@@ -3252,12 +3234,6 @@ export function __wbg_warn_1d74dddbe2fd1dbb(arg0) {
|
|
|
3252
3234
|
console.warn(getObject(arg0));
|
|
3253
3235
|
};
|
|
3254
3236
|
|
|
3255
|
-
export function __wbindgen_cast_2116c94cd3735b0a(arg0, arg1) {
|
|
3256
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx: 338, function: Function { arguments: [], shim_idx: 339, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3257
|
-
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3116, __wasm_bindgen_func_elem_3120);
|
|
3258
|
-
return addHeapObject(ret);
|
|
3259
|
-
};
|
|
3260
|
-
|
|
3261
3237
|
export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
|
|
3262
3238
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
3263
3239
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
@@ -3270,15 +3246,21 @@ export function __wbindgen_cast_4625c577ab2ec9ee(arg0) {
|
|
|
3270
3246
|
return addHeapObject(ret);
|
|
3271
3247
|
};
|
|
3272
3248
|
|
|
3249
|
+
export function __wbindgen_cast_7f6d2ab049d5d8fd(arg0, arg1) {
|
|
3250
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 334, function: Function { arguments: [], shim_idx: 335, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3251
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3093, __wasm_bindgen_func_elem_3097);
|
|
3252
|
+
return addHeapObject(ret);
|
|
3253
|
+
};
|
|
3254
|
+
|
|
3273
3255
|
export function __wbindgen_cast_9ae0607507abb057(arg0) {
|
|
3274
3256
|
// Cast intrinsic for `I64 -> Externref`.
|
|
3275
3257
|
const ret = arg0;
|
|
3276
3258
|
return addHeapObject(ret);
|
|
3277
3259
|
};
|
|
3278
3260
|
|
|
3279
|
-
export function
|
|
3280
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
3281
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
3261
|
+
export function __wbindgen_cast_b2b7ff753c8c06bb(arg0, arg1) {
|
|
3262
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 366, function: Function { arguments: [Externref], shim_idx: 361, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3263
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3222, __wasm_bindgen_func_elem_3203);
|
|
3282
3264
|
return addHeapObject(ret);
|
|
3283
3265
|
};
|
|
3284
3266
|
|
|
Binary file
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
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;
|
|
5
|
-
export const getDecreaseSpotPositionQuote: (a: bigint, b: number, c: number, d: number, e: number, f:
|
|
5
|
+
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;
|
|
6
6
|
export const getLiquidationPrice: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
7
|
-
export const getTradableAmount: (a: number, b: number, c: bigint, d: number, e: number, f:
|
|
7
|
+
export const getTradableAmount: (a: number, b: number, c: bigint, d: number, e: number, f: bigint, g: number, h: number, i: number, j: number) => void;
|
|
8
8
|
export const calculateTunaProtocolFee: (a: number, b: number, c: bigint, d: bigint, e: number, f: number) => number;
|
|
9
9
|
export const _INVALID_ARGUMENTS: (a: number) => void;
|
|
10
|
-
export const _TICK_ARRAYS_NOT_PROVIDED: (a: number) => void;
|
|
11
10
|
export const _JUPITER_QUOTE_REQUEST_ERROR: (a: number) => void;
|
|
12
11
|
export const _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR: (a: number) => void;
|
|
13
12
|
export const __wbg_transaction_free: (a: number, b: number) => void;
|
|
@@ -137,10 +136,10 @@ export const limitOrderQuoteByInputToken: (a: number, b: bigint, c: number, d: n
|
|
|
137
136
|
export const limitOrderQuoteByOutputToken: (a: number, b: bigint, c: number, d: number, e: number) => void;
|
|
138
137
|
export const limitOrderRewardByOutputToken: (a: number, b: bigint, c: number, d: number) => void;
|
|
139
138
|
export const decreaseLimitOrderQuote: (a: number, b: number, c: number, d: number, e: bigint, f: number, g: number) => void;
|
|
140
|
-
export const
|
|
141
|
-
export const
|
|
142
|
-
export const
|
|
143
|
-
export const
|
|
139
|
+
export const __wasm_bindgen_func_elem_3203: (a: number, b: number, c: number) => void;
|
|
140
|
+
export const __wasm_bindgen_func_elem_3222: (a: number, b: number) => void;
|
|
141
|
+
export const __wasm_bindgen_func_elem_3097: (a: number, b: number) => void;
|
|
142
|
+
export const __wasm_bindgen_func_elem_3093: (a: number, b: number) => void;
|
|
144
143
|
export const __wasm_bindgen_func_elem_480: (a: number, b: number, c: number, d: number) => void;
|
|
145
144
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
146
145
|
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
@@ -658,20 +658,17 @@ export function getIncreaseSpotPositionQuote(increase_amount: bigint, collateral
|
|
|
658
658
|
* - `decrease_amount`: Position total decrease size in the collateral_token.
|
|
659
659
|
* - `collateral_token`: Collateral token.
|
|
660
660
|
* - `leverage`: Leverage (1.0 or higher).
|
|
661
|
-
* - `reduce_only`: Only allow reducing the existing position.
|
|
662
661
|
* - `slippage_tolerance_bps`: An optional slippage tolerance in basis points. Defaults to the global slippage tolerance if not provided.
|
|
663
662
|
* - `position_token`: Token of the existing position.
|
|
664
663
|
* - `position_amount`: Existing position amount in the position_token.
|
|
665
664
|
* - `position_debt`: Existing position debt in the token opposite to the position_token.
|
|
666
|
-
* - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
667
|
-
* - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
668
665
|
* - `fusion_pool`: Fusion pool.
|
|
669
666
|
* - `tick_arrays`: Optional five tick arrays around the current pool price. If not provided, the quote will be calculated using the Jupiter Aggregator.
|
|
670
667
|
*
|
|
671
668
|
* # Returns
|
|
672
669
|
* - `DecreaseSpotPositionQuoteResult`: quote result
|
|
673
670
|
*/
|
|
674
|
-
export function getDecreaseSpotPositionQuote(decrease_amount: bigint, collateral_token: number, leverage: number,
|
|
671
|
+
export function getDecreaseSpotPositionQuote(decrease_amount: bigint, collateral_token: number, leverage: number, slippage_tolerance_bps: number | null | undefined, position_token: number, position_amount: bigint, position_debt: bigint, mint_a: Pubkey, mint_b: Pubkey, fusion_pool: FusionPoolFacade, tick_arrays?: TickArrayFacade[] | null): Promise<any>;
|
|
675
672
|
/**
|
|
676
673
|
* Returns the liquidation price
|
|
677
674
|
*
|
|
@@ -692,23 +689,19 @@ export function getLiquidationPrice(position_token: number, amount: number, debt
|
|
|
692
689
|
* - `collateral_token`: Collateral token.
|
|
693
690
|
* - `available_balance`: Available wallet balance in the collateral_token.
|
|
694
691
|
* - `leverage`: Leverage (1.0 or higher).
|
|
695
|
-
* - `new_position_token`: Token of the new position.
|
|
696
692
|
* - `position_token`: Token of the existing position. Should be set to new_position_token if position_amount is zero.
|
|
697
693
|
* - `position_amount`: Existing position amount in the position_token.
|
|
698
|
-
* - `position_debt`: Existing position debt in the token opposite to the position_token.
|
|
699
|
-
* - `reduce_only`: Only allow reducing the existing position.///
|
|
700
694
|
* - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
701
695
|
* - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
702
696
|
* - `fusion_pool`: Fusion pool.
|
|
703
|
-
* - `
|
|
697
|
+
* - `increase`: true if increasing the position
|
|
704
698
|
*
|
|
705
699
|
* # Returns
|
|
706
700
|
* - `u64`: the maximum tradable amount
|
|
707
701
|
*/
|
|
708
|
-
export function getTradableAmount(collateral_token: number, available_balance: bigint, leverage: number,
|
|
702
|
+
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;
|
|
709
703
|
export function calculateTunaProtocolFee(collateral_token: number, borrowed_token: number, collateral: bigint, borrow: bigint, protocol_fee_rate_on_collateral: number, protocol_fee_rate: number): TokenPair;
|
|
710
704
|
export function _INVALID_ARGUMENTS(): string;
|
|
711
|
-
export function _TICK_ARRAYS_NOT_PROVIDED(): string;
|
|
712
705
|
export function _JUPITER_QUOTE_REQUEST_ERROR(): string;
|
|
713
706
|
export function _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR(): string;
|
|
714
707
|
/**
|
|
@@ -834,20 +827,6 @@ export interface PositionRatio {
|
|
|
834
827
|
ratioB: bigint;
|
|
835
828
|
}
|
|
836
829
|
|
|
837
|
-
export interface TunaSpotPositionFacade {
|
|
838
|
-
version: number;
|
|
839
|
-
marketMaker: number;
|
|
840
|
-
positionToken: number;
|
|
841
|
-
collateralToken: number;
|
|
842
|
-
flags: number;
|
|
843
|
-
amount: bigint;
|
|
844
|
-
loanShares: bigint;
|
|
845
|
-
loanFunds: bigint;
|
|
846
|
-
entrySqrtPrice: bigint;
|
|
847
|
-
lowerLimitOrderSqrtPrice: bigint;
|
|
848
|
-
upperLimitOrderSqrtPrice: bigint;
|
|
849
|
-
}
|
|
850
|
-
|
|
851
830
|
export interface SwapInstruction {
|
|
852
831
|
data: number[];
|
|
853
832
|
accounts: AccountMeta[];
|
|
@@ -868,19 +847,26 @@ export interface IncreaseSpotPositionQuoteResult {
|
|
|
868
847
|
|
|
869
848
|
export interface DecreaseSpotPositionQuoteResult {
|
|
870
849
|
decreasePercent: number;
|
|
871
|
-
|
|
872
|
-
positionToken: number;
|
|
873
|
-
collateral: bigint;
|
|
874
|
-
borrow: bigint;
|
|
875
|
-
decreaseAcceptableSwapAmount: bigint;
|
|
876
|
-
increaseMinSwapOutputAmount: bigint;
|
|
850
|
+
requiredSwapAmount: bigint;
|
|
877
851
|
estimatedAmount: bigint;
|
|
878
|
-
protocolFeeA: bigint;
|
|
879
|
-
protocolFeeB: bigint;
|
|
880
852
|
priceImpact: number;
|
|
881
853
|
jupiterSwapIx: SwapInstruction | undefined;
|
|
882
854
|
}
|
|
883
855
|
|
|
856
|
+
export interface TunaSpotPositionFacade {
|
|
857
|
+
version: number;
|
|
858
|
+
marketMaker: number;
|
|
859
|
+
positionToken: number;
|
|
860
|
+
collateralToken: number;
|
|
861
|
+
flags: number;
|
|
862
|
+
amount: bigint;
|
|
863
|
+
loanShares: bigint;
|
|
864
|
+
loanFunds: bigint;
|
|
865
|
+
entrySqrtPrice: bigint;
|
|
866
|
+
lowerLimitOrderSqrtPrice: bigint;
|
|
867
|
+
upperLimitOrderSqrtPrice: bigint;
|
|
868
|
+
}
|
|
869
|
+
|
|
884
870
|
/**
|
|
885
871
|
* A hash; the 32-byte output of a hashing algorithm.
|
|
886
872
|
*
|
|
@@ -1680,25 +1680,22 @@ exports.getIncreaseSpotPositionQuote = function(increase_amount, collateral_toke
|
|
|
1680
1680
|
* - `decrease_amount`: Position total decrease size in the collateral_token.
|
|
1681
1681
|
* - `collateral_token`: Collateral token.
|
|
1682
1682
|
* - `leverage`: Leverage (1.0 or higher).
|
|
1683
|
-
* - `reduce_only`: Only allow reducing the existing position.
|
|
1684
1683
|
* - `slippage_tolerance_bps`: An optional slippage tolerance in basis points. Defaults to the global slippage tolerance if not provided.
|
|
1685
1684
|
* - `position_token`: Token of the existing position.
|
|
1686
1685
|
* - `position_amount`: Existing position amount in the position_token.
|
|
1687
1686
|
* - `position_debt`: Existing position debt in the token opposite to the position_token.
|
|
1688
|
-
* - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1689
|
-
* - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1690
1687
|
* - `fusion_pool`: Fusion pool.
|
|
1691
1688
|
* - `tick_arrays`: Optional five tick arrays around the current pool price. If not provided, the quote will be calculated using the Jupiter Aggregator.
|
|
1692
1689
|
*
|
|
1693
1690
|
* # Returns
|
|
1694
1691
|
* - `DecreaseSpotPositionQuoteResult`: quote result
|
|
1695
1692
|
*/
|
|
1696
|
-
exports.getDecreaseSpotPositionQuote = function(decrease_amount, collateral_token, leverage,
|
|
1693
|
+
exports.getDecreaseSpotPositionQuote = function(decrease_amount, collateral_token, leverage, slippage_tolerance_bps, position_token, position_amount, position_debt, mint_a, mint_b, fusion_pool, tick_arrays) {
|
|
1697
1694
|
_assertClass(mint_a, Pubkey);
|
|
1698
1695
|
var ptr0 = mint_a.__destroy_into_raw();
|
|
1699
1696
|
_assertClass(mint_b, Pubkey);
|
|
1700
1697
|
var ptr1 = mint_b.__destroy_into_raw();
|
|
1701
|
-
const ret = wasm.getDecreaseSpotPositionQuote(decrease_amount, collateral_token, leverage,
|
|
1698
|
+
const ret = wasm.getDecreaseSpotPositionQuote(decrease_amount, collateral_token, leverage, isLikeNone(slippage_tolerance_bps) ? 0xFFFFFF : slippage_tolerance_bps, position_token, position_amount, position_debt, ptr0, ptr1, addHeapObject(fusion_pool), isLikeNone(tick_arrays) ? 0 : addHeapObject(tick_arrays));
|
|
1702
1699
|
return takeObject(ret);
|
|
1703
1700
|
};
|
|
1704
1701
|
|
|
@@ -1737,23 +1734,20 @@ exports.getLiquidationPrice = function(position_token, amount, debt, liquidation
|
|
|
1737
1734
|
* - `collateral_token`: Collateral token.
|
|
1738
1735
|
* - `available_balance`: Available wallet balance in the collateral_token.
|
|
1739
1736
|
* - `leverage`: Leverage (1.0 or higher).
|
|
1740
|
-
* - `new_position_token`: Token of the new position.
|
|
1741
1737
|
* - `position_token`: Token of the existing position. Should be set to new_position_token if position_amount is zero.
|
|
1742
1738
|
* - `position_amount`: Existing position amount in the position_token.
|
|
1743
|
-
* - `position_debt`: Existing position debt in the token opposite to the position_token.
|
|
1744
|
-
* - `reduce_only`: Only allow reducing the existing position.///
|
|
1745
1739
|
* - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1746
1740
|
* - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1747
1741
|
* - `fusion_pool`: Fusion pool.
|
|
1748
|
-
* - `
|
|
1742
|
+
* - `increase`: true if increasing the position
|
|
1749
1743
|
*
|
|
1750
1744
|
* # Returns
|
|
1751
1745
|
* - `u64`: the maximum tradable amount
|
|
1752
1746
|
*/
|
|
1753
|
-
exports.getTradableAmount = function(collateral_token, available_balance, leverage,
|
|
1747
|
+
exports.getTradableAmount = function(collateral_token, available_balance, leverage, position_token, position_amount, protocol_fee_rate, protocol_fee_rate_on_collateral, fusion_pool, increase) {
|
|
1754
1748
|
try {
|
|
1755
1749
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1756
|
-
wasm.getTradableAmount(retptr, collateral_token, available_balance, leverage,
|
|
1750
|
+
wasm.getTradableAmount(retptr, collateral_token, available_balance, leverage, position_token, position_amount, protocol_fee_rate, protocol_fee_rate_on_collateral, addHeapObject(fusion_pool), increase);
|
|
1757
1751
|
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1758
1752
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1759
1753
|
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
@@ -1783,18 +1777,6 @@ exports._INVALID_ARGUMENTS = function() {
|
|
|
1783
1777
|
}
|
|
1784
1778
|
};
|
|
1785
1779
|
|
|
1786
|
-
exports._TICK_ARRAYS_NOT_PROVIDED = function() {
|
|
1787
|
-
try {
|
|
1788
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1789
|
-
wasm._TICK_ARRAYS_NOT_PROVIDED(retptr);
|
|
1790
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1791
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1792
|
-
return getStringFromWasm0(r0, r1);
|
|
1793
|
-
} finally {
|
|
1794
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1795
|
-
}
|
|
1796
|
-
};
|
|
1797
|
-
|
|
1798
1780
|
exports._JUPITER_QUOTE_REQUEST_ERROR = function() {
|
|
1799
1781
|
try {
|
|
1800
1782
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
@@ -1826,12 +1808,12 @@ exports.solana_program_init = function() {
|
|
|
1826
1808
|
wasm.solana_program_init();
|
|
1827
1809
|
};
|
|
1828
1810
|
|
|
1829
|
-
function
|
|
1830
|
-
wasm.
|
|
1811
|
+
function __wasm_bindgen_func_elem_3203(arg0, arg1, arg2) {
|
|
1812
|
+
wasm.__wasm_bindgen_func_elem_3203(arg0, arg1, addHeapObject(arg2));
|
|
1831
1813
|
}
|
|
1832
1814
|
|
|
1833
|
-
function
|
|
1834
|
-
wasm.
|
|
1815
|
+
function __wasm_bindgen_func_elem_3097(arg0, arg1) {
|
|
1816
|
+
wasm.__wasm_bindgen_func_elem_3097(arg0, arg1);
|
|
1835
1817
|
}
|
|
1836
1818
|
|
|
1837
1819
|
function __wasm_bindgen_func_elem_480(arg0, arg1, arg2, arg3) {
|
|
@@ -3258,12 +3240,6 @@ exports.__wbg_warn_1d74dddbe2fd1dbb = function(arg0) {
|
|
|
3258
3240
|
console.warn(getObject(arg0));
|
|
3259
3241
|
};
|
|
3260
3242
|
|
|
3261
|
-
exports.__wbindgen_cast_2116c94cd3735b0a = function(arg0, arg1) {
|
|
3262
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx: 338, function: Function { arguments: [], shim_idx: 339, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3263
|
-
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3116, __wasm_bindgen_func_elem_3120);
|
|
3264
|
-
return addHeapObject(ret);
|
|
3265
|
-
};
|
|
3266
|
-
|
|
3267
3243
|
exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
3268
3244
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
3269
3245
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
@@ -3276,15 +3252,21 @@ exports.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
|
|
|
3276
3252
|
return addHeapObject(ret);
|
|
3277
3253
|
};
|
|
3278
3254
|
|
|
3255
|
+
exports.__wbindgen_cast_7f6d2ab049d5d8fd = function(arg0, arg1) {
|
|
3256
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 334, function: Function { arguments: [], shim_idx: 335, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3257
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3093, __wasm_bindgen_func_elem_3097);
|
|
3258
|
+
return addHeapObject(ret);
|
|
3259
|
+
};
|
|
3260
|
+
|
|
3279
3261
|
exports.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
|
|
3280
3262
|
// Cast intrinsic for `I64 -> Externref`.
|
|
3281
3263
|
const ret = arg0;
|
|
3282
3264
|
return addHeapObject(ret);
|
|
3283
3265
|
};
|
|
3284
3266
|
|
|
3285
|
-
exports.
|
|
3286
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
3287
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
3267
|
+
exports.__wbindgen_cast_b2b7ff753c8c06bb = function(arg0, arg1) {
|
|
3268
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 366, function: Function { arguments: [Externref], shim_idx: 361, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3269
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3222, __wasm_bindgen_func_elem_3203);
|
|
3288
3270
|
return addHeapObject(ret);
|
|
3289
3271
|
};
|
|
3290
3272
|
|
|
Binary file
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
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;
|
|
5
|
-
export const getDecreaseSpotPositionQuote: (a: bigint, b: number, c: number, d: number, e: number, f:
|
|
5
|
+
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;
|
|
6
6
|
export const getLiquidationPrice: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
7
|
-
export const getTradableAmount: (a: number, b: number, c: bigint, d: number, e: number, f:
|
|
7
|
+
export const getTradableAmount: (a: number, b: number, c: bigint, d: number, e: number, f: bigint, g: number, h: number, i: number, j: number) => void;
|
|
8
8
|
export const calculateTunaProtocolFee: (a: number, b: number, c: bigint, d: bigint, e: number, f: number) => number;
|
|
9
9
|
export const _INVALID_ARGUMENTS: (a: number) => void;
|
|
10
|
-
export const _TICK_ARRAYS_NOT_PROVIDED: (a: number) => void;
|
|
11
10
|
export const _JUPITER_QUOTE_REQUEST_ERROR: (a: number) => void;
|
|
12
11
|
export const _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR: (a: number) => void;
|
|
13
12
|
export const __wbg_transaction_free: (a: number, b: number) => void;
|
|
@@ -137,10 +136,10 @@ export const limitOrderQuoteByInputToken: (a: number, b: bigint, c: number, d: n
|
|
|
137
136
|
export const limitOrderQuoteByOutputToken: (a: number, b: bigint, c: number, d: number, e: number) => void;
|
|
138
137
|
export const limitOrderRewardByOutputToken: (a: number, b: bigint, c: number, d: number) => void;
|
|
139
138
|
export const decreaseLimitOrderQuote: (a: number, b: number, c: number, d: number, e: bigint, f: number, g: number) => void;
|
|
140
|
-
export const
|
|
141
|
-
export const
|
|
142
|
-
export const
|
|
143
|
-
export const
|
|
139
|
+
export const __wasm_bindgen_func_elem_3203: (a: number, b: number, c: number) => void;
|
|
140
|
+
export const __wasm_bindgen_func_elem_3222: (a: number, b: number) => void;
|
|
141
|
+
export const __wasm_bindgen_func_elem_3097: (a: number, b: number) => void;
|
|
142
|
+
export const __wasm_bindgen_func_elem_3093: (a: number, b: number) => void;
|
|
144
143
|
export const __wasm_bindgen_func_elem_480: (a: number, b: number, c: number, d: number) => void;
|
|
145
144
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
146
145
|
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.3.
|
|
4
|
+
"version": "3.3.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.3.
|
|
26
|
+
"@crypticdot/defituna-rust-core": "3.3.1"
|
|
27
27
|
},
|
|
28
28
|
"license": "SEE LICENSE IN LICENSE",
|
|
29
29
|
"keywords": [
|