@suilend/sdk 2.0.4 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.js +11 -32
- package/lib/coin.d.ts +3 -0
- package/lib/coin.js +67 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/initialize.js +4 -3
- package/lib/strategyOwnerCap.d.ts +12 -7
- package/lib/strategyOwnerCap.js +159 -156
- package/package.json +1 -1
- package/strategies.d.ts +1 -1
- package/strategies.js +302 -82
- package/swap/transaction.js +3 -11
package/swap/transaction.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { BluefinXTx, buildTx as buildBluefin7kTransaction, } from "@bluefin-exchange/bluefin7k-aggregator-sdk/cjs";
|
|
11
11
|
import { Coin as FlowXCoin, Commission as FlowXCommission, CommissionType as FlowXCommissionType, TradeBuilder as FlowXTradeBuilder, } from "@flowx-finance/sdk";
|
|
12
|
-
import {
|
|
12
|
+
import { getSpendableCoin } from "../lib/coin";
|
|
13
13
|
import { QuoteProvider } from "./quote";
|
|
14
14
|
const getSwapTransactionWrapper = (provider, getSwapTransaction) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
15
|
console.log(`[getSwapTransactionWrapper] fetching transaction for ${provider} quote`);
|
|
@@ -44,11 +44,7 @@ export const getSwapTransaction = (suiClient, address, quote, slippagePercent, s
|
|
|
44
44
|
else if (quote.provider === QuoteProvider.CETUS) {
|
|
45
45
|
return getSwapTransactionWrapper(QuoteProvider.CETUS, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
46
|
if (!coinIn) {
|
|
47
|
-
|
|
48
|
-
const mergeCoinIn = mergeAllCoins(quote.in.coinType, transaction, allCoinsIn);
|
|
49
|
-
[coinIn] = transaction.splitCoins(isSui(quote.in.coinType)
|
|
50
|
-
? transaction.gas
|
|
51
|
-
: transaction.object(mergeCoinIn.coinObjectId), [BigInt(quote.quote.amountIn.toString())]);
|
|
47
|
+
coinIn = yield getSpendableCoin(suiClient, address, quote.in.coinType, quote.quote.amountIn.toString(), transaction);
|
|
52
48
|
}
|
|
53
49
|
const coinOut = yield sdkMap[QuoteProvider.CETUS].routerSwap({
|
|
54
50
|
router: quote.quote,
|
|
@@ -93,11 +89,7 @@ export const getSwapTransaction = (suiClient, address, quote, slippagePercent, s
|
|
|
93
89
|
else if (quote.provider === QuoteProvider.FLOWX) {
|
|
94
90
|
return getSwapTransactionWrapper(QuoteProvider.FLOWX, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
95
91
|
if (!coinIn) {
|
|
96
|
-
|
|
97
|
-
const mergeCoinIn = mergeAllCoins(quote.in.coinType, transaction, allCoinsIn);
|
|
98
|
-
[coinIn] = transaction.splitCoins(isSui(quote.in.coinType)
|
|
99
|
-
? transaction.gas
|
|
100
|
-
: transaction.object(mergeCoinIn.coinObjectId), [BigInt(quote.quote.amountIn.toString())]);
|
|
92
|
+
coinIn = yield getSpendableCoin(suiClient, address, quote.in.coinType, quote.quote.amountIn.toString(), transaction);
|
|
101
93
|
}
|
|
102
94
|
const trade = new FlowXTradeBuilder("mainnet", quote.quote.routes)
|
|
103
95
|
.slippage((slippagePercent / 100) * 1e6)
|