@crypticdot/defituna-core 3.2.1 → 3.2.3
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 +15 -16
- package/dist/browser/defituna_core_js_bindings_bg.js +10 -18
- 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 +15 -16
- package/dist/nodejs/defituna_core_js_bindings.js +10 -18
- 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 +2 -2
|
@@ -640,6 +640,7 @@ export function _INVALID_ARGUMENTS(): string;
|
|
|
640
640
|
* - `collateral_token`: Collateral token.
|
|
641
641
|
* - `position_token`: Token of the position.
|
|
642
642
|
* - `leverage`: Leverage (1.0 or higher).
|
|
643
|
+
* - `slippage_tolerance_bps`: An optional slippage tolerance in basis points. Defaults to the global slippage tolerance if not provided.
|
|
643
644
|
* - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
644
645
|
* - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
645
646
|
* - `fusion_pool`: Fusion pool.
|
|
@@ -648,18 +649,19 @@ export function _INVALID_ARGUMENTS(): string;
|
|
|
648
649
|
* # Returns
|
|
649
650
|
* - `IncreaseSpotPositionQuoteResult`: quote result
|
|
650
651
|
*/
|
|
651
|
-
export function getIncreaseSpotPositionQuote(increase_amount: bigint, collateral_token:
|
|
652
|
+
export function getIncreaseSpotPositionQuote(increase_amount: bigint, collateral_token: number, position_token: number, leverage: number, slippage_tolerance_bps: number | null | undefined, protocol_fee_rate: number, protocol_fee_rate_on_collateral: number, fusion_pool: FusionPoolFacade, tick_arrays: TickArrayFacade[]): IncreaseSpotPositionQuoteResult;
|
|
652
653
|
/**
|
|
653
654
|
* Spot position decrease quote
|
|
654
655
|
*
|
|
655
656
|
* # Parameters
|
|
656
657
|
* - `increase_amount`: Position total size in the collateral_token.
|
|
657
658
|
* - `collateral_token`: Collateral token.
|
|
658
|
-
* - `position_token`: Token of the existing position.
|
|
659
659
|
* - `leverage`: Leverage (1.0 or higher).
|
|
660
|
+
* - `reduce_only`: Only allow reducing the existing position.
|
|
661
|
+
* - `slippage_tolerance_bps`: An optional slippage tolerance in basis points. Defaults to the global slippage tolerance if not provided.
|
|
662
|
+
* - `position_token`: Token of the existing position.
|
|
660
663
|
* - `position_amount`: Existing position amount in the position_token.
|
|
661
664
|
* - `position_debt`: Existing position debt in the token opposite to the position_token.
|
|
662
|
-
* - `reduce_only`: Only allow reducing the existing position.
|
|
663
665
|
* - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
664
666
|
* - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
665
667
|
* - `fusion_pool`: Fusion pool.
|
|
@@ -668,7 +670,7 @@ export function getIncreaseSpotPositionQuote(increase_amount: bigint, collateral
|
|
|
668
670
|
* # Returns
|
|
669
671
|
* - `DecreaseSpotPositionQuoteResult`: quote result
|
|
670
672
|
*/
|
|
671
|
-
export function getDecreaseSpotPositionQuote(decrease_amount: bigint, collateral_token:
|
|
673
|
+
export function getDecreaseSpotPositionQuote(decrease_amount: bigint, collateral_token: number, leverage: number, reduce_only: boolean, slippage_tolerance_bps: number | null | undefined, position_token: number, position_amount: bigint, position_debt: bigint, protocol_fee_rate: number, protocol_fee_rate_on_collateral: number, fusion_pool: FusionPoolFacade, tick_arrays: TickArrayFacade[]): DecreaseSpotPositionQuoteResult;
|
|
672
674
|
/**
|
|
673
675
|
* Returns the liquidation price
|
|
674
676
|
*
|
|
@@ -681,7 +683,7 @@ export function getDecreaseSpotPositionQuote(decrease_amount: bigint, collateral
|
|
|
681
683
|
* # Returns
|
|
682
684
|
* - `f64`: Decimal liquidation price
|
|
683
685
|
*/
|
|
684
|
-
export function getLiquidationPrice(position_token:
|
|
686
|
+
export function getLiquidationPrice(position_token: number, amount: number, debt: number, liquidation_threshold: number): number;
|
|
685
687
|
/**
|
|
686
688
|
* Calculates the maximum tradable amount in the collateral token.
|
|
687
689
|
*
|
|
@@ -702,7 +704,7 @@ export function getLiquidationPrice(position_token: PoolTokenFacade, amount: num
|
|
|
702
704
|
* # Returns
|
|
703
705
|
* - `u64`: the maximum tradable amount
|
|
704
706
|
*/
|
|
705
|
-
export function getTradableAmount(collateral_token:
|
|
707
|
+
export function getTradableAmount(collateral_token: number, available_balance: bigint, leverage: number, new_position_token: number, reduce_only: boolean, position_token: number, position_amount: bigint, position_debt: bigint, protocol_fee_rate: number, protocol_fee_rate_on_collateral: number, fusion_pool: FusionPoolFacade, tick_arrays: TickArrayFacade[]): bigint;
|
|
706
708
|
export interface TickArrayFacade {
|
|
707
709
|
startTickIndex: number;
|
|
708
710
|
ticks: TickFacade[];
|
|
@@ -824,9 +826,9 @@ export interface PositionRatio {
|
|
|
824
826
|
|
|
825
827
|
export interface TunaSpotPositionFacade {
|
|
826
828
|
version: number;
|
|
827
|
-
marketMaker:
|
|
828
|
-
positionToken:
|
|
829
|
-
collateralToken:
|
|
829
|
+
marketMaker: number;
|
|
830
|
+
positionToken: number;
|
|
831
|
+
collateralToken: number;
|
|
830
832
|
flags: number;
|
|
831
833
|
amount: bigint;
|
|
832
834
|
loanShares: bigint;
|
|
@@ -836,17 +838,13 @@ export interface TunaSpotPositionFacade {
|
|
|
836
838
|
upperLimitOrderSqrtPrice: bigint;
|
|
837
839
|
}
|
|
838
840
|
|
|
839
|
-
export type MarketMakerFacade = "orca" | "fusion";
|
|
840
|
-
|
|
841
|
-
export type PoolTokenFacade = "a" | "b";
|
|
842
|
-
|
|
843
841
|
export interface DecreaseSpotPositionQuoteResult {
|
|
844
842
|
decreasePercent: number;
|
|
845
|
-
collateralToken:
|
|
846
|
-
positionToken:
|
|
843
|
+
collateralToken: number;
|
|
844
|
+
positionToken: number;
|
|
847
845
|
collateral: bigint;
|
|
848
846
|
borrow: bigint;
|
|
849
|
-
|
|
847
|
+
maxSwapInputAmount: bigint;
|
|
850
848
|
estimatedAmount: bigint;
|
|
851
849
|
protocolFeeA: bigint;
|
|
852
850
|
protocolFeeB: bigint;
|
|
@@ -858,6 +856,7 @@ export interface IncreaseSpotPositionQuoteResult {
|
|
|
858
856
|
borrow: bigint;
|
|
859
857
|
estimatedAmount: bigint;
|
|
860
858
|
swapInputAmount: bigint;
|
|
859
|
+
minSwapOutputAmount: bigint;
|
|
861
860
|
protocolFeeA: bigint;
|
|
862
861
|
protocolFeeB: bigint;
|
|
863
862
|
priceImpact: number;
|
|
@@ -1626,6 +1626,7 @@ export function _INVALID_ARGUMENTS() {
|
|
|
1626
1626
|
* - `collateral_token`: Collateral token.
|
|
1627
1627
|
* - `position_token`: Token of the position.
|
|
1628
1628
|
* - `leverage`: Leverage (1.0 or higher).
|
|
1629
|
+
* - `slippage_tolerance_bps`: An optional slippage tolerance in basis points. Defaults to the global slippage tolerance if not provided.
|
|
1629
1630
|
* - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1630
1631
|
* - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1631
1632
|
* - `fusion_pool`: Fusion pool.
|
|
@@ -1634,10 +1635,10 @@ export function _INVALID_ARGUMENTS() {
|
|
|
1634
1635
|
* # Returns
|
|
1635
1636
|
* - `IncreaseSpotPositionQuoteResult`: quote result
|
|
1636
1637
|
*/
|
|
1637
|
-
export function getIncreaseSpotPositionQuote(increase_amount, collateral_token, position_token, leverage, protocol_fee_rate, protocol_fee_rate_on_collateral, fusion_pool, tick_arrays) {
|
|
1638
|
+
export function getIncreaseSpotPositionQuote(increase_amount, collateral_token, position_token, leverage, slippage_tolerance_bps, protocol_fee_rate, protocol_fee_rate_on_collateral, fusion_pool, tick_arrays) {
|
|
1638
1639
|
try {
|
|
1639
1640
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1640
|
-
wasm.getIncreaseSpotPositionQuote(retptr, increase_amount,
|
|
1641
|
+
wasm.getIncreaseSpotPositionQuote(retptr, increase_amount, collateral_token, position_token, leverage, isLikeNone(slippage_tolerance_bps) ? 0xFFFFFF : slippage_tolerance_bps, protocol_fee_rate, protocol_fee_rate_on_collateral, addHeapObject(fusion_pool), addHeapObject(tick_arrays));
|
|
1641
1642
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1642
1643
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1643
1644
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -1656,11 +1657,12 @@ export function getIncreaseSpotPositionQuote(increase_amount, collateral_token,
|
|
|
1656
1657
|
* # Parameters
|
|
1657
1658
|
* - `increase_amount`: Position total size in the collateral_token.
|
|
1658
1659
|
* - `collateral_token`: Collateral token.
|
|
1659
|
-
* - `position_token`: Token of the existing position.
|
|
1660
1660
|
* - `leverage`: Leverage (1.0 or higher).
|
|
1661
|
+
* - `reduce_only`: Only allow reducing the existing position.
|
|
1662
|
+
* - `slippage_tolerance_bps`: An optional slippage tolerance in basis points. Defaults to the global slippage tolerance if not provided.
|
|
1663
|
+
* - `position_token`: Token of the existing position.
|
|
1661
1664
|
* - `position_amount`: Existing position amount in the position_token.
|
|
1662
1665
|
* - `position_debt`: Existing position debt in the token opposite to the position_token.
|
|
1663
|
-
* - `reduce_only`: Only allow reducing the existing position.
|
|
1664
1666
|
* - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1665
1667
|
* - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1666
1668
|
* - `fusion_pool`: Fusion pool.
|
|
@@ -1669,10 +1671,10 @@ export function getIncreaseSpotPositionQuote(increase_amount, collateral_token,
|
|
|
1669
1671
|
* # Returns
|
|
1670
1672
|
* - `DecreaseSpotPositionQuoteResult`: quote result
|
|
1671
1673
|
*/
|
|
1672
|
-
export function getDecreaseSpotPositionQuote(decrease_amount, collateral_token, leverage, reduce_only, position_token, position_amount, position_debt, protocol_fee_rate, protocol_fee_rate_on_collateral, fusion_pool, tick_arrays) {
|
|
1674
|
+
export function getDecreaseSpotPositionQuote(decrease_amount, collateral_token, leverage, reduce_only, slippage_tolerance_bps, position_token, position_amount, position_debt, protocol_fee_rate, protocol_fee_rate_on_collateral, fusion_pool, tick_arrays) {
|
|
1673
1675
|
try {
|
|
1674
1676
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1675
|
-
wasm.getDecreaseSpotPositionQuote(retptr, decrease_amount,
|
|
1677
|
+
wasm.getDecreaseSpotPositionQuote(retptr, decrease_amount, collateral_token, leverage, reduce_only, isLikeNone(slippage_tolerance_bps) ? 0xFFFFFF : slippage_tolerance_bps, position_token, position_amount, position_debt, protocol_fee_rate, protocol_fee_rate_on_collateral, addHeapObject(fusion_pool), addHeapObject(tick_arrays));
|
|
1676
1678
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1677
1679
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1678
1680
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -1700,7 +1702,7 @@ export function getDecreaseSpotPositionQuote(decrease_amount, collateral_token,
|
|
|
1700
1702
|
export function getLiquidationPrice(position_token, amount, debt, liquidation_threshold) {
|
|
1701
1703
|
try {
|
|
1702
1704
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1703
|
-
wasm.getLiquidationPrice(retptr,
|
|
1705
|
+
wasm.getLiquidationPrice(retptr, position_token, amount, debt, liquidation_threshold);
|
|
1704
1706
|
var r0 = getDataViewMemory0().getFloat64(retptr + 8 * 0, true);
|
|
1705
1707
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1706
1708
|
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
@@ -1736,7 +1738,7 @@ export function getLiquidationPrice(position_token, amount, debt, liquidation_th
|
|
|
1736
1738
|
export function getTradableAmount(collateral_token, available_balance, leverage, new_position_token, reduce_only, position_token, position_amount, position_debt, protocol_fee_rate, protocol_fee_rate_on_collateral, fusion_pool, tick_arrays) {
|
|
1737
1739
|
try {
|
|
1738
1740
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1739
|
-
wasm.getTradableAmount(retptr,
|
|
1741
|
+
wasm.getTradableAmount(retptr, collateral_token, available_balance, leverage, new_position_token, reduce_only, position_token, position_amount, position_debt, protocol_fee_rate, protocol_fee_rate_on_collateral, addHeapObject(fusion_pool), addHeapObject(tick_arrays));
|
|
1740
1742
|
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1741
1743
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1742
1744
|
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
@@ -1809,11 +1811,6 @@ export function __wbg___wbindgen_is_object_c818261d21f283a4(arg0) {
|
|
|
1809
1811
|
return ret;
|
|
1810
1812
|
};
|
|
1811
1813
|
|
|
1812
|
-
export function __wbg___wbindgen_is_string_fbb76cb2940daafd(arg0) {
|
|
1813
|
-
const ret = typeof(getObject(arg0)) === 'string';
|
|
1814
|
-
return ret;
|
|
1815
|
-
};
|
|
1816
|
-
|
|
1817
1814
|
export function __wbg___wbindgen_is_undefined_2d472862bd29a478(arg0) {
|
|
1818
1815
|
const ret = getObject(arg0) === undefined;
|
|
1819
1816
|
return ret;
|
|
@@ -1864,11 +1861,6 @@ export function __wbg_done_2042aa2670fb1db1(arg0) {
|
|
|
1864
1861
|
return ret;
|
|
1865
1862
|
};
|
|
1866
1863
|
|
|
1867
|
-
export function __wbg_entries_e171b586f8f6bdbf(arg0) {
|
|
1868
|
-
const ret = Object.entries(getObject(arg0));
|
|
1869
|
-
return addHeapObject(ret);
|
|
1870
|
-
};
|
|
1871
|
-
|
|
1872
1864
|
export function __wbg_get_7bed016f185add81(arg0, arg1) {
|
|
1873
1865
|
const ret = getObject(arg0)[arg1 >>> 0];
|
|
1874
1866
|
return addHeapObject(ret);
|
|
Binary file
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const _INVALID_ARGUMENTS: (a: number) => void;
|
|
5
|
-
export const getIncreaseSpotPositionQuote: (a: number, b: bigint, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
6
|
-
export const getDecreaseSpotPositionQuote: (a: number, b: bigint, c: number, d: number, e: number, f: number, g:
|
|
5
|
+
export const getIncreaseSpotPositionQuote: (a: number, b: bigint, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
|
|
6
|
+
export const getDecreaseSpotPositionQuote: (a: number, b: bigint, c: number, d: number, e: number, f: number, g: number, h: bigint, i: bigint, j: number, k: number, l: number, m: number) => void;
|
|
7
7
|
export const getLiquidationPrice: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
8
8
|
export const getTradableAmount: (a: number, b: number, c: bigint, d: number, e: number, f: number, g: number, h: bigint, i: bigint, j: number, k: number, l: number, m: number) => void;
|
|
9
9
|
export const decreaseLiquidityQuote: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
@@ -640,6 +640,7 @@ export function _INVALID_ARGUMENTS(): string;
|
|
|
640
640
|
* - `collateral_token`: Collateral token.
|
|
641
641
|
* - `position_token`: Token of the position.
|
|
642
642
|
* - `leverage`: Leverage (1.0 or higher).
|
|
643
|
+
* - `slippage_tolerance_bps`: An optional slippage tolerance in basis points. Defaults to the global slippage tolerance if not provided.
|
|
643
644
|
* - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
644
645
|
* - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
645
646
|
* - `fusion_pool`: Fusion pool.
|
|
@@ -648,18 +649,19 @@ export function _INVALID_ARGUMENTS(): string;
|
|
|
648
649
|
* # Returns
|
|
649
650
|
* - `IncreaseSpotPositionQuoteResult`: quote result
|
|
650
651
|
*/
|
|
651
|
-
export function getIncreaseSpotPositionQuote(increase_amount: bigint, collateral_token:
|
|
652
|
+
export function getIncreaseSpotPositionQuote(increase_amount: bigint, collateral_token: number, position_token: number, leverage: number, slippage_tolerance_bps: number | null | undefined, protocol_fee_rate: number, protocol_fee_rate_on_collateral: number, fusion_pool: FusionPoolFacade, tick_arrays: TickArrayFacade[]): IncreaseSpotPositionQuoteResult;
|
|
652
653
|
/**
|
|
653
654
|
* Spot position decrease quote
|
|
654
655
|
*
|
|
655
656
|
* # Parameters
|
|
656
657
|
* - `increase_amount`: Position total size in the collateral_token.
|
|
657
658
|
* - `collateral_token`: Collateral token.
|
|
658
|
-
* - `position_token`: Token of the existing position.
|
|
659
659
|
* - `leverage`: Leverage (1.0 or higher).
|
|
660
|
+
* - `reduce_only`: Only allow reducing the existing position.
|
|
661
|
+
* - `slippage_tolerance_bps`: An optional slippage tolerance in basis points. Defaults to the global slippage tolerance if not provided.
|
|
662
|
+
* - `position_token`: Token of the existing position.
|
|
660
663
|
* - `position_amount`: Existing position amount in the position_token.
|
|
661
664
|
* - `position_debt`: Existing position debt in the token opposite to the position_token.
|
|
662
|
-
* - `reduce_only`: Only allow reducing the existing position.
|
|
663
665
|
* - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
664
666
|
* - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
665
667
|
* - `fusion_pool`: Fusion pool.
|
|
@@ -668,7 +670,7 @@ export function getIncreaseSpotPositionQuote(increase_amount: bigint, collateral
|
|
|
668
670
|
* # Returns
|
|
669
671
|
* - `DecreaseSpotPositionQuoteResult`: quote result
|
|
670
672
|
*/
|
|
671
|
-
export function getDecreaseSpotPositionQuote(decrease_amount: bigint, collateral_token:
|
|
673
|
+
export function getDecreaseSpotPositionQuote(decrease_amount: bigint, collateral_token: number, leverage: number, reduce_only: boolean, slippage_tolerance_bps: number | null | undefined, position_token: number, position_amount: bigint, position_debt: bigint, protocol_fee_rate: number, protocol_fee_rate_on_collateral: number, fusion_pool: FusionPoolFacade, tick_arrays: TickArrayFacade[]): DecreaseSpotPositionQuoteResult;
|
|
672
674
|
/**
|
|
673
675
|
* Returns the liquidation price
|
|
674
676
|
*
|
|
@@ -681,7 +683,7 @@ export function getDecreaseSpotPositionQuote(decrease_amount: bigint, collateral
|
|
|
681
683
|
* # Returns
|
|
682
684
|
* - `f64`: Decimal liquidation price
|
|
683
685
|
*/
|
|
684
|
-
export function getLiquidationPrice(position_token:
|
|
686
|
+
export function getLiquidationPrice(position_token: number, amount: number, debt: number, liquidation_threshold: number): number;
|
|
685
687
|
/**
|
|
686
688
|
* Calculates the maximum tradable amount in the collateral token.
|
|
687
689
|
*
|
|
@@ -702,7 +704,7 @@ export function getLiquidationPrice(position_token: PoolTokenFacade, amount: num
|
|
|
702
704
|
* # Returns
|
|
703
705
|
* - `u64`: the maximum tradable amount
|
|
704
706
|
*/
|
|
705
|
-
export function getTradableAmount(collateral_token:
|
|
707
|
+
export function getTradableAmount(collateral_token: number, available_balance: bigint, leverage: number, new_position_token: number, reduce_only: boolean, position_token: number, position_amount: bigint, position_debt: bigint, protocol_fee_rate: number, protocol_fee_rate_on_collateral: number, fusion_pool: FusionPoolFacade, tick_arrays: TickArrayFacade[]): bigint;
|
|
706
708
|
export interface TickArrayFacade {
|
|
707
709
|
startTickIndex: number;
|
|
708
710
|
ticks: TickFacade[];
|
|
@@ -824,9 +826,9 @@ export interface PositionRatio {
|
|
|
824
826
|
|
|
825
827
|
export interface TunaSpotPositionFacade {
|
|
826
828
|
version: number;
|
|
827
|
-
marketMaker:
|
|
828
|
-
positionToken:
|
|
829
|
-
collateralToken:
|
|
829
|
+
marketMaker: number;
|
|
830
|
+
positionToken: number;
|
|
831
|
+
collateralToken: number;
|
|
830
832
|
flags: number;
|
|
831
833
|
amount: bigint;
|
|
832
834
|
loanShares: bigint;
|
|
@@ -836,17 +838,13 @@ export interface TunaSpotPositionFacade {
|
|
|
836
838
|
upperLimitOrderSqrtPrice: bigint;
|
|
837
839
|
}
|
|
838
840
|
|
|
839
|
-
export type MarketMakerFacade = "orca" | "fusion";
|
|
840
|
-
|
|
841
|
-
export type PoolTokenFacade = "a" | "b";
|
|
842
|
-
|
|
843
841
|
export interface DecreaseSpotPositionQuoteResult {
|
|
844
842
|
decreasePercent: number;
|
|
845
|
-
collateralToken:
|
|
846
|
-
positionToken:
|
|
843
|
+
collateralToken: number;
|
|
844
|
+
positionToken: number;
|
|
847
845
|
collateral: bigint;
|
|
848
846
|
borrow: bigint;
|
|
849
|
-
|
|
847
|
+
maxSwapInputAmount: bigint;
|
|
850
848
|
estimatedAmount: bigint;
|
|
851
849
|
protocolFeeA: bigint;
|
|
852
850
|
protocolFeeB: bigint;
|
|
@@ -858,6 +856,7 @@ export interface IncreaseSpotPositionQuoteResult {
|
|
|
858
856
|
borrow: bigint;
|
|
859
857
|
estimatedAmount: bigint;
|
|
860
858
|
swapInputAmount: bigint;
|
|
859
|
+
minSwapOutputAmount: bigint;
|
|
861
860
|
protocolFeeA: bigint;
|
|
862
861
|
protocolFeeB: bigint;
|
|
863
862
|
priceImpact: number;
|
|
@@ -1616,6 +1616,7 @@ exports._INVALID_ARGUMENTS = function() {
|
|
|
1616
1616
|
* - `collateral_token`: Collateral token.
|
|
1617
1617
|
* - `position_token`: Token of the position.
|
|
1618
1618
|
* - `leverage`: Leverage (1.0 or higher).
|
|
1619
|
+
* - `slippage_tolerance_bps`: An optional slippage tolerance in basis points. Defaults to the global slippage tolerance if not provided.
|
|
1619
1620
|
* - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1620
1621
|
* - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1621
1622
|
* - `fusion_pool`: Fusion pool.
|
|
@@ -1624,10 +1625,10 @@ exports._INVALID_ARGUMENTS = function() {
|
|
|
1624
1625
|
* # Returns
|
|
1625
1626
|
* - `IncreaseSpotPositionQuoteResult`: quote result
|
|
1626
1627
|
*/
|
|
1627
|
-
exports.getIncreaseSpotPositionQuote = function(increase_amount, collateral_token, position_token, leverage, protocol_fee_rate, protocol_fee_rate_on_collateral, fusion_pool, tick_arrays) {
|
|
1628
|
+
exports.getIncreaseSpotPositionQuote = function(increase_amount, collateral_token, position_token, leverage, slippage_tolerance_bps, protocol_fee_rate, protocol_fee_rate_on_collateral, fusion_pool, tick_arrays) {
|
|
1628
1629
|
try {
|
|
1629
1630
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1630
|
-
wasm.getIncreaseSpotPositionQuote(retptr, increase_amount,
|
|
1631
|
+
wasm.getIncreaseSpotPositionQuote(retptr, increase_amount, collateral_token, position_token, leverage, isLikeNone(slippage_tolerance_bps) ? 0xFFFFFF : slippage_tolerance_bps, protocol_fee_rate, protocol_fee_rate_on_collateral, addHeapObject(fusion_pool), addHeapObject(tick_arrays));
|
|
1631
1632
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1632
1633
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1633
1634
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -1646,11 +1647,12 @@ exports.getIncreaseSpotPositionQuote = function(increase_amount, collateral_toke
|
|
|
1646
1647
|
* # Parameters
|
|
1647
1648
|
* - `increase_amount`: Position total size in the collateral_token.
|
|
1648
1649
|
* - `collateral_token`: Collateral token.
|
|
1649
|
-
* - `position_token`: Token of the existing position.
|
|
1650
1650
|
* - `leverage`: Leverage (1.0 or higher).
|
|
1651
|
+
* - `reduce_only`: Only allow reducing the existing position.
|
|
1652
|
+
* - `slippage_tolerance_bps`: An optional slippage tolerance in basis points. Defaults to the global slippage tolerance if not provided.
|
|
1653
|
+
* - `position_token`: Token of the existing position.
|
|
1651
1654
|
* - `position_amount`: Existing position amount in the position_token.
|
|
1652
1655
|
* - `position_debt`: Existing position debt in the token opposite to the position_token.
|
|
1653
|
-
* - `reduce_only`: Only allow reducing the existing position.
|
|
1654
1656
|
* - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1655
1657
|
* - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1656
1658
|
* - `fusion_pool`: Fusion pool.
|
|
@@ -1659,10 +1661,10 @@ exports.getIncreaseSpotPositionQuote = function(increase_amount, collateral_toke
|
|
|
1659
1661
|
* # Returns
|
|
1660
1662
|
* - `DecreaseSpotPositionQuoteResult`: quote result
|
|
1661
1663
|
*/
|
|
1662
|
-
exports.getDecreaseSpotPositionQuote = function(decrease_amount, collateral_token, leverage, reduce_only, position_token, position_amount, position_debt, protocol_fee_rate, protocol_fee_rate_on_collateral, fusion_pool, tick_arrays) {
|
|
1664
|
+
exports.getDecreaseSpotPositionQuote = function(decrease_amount, collateral_token, leverage, reduce_only, slippage_tolerance_bps, position_token, position_amount, position_debt, protocol_fee_rate, protocol_fee_rate_on_collateral, fusion_pool, tick_arrays) {
|
|
1663
1665
|
try {
|
|
1664
1666
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1665
|
-
wasm.getDecreaseSpotPositionQuote(retptr, decrease_amount,
|
|
1667
|
+
wasm.getDecreaseSpotPositionQuote(retptr, decrease_amount, collateral_token, leverage, reduce_only, isLikeNone(slippage_tolerance_bps) ? 0xFFFFFF : slippage_tolerance_bps, position_token, position_amount, position_debt, protocol_fee_rate, protocol_fee_rate_on_collateral, addHeapObject(fusion_pool), addHeapObject(tick_arrays));
|
|
1666
1668
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1667
1669
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1668
1670
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -1690,7 +1692,7 @@ exports.getDecreaseSpotPositionQuote = function(decrease_amount, collateral_toke
|
|
|
1690
1692
|
exports.getLiquidationPrice = function(position_token, amount, debt, liquidation_threshold) {
|
|
1691
1693
|
try {
|
|
1692
1694
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1693
|
-
wasm.getLiquidationPrice(retptr,
|
|
1695
|
+
wasm.getLiquidationPrice(retptr, position_token, amount, debt, liquidation_threshold);
|
|
1694
1696
|
var r0 = getDataViewMemory0().getFloat64(retptr + 8 * 0, true);
|
|
1695
1697
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1696
1698
|
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
@@ -1726,7 +1728,7 @@ exports.getLiquidationPrice = function(position_token, amount, debt, liquidation
|
|
|
1726
1728
|
exports.getTradableAmount = function(collateral_token, available_balance, leverage, new_position_token, reduce_only, position_token, position_amount, position_debt, protocol_fee_rate, protocol_fee_rate_on_collateral, fusion_pool, tick_arrays) {
|
|
1727
1729
|
try {
|
|
1728
1730
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1729
|
-
wasm.getTradableAmount(retptr,
|
|
1731
|
+
wasm.getTradableAmount(retptr, collateral_token, available_balance, leverage, new_position_token, reduce_only, position_token, position_amount, position_debt, protocol_fee_rate, protocol_fee_rate_on_collateral, addHeapObject(fusion_pool), addHeapObject(tick_arrays));
|
|
1730
1732
|
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1731
1733
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1732
1734
|
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
@@ -1799,11 +1801,6 @@ exports.__wbg___wbindgen_is_object_c818261d21f283a4 = function(arg0) {
|
|
|
1799
1801
|
return ret;
|
|
1800
1802
|
};
|
|
1801
1803
|
|
|
1802
|
-
exports.__wbg___wbindgen_is_string_fbb76cb2940daafd = function(arg0) {
|
|
1803
|
-
const ret = typeof(getObject(arg0)) === 'string';
|
|
1804
|
-
return ret;
|
|
1805
|
-
};
|
|
1806
|
-
|
|
1807
1804
|
exports.__wbg___wbindgen_is_undefined_2d472862bd29a478 = function(arg0) {
|
|
1808
1805
|
const ret = getObject(arg0) === undefined;
|
|
1809
1806
|
return ret;
|
|
@@ -1854,11 +1851,6 @@ exports.__wbg_done_2042aa2670fb1db1 = function(arg0) {
|
|
|
1854
1851
|
return ret;
|
|
1855
1852
|
};
|
|
1856
1853
|
|
|
1857
|
-
exports.__wbg_entries_e171b586f8f6bdbf = function(arg0) {
|
|
1858
|
-
const ret = Object.entries(getObject(arg0));
|
|
1859
|
-
return addHeapObject(ret);
|
|
1860
|
-
};
|
|
1861
|
-
|
|
1862
1854
|
exports.__wbg_get_7bed016f185add81 = function(arg0, arg1) {
|
|
1863
1855
|
const ret = getObject(arg0)[arg1 >>> 0];
|
|
1864
1856
|
return addHeapObject(ret);
|
|
Binary file
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const _INVALID_ARGUMENTS: (a: number) => void;
|
|
5
|
-
export const getIncreaseSpotPositionQuote: (a: number, b: bigint, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
6
|
-
export const getDecreaseSpotPositionQuote: (a: number, b: bigint, c: number, d: number, e: number, f: number, g:
|
|
5
|
+
export const getIncreaseSpotPositionQuote: (a: number, b: bigint, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
|
|
6
|
+
export const getDecreaseSpotPositionQuote: (a: number, b: bigint, c: number, d: number, e: number, f: number, g: number, h: bigint, i: bigint, j: number, k: number, l: number, m: number) => void;
|
|
7
7
|
export const getLiquidationPrice: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
8
8
|
export const getTradableAmount: (a: number, b: number, c: bigint, d: number, e: number, f: number, g: number, h: bigint, i: bigint, j: number, k: number, l: number, m: number) => void;
|
|
9
9
|
export const decreaseLiquidityQuote: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crypticdot/defituna-core",
|
|
3
3
|
"description": "DefiTuna core typescript package.",
|
|
4
|
-
"version": "3.2.
|
|
4
|
+
"version": "3.2.3",
|
|
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.2.
|
|
26
|
+
"@crypticdot/defituna-rust-core": "3.2.3"
|
|
27
27
|
},
|
|
28
28
|
"license": "SEE LICENSE IN LICENSE",
|
|
29
29
|
"keywords": [
|