@7kprotocol/sdk-ts 2.4.0 → 2.4.2-beta.0
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 +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 +36 -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 +5 -3
- 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 +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 +36 -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,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.DeepBookContract = void 0;
|
|
13
|
-
const utils_1 = require("@mysten/sui/utils");
|
|
14
|
-
const base_1 = require("../base");
|
|
15
|
-
const _7k_1 = require("../../../constants/_7k");
|
|
16
|
-
const sui_1 = require("../../../utils/sui");
|
|
17
|
-
const MODULE_NAME = "clob_v2";
|
|
18
|
-
class DeepBookContract extends base_1.BaseContract {
|
|
19
|
-
swap(tx) {
|
|
20
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
var _a;
|
|
22
|
-
const swapXtoY = this.swapInfo.swapXtoY;
|
|
23
|
-
const poolId = this.swapInfo.poolId;
|
|
24
|
-
const clientOrderId = Date.now();
|
|
25
|
-
const typeArgs = this.getTypeParams();
|
|
26
|
-
const lotSize = (_a = this.swapInfo.extra) === null || _a === void 0 ? void 0 : _a.lotSize;
|
|
27
|
-
const [baseAsset, quoteAsset] = typeArgs;
|
|
28
|
-
const accountCap = this.createAccountCap(tx);
|
|
29
|
-
const amountIn = this.getInputCoinValue(tx);
|
|
30
|
-
const config = this.config.deepbook;
|
|
31
|
-
let result;
|
|
32
|
-
if (swapXtoY) {
|
|
33
|
-
const amountInRound = tx.moveCall({
|
|
34
|
-
target: `${_7k_1._7K_PACKAGE_ID}::math::m_round_down`,
|
|
35
|
-
arguments: [
|
|
36
|
-
amountIn, // input coin value
|
|
37
|
-
tx.pure.u64(lotSize), // lot size
|
|
38
|
-
],
|
|
39
|
-
});
|
|
40
|
-
const [base_coin_ret, quote_coin_ret] = tx.moveCall({
|
|
41
|
-
target: `${config.package}::${MODULE_NAME}::swap_exact_base_for_quote`,
|
|
42
|
-
typeArguments: [baseAsset, quoteAsset],
|
|
43
|
-
arguments: [
|
|
44
|
-
tx.object(poolId),
|
|
45
|
-
tx.pure.u64(clientOrderId),
|
|
46
|
-
accountCap,
|
|
47
|
-
amountInRound,
|
|
48
|
-
this.inputCoinObject, // coin 0 ~ base
|
|
49
|
-
tx.moveCall({
|
|
50
|
-
typeArguments: [quoteAsset],
|
|
51
|
-
target: `0x2::coin::zero`,
|
|
52
|
-
arguments: [],
|
|
53
|
-
}), // coin 1 ~ quote
|
|
54
|
-
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
55
|
-
],
|
|
56
|
-
});
|
|
57
|
-
this.deleteAccountCap(tx, accountCap);
|
|
58
|
-
sui_1.SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, base_coin_ret, this.currentAccount);
|
|
59
|
-
result = quote_coin_ret;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
const [base_coin_ret, quote_coin_ret] = tx.moveCall({
|
|
63
|
-
target: `${config.package}::${MODULE_NAME}::swap_exact_quote_for_base`,
|
|
64
|
-
typeArguments: [baseAsset, quoteAsset],
|
|
65
|
-
arguments: [
|
|
66
|
-
tx.object(poolId),
|
|
67
|
-
tx.pure.u64(clientOrderId),
|
|
68
|
-
accountCap,
|
|
69
|
-
amountIn,
|
|
70
|
-
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
71
|
-
this.inputCoinObject, // coin 1 ~ quote
|
|
72
|
-
],
|
|
73
|
-
});
|
|
74
|
-
this.deleteAccountCap(tx, accountCap);
|
|
75
|
-
sui_1.SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, quote_coin_ret, this.currentAccount);
|
|
76
|
-
result = base_coin_ret;
|
|
77
|
-
}
|
|
78
|
-
return result;
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
createAccountCap(tx) {
|
|
82
|
-
const [cap] = tx.moveCall({
|
|
83
|
-
typeArguments: [],
|
|
84
|
-
target: `${this.config.deepbook.package}::${MODULE_NAME}::create_account`,
|
|
85
|
-
arguments: [],
|
|
86
|
-
});
|
|
87
|
-
return cap;
|
|
88
|
-
}
|
|
89
|
-
deleteAccountCap(tx, accountCap) {
|
|
90
|
-
tx.moveCall({
|
|
91
|
-
target: `${this.config.deepbook.package}::custodian_v2::delete_account_cap`,
|
|
92
|
-
arguments: [accountCap],
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.DeepBookContract = DeepBookContract;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/deepbook/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMvC,qBAAa,gBAAiB,SAAQ,YAAY;IAC1C,IAAI,CAAC,EAAE,EAAE,WAAW;;;;IAyE1B,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,gBAAgB;CAMzB"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
|
|
2
|
-
import { BaseContract } from "../base";
|
|
3
|
-
import { _7K_PACKAGE_ID } from "../../../constants/_7k";
|
|
4
|
-
import { SuiUtils } from "../../../utils/sui";
|
|
5
|
-
const MODULE_NAME = "clob_v2";
|
|
6
|
-
export class DeepBookContract extends BaseContract {
|
|
7
|
-
async swap(tx) {
|
|
8
|
-
const swapXtoY = this.swapInfo.swapXtoY;
|
|
9
|
-
const poolId = this.swapInfo.poolId;
|
|
10
|
-
const clientOrderId = Date.now();
|
|
11
|
-
const typeArgs = this.getTypeParams();
|
|
12
|
-
const lotSize = this.swapInfo.extra?.lotSize;
|
|
13
|
-
const [baseAsset, quoteAsset] = typeArgs;
|
|
14
|
-
const accountCap = this.createAccountCap(tx);
|
|
15
|
-
const amountIn = this.getInputCoinValue(tx);
|
|
16
|
-
const config = this.config.deepbook;
|
|
17
|
-
let result;
|
|
18
|
-
if (swapXtoY) {
|
|
19
|
-
const amountInRound = tx.moveCall({
|
|
20
|
-
target: `${_7K_PACKAGE_ID}::math::m_round_down`,
|
|
21
|
-
arguments: [
|
|
22
|
-
amountIn, // input coin value
|
|
23
|
-
tx.pure.u64(lotSize), // lot size
|
|
24
|
-
],
|
|
25
|
-
});
|
|
26
|
-
const [base_coin_ret, quote_coin_ret] = tx.moveCall({
|
|
27
|
-
target: `${config.package}::${MODULE_NAME}::swap_exact_base_for_quote`,
|
|
28
|
-
typeArguments: [baseAsset, quoteAsset],
|
|
29
|
-
arguments: [
|
|
30
|
-
tx.object(poolId),
|
|
31
|
-
tx.pure.u64(clientOrderId),
|
|
32
|
-
accountCap,
|
|
33
|
-
amountInRound,
|
|
34
|
-
this.inputCoinObject, // coin 0 ~ base
|
|
35
|
-
tx.moveCall({
|
|
36
|
-
typeArguments: [quoteAsset],
|
|
37
|
-
target: `0x2::coin::zero`,
|
|
38
|
-
arguments: [],
|
|
39
|
-
}), // coin 1 ~ quote
|
|
40
|
-
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
41
|
-
],
|
|
42
|
-
});
|
|
43
|
-
this.deleteAccountCap(tx, accountCap);
|
|
44
|
-
SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, base_coin_ret, this.currentAccount);
|
|
45
|
-
result = quote_coin_ret;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
const [base_coin_ret, quote_coin_ret] = tx.moveCall({
|
|
49
|
-
target: `${config.package}::${MODULE_NAME}::swap_exact_quote_for_base`,
|
|
50
|
-
typeArguments: [baseAsset, quoteAsset],
|
|
51
|
-
arguments: [
|
|
52
|
-
tx.object(poolId),
|
|
53
|
-
tx.pure.u64(clientOrderId),
|
|
54
|
-
accountCap,
|
|
55
|
-
amountIn,
|
|
56
|
-
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
57
|
-
this.inputCoinObject, // coin 1 ~ quote
|
|
58
|
-
],
|
|
59
|
-
});
|
|
60
|
-
this.deleteAccountCap(tx, accountCap);
|
|
61
|
-
SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, quote_coin_ret, this.currentAccount);
|
|
62
|
-
result = base_coin_ret;
|
|
63
|
-
}
|
|
64
|
-
return result;
|
|
65
|
-
}
|
|
66
|
-
createAccountCap(tx) {
|
|
67
|
-
const [cap] = tx.moveCall({
|
|
68
|
-
typeArguments: [],
|
|
69
|
-
target: `${this.config.deepbook.package}::${MODULE_NAME}::create_account`,
|
|
70
|
-
arguments: [],
|
|
71
|
-
});
|
|
72
|
-
return cap;
|
|
73
|
-
}
|
|
74
|
-
deleteAccountCap(tx, accountCap) {
|
|
75
|
-
tx.moveCall({
|
|
76
|
-
target: `${this.config.deepbook.package}::custodian_v2::delete_account_cap`,
|
|
77
|
-
arguments: [accountCap],
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/deepbook/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMvC,qBAAa,gBAAiB,SAAQ,YAAY;IAC1C,IAAI,CAAC,EAAE,EAAE,WAAW;;;;IAyE1B,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,gBAAgB;CAMzB"}
|