@7kprotocol/sdk-ts 2.4.1 → 2.4.2-beta.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/README.md +30 -3
- package/lib/cjs/config/fetchClient.js +11 -19
- package/lib/cjs/config/index.js +22 -0
- package/lib/cjs/constants/_7k.js +6 -3
- package/lib/cjs/features/limitDca/cancelDcaOrder.js +7 -18
- package/lib/cjs/features/limitDca/cancelLimitOrder.js +7 -18
- package/lib/cjs/features/limitDca/claimExpiredLimitOrder.js +7 -18
- package/lib/cjs/features/limitDca/constants.js +1 -5
- package/lib/cjs/features/limitDca/getClosedDcaOrders.js +16 -27
- package/lib/cjs/features/limitDca/getClosedLimitOrders.js +15 -26
- package/lib/cjs/features/limitDca/getDcaOrderExecutions.js +16 -27
- package/lib/cjs/features/limitDca/getOpenDcaOrders.js +15 -26
- package/lib/cjs/features/limitDca/getOpenLimitOrders.js +15 -26
- package/lib/cjs/features/limitDca/placeDcaOrder.js +25 -36
- package/lib/cjs/features/limitDca/placeLimitOrder.js +14 -25
- package/lib/cjs/features/prices/index.js +47 -64
- package/lib/cjs/features/swap/buildTx.js +88 -39
- package/lib/cjs/features/swap/config.js +32 -32
- package/lib/cjs/features/swap/estimateGasFee.js +36 -46
- package/lib/cjs/features/swap/executeTx.js +52 -0
- package/lib/cjs/features/swap/getQuote.js +41 -31
- package/lib/cjs/features/swap/getSwapHistory.js +14 -25
- package/lib/cjs/features/swap/index.js +1 -0
- package/lib/cjs/index.js +16 -9
- package/lib/cjs/libs/getCoinOjectIdsByAmount.js +15 -24
- package/lib/cjs/libs/getSplitCoinForTx.js +8 -15
- package/lib/cjs/libs/groupSwapRoutes.js +10 -12
- package/lib/cjs/libs/protocols/aftermath/index.js +25 -36
- package/lib/cjs/libs/protocols/base.js +10 -3
- package/lib/cjs/libs/protocols/bluefin/index.js +26 -43
- package/lib/cjs/libs/protocols/bluefinx/client.js +35 -0
- package/lib/cjs/libs/protocols/bluefinx/index.js +48 -0
- package/lib/cjs/libs/protocols/bluefinx/types.js +10 -0
- package/lib/cjs/libs/protocols/bluemove/index.js +14 -25
- package/lib/cjs/libs/protocols/cetus/index.js +32 -43
- package/lib/cjs/libs/protocols/deepbookV3/sponsored.js +19 -30
- package/lib/cjs/libs/protocols/flowx/index.js +9 -20
- package/lib/cjs/libs/protocols/flowxV3/index.js +25 -39
- package/lib/cjs/libs/protocols/haedal_pmm/index.js +33 -0
- package/lib/cjs/libs/protocols/index.js +7 -2
- package/lib/cjs/libs/protocols/kriya/index.js +20 -31
- package/lib/cjs/libs/protocols/kriyaV3/index.js +54 -65
- package/lib/cjs/libs/protocols/magma/index.js +28 -40
- package/lib/cjs/libs/protocols/momentum/index.js +49 -0
- package/lib/cjs/libs/protocols/obric/index.js +20 -31
- package/lib/cjs/libs/protocols/springsui/index.js +14 -25
- package/lib/cjs/libs/protocols/steamm/index.js +57 -58
- package/lib/cjs/libs/protocols/stsui/index.js +14 -25
- package/lib/cjs/libs/protocols/suiswap/index.js +23 -34
- package/lib/cjs/libs/protocols/turbos/index.js +23 -38
- package/lib/cjs/libs/protocols/utils.js +1 -5
- package/lib/cjs/libs/swapWithRoute.js +17 -27
- package/lib/cjs/types/aggregator.js +17 -0
- package/lib/cjs/types/config/index.d.ts +9 -0
- package/lib/cjs/types/config/index.d.ts.map +1 -1
- package/lib/cjs/types/constants/_7k.d.ts +3 -3
- package/lib/cjs/types/constants/_7k.d.ts.map +1 -1
- package/lib/cjs/types/features/limitDca/constants.d.ts +1 -2
- package/lib/cjs/types/features/limitDca/constants.d.ts.map +1 -1
- package/lib/cjs/types/features/swap/buildTx.d.ts +2 -5
- package/lib/cjs/types/features/swap/buildTx.d.ts.map +1 -1
- package/lib/cjs/types/features/swap/config.d.ts.map +1 -1
- package/lib/cjs/types/features/swap/estimateGasFee.d.ts.map +1 -1
- package/lib/cjs/types/features/swap/executeTx.d.ts +24 -0
- package/lib/cjs/types/features/swap/executeTx.d.ts.map +1 -0
- package/lib/cjs/types/features/swap/getQuote.d.ts +8 -1
- package/lib/cjs/types/features/swap/getQuote.d.ts.map +1 -1
- package/lib/cjs/types/features/swap/index.d.ts +1 -0
- package/lib/cjs/types/features/swap/index.d.ts.map +1 -1
- package/lib/cjs/types/index.d.ts +13 -8
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/libs/getCoinOjectIdsByAmount.d.ts.map +1 -1
- package/lib/cjs/types/libs/getSplitCoinForTx.d.ts.map +1 -1
- package/lib/cjs/types/libs/groupSwapRoutes.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/base.d.ts +6 -2
- package/lib/cjs/types/libs/protocols/base.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/bluefin/index.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/bluefinx/client.d.ts +13 -0
- package/lib/cjs/types/libs/protocols/bluefinx/client.d.ts.map +1 -0
- package/lib/cjs/types/libs/protocols/bluefinx/index.d.ts +17 -0
- package/lib/cjs/types/libs/protocols/bluefinx/index.d.ts.map +1 -0
- package/lib/cjs/types/libs/protocols/bluefinx/types.d.ts +34 -0
- package/lib/cjs/types/libs/protocols/bluefinx/types.d.ts.map +1 -0
- package/lib/cjs/types/libs/protocols/cetus/index.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/deepbookV3/sponsored.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/flowxV3/index.d.ts.map +1 -1
- package/lib/{esm/types/libs/protocols/deepbook → cjs/types/libs/protocols/haedal_pmm}/index.d.ts +1 -3
- package/lib/cjs/types/libs/protocols/haedal_pmm/index.d.ts.map +1 -0
- package/lib/cjs/types/libs/protocols/index.d.ts +7 -2
- package/lib/cjs/types/libs/protocols/index.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/magma/index.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/{deepbook → momentum}/index.d.ts +1 -3
- package/lib/cjs/types/libs/protocols/momentum/index.d.ts.map +1 -0
- package/lib/cjs/types/libs/protocols/steamm/index.d.ts +13 -2
- package/lib/cjs/types/libs/protocols/steamm/index.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/suiswap/index.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/turbos/index.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/utils.d.ts +1 -2
- package/lib/cjs/types/libs/protocols/utils.d.ts.map +1 -1
- package/lib/cjs/types/libs/swapWithRoute.d.ts +3 -1
- package/lib/cjs/types/libs/swapWithRoute.d.ts.map +1 -1
- package/lib/cjs/types/types/aggregator.d.ts +36 -2
- package/lib/cjs/types/types/aggregator.d.ts.map +1 -1
- package/lib/cjs/types/types/tx.d.ts +1 -2
- package/lib/cjs/types/types/tx.d.ts.map +1 -1
- package/lib/cjs/types/utils/number.d.ts +1 -3
- package/lib/cjs/types/utils/number.d.ts.map +1 -1
- package/lib/cjs/types/utils/sui.d.ts +1 -1
- package/lib/cjs/types/utils/sui.d.ts.map +1 -1
- package/lib/cjs/utils/number.js +4 -10
- package/lib/cjs/utils/sui.js +71 -80
- package/lib/esm/config/index.js +22 -0
- package/lib/esm/constants/_7k.js +6 -3
- package/lib/esm/features/limitDca/constants.js +1 -2
- package/lib/esm/features/swap/buildTx.js +81 -20
- package/lib/esm/features/swap/config.js +19 -8
- package/lib/esm/features/swap/estimateGasFee.js +13 -9
- package/lib/esm/features/swap/executeTx.js +48 -0
- package/lib/esm/features/swap/getQuote.js +24 -3
- package/lib/esm/features/swap/index.js +1 -0
- package/lib/esm/index.mjs +8 -4
- package/lib/esm/libs/getCoinOjectIdsByAmount.js +7 -7
- package/lib/esm/libs/getSplitCoinForTx.js +4 -2
- package/lib/esm/libs/groupSwapRoutes.js +1 -2
- package/lib/esm/libs/protocols/base.js +10 -1
- package/lib/esm/libs/protocols/bluefin/index.js +2 -5
- package/lib/esm/libs/protocols/bluefinx/client.js +30 -0
- package/lib/esm/libs/protocols/bluefinx/index.js +44 -0
- package/lib/esm/libs/protocols/bluefinx/types.js +8 -0
- package/lib/esm/libs/protocols/cetus/index.js +1 -1
- package/lib/esm/libs/protocols/deepbookV3/sponsored.js +1 -1
- package/lib/esm/libs/protocols/flowxV3/index.js +1 -4
- package/lib/esm/libs/protocols/haedal_pmm/index.js +29 -0
- package/lib/esm/libs/protocols/index.js +7 -2
- package/lib/esm/libs/protocols/magma/index.js +1 -2
- package/lib/esm/libs/protocols/momentum/index.js +45 -0
- package/lib/esm/libs/protocols/steamm/index.js +58 -48
- package/lib/esm/libs/protocols/suiswap/index.js +1 -1
- package/lib/esm/libs/protocols/turbos/index.js +2 -6
- package/lib/esm/libs/protocols/utils.js +1 -2
- package/lib/esm/libs/swapWithRoute.js +2 -1
- package/lib/esm/types/aggregator.js +14 -1
- package/lib/esm/types/config/index.d.ts +9 -0
- package/lib/esm/types/config/index.d.ts.map +1 -1
- package/lib/esm/types/constants/_7k.d.ts +3 -3
- package/lib/esm/types/constants/_7k.d.ts.map +1 -1
- package/lib/esm/types/features/limitDca/constants.d.ts +1 -2
- package/lib/esm/types/features/limitDca/constants.d.ts.map +1 -1
- package/lib/esm/types/features/swap/buildTx.d.ts +2 -5
- package/lib/esm/types/features/swap/buildTx.d.ts.map +1 -1
- package/lib/esm/types/features/swap/config.d.ts.map +1 -1
- package/lib/esm/types/features/swap/estimateGasFee.d.ts.map +1 -1
- package/lib/esm/types/features/swap/executeTx.d.ts +24 -0
- package/lib/esm/types/features/swap/executeTx.d.ts.map +1 -0
- package/lib/esm/types/features/swap/getQuote.d.ts +8 -1
- package/lib/esm/types/features/swap/getQuote.d.ts.map +1 -1
- package/lib/esm/types/features/swap/index.d.ts +1 -0
- package/lib/esm/types/features/swap/index.d.ts.map +1 -1
- package/lib/esm/types/index.d.ts +13 -8
- package/lib/esm/types/index.d.ts.map +1 -1
- package/lib/esm/types/libs/getCoinOjectIdsByAmount.d.ts.map +1 -1
- package/lib/esm/types/libs/getSplitCoinForTx.d.ts.map +1 -1
- package/lib/esm/types/libs/groupSwapRoutes.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/base.d.ts +6 -2
- package/lib/esm/types/libs/protocols/base.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/bluefin/index.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/bluefinx/client.d.ts +13 -0
- package/lib/esm/types/libs/protocols/bluefinx/client.d.ts.map +1 -0
- package/lib/esm/types/libs/protocols/bluefinx/index.d.ts +17 -0
- package/lib/esm/types/libs/protocols/bluefinx/index.d.ts.map +1 -0
- package/lib/esm/types/libs/protocols/bluefinx/types.d.ts +34 -0
- package/lib/esm/types/libs/protocols/bluefinx/types.d.ts.map +1 -0
- package/lib/esm/types/libs/protocols/cetus/index.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/deepbookV3/sponsored.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/flowxV3/index.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/haedal_pmm/index.d.ts +9 -0
- package/lib/esm/types/libs/protocols/haedal_pmm/index.d.ts.map +1 -0
- package/lib/esm/types/libs/protocols/index.d.ts +7 -2
- package/lib/esm/types/libs/protocols/index.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/magma/index.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/momentum/index.d.ts +9 -0
- package/lib/esm/types/libs/protocols/momentum/index.d.ts.map +1 -0
- package/lib/esm/types/libs/protocols/steamm/index.d.ts +13 -2
- package/lib/esm/types/libs/protocols/steamm/index.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/suiswap/index.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/turbos/index.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/utils.d.ts +1 -2
- package/lib/esm/types/libs/protocols/utils.d.ts.map +1 -1
- package/lib/esm/types/libs/swapWithRoute.d.ts +3 -1
- package/lib/esm/types/libs/swapWithRoute.d.ts.map +1 -1
- package/lib/esm/types/types/aggregator.d.ts +36 -2
- package/lib/esm/types/types/aggregator.d.ts.map +1 -1
- package/lib/esm/types/types/tx.d.ts +1 -2
- package/lib/esm/types/types/tx.d.ts.map +1 -1
- package/lib/esm/types/utils/number.d.ts +1 -3
- package/lib/esm/types/utils/number.d.ts.map +1 -1
- package/lib/esm/types/utils/sui.d.ts +1 -1
- package/lib/esm/types/utils/sui.d.ts.map +1 -1
- package/lib/esm/utils/number.js +4 -6
- package/lib/esm/utils/sui.js +4 -3
- package/package.json +14 -15
- package/lib/cjs/libs/protocols/deepbook/index.js +0 -96
- package/lib/cjs/types/libs/protocols/deepbook/index.d.ts.map +0 -1
- package/lib/esm/libs/protocols/deepbook/index.js +0 -80
- package/lib/esm/types/libs/protocols/deepbook/index.d.ts.map +0 -1
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { BaseContract } from "../base";
|
|
2
|
-
import { normalizeStructTag, parseStructTag, SUI_CLOCK_OBJECT_ID, } from "@mysten/sui/utils";
|
|
2
|
+
import { normalizeStructTag, parseStructTag, SUI_CLOCK_OBJECT_ID, toHex, } from "@mysten/sui/utils";
|
|
3
3
|
import { SuiUtils } from "../../../utils/sui";
|
|
4
4
|
export class SteammContract extends BaseContract {
|
|
5
5
|
async swap(tx) {
|
|
6
|
-
|
|
6
|
+
if (this.extra.poolStructTag.includes("omm::OracleQuoter")) {
|
|
7
|
+
return this.ommSwap(tx);
|
|
8
|
+
}
|
|
9
|
+
else if (this.extra.poolStructTag.includes("cpmm::CpQuoter")) {
|
|
10
|
+
return this.cpmmSwap(tx);
|
|
11
|
+
}
|
|
12
|
+
throw new Error(`Unsupported pool type: ${this.extra.poolStructTag}`);
|
|
7
13
|
}
|
|
8
14
|
cpmmSwap(tx) {
|
|
9
|
-
const extra = this.
|
|
15
|
+
const extra = this.extra;
|
|
10
16
|
if (!extra ||
|
|
11
17
|
!extra.bankAStructTag ||
|
|
12
18
|
!extra.bankBStructTag ||
|
|
@@ -56,10 +62,10 @@ export class SteammContract extends BaseContract {
|
|
|
56
62
|
});
|
|
57
63
|
const coinIn = xToY ? coinA : coinB;
|
|
58
64
|
const coinOut = xToY ? coinB : coinA;
|
|
59
|
-
SuiUtils.
|
|
65
|
+
SuiUtils.collectDust(tx, this.swapInfo.assetIn, coinIn);
|
|
60
66
|
return coinOut;
|
|
61
67
|
}
|
|
62
|
-
|
|
68
|
+
ommSwap(tx) {
|
|
63
69
|
const extra = this.swapInfo.extra;
|
|
64
70
|
if (!extra ||
|
|
65
71
|
!extra.bankAStructTag ||
|
|
@@ -73,71 +79,75 @@ export class SteammContract extends BaseContract {
|
|
|
73
79
|
}
|
|
74
80
|
// the pool script v1 only support same lending market
|
|
75
81
|
if (extra.lendingMarketA !== extra.lendingMarketB) {
|
|
76
|
-
throw new Error(`Invalid lending market for
|
|
82
|
+
throw new Error(`Invalid lending market for ommSwap`);
|
|
77
83
|
}
|
|
78
84
|
const [btokenA, bTokenB, _quoter, lp] = parseStructTag(extra.poolStructTag).typeParams;
|
|
79
85
|
const [lendingMarket, coinTypeA, _bTokenA] = parseStructTag(extra.bankAStructTag).typeParams;
|
|
80
86
|
const [_lendingMarket, coinTypeB, _bTokenB] = parseStructTag(extra.bankBStructTag).typeParams;
|
|
81
|
-
const
|
|
82
|
-
const xToY = coinX.address === this.swapInfo.assetIn;
|
|
87
|
+
const xToY = this.swapInfo.swapXtoY;
|
|
83
88
|
const coinA = xToY
|
|
84
89
|
? this.inputCoinObject
|
|
85
90
|
: SuiUtils.zeroCoin(tx, normalizeStructTag(coinTypeA));
|
|
86
91
|
const coinB = !xToY
|
|
87
92
|
? this.inputCoinObject
|
|
88
93
|
: SuiUtils.zeroCoin(tx, normalizeStructTag(coinTypeB));
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
const [priceA, priceB] = this.getOraclePriceUpdate(tx);
|
|
95
|
+
tx.moveCall({
|
|
96
|
+
target: `${this.config.steamm.script}::pool_script_v2::omm_swap`,
|
|
97
|
+
typeArguments: [
|
|
98
|
+
lendingMarket,
|
|
99
|
+
coinTypeA,
|
|
100
|
+
coinTypeB,
|
|
101
|
+
btokenA,
|
|
102
|
+
bTokenB,
|
|
103
|
+
lp,
|
|
104
|
+
].map(normalizeStructTag),
|
|
97
105
|
arguments: [
|
|
98
|
-
tx.object(
|
|
106
|
+
tx.object(this.swapInfo.poolId),
|
|
107
|
+
tx.object(extra.bankA),
|
|
108
|
+
tx.object(extra.bankB),
|
|
99
109
|
tx.object(extra.lendingMarketA),
|
|
100
|
-
|
|
110
|
+
priceA,
|
|
111
|
+
priceB,
|
|
112
|
+
coinA,
|
|
113
|
+
coinB,
|
|
114
|
+
tx.pure.bool(xToY),
|
|
101
115
|
this.getInputCoinValue(tx),
|
|
116
|
+
tx.pure.u64(0),
|
|
102
117
|
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
103
118
|
],
|
|
104
119
|
});
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
tx.
|
|
108
|
-
|
|
109
|
-
|
|
120
|
+
const coinIn = xToY ? coinA : coinB;
|
|
121
|
+
const coinOut = xToY ? coinB : coinA;
|
|
122
|
+
SuiUtils.collectDust(tx, this.swapInfo.assetIn, coinIn);
|
|
123
|
+
return coinOut;
|
|
124
|
+
}
|
|
125
|
+
getOraclePriceUpdate(tx) {
|
|
126
|
+
const oracleA = this.extra.oracles?.[0]?.Pyth?.price_identifier?.bytes;
|
|
127
|
+
const oracleB = this.extra.oracles?.[1]?.Pyth?.price_identifier?.bytes;
|
|
128
|
+
const registry = this.extra.oracleRegistry;
|
|
129
|
+
const indexes = this.extra.oracleIndexes;
|
|
130
|
+
if (!oracleA || !oracleB || !registry || indexes?.length !== 2) {
|
|
131
|
+
throw new Error(`Invalid oracle info for getOraclePriceUpdate`);
|
|
132
|
+
}
|
|
133
|
+
const [a] = tx.moveCall({
|
|
134
|
+
target: `${this.config.steamm.oracle}::oracles::get_pyth_price`,
|
|
110
135
|
arguments: [
|
|
111
|
-
tx.object(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
tx.
|
|
115
|
-
SuiUtils.getCoinValue(normalizeStructTag(xToY ? btokenA : bTokenB), bTokenIn, tx),
|
|
116
|
-
tx.pure.u64(0), // min output
|
|
136
|
+
tx.object(registry),
|
|
137
|
+
tx.object(this.pythMap["0x" + toHex(Uint8Array.from(oracleA))]),
|
|
138
|
+
tx.pure.u64(indexes[0]),
|
|
139
|
+
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
117
140
|
],
|
|
118
141
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
target: `${this.config.steamm.package}::bank::burn_btokens`,
|
|
122
|
-
typeArguments: bankOutTypeArgs,
|
|
142
|
+
const [b] = tx.moveCall({
|
|
143
|
+
target: `${this.config.steamm.oracle}::oracles::get_pyth_price`,
|
|
123
144
|
arguments: [
|
|
124
|
-
tx.object(
|
|
125
|
-
tx.object(
|
|
126
|
-
|
|
127
|
-
SuiUtils.getCoinValue(normalizeStructTag(xToY ? bTokenB : btokenA), bTokenOut, tx),
|
|
145
|
+
tx.object(registry),
|
|
146
|
+
tx.object(this.pythMap["0x" + toHex(Uint8Array.from(oracleB))]),
|
|
147
|
+
tx.pure.u64(indexes[1]),
|
|
128
148
|
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
129
149
|
],
|
|
130
150
|
});
|
|
131
|
-
|
|
132
|
-
const coinOut = xToY ? coinB : coinA;
|
|
133
|
-
// the coinIn was mutated by mint_btokens above, but not consumed, so we need to transfer or destroy it
|
|
134
|
-
SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, coinIn, this.currentAccount);
|
|
135
|
-
// bTokenIn was mutated by cpmm::swap above, but not consumed, so we need to transfer or destroy it
|
|
136
|
-
SuiUtils.transferOrDestroyZeroCoin(tx, normalizeStructTag(xToY ? btokenA : bTokenB), bTokenIn, this.currentAccount);
|
|
137
|
-
// bTokenOut was burned by burn_btokens above, but not consumed, so we need to transfer or destroy it
|
|
138
|
-
SuiUtils.transferOrDestroyZeroCoin(tx, normalizeStructTag(xToY ? bTokenB : btokenA), bTokenOut, this.currentAccount);
|
|
139
|
-
// after all we need to merge the placeholder output coin (zero) with actual output coin from swap burn
|
|
140
|
-
tx.mergeCoins(coinOut, [outCoin]);
|
|
141
|
-
return coinOut;
|
|
151
|
+
return [a, b];
|
|
142
152
|
}
|
|
143
153
|
}
|
|
@@ -24,7 +24,7 @@ export class SuiswapContract extends BaseContract {
|
|
|
24
24
|
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
25
25
|
],
|
|
26
26
|
});
|
|
27
|
-
SuiUtils.
|
|
27
|
+
SuiUtils.collectDust(tx, this.swapInfo.assetIn, tokenIn);
|
|
28
28
|
return tokenOut;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -6,17 +6,13 @@ const ONE_MINUTE = 60 * 1000;
|
|
|
6
6
|
export class TurbosContract extends BaseContract {
|
|
7
7
|
async swap(tx) {
|
|
8
8
|
const a2b = this.swapInfo.swapXtoY;
|
|
9
|
-
const { poolId, address } = {
|
|
10
|
-
poolId: this.swapInfo.poolId,
|
|
11
|
-
address: this.currentAccount,
|
|
12
|
-
};
|
|
13
9
|
const { package: PACKAGE_ID, version: VERSION } = this.config.turbos;
|
|
14
10
|
const inputAmount = this.getInputCoinValue(tx);
|
|
15
11
|
const [tokenOut, tokenIn] = tx.moveCall({
|
|
16
12
|
target: `${PACKAGE_ID}::swap_router::swap_${a2b ? "a_b" : "b_a"}_with_return_`,
|
|
17
13
|
typeArguments: this.getTypeParams(),
|
|
18
14
|
arguments: [
|
|
19
|
-
tx.object(poolId),
|
|
15
|
+
tx.object(this.swapInfo.poolId),
|
|
20
16
|
tx.makeMoveVec({
|
|
21
17
|
elements: [this.inputCoinObject],
|
|
22
18
|
}),
|
|
@@ -30,7 +26,7 @@ export class TurbosContract extends BaseContract {
|
|
|
30
26
|
tx.object(VERSION),
|
|
31
27
|
],
|
|
32
28
|
});
|
|
33
|
-
SuiUtils.
|
|
29
|
+
SuiUtils.collectDust(tx, this.swapInfo.assetIn, tokenIn);
|
|
34
30
|
return tokenOut;
|
|
35
31
|
}
|
|
36
32
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProtocolContract } from "./protocols";
|
|
2
|
-
export async function swapWithRoute({ route, inputCoinObject, currentAccount, config, tx, }) {
|
|
2
|
+
export async function swapWithRoute({ route, inputCoinObject, currentAccount, config, pythMap, tx, }) {
|
|
3
3
|
let inputTokenObject = inputCoinObject;
|
|
4
4
|
let txbResultToReturn;
|
|
5
5
|
for (const swap of route) {
|
|
@@ -9,6 +9,7 @@ export async function swapWithRoute({ route, inputCoinObject, currentAccount, co
|
|
|
9
9
|
inputCoinObject: inputTokenObject,
|
|
10
10
|
currentAccount,
|
|
11
11
|
config,
|
|
12
|
+
pythMap,
|
|
12
13
|
});
|
|
13
14
|
const tokenOut = await contractInstance.swap(tx);
|
|
14
15
|
inputTokenObject = tokenOut;
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { Transaction, } from "@mysten/sui/transactions";
|
|
2
|
+
import { BluefinXTx } from "../libs/protocols/bluefinx/types";
|
|
3
|
+
export { BluefinXTx };
|
|
4
|
+
export const isSuiTransaction = (tx) => tx instanceof Transaction;
|
|
5
|
+
/**
|
|
6
|
+
* Check if the sor response is a bluefinx routing
|
|
7
|
+
* @param sor
|
|
8
|
+
* @returns boolean
|
|
9
|
+
*/
|
|
10
|
+
export const isBluefinXRouting = (sor) => {
|
|
11
|
+
return (sor.routes?.length === 1 &&
|
|
12
|
+
sor.routes[0].hops.length === 1 &&
|
|
13
|
+
sor.routes[0].hops[0].pool.type === "bluefinx");
|
|
14
|
+
};
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import { SuiClient } from "@mysten/sui/client";
|
|
2
|
+
import { SuiPriceServiceConnection, SuiPythClient } from "@pythnetwork/pyth-sui-js";
|
|
2
3
|
declare function setApiKey(key: string): void;
|
|
3
4
|
declare function getApiKey(): string;
|
|
4
5
|
declare function getSuiClient(): SuiClient;
|
|
5
6
|
declare function setSuiClient(client: SuiClient): void;
|
|
7
|
+
declare function setPythClient(client: SuiPythClient): void;
|
|
8
|
+
declare function getPythClient(): SuiPythClient;
|
|
9
|
+
declare function setPythConnection(connection: SuiPriceServiceConnection): void;
|
|
10
|
+
declare function getPythConnection(): SuiPriceServiceConnection;
|
|
6
11
|
declare const Config: {
|
|
7
12
|
setApiKey: typeof setApiKey;
|
|
8
13
|
getApiKey: typeof getApiKey;
|
|
9
14
|
setSuiClient: typeof setSuiClient;
|
|
10
15
|
getSuiClient: typeof getSuiClient;
|
|
16
|
+
setPythClient: typeof setPythClient;
|
|
17
|
+
getPythClient: typeof getPythClient;
|
|
18
|
+
setPythConnection: typeof setPythConnection;
|
|
19
|
+
getPythConnection: typeof getPythConnection;
|
|
11
20
|
};
|
|
12
21
|
export { Config };
|
|
13
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EACL,yBAAyB,EACzB,aAAa,EACd,MAAM,0BAA0B,CAAC;AAqBlC,iBAAS,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEpC;AAED,iBAAS,SAAS,IAAI,MAAM,CAE3B;AAED,iBAAS,YAAY,IAAI,SAAS,CAEjC;AAED,iBAAS,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAE7C;AAED,iBAAS,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAElD;AAED,iBAAS,aAAa,IAAI,aAAa,CAEtC;AAED,iBAAS,iBAAiB,CAAC,UAAU,EAAE,yBAAyB,GAAG,IAAI,CAEtE;AAED,iBAAS,iBAAiB,IAAI,yBAAyB,CAEtD;AAED,QAAA,MAAM,MAAM;;;;;;;;;CASX,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const _7K_PACKAGE_ID = "
|
|
2
|
-
export declare const _7K_CONFIG = "
|
|
3
|
-
export declare const _7K_VAULT = "
|
|
1
|
+
export declare const _7K_PACKAGE_ID = "0xe8f996ea6ff38c557c253d3b93cfe2ebf393816487266786371aa4532a9229f2";
|
|
2
|
+
export declare const _7K_CONFIG = "0x47442a93f7727d188ba7cb71031170d1786af70013cb7ad5115f3fe877ff0c54";
|
|
3
|
+
export declare const _7K_VAULT = "0x442ad50389ed5cda6f7a6f5a7ae6361a4c05ef1d9fb2e54fbba5a268d690bfe6";
|
|
4
4
|
//# sourceMappingURL=_7k.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_7k.d.ts","sourceRoot":"","sources":["../../../../src/constants/_7k.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,uEAC2C,CAAC;
|
|
1
|
+
{"version":3,"file":"_7k.d.ts","sourceRoot":"","sources":["../../../../src/constants/_7k.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,uEAC2C,CAAC;AAIvE,eAAO,MAAM,UAAU,uEAC+C,CAAC;AAGvE,eAAO,MAAM,SAAS,uEACgD,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import BigNumber from "bignumber.js";
|
|
2
1
|
export declare const GLOBAL_CONFIG_ID = "0xffc7f420b481ed7a012b42e125fd7e5716b5673759cf4629e5fcfebce970a72d";
|
|
3
2
|
export declare const RATE_SCALE: bigint;
|
|
4
3
|
export declare const SLIPPAGE_SCALE: bigint;
|
|
@@ -6,6 +5,6 @@ export declare const PACKAGE = "0x0ef0f805710cf53c10f29c4f73e1144a662747e1839689
|
|
|
6
5
|
export declare const LIMIT_ORDER_MODULE_ID = "0x0ef0f805710cf53c10f29c4f73e1144a662747e1839689a846e2520cae122adc::limit_order";
|
|
7
6
|
export declare const DCA_ORDER_MODULE_ID = "0x0ef0f805710cf53c10f29c4f73e1144a662747e1839689a846e2520cae122adc::dca_order";
|
|
8
7
|
export declare const CONFIG_MODULE_ID = "0x0ef0f805710cf53c10f29c4f73e1144a662747e1839689a846e2520cae122adc::config";
|
|
9
|
-
export declare const DCA_MAX_RATE:
|
|
8
|
+
export declare const DCA_MAX_RATE: bigint;
|
|
10
9
|
export declare const LO_DCA_API: string;
|
|
11
10
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/features/limitDca/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/features/limitDca/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB,uEACyC,CAAC;AACvE,eAAO,MAAM,UAAU,QAA0B,CAAC;AAClD,eAAO,MAAM,cAAc,QAAkB,CAAC;AAC9C,eAAO,MAAM,OAAO,uEACkD,CAAC;AACvE,eAAO,MAAM,qBAAqB,oFAA4B,CAAC;AAC/D,eAAO,MAAM,mBAAmB,kFAA0B,CAAC;AAC3D,eAAO,MAAM,gBAAgB,+EAAuB,CAAC;AACrD,eAAO,MAAM,YAAY,QAAiC,CAAC;AAC3D,eAAO,MAAM,UAAU,QAAgC,CAAC"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BuildTxResult } from "../../types/aggregator";
|
|
2
2
|
import { BuildTxParams } from "../../types/tx";
|
|
3
|
-
export declare const buildTx: ({ quoteResponse, accountAddress, slippage, commission:
|
|
4
|
-
tx: Transaction;
|
|
5
|
-
coinOut: TransactionObjectArgument | undefined;
|
|
6
|
-
}>;
|
|
3
|
+
export declare const buildTx: ({ quoteResponse, accountAddress, slippage, commission: __commission, devInspect, extendTx, isSponsored, }: BuildTxParams) => Promise<BuildTxResult>;
|
|
7
4
|
//# sourceMappingURL=buildTx.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildTx.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/buildTx.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildTx.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/buildTx.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,aAAa,EAGd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAK/C,eAAO,MAAM,OAAO,GAAU,2GAQ3B,aAAa,KAAG,OAAO,CAAC,aAAa,CAuIvC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,eAAO,MAAM,cAAc,EAAE,MAyI5B,CAAC;AAGF,wBAAsB,SAAS,oBAe9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"estimateGasFee.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/estimateGasFee.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"estimateGasFee.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/estimateGasFee.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAMtD,wBAAsB,cAAc,CAAC,EACnC,aAAa,EACb,cAAc,EACd,QAAQ,EACR,QAAQ,EAAE,SAAS,EACnB,QAAQ,EACR,UAAU,GACX,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,CAwCxC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SuiTransactionBlockResponse, SuiTransactionBlockResponseOptions } from "@mysten/sui/client";
|
|
2
|
+
import { AggregatorTx } from "../../types/aggregator";
|
|
3
|
+
/**
|
|
4
|
+
* Execute a transaction after it is signed
|
|
5
|
+
*
|
|
6
|
+
* Automatically handle BluefinX transaction execution if needed
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const { mutateAsync: signTransaction } = useSignTransaction();
|
|
10
|
+
* const quoteResponse = await getQuote(...quoteParams);
|
|
11
|
+
* const { tx } = await buildTx(...buildTxParams);
|
|
12
|
+
* const {signature, bytes} = await signTransaction({
|
|
13
|
+
* transaction: tx instanceof BluefinXTx ? tx.txBytes : tx,
|
|
14
|
+
* });
|
|
15
|
+
* const res = await executeTx(tx, signature, bytes);
|
|
16
|
+
* ```
|
|
17
|
+
* @param tx - AggregatorTx - received from `buildTx`
|
|
18
|
+
* @param signature - User signature after signing the transaction
|
|
19
|
+
* @param signedTxBytes - Signed transaction bytes after signing the transaction
|
|
20
|
+
* @param options - Options for the transaction
|
|
21
|
+
* @returns `SuiTransactionBlockResponse`
|
|
22
|
+
*/
|
|
23
|
+
export declare const executeTx: (tx: AggregatorTx, signature: string, signedTxBytes: string, options?: SuiTransactionBlockResponseOptions) => Promise<SuiTransactionBlockResponse>;
|
|
24
|
+
//# sourceMappingURL=executeTx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executeTx.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/executeTx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,kCAAkC,EACnC,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,SAAS,GACpB,IAAI,YAAY,EAChB,WAAW,MAAM,EACjB,eAAe,MAAM,EACrB,UAAU,kCAAkC,yCA0B7C,CAAC"}
|
|
@@ -3,13 +3,20 @@ interface Params {
|
|
|
3
3
|
tokenIn: string;
|
|
4
4
|
tokenOut: string;
|
|
5
5
|
amountIn: string;
|
|
6
|
+
/**
|
|
7
|
+
* @default DEFAULT_SOURCES
|
|
8
|
+
* @warning BluefinX must be explicitly specified if needed
|
|
9
|
+
* @example ```sources: [...DEFAULT_SOURCES, "bluefinx"]``` */
|
|
6
10
|
sources?: SourceDex[];
|
|
11
|
+
commissionBps?: number;
|
|
7
12
|
/** Limit the route to a specific set of pools */
|
|
8
13
|
targetPools?: string[];
|
|
9
14
|
/** Exclude a specific set of pools from the route */
|
|
10
15
|
excludedPools?: string[];
|
|
16
|
+
/** The taker address, required for bluefinx */
|
|
17
|
+
taker?: string;
|
|
11
18
|
}
|
|
12
19
|
export declare const DEFAULT_SOURCES: SourceDex[];
|
|
13
|
-
export declare function getQuote({ tokenIn, tokenOut, amountIn, sources, targetPools, excludedPools, }: Params): Promise<QuoteResponse>;
|
|
20
|
+
export declare function getQuote({ tokenIn, tokenOut, amountIn, sources, commissionBps, targetPools, excludedPools, taker, }: Params): Promise<QuoteResponse>;
|
|
14
21
|
export {};
|
|
15
22
|
//# sourceMappingURL=getQuote.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getQuote.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/getQuote.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getQuote.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/getQuote.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqB,aAAa,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAErF,UAAU,MAAM;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB;;;kEAG8D;IAC9D,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,qDAAqD;IACrD,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,eAAe,EAAE,SAAS,EAoBtC,CAAC;AAEF,wBAAsB,QAAQ,CAAC,EAC7B,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,OAAyB,EACzB,aAAa,EACb,WAAW,EACX,aAAa,EACb,KAAK,GACN,EAAE,MAAM,0BA+BR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
|
package/lib/esm/types/index.d.ts
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
export * from "./types/aggregator";
|
|
2
2
|
import { Config } from "./config";
|
|
3
|
-
import { getTokenPrice, getTokenPrices
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { getSuiPrice, getTokenPrice, getTokenPrices } from "./features/prices";
|
|
4
|
+
import { executeBluefinTx } from "./libs/protocols/bluefinx/client";
|
|
5
|
+
import { buildTx, estimateGasFee, executeTx, getQuote, getSwapHistory, DEFAULT_SOURCES } from "./features/swap";
|
|
6
|
+
import { cancelDcaOrder, cancelLimitOrder, claimExpiredLimitOrder, getClosedDcaOrders, getClosedLimitOrders, getDcaOrderExecutions, getOpenDcaOrders, getOpenLimitOrders, placeDcaOrder, placeLimitOrder } from "./features/limitDca";
|
|
6
7
|
declare const getSuiClient: () => import("@mysten/sui/dist/cjs/client").SuiClient;
|
|
7
8
|
declare const setSuiClient: (client: import("@mysten/sui/dist/cjs/client").SuiClient) => void;
|
|
8
|
-
export { Config, getSuiClient, setSuiClient, getTokenPrice, getTokenPrices, getSuiPrice, getQuote, estimateGasFee, buildTx, getSwapHistory, placeLimitOrder, getOpenLimitOrders, cancelLimitOrder, claimExpiredLimitOrder, getClosedLimitOrders, placeDcaOrder, getOpenDcaOrders, cancelDcaOrder, getClosedDcaOrders, getDcaOrderExecutions, };
|
|
9
|
+
export { Config, getSuiClient, setSuiClient, getTokenPrice, getTokenPrices, getSuiPrice, getQuote, estimateGasFee, buildTx, getSwapHistory, executeTx, executeBluefinTx, DEFAULT_SOURCES, placeLimitOrder, getOpenLimitOrders, cancelLimitOrder, claimExpiredLimitOrder, getClosedLimitOrders, placeDcaOrder, getOpenDcaOrders, cancelDcaOrder, getClosedDcaOrders, getDcaOrderExecutions, };
|
|
9
10
|
declare const _default: {
|
|
10
11
|
Config: {
|
|
11
12
|
setApiKey: (key: string) => void;
|
|
12
13
|
getApiKey: () => string;
|
|
13
14
|
setSuiClient: (client: import("@mysten/sui/dist/cjs/client").SuiClient) => void;
|
|
14
15
|
getSuiClient: () => import("@mysten/sui/dist/cjs/client").SuiClient;
|
|
16
|
+
setPythClient: (client: import("@pythnetwork/pyth-sui-js").SuiPythClient) => void;
|
|
17
|
+
getPythClient: () => import("@pythnetwork/pyth-sui-js").SuiPythClient;
|
|
18
|
+
setPythConnection: (connection: import("@pythnetwork/pyth-sui-js").SuiPriceServiceConnection) => void;
|
|
19
|
+
getPythConnection: () => import("@pythnetwork/pyth-sui-js").SuiPriceServiceConnection;
|
|
15
20
|
};
|
|
16
21
|
getSuiClient: () => import("@mysten/sui/dist/cjs/client").SuiClient;
|
|
17
22
|
setSuiClient: (client: import("@mysten/sui/dist/cjs/client").SuiClient) => void;
|
|
@@ -20,11 +25,11 @@ declare const _default: {
|
|
|
20
25
|
getSuiPrice: typeof getSuiPrice;
|
|
21
26
|
getQuote: typeof getQuote;
|
|
22
27
|
estimateGasFee: typeof estimateGasFee;
|
|
23
|
-
buildTx: ({ quoteResponse, accountAddress, slippage, commission:
|
|
24
|
-
tx: import("@mysten/sui/dist/cjs/transactions").Transaction;
|
|
25
|
-
coinOut: import("@mysten/sui/dist/cjs/transactions").TransactionObjectArgument | undefined;
|
|
26
|
-
}>;
|
|
28
|
+
buildTx: ({ quoteResponse, accountAddress, slippage, commission: __commission, devInspect, extendTx, isSponsored, }: import("./types/tx").BuildTxParams) => Promise<import("./types/aggregator").BuildTxResult>;
|
|
27
29
|
getSwapHistory: typeof getSwapHistory;
|
|
30
|
+
executeTx: (tx: import("./types/aggregator").AggregatorTx, signature: string, signedTxBytes: string, options?: import("@mysten/sui/dist/cjs/client").SuiTransactionBlockResponseOptions) => Promise<import("@mysten/sui/dist/cjs/client").SuiTransactionBlockResponse>;
|
|
31
|
+
executeBluefinTx: (tx: import("./types/aggregator").BluefinXTx, signature: string) => Promise<import("./libs/protocols/bluefinx/types").SwapResponse>;
|
|
32
|
+
DEFAULT_SOURCES: import("./types/aggregator").SourceDex[];
|
|
28
33
|
placeLimitOrder: typeof placeLimitOrder;
|
|
29
34
|
getOpenLimitOrders: typeof getOpenLimitOrders;
|
|
30
35
|
cancelLimitOrder: typeof cancelLimitOrder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,EACL,OAAO,EACP,cAAc,EACd,SAAS,EACT,QAAQ,EACR,cAAc,EACd,eAAe,EAChB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAG7B,QAAA,MAAM,YAAY,uDAAsB,CAAC;AACzC,QAAA,MAAM,YAAY,mEAAsB,CAAC;AAEzC,OAAO,EAEL,MAAM,EAGN,YAAY,EACZ,YAAY,EAGZ,aAAa,EACb,cAAc,EACd,WAAW,EAGX,QAAQ,EACR,cAAc,EACd,OAAO,EACP,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,eAAe,EAGf,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EAGpB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,qBAAqB,GACtB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,wBAmCE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCoinOjectIdsByAmount.d.ts","sourceRoot":"","sources":["../../../../src/libs/getCoinOjectIdsByAmount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAkB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"getCoinOjectIdsByAmount.d.ts","sourceRoot":"","sources":["../../../../src/libs/getCoinOjectIdsByAmount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAkB,MAAM,oBAAoB,CAAC;AA4BhE,eAAO,MAAM,uBAAuB,GAClC,SAAS,MAAM,EACf,QAAQ,MAAM,EACd,UAAU,MAAM,KACf,OAAO,CAAC;IACT,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB,CA2CA,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSplitCoinForTx.d.ts","sourceRoot":"","sources":["../../../../src/libs/getSplitCoinForTx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"getSplitCoinForTx.d.ts","sourceRoot":"","sources":["../../../../src/libs/getSplitCoinForTx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAK1E,eAAO,MAAM,iBAAiB,GAC5B,SAAS,MAAM,EACf,QAAQ,MAAM,EACd,QAAQ,MAAM,EAAE,EAChB,UAAU,MAAM,EAChB,YAAY,WAAW,EACvB,oBAAoB,OAAO,EAC3B,qBAAmB,KAClB,OAAO,CAAC;IACT,EAAE,EAAE,WAAW,CAAC;IAChB,QAAQ,EAAE,iBAAiB,CAAC;CAC7B,CAqCA,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"groupSwapRoutes.d.ts","sourceRoot":"","sources":["../../../../src/libs/groupSwapRoutes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"groupSwapRoutes.d.ts","sourceRoot":"","sources":["../../../../src/libs/groupSwapRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,aAAa,EACb,SAAS,EACV,MAAM,qBAAqB,CAAC;AAG7B,wBAAgB,eAAe,CAAC,aAAa,EAAE,aAAa,GAAG,SAAS,EAAE,EAAE,CA2B3E"}
|
|
@@ -6,15 +6,19 @@ export interface BaseContractParams {
|
|
|
6
6
|
inputCoinObject: TransactionResultItem;
|
|
7
7
|
currentAccount: string;
|
|
8
8
|
config: Config;
|
|
9
|
+
/** map price feed id to onchain priceInfoObject id */
|
|
10
|
+
pythMap: Record<string, string>;
|
|
9
11
|
}
|
|
10
|
-
export declare abstract class BaseContract {
|
|
12
|
+
export declare abstract class BaseContract<T = any> {
|
|
11
13
|
protected swapInfo: TxSorSwap;
|
|
12
14
|
protected inputCoinObject: TransactionResultItem;
|
|
13
15
|
protected currentAccount: string;
|
|
14
16
|
protected config: Config;
|
|
15
|
-
|
|
17
|
+
protected pythMap: Record<string, string>;
|
|
18
|
+
constructor({ swapInfo, inputCoinObject, currentAccount, config, pythMap, }: BaseContractParams);
|
|
16
19
|
abstract swap(tx: Transaction): Promise<TransactionResultItem>;
|
|
17
20
|
protected getInputCoinValue(tx: Transaction): import("@mysten/sui/transactions").TransactionArgument;
|
|
18
21
|
protected getTypeParams(): string[];
|
|
22
|
+
protected get extra(): NonNullable<T>;
|
|
19
23
|
}
|
|
20
24
|
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../../src/libs/protocols/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAG3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,eAAe,EAAE,qBAAqB,CAAC;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../../src/libs/protocols/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAG3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,eAAe,EAAE,qBAAqB,CAAC;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,8BAAsB,YAAY,CAAC,CAAC,GAAG,GAAG;IACxC,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC9B,SAAS,CAAC,eAAe,EAAE,qBAAqB,CAAC;IACjD,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC;IACjC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAE9B,EACV,QAAQ,EACR,eAAe,EACf,cAAc,EACd,MAAM,EACN,OAAO,GACR,EAAE,kBAAkB;IAQrB,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAE9D,SAAS,CAAC,iBAAiB,CAAC,EAAE,EAAE,WAAW;IAQ3C,SAAS,CAAC,aAAa;IAMvB,SAAS,KAAK,KAAK,mBAMlB;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/bluefin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/bluefin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAIvC,qBAAa,eAAgB,SAAQ,YAAY;IACzC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CAyC3B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BluefinXTx, SponsorRequest, SponsorResponse, SwapResponse } from "./types";
|
|
2
|
+
export declare const sponsorBluefinX: (body: SponsorRequest) => Promise<SponsorResponse>;
|
|
3
|
+
/**
|
|
4
|
+
* Request BluefinX for signing sponsored tx and execute it
|
|
5
|
+
*
|
|
6
|
+
* @Warning
|
|
7
|
+
* User must use this function to execute BluefinX tx, otherwise the tx will be rejected by BluefinX contract
|
|
8
|
+
* @param tx - BluefinX tx which is generated by `buildTx`
|
|
9
|
+
* @param signature - user signature after signing the transaction
|
|
10
|
+
* @returns `SwapResponse`
|
|
11
|
+
*/
|
|
12
|
+
export declare const executeBluefinTx: (tx: BluefinXTx, signature: string) => Promise<SwapResponse>;
|
|
13
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/bluefinx/client.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,cAAc,EACd,eAAe,EACf,YAAY,EACb,MAAM,SAAS,CAAC;AAYjB,eAAO,MAAM,eAAe,GAAU,MAAM,cAAc,6BAEzD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAU,IAAI,UAAU,EAAE,WAAW,MAAM,0BAMvE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
2
|
+
import { BaseContract } from "../base";
|
|
3
|
+
export type BluefinXExtra = {
|
|
4
|
+
quoteId: string;
|
|
5
|
+
signature: string;
|
|
6
|
+
taker: string;
|
|
7
|
+
vault: string;
|
|
8
|
+
quoteExpiresAtUtcMillis: number;
|
|
9
|
+
createdAtUtcMillis: number;
|
|
10
|
+
};
|
|
11
|
+
export declare class BluefinXContract extends BaseContract {
|
|
12
|
+
swap(tx: Transaction): Promise<{
|
|
13
|
+
$kind: "NestedResult";
|
|
14
|
+
NestedResult: [number, number];
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/bluefinx/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAOvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAcvC,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB,EAAE,MAAM,CAAC;IAChC,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC;AACF,qBAAa,gBAAiB,SAAQ,YAAY;IAC1C,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CA+B3B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare class BluefinXTx {
|
|
2
|
+
quoteId: string;
|
|
3
|
+
txBytes: string;
|
|
4
|
+
constructor(quoteId: string, txBytes: string);
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Response from BluefinX swap
|
|
8
|
+
*/
|
|
9
|
+
export type SwapResponse = {
|
|
10
|
+
/** Whether the swap is approved */
|
|
11
|
+
approved: boolean;
|
|
12
|
+
/** Whether the swap is executed */
|
|
13
|
+
executed: boolean;
|
|
14
|
+
/** Transaction digest */
|
|
15
|
+
txDigest: string;
|
|
16
|
+
/** Quote ID */
|
|
17
|
+
quoteId: string;
|
|
18
|
+
};
|
|
19
|
+
export type SponsorRequest = {
|
|
20
|
+
quoteId: string;
|
|
21
|
+
txBytes: string;
|
|
22
|
+
sender: string;
|
|
23
|
+
};
|
|
24
|
+
type SponsoredTxData = {
|
|
25
|
+
txBytes: string;
|
|
26
|
+
txDigest: string;
|
|
27
|
+
};
|
|
28
|
+
export type SponsorResponse = {
|
|
29
|
+
success: boolean;
|
|
30
|
+
quoteId: string;
|
|
31
|
+
data: SponsoredTxData;
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/bluefinx/types.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAU;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;gBACJ,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAI7C;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,mCAAmC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,mCAAmC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/cetus/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMvC,qBAAa,aAAc,SAAQ,YAAY;IACvC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/cetus/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMvC,qBAAa,aAAc,SAAQ,YAAY;IACvC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CA2C3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sponsored.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/deepbookV3/sponsored.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAG3D,qBAAa,2BAA4B,SAAQ,YAAY;IACrD,IAAI,CAAC,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"sponsored.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/deepbookV3/sponsored.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAG3D,qBAAa,2BAA4B,SAAQ,YAAY;IACrD,IAAI,CAAC,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAyB5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/flowxV3/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/flowxV3/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,qBAAa,eAAgB,SAAQ,YAAY;IACzC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CA+B3B"}
|