@7kprotocol/sdk-ts 2.1.3 → 2.1.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/lib/cjs/buildTx.js +1 -0
- package/lib/cjs/getQuote.js +1 -0
- package/lib/cjs/libs/protocols/bluefin/index.js +56 -0
- package/lib/cjs/libs/protocols/cetus/index.js +1 -1
- package/lib/cjs/libs/protocols/deepbook/index.js +3 -3
- package/lib/cjs/libs/protocols/deepbookV3/sponsored.js +4 -2
- package/lib/cjs/libs/protocols/index.js +2 -0
- package/lib/cjs/libs/protocols/suiswap/index.js +2 -1
- package/lib/cjs/libs/protocols/turbos/index.js +2 -1
- package/lib/cjs/types/buildTx.d.ts.map +1 -1
- package/lib/cjs/types/getQuote.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/bluefin/index.d.ts +9 -0
- package/lib/cjs/types/libs/protocols/bluefin/index.d.ts.map +1 -0
- package/lib/cjs/types/libs/protocols/cetus/index.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/deepbook/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/index.d.ts +2 -0
- package/lib/cjs/types/libs/protocols/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/types/aggregator.d.ts +1 -1
- package/lib/cjs/types/types/aggregator.d.ts.map +1 -1
- package/lib/cjs/types/utils/sui.d.ts +13 -0
- package/lib/cjs/types/utils/sui.d.ts.map +1 -1
- package/lib/cjs/utils/sui.js +28 -0
- package/lib/esm/buildTx.js +1 -0
- package/lib/esm/getQuote.js +1 -0
- package/lib/esm/libs/protocols/bluefin/index.js +38 -0
- package/lib/esm/libs/protocols/cetus/index.js +1 -1
- package/lib/esm/libs/protocols/deepbook/index.js +3 -3
- package/lib/esm/libs/protocols/deepbookV3/sponsored.js +5 -3
- package/lib/esm/libs/protocols/index.js +2 -0
- package/lib/esm/libs/protocols/suiswap/index.js +2 -1
- package/lib/esm/libs/protocols/turbos/index.js +2 -1
- package/lib/esm/types/buildTx.d.ts.map +1 -1
- package/lib/esm/types/getQuote.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/bluefin/index.d.ts +9 -0
- package/lib/esm/types/libs/protocols/bluefin/index.d.ts.map +1 -0
- package/lib/esm/types/libs/protocols/cetus/index.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/deepbook/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/index.d.ts +2 -0
- package/lib/esm/types/libs/protocols/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/types/aggregator.d.ts +1 -1
- package/lib/esm/types/types/aggregator.d.ts.map +1 -1
- package/lib/esm/types/utils/sui.d.ts +13 -0
- package/lib/esm/types/utils/sui.d.ts.map +1 -1
- package/lib/esm/utils/sui.js +28 -0
- package/package.json +1 -1
package/lib/cjs/buildTx.js
CHANGED
|
@@ -40,6 +40,7 @@ const buildTx = (_a) => __awaiter(void 0, [_a], void 0, function* ({ quoteRespon
|
|
|
40
40
|
let coinData;
|
|
41
41
|
if (coinIn) {
|
|
42
42
|
coinData = tx.splitCoins(coinIn, splits);
|
|
43
|
+
sui_1.SuiUtils.transferOrDestroyZeroCoin(tx, quoteResponse.tokenIn, coinIn, accountAddress);
|
|
43
44
|
}
|
|
44
45
|
else {
|
|
45
46
|
const { coinData: _data } = yield (0, getSplitCoinForTx_1.getSplitCoinForTx)(accountAddress, quoteResponse.swapAmountWithDecimal, splits, (0, token_1.denormalizeTokenType)(quoteResponse.tokenIn), tx, devInspect);
|
package/lib/cjs/getQuote.js
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.BluefinContract = void 0;
|
|
16
|
+
const base_1 = require("../base");
|
|
17
|
+
const utils_1 = require("@mysten/sui/utils");
|
|
18
|
+
const utils_2 = require("../utils");
|
|
19
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
20
|
+
const sui_1 = require("../../../utils/sui");
|
|
21
|
+
const PACKAGE_ID = "0xbe89d6ecf91fea245164e5e8ed5a6cc8af4e9361b8a9e33dbaf7316af0dc7732";
|
|
22
|
+
const CONFIG_ID = "0x03db251ba509a8d5d8777b6338836082335d93eecbdd09a11e190a1cff51c352";
|
|
23
|
+
class BluefinContract extends base_1.BaseContract {
|
|
24
|
+
swap(tx) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const [coinX, coinY] = this.swapInfo.pool.allTokens;
|
|
27
|
+
const swapXtoY = this.swapInfo.swapXtoY;
|
|
28
|
+
const amountIn = this.getInputCoinValue(tx);
|
|
29
|
+
const coinInBalance = sui_1.SuiUtils.coinIntoBalance(tx, this.swapInfo.assetIn, this.inputCoinObject);
|
|
30
|
+
const coinOutBalance = sui_1.SuiUtils.zeroBalance(tx, this.swapInfo.assetOut);
|
|
31
|
+
const [balanceOutX, balanceOutY] = tx.moveCall({
|
|
32
|
+
target: `${PACKAGE_ID}::pool::swap`,
|
|
33
|
+
typeArguments: [coinX.address, coinY.address],
|
|
34
|
+
arguments: [
|
|
35
|
+
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
36
|
+
tx.object(CONFIG_ID),
|
|
37
|
+
tx.object(this.swapInfo.poolId),
|
|
38
|
+
swapXtoY ? coinInBalance : coinOutBalance,
|
|
39
|
+
swapXtoY ? coinOutBalance : coinInBalance,
|
|
40
|
+
tx.pure.bool(swapXtoY),
|
|
41
|
+
tx.pure.bool(true),
|
|
42
|
+
amountIn,
|
|
43
|
+
tx.pure.u64(0),
|
|
44
|
+
tx.pure.u128((0, utils_2.getDefaultSqrtPriceLimit)(swapXtoY)
|
|
45
|
+
.add(swapXtoY ? new bn_js_1.default(1) : new bn_js_1.default(-1))
|
|
46
|
+
.toString(10)),
|
|
47
|
+
],
|
|
48
|
+
});
|
|
49
|
+
const coinOutX = sui_1.SuiUtils.coinFromBalance(tx, coinX.address, balanceOutX);
|
|
50
|
+
const coinOutY = sui_1.SuiUtils.coinFromBalance(tx, coinY.address, balanceOutY);
|
|
51
|
+
sui_1.SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, swapXtoY ? coinOutX : coinOutY, this.currentAccount);
|
|
52
|
+
return swapXtoY ? coinOutY : coinOutX;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.BluefinContract = BluefinContract;
|
|
@@ -48,7 +48,7 @@ class CetusContract extends base_1.BaseContract {
|
|
|
48
48
|
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
49
49
|
],
|
|
50
50
|
});
|
|
51
|
-
|
|
51
|
+
sui_1.SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, this.swapInfo.swapXtoY ? receiveA : receiveB, this.currentAccount);
|
|
52
52
|
return this.swapInfo.swapXtoY ? receiveB : receiveA;
|
|
53
53
|
});
|
|
54
54
|
}
|
|
@@ -13,6 +13,7 @@ exports.DeepBookContract = void 0;
|
|
|
13
13
|
const utils_1 = require("@mysten/sui/utils");
|
|
14
14
|
const base_1 = require("../base");
|
|
15
15
|
const _7k_1 = require("../../../constants/_7k");
|
|
16
|
+
const sui_1 = require("../../../utils/sui");
|
|
16
17
|
const PACKAGE_ID = "0xdee9";
|
|
17
18
|
const MODULE_NAME = "clob_v2";
|
|
18
19
|
class DeepBookContract extends base_1.BaseContract {
|
|
@@ -22,7 +23,6 @@ class DeepBookContract extends base_1.BaseContract {
|
|
|
22
23
|
const swapXtoY = this.swapInfo.swapXtoY;
|
|
23
24
|
const poolId = this.swapInfo.poolId;
|
|
24
25
|
const clientOrderId = Date.now();
|
|
25
|
-
const currentAddress = this.currentAccount;
|
|
26
26
|
const typeArgs = this.getTypeParams();
|
|
27
27
|
const lotSize = (_a = this.swapInfo.extra) === null || _a === void 0 ? void 0 : _a.lotSize;
|
|
28
28
|
const [baseAsset, quoteAsset] = typeArgs;
|
|
@@ -55,7 +55,7 @@ class DeepBookContract extends base_1.BaseContract {
|
|
|
55
55
|
],
|
|
56
56
|
});
|
|
57
57
|
this.deleteAccountCap(tx, accountCap);
|
|
58
|
-
tx.
|
|
58
|
+
sui_1.SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, base_coin_ret, this.currentAccount);
|
|
59
59
|
result = quote_coin_ret;
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
@@ -72,7 +72,7 @@ class DeepBookContract extends base_1.BaseContract {
|
|
|
72
72
|
],
|
|
73
73
|
});
|
|
74
74
|
this.deleteAccountCap(tx, accountCap);
|
|
75
|
-
tx.
|
|
75
|
+
sui_1.SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, quote_coin_ret, this.currentAccount);
|
|
76
76
|
result = base_coin_ret;
|
|
77
77
|
}
|
|
78
78
|
return result;
|
|
@@ -12,13 +12,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.SponsoredDeepBookV3Contract = void 0;
|
|
13
13
|
const base_1 = require("../base");
|
|
14
14
|
const utils_1 = require("@mysten/sui/utils");
|
|
15
|
+
const sui_1 = require("../../../utils/sui");
|
|
15
16
|
const PACKAGE_ID = "0x951a01360d85b06722edf896852bf8005b81cdb26375235c935138987f629502";
|
|
16
17
|
const FUND_ID = "0xf245e7a4b83ed9a26622f5818a158c2ba7a03b91e62717b557a7df1d4dab38df";
|
|
17
18
|
class SponsoredDeepBookV3Contract extends base_1.BaseContract {
|
|
18
19
|
swap(tx) {
|
|
19
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
21
|
const [coinX] = this.swapInfo.pool.allTokens;
|
|
21
|
-
const swapXtoY = coinX.address ===
|
|
22
|
+
const swapXtoY = (0, utils_1.normalizeStructTag)(coinX.address) ===
|
|
23
|
+
(0, utils_1.normalizeStructTag)(this.swapInfo.assetIn);
|
|
22
24
|
const [base, quote] = tx.moveCall({
|
|
23
25
|
target: `${PACKAGE_ID}::sponsored::${swapXtoY ? "swap_exact_base_for_quote" : "swap_exact_quote_for_base"}`,
|
|
24
26
|
typeArguments: this.getTypeParams(),
|
|
@@ -32,7 +34,7 @@ class SponsoredDeepBookV3Contract extends base_1.BaseContract {
|
|
|
32
34
|
});
|
|
33
35
|
const coinIn = swapXtoY ? base : quote;
|
|
34
36
|
const coinOut = swapXtoY ? quote : base;
|
|
35
|
-
tx.
|
|
37
|
+
sui_1.SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, coinIn, this.currentAccount);
|
|
36
38
|
return coinOut;
|
|
37
39
|
});
|
|
38
40
|
}
|
|
@@ -11,6 +11,7 @@ const suiswap_1 = require("./suiswap");
|
|
|
11
11
|
const bluemove_1 = require("./bluemove");
|
|
12
12
|
const kriyaV3_1 = require("./kriyaV3");
|
|
13
13
|
const sponsored_1 = require("./deepbookV3/sponsored");
|
|
14
|
+
const bluefin_1 = require("./bluefin");
|
|
14
15
|
exports.ProtocolContract = {
|
|
15
16
|
cetus: cetus_1.CetusContract,
|
|
16
17
|
turbos: turbos_1.TurbosContract,
|
|
@@ -22,4 +23,5 @@ exports.ProtocolContract = {
|
|
|
22
23
|
deepbook_v3: sponsored_1.SponsoredDeepBookV3Contract,
|
|
23
24
|
flowx: flowx_1.FlowXContract,
|
|
24
25
|
kriya_v3: kriyaV3_1.KriyaV3Contract,
|
|
26
|
+
bluefin: bluefin_1.BluefinContract,
|
|
25
27
|
};
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.SuiswapContract = void 0;
|
|
13
13
|
const utils_1 = require("@mysten/sui/utils");
|
|
14
14
|
const base_1 = require("../base");
|
|
15
|
+
const sui_1 = require("../../../utils/sui");
|
|
15
16
|
const PACKAGE_ID = "0xd075d51486df71e750872b4edf82ea3409fda397ceecc0b6aedf573d923c54a0";
|
|
16
17
|
const MODULE_NAME = "pool";
|
|
17
18
|
class SuiswapContract extends base_1.BaseContract {
|
|
@@ -37,7 +38,7 @@ class SuiswapContract extends base_1.BaseContract {
|
|
|
37
38
|
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
38
39
|
],
|
|
39
40
|
});
|
|
40
|
-
tx.
|
|
41
|
+
sui_1.SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, tokenIn, this.currentAccount);
|
|
41
42
|
return tokenOut;
|
|
42
43
|
});
|
|
43
44
|
}
|
|
@@ -14,6 +14,7 @@ const utils_1 = require("@mysten/sui/utils");
|
|
|
14
14
|
const base_1 = require("../base");
|
|
15
15
|
const utils_2 = require("../utils");
|
|
16
16
|
const constants_1 = require("./constants");
|
|
17
|
+
const sui_1 = require("../../../utils/sui");
|
|
17
18
|
const PACKAGE_ID = "0x1a3c42ded7b75cdf4ebc7c7b7da9d1e1db49f16fcdca934fac003f35f39ecad9";
|
|
18
19
|
const MODULE_NAME = "swap_router";
|
|
19
20
|
const VERSION = "0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f";
|
|
@@ -45,7 +46,7 @@ class TurbosContract extends base_1.BaseContract {
|
|
|
45
46
|
tx.object(VERSION),
|
|
46
47
|
],
|
|
47
48
|
});
|
|
48
|
-
tx.
|
|
49
|
+
sui_1.SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, tokenIn, address);
|
|
49
50
|
return tokenOut;
|
|
50
51
|
});
|
|
51
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildTx.d.ts","sourceRoot":"","sources":["../../../src/buildTx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,yBAAyB,EAE1B,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAI3C,eAAO,MAAM,OAAO,gGAOjB,aAAa;;;
|
|
1
|
+
{"version":3,"file":"buildTx.d.ts","sourceRoot":"","sources":["../../../src/buildTx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,yBAAyB,EAE1B,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAI3C,eAAO,MAAM,OAAO,gGAOjB,aAAa;;;EAiGf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getQuote.d.ts","sourceRoot":"","sources":["../../../src/getQuote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG9D,UAAU,MAAM;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;CACvB;
|
|
1
|
+
{"version":3,"file":"getQuote.d.ts","sourceRoot":"","sources":["../../../src/getQuote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG9D,UAAU,MAAM;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;CACvB;AAgBD,wBAAsB,QAAQ,CAAC,EAC7B,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,OAAyB,GAC1B,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAUjC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
2
|
+
import { BaseContract } from "../base";
|
|
3
|
+
export declare class BluefinContract extends BaseContract {
|
|
4
|
+
swap(tx: Transaction): Promise<{
|
|
5
|
+
$kind: "NestedResult";
|
|
6
|
+
NestedResult: [number, number];
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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;AAWvC,qBAAa,eAAgB,SAAQ,YAAY;IACzC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CA2C3B"}
|
|
@@ -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;AAWvC,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;AAWvC,qBAAa,aAAc,SAAQ,YAAY;IACvC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CA2C3B"}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAOvC,qBAAa,gBAAiB,SAAQ,YAAY;IAC1C,IAAI,CAAC,EAAE,EAAE,WAAW;;;;IAwE1B,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,gBAAgB;CAMzB"}
|
|
@@ -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;
|
|
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;AAO3D,qBAAa,2BAA4B,SAAQ,YAAY;IACrD,IAAI,CAAC,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;CA6B5D"}
|
|
@@ -8,6 +8,7 @@ import { SuiswapContract } from "./suiswap";
|
|
|
8
8
|
import { BluemoveContract } from "./bluemove";
|
|
9
9
|
import { KriyaV3Contract } from "./kriyaV3";
|
|
10
10
|
import { SponsoredDeepBookV3Contract } from "./deepbookV3/sponsored";
|
|
11
|
+
import { BluefinContract } from "./bluefin";
|
|
11
12
|
export declare const ProtocolContract: {
|
|
12
13
|
cetus: typeof CetusContract;
|
|
13
14
|
turbos: typeof TurbosContract;
|
|
@@ -19,5 +20,6 @@ export declare const ProtocolContract: {
|
|
|
19
20
|
deepbook_v3: typeof SponsoredDeepBookV3Contract;
|
|
20
21
|
flowx: typeof FlowXContract;
|
|
21
22
|
kriya_v3: typeof KriyaV3Contract;
|
|
23
|
+
bluefin: typeof BluefinContract;
|
|
22
24
|
};
|
|
23
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/libs/protocols/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/libs/protocols/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,eAAO,MAAM,gBAAgB;;;;;;;;;;;;CAY5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/suiswap/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/suiswap/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAOvC,qBAAa,eAAgB,SAAQ,YAAY;IACzC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CA+B3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/turbos/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/turbos/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAWvC,qBAAa,cAAe,SAAQ,YAAY;IACxC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CAyC3B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type SourceDex = "suiswap" | "turbos" | "cetus" | "bluemove" | "kriya" | "kriya_v3" | "aftermath" | "deepbook" | "deepbook_v3" | "flowx";
|
|
1
|
+
export type SourceDex = "suiswap" | "turbos" | "cetus" | "bluemove" | "kriya" | "kriya_v3" | "aftermath" | "deepbook" | "deepbook_v3" | "flowx" | "bluefin";
|
|
2
2
|
export type SorSwap = {
|
|
3
3
|
poolId: string;
|
|
4
4
|
assetInIndex: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregator.d.ts","sourceRoot":"","sources":["../../../../src/types/aggregator.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,QAAQ,GACR,OAAO,GACP,UAAU,GACV,OAAO,GACP,UAAU,GACV,WAAW,GACX,UAAU,GACV,aAAa,GACb,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"aggregator.d.ts","sourceRoot":"","sources":["../../../../src/types/aggregator.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,QAAQ,GACR,OAAO,GACP,UAAU,GACV,OAAO,GACP,UAAU,GACV,WAAW,GACX,UAAU,GACV,aAAa,GACb,OAAO,GACP,SAAS,CAAC;AAEd,MAAM,MAAM,OAAO,GAAG;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,GAAG,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvD,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,uBAAuB,EAAE,MAAM,CAAC;IAChC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;IACpB,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,SAAU,SAAQ,OAAO;IACxC,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,IAAI,CAAC;IACZ,KAAK,EAAE,IAAI,CAAC;IACZ,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -33,6 +33,19 @@ export declare const SuiUtils: {
|
|
|
33
33
|
}[]): string[];
|
|
34
34
|
getOwnedObjectsByPage(owner: string, query: SuiObjectResponseQuery, paginationArgs?: PaginationArgs): Promise<DataPage<any>>;
|
|
35
35
|
isValidStructTag(value: string): boolean;
|
|
36
|
+
zeroBalance(tx: Transaction, coinType: string): {
|
|
37
|
+
$kind: "NestedResult";
|
|
38
|
+
NestedResult: [number, number];
|
|
39
|
+
};
|
|
40
|
+
coinIntoBalance(tx: Transaction, coinType: string, coinObject: TransactionArgument): {
|
|
41
|
+
$kind: "NestedResult";
|
|
42
|
+
NestedResult: [number, number];
|
|
43
|
+
};
|
|
44
|
+
coinFromBalance(tx: Transaction, coinType: string, balance: TransactionArgument): {
|
|
45
|
+
$kind: "NestedResult";
|
|
46
|
+
NestedResult: [number, number];
|
|
47
|
+
};
|
|
48
|
+
transferOrDestroyZeroCoin(tx: Transaction, coinType: string, coin: TransactionArgument, to?: string): void;
|
|
36
49
|
};
|
|
37
50
|
export {};
|
|
38
51
|
//# sourceMappingURL=sui.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../../../src/utils/sui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACL,UAAU,EAEV,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAK5B,KAAK,QAAQ,CAAC,CAAC,IAAI;IACjB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,KAAK,cAAc,GAAG,KAAK,GAAG,SAAS,CAAC;AAExC,eAAO,MAAM,QAAQ;uBAET,MAAM,GAAG,mBAAmB,OAC/B,WAAW,GACf,mBAAmB;4BAMP,KAAK,CAAC,MAAM,GAAG,mBAAmB,CAAC,OAC3C,WAAW,GACf,mBAAmB,GAAG,SAAS;2BAsBtB,MAAM,cACJ,MAAM,GAAG,mBAAmB,OACnC,WAAW,GACf,mBAAmB;mCAYV,MAAM,SACT;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,UACtC,MAAM,OACT,WAAW;;;;gCAoBgB,MAAM,iBAAiB,MAAM;qCAoCtD,UAAU,EAAE,YACT,MAAM,OACX,WAAW;uCAsBuB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;sCA8BhE,MAAM,SACP;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE;iCA6BvC,MAAM,SACN,sBAAsB,mBACb,cAAc,GAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;4BAyBD,MAAM;
|
|
1
|
+
{"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../../../src/utils/sui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACL,UAAU,EAEV,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAK5B,KAAK,QAAQ,CAAC,CAAC,IAAI;IACjB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,KAAK,cAAc,GAAG,KAAK,GAAG,SAAS,CAAC;AAExC,eAAO,MAAM,QAAQ;uBAET,MAAM,GAAG,mBAAmB,OAC/B,WAAW,GACf,mBAAmB;4BAMP,KAAK,CAAC,MAAM,GAAG,mBAAmB,CAAC,OAC3C,WAAW,GACf,mBAAmB,GAAG,SAAS;2BAsBtB,MAAM,cACJ,MAAM,GAAG,mBAAmB,OACnC,WAAW,GACf,mBAAmB;mCAYV,MAAM,SACT;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,UACtC,MAAM,OACT,WAAW;;;;gCAoBgB,MAAM,iBAAiB,MAAM;qCAoCtD,UAAU,EAAE,YACT,MAAM,OACX,WAAW;uCAsBuB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;sCA8BhE,MAAM,SACP;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE;iCA6BvC,MAAM,SACN,sBAAsB,mBACb,cAAc,GAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;4BAyBD,MAAM;oBAQd,WAAW,YAAY,MAAM;;;;wBASvC,WAAW,YACL,MAAM,cACJ,mBAAmB;;;;wBAU3B,WAAW,YACL,MAAM,WACP,mBAAmB;;;;kCAUxB,WAAW,YACL,MAAM,QACV,mBAAmB,OACpB,MAAM;CAUd,CAAC"}
|
package/lib/cjs/utils/sui.js
CHANGED
|
@@ -176,4 +176,32 @@ exports.SuiUtils = {
|
|
|
176
176
|
return false;
|
|
177
177
|
}
|
|
178
178
|
},
|
|
179
|
+
zeroBalance(tx, coinType) {
|
|
180
|
+
return tx.moveCall({
|
|
181
|
+
target: `0x2::balance::zero`,
|
|
182
|
+
typeArguments: [coinType],
|
|
183
|
+
arguments: [],
|
|
184
|
+
})[0];
|
|
185
|
+
},
|
|
186
|
+
coinIntoBalance(tx, coinType, coinObject) {
|
|
187
|
+
return tx.moveCall({
|
|
188
|
+
target: `0x2::coin::into_balance`,
|
|
189
|
+
typeArguments: [coinType],
|
|
190
|
+
arguments: [coinObject],
|
|
191
|
+
})[0];
|
|
192
|
+
},
|
|
193
|
+
coinFromBalance(tx, coinType, balance) {
|
|
194
|
+
return tx.moveCall({
|
|
195
|
+
target: `0x2::coin::from_balance`,
|
|
196
|
+
typeArguments: [coinType],
|
|
197
|
+
arguments: [balance],
|
|
198
|
+
})[0];
|
|
199
|
+
},
|
|
200
|
+
transferOrDestroyZeroCoin(tx, coinType, coin, to) {
|
|
201
|
+
tx.moveCall({
|
|
202
|
+
target: `0x6f5e582ede61fe5395b50c4a449ec11479a54d7ff8e0158247adfda60d98970b::utils::${to ? "send_coin" : "transfer_coin_to_sender"}`,
|
|
203
|
+
typeArguments: [coinType],
|
|
204
|
+
arguments: [coin, ...(to ? [tx.pure.address(to)] : [])],
|
|
205
|
+
});
|
|
206
|
+
},
|
|
179
207
|
};
|
package/lib/esm/buildTx.js
CHANGED
|
@@ -25,6 +25,7 @@ export const buildTx = async ({ quoteResponse, accountAddress, slippage, commiss
|
|
|
25
25
|
let coinData;
|
|
26
26
|
if (coinIn) {
|
|
27
27
|
coinData = tx.splitCoins(coinIn, splits);
|
|
28
|
+
SuiUtils.transferOrDestroyZeroCoin(tx, quoteResponse.tokenIn, coinIn, accountAddress);
|
|
28
29
|
}
|
|
29
30
|
else {
|
|
30
31
|
const { coinData: _data } = await getSplitCoinForTx(accountAddress, quoteResponse.swapAmountWithDecimal, splits, denormalizeTokenType(quoteResponse.tokenIn), tx, devInspect);
|
package/lib/esm/getQuote.js
CHANGED
|
@@ -10,6 +10,7 @@ const DEFAULT_SOURCES = [
|
|
|
10
10
|
"deepbook",
|
|
11
11
|
"deepbook_v3",
|
|
12
12
|
"flowx",
|
|
13
|
+
"bluefin",
|
|
13
14
|
];
|
|
14
15
|
export async function getQuote({ tokenIn, tokenOut, amountIn, sources = DEFAULT_SOURCES, }) {
|
|
15
16
|
const response = await fetch(`https://api.7k.ag/quote?amount=${amountIn}&from=${normalizeTokenType(tokenIn)}&to=${normalizeTokenType(tokenOut)}&sources=${sources}`);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BaseContract } from "../base";
|
|
2
|
+
import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
|
|
3
|
+
import { getDefaultSqrtPriceLimit } from "../utils";
|
|
4
|
+
import BN from "bn.js";
|
|
5
|
+
import { SuiUtils } from "../../../utils/sui";
|
|
6
|
+
const PACKAGE_ID = "0xbe89d6ecf91fea245164e5e8ed5a6cc8af4e9361b8a9e33dbaf7316af0dc7732";
|
|
7
|
+
const CONFIG_ID = "0x03db251ba509a8d5d8777b6338836082335d93eecbdd09a11e190a1cff51c352";
|
|
8
|
+
export class BluefinContract extends BaseContract {
|
|
9
|
+
async swap(tx) {
|
|
10
|
+
const [coinX, coinY] = this.swapInfo.pool.allTokens;
|
|
11
|
+
const swapXtoY = this.swapInfo.swapXtoY;
|
|
12
|
+
const amountIn = this.getInputCoinValue(tx);
|
|
13
|
+
const coinInBalance = SuiUtils.coinIntoBalance(tx, this.swapInfo.assetIn, this.inputCoinObject);
|
|
14
|
+
const coinOutBalance = SuiUtils.zeroBalance(tx, this.swapInfo.assetOut);
|
|
15
|
+
const [balanceOutX, balanceOutY] = tx.moveCall({
|
|
16
|
+
target: `${PACKAGE_ID}::pool::swap`,
|
|
17
|
+
typeArguments: [coinX.address, coinY.address],
|
|
18
|
+
arguments: [
|
|
19
|
+
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
20
|
+
tx.object(CONFIG_ID),
|
|
21
|
+
tx.object(this.swapInfo.poolId),
|
|
22
|
+
swapXtoY ? coinInBalance : coinOutBalance,
|
|
23
|
+
swapXtoY ? coinOutBalance : coinInBalance,
|
|
24
|
+
tx.pure.bool(swapXtoY),
|
|
25
|
+
tx.pure.bool(true),
|
|
26
|
+
amountIn,
|
|
27
|
+
tx.pure.u64(0),
|
|
28
|
+
tx.pure.u128(getDefaultSqrtPriceLimit(swapXtoY)
|
|
29
|
+
.add(swapXtoY ? new BN(1) : new BN(-1))
|
|
30
|
+
.toString(10)),
|
|
31
|
+
],
|
|
32
|
+
});
|
|
33
|
+
const coinOutX = SuiUtils.coinFromBalance(tx, coinX.address, balanceOutX);
|
|
34
|
+
const coinOutY = SuiUtils.coinFromBalance(tx, coinY.address, balanceOutY);
|
|
35
|
+
SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, swapXtoY ? coinOutX : coinOutY, this.currentAccount);
|
|
36
|
+
return swapXtoY ? coinOutY : coinOutX;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -35,7 +35,7 @@ export class CetusContract extends BaseContract {
|
|
|
35
35
|
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
36
36
|
],
|
|
37
37
|
});
|
|
38
|
-
|
|
38
|
+
SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, this.swapInfo.swapXtoY ? receiveA : receiveB, this.currentAccount);
|
|
39
39
|
return this.swapInfo.swapXtoY ? receiveB : receiveA;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
|
|
2
2
|
import { BaseContract } from "../base";
|
|
3
3
|
import { _7K_PACKAGE_ID } from "../../../constants/_7k";
|
|
4
|
+
import { SuiUtils } from "../../../utils/sui";
|
|
4
5
|
const PACKAGE_ID = "0xdee9";
|
|
5
6
|
const MODULE_NAME = "clob_v2";
|
|
6
7
|
export class DeepBookContract extends BaseContract {
|
|
@@ -8,7 +9,6 @@ export class DeepBookContract extends BaseContract {
|
|
|
8
9
|
const swapXtoY = this.swapInfo.swapXtoY;
|
|
9
10
|
const poolId = this.swapInfo.poolId;
|
|
10
11
|
const clientOrderId = Date.now();
|
|
11
|
-
const currentAddress = this.currentAccount;
|
|
12
12
|
const typeArgs = this.getTypeParams();
|
|
13
13
|
const lotSize = this.swapInfo.extra?.lotSize;
|
|
14
14
|
const [baseAsset, quoteAsset] = typeArgs;
|
|
@@ -41,7 +41,7 @@ export class DeepBookContract extends BaseContract {
|
|
|
41
41
|
],
|
|
42
42
|
});
|
|
43
43
|
this.deleteAccountCap(tx, accountCap);
|
|
44
|
-
tx.
|
|
44
|
+
SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, base_coin_ret, this.currentAccount);
|
|
45
45
|
result = quote_coin_ret;
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
@@ -58,7 +58,7 @@ export class DeepBookContract extends BaseContract {
|
|
|
58
58
|
],
|
|
59
59
|
});
|
|
60
60
|
this.deleteAccountCap(tx, accountCap);
|
|
61
|
-
tx.
|
|
61
|
+
SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, quote_coin_ret, this.currentAccount);
|
|
62
62
|
result = base_coin_ret;
|
|
63
63
|
}
|
|
64
64
|
return result;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { BaseContract } from "../base";
|
|
2
|
-
import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
|
|
2
|
+
import { normalizeStructTag, SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
|
|
3
|
+
import { SuiUtils } from "../../../utils/sui";
|
|
3
4
|
const PACKAGE_ID = "0x951a01360d85b06722edf896852bf8005b81cdb26375235c935138987f629502";
|
|
4
5
|
const FUND_ID = "0xf245e7a4b83ed9a26622f5818a158c2ba7a03b91e62717b557a7df1d4dab38df";
|
|
5
6
|
export class SponsoredDeepBookV3Contract extends BaseContract {
|
|
6
7
|
async swap(tx) {
|
|
7
8
|
const [coinX] = this.swapInfo.pool.allTokens;
|
|
8
|
-
const swapXtoY = coinX.address ===
|
|
9
|
+
const swapXtoY = normalizeStructTag(coinX.address) ===
|
|
10
|
+
normalizeStructTag(this.swapInfo.assetIn);
|
|
9
11
|
const [base, quote] = tx.moveCall({
|
|
10
12
|
target: `${PACKAGE_ID}::sponsored::${swapXtoY ? "swap_exact_base_for_quote" : "swap_exact_quote_for_base"}`,
|
|
11
13
|
typeArguments: this.getTypeParams(),
|
|
@@ -19,7 +21,7 @@ export class SponsoredDeepBookV3Contract extends BaseContract {
|
|
|
19
21
|
});
|
|
20
22
|
const coinIn = swapXtoY ? base : quote;
|
|
21
23
|
const coinOut = swapXtoY ? quote : base;
|
|
22
|
-
tx.
|
|
24
|
+
SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, coinIn, this.currentAccount);
|
|
23
25
|
return coinOut;
|
|
24
26
|
}
|
|
25
27
|
}
|
|
@@ -8,6 +8,7 @@ import { SuiswapContract } from "./suiswap";
|
|
|
8
8
|
import { BluemoveContract } from "./bluemove";
|
|
9
9
|
import { KriyaV3Contract } from "./kriyaV3";
|
|
10
10
|
import { SponsoredDeepBookV3Contract } from "./deepbookV3/sponsored";
|
|
11
|
+
import { BluefinContract } from "./bluefin";
|
|
11
12
|
export const ProtocolContract = {
|
|
12
13
|
cetus: CetusContract,
|
|
13
14
|
turbos: TurbosContract,
|
|
@@ -19,4 +20,5 @@ export const ProtocolContract = {
|
|
|
19
20
|
deepbook_v3: SponsoredDeepBookV3Contract,
|
|
20
21
|
flowx: FlowXContract,
|
|
21
22
|
kriya_v3: KriyaV3Contract,
|
|
23
|
+
bluefin: BluefinContract,
|
|
22
24
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
|
|
2
2
|
import { BaseContract } from "../base";
|
|
3
|
+
import { SuiUtils } from "../../../utils/sui";
|
|
3
4
|
const PACKAGE_ID = "0xd075d51486df71e750872b4edf82ea3409fda397ceecc0b6aedf573d923c54a0";
|
|
4
5
|
const MODULE_NAME = "pool";
|
|
5
6
|
export class SuiswapContract extends BaseContract {
|
|
@@ -24,7 +25,7 @@ export class SuiswapContract extends BaseContract {
|
|
|
24
25
|
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
25
26
|
],
|
|
26
27
|
});
|
|
27
|
-
tx.
|
|
28
|
+
SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, tokenIn, this.currentAccount);
|
|
28
29
|
return tokenOut;
|
|
29
30
|
}
|
|
30
31
|
}
|
|
@@ -2,6 +2,7 @@ import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
|
|
|
2
2
|
import { BaseContract } from "../base";
|
|
3
3
|
import { getDefaultSqrtPriceLimit } from "../utils";
|
|
4
4
|
import { ONE_MINUTE } from "./constants";
|
|
5
|
+
import { SuiUtils } from "../../../utils/sui";
|
|
5
6
|
const PACKAGE_ID = "0x1a3c42ded7b75cdf4ebc7c7b7da9d1e1db49f16fcdca934fac003f35f39ecad9";
|
|
6
7
|
const MODULE_NAME = "swap_router";
|
|
7
8
|
const VERSION = "0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f";
|
|
@@ -32,7 +33,7 @@ export class TurbosContract extends BaseContract {
|
|
|
32
33
|
tx.object(VERSION),
|
|
33
34
|
],
|
|
34
35
|
});
|
|
35
|
-
tx.
|
|
36
|
+
SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, tokenIn, address);
|
|
36
37
|
return tokenOut;
|
|
37
38
|
}
|
|
38
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildTx.d.ts","sourceRoot":"","sources":["../../../src/buildTx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,yBAAyB,EAE1B,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAI3C,eAAO,MAAM,OAAO,gGAOjB,aAAa;;;
|
|
1
|
+
{"version":3,"file":"buildTx.d.ts","sourceRoot":"","sources":["../../../src/buildTx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,yBAAyB,EAE1B,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAI3C,eAAO,MAAM,OAAO,gGAOjB,aAAa;;;EAiGf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getQuote.d.ts","sourceRoot":"","sources":["../../../src/getQuote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG9D,UAAU,MAAM;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;CACvB;
|
|
1
|
+
{"version":3,"file":"getQuote.d.ts","sourceRoot":"","sources":["../../../src/getQuote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG9D,UAAU,MAAM;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;CACvB;AAgBD,wBAAsB,QAAQ,CAAC,EAC7B,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,OAAyB,GAC1B,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAUjC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
2
|
+
import { BaseContract } from "../base";
|
|
3
|
+
export declare class BluefinContract extends BaseContract {
|
|
4
|
+
swap(tx: Transaction): Promise<{
|
|
5
|
+
$kind: "NestedResult";
|
|
6
|
+
NestedResult: [number, number];
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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;AAWvC,qBAAa,eAAgB,SAAQ,YAAY;IACzC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CA2C3B"}
|
|
@@ -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;AAWvC,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;AAWvC,qBAAa,aAAc,SAAQ,YAAY;IACvC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CA2C3B"}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAOvC,qBAAa,gBAAiB,SAAQ,YAAY;IAC1C,IAAI,CAAC,EAAE,EAAE,WAAW;;;;IAwE1B,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,gBAAgB;CAMzB"}
|
|
@@ -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;
|
|
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;AAO3D,qBAAa,2BAA4B,SAAQ,YAAY;IACrD,IAAI,CAAC,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;CA6B5D"}
|
|
@@ -8,6 +8,7 @@ import { SuiswapContract } from "./suiswap";
|
|
|
8
8
|
import { BluemoveContract } from "./bluemove";
|
|
9
9
|
import { KriyaV3Contract } from "./kriyaV3";
|
|
10
10
|
import { SponsoredDeepBookV3Contract } from "./deepbookV3/sponsored";
|
|
11
|
+
import { BluefinContract } from "./bluefin";
|
|
11
12
|
export declare const ProtocolContract: {
|
|
12
13
|
cetus: typeof CetusContract;
|
|
13
14
|
turbos: typeof TurbosContract;
|
|
@@ -19,5 +20,6 @@ export declare const ProtocolContract: {
|
|
|
19
20
|
deepbook_v3: typeof SponsoredDeepBookV3Contract;
|
|
20
21
|
flowx: typeof FlowXContract;
|
|
21
22
|
kriya_v3: typeof KriyaV3Contract;
|
|
23
|
+
bluefin: typeof BluefinContract;
|
|
22
24
|
};
|
|
23
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/libs/protocols/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/libs/protocols/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,eAAO,MAAM,gBAAgB;;;;;;;;;;;;CAY5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/suiswap/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/suiswap/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAOvC,qBAAa,eAAgB,SAAQ,YAAY;IACzC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CA+B3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/turbos/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/turbos/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAWvC,qBAAa,cAAe,SAAQ,YAAY;IACxC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CAyC3B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type SourceDex = "suiswap" | "turbos" | "cetus" | "bluemove" | "kriya" | "kriya_v3" | "aftermath" | "deepbook" | "deepbook_v3" | "flowx";
|
|
1
|
+
export type SourceDex = "suiswap" | "turbos" | "cetus" | "bluemove" | "kriya" | "kriya_v3" | "aftermath" | "deepbook" | "deepbook_v3" | "flowx" | "bluefin";
|
|
2
2
|
export type SorSwap = {
|
|
3
3
|
poolId: string;
|
|
4
4
|
assetInIndex: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregator.d.ts","sourceRoot":"","sources":["../../../../src/types/aggregator.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,QAAQ,GACR,OAAO,GACP,UAAU,GACV,OAAO,GACP,UAAU,GACV,WAAW,GACX,UAAU,GACV,aAAa,GACb,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"aggregator.d.ts","sourceRoot":"","sources":["../../../../src/types/aggregator.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,QAAQ,GACR,OAAO,GACP,UAAU,GACV,OAAO,GACP,UAAU,GACV,WAAW,GACX,UAAU,GACV,aAAa,GACb,OAAO,GACP,SAAS,CAAC;AAEd,MAAM,MAAM,OAAO,GAAG;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,GAAG,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvD,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,uBAAuB,EAAE,MAAM,CAAC;IAChC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;IACpB,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,SAAU,SAAQ,OAAO;IACxC,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,IAAI,CAAC;IACZ,KAAK,EAAE,IAAI,CAAC;IACZ,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -33,6 +33,19 @@ export declare const SuiUtils: {
|
|
|
33
33
|
}[]): string[];
|
|
34
34
|
getOwnedObjectsByPage(owner: string, query: SuiObjectResponseQuery, paginationArgs?: PaginationArgs): Promise<DataPage<any>>;
|
|
35
35
|
isValidStructTag(value: string): boolean;
|
|
36
|
+
zeroBalance(tx: Transaction, coinType: string): {
|
|
37
|
+
$kind: "NestedResult";
|
|
38
|
+
NestedResult: [number, number];
|
|
39
|
+
};
|
|
40
|
+
coinIntoBalance(tx: Transaction, coinType: string, coinObject: TransactionArgument): {
|
|
41
|
+
$kind: "NestedResult";
|
|
42
|
+
NestedResult: [number, number];
|
|
43
|
+
};
|
|
44
|
+
coinFromBalance(tx: Transaction, coinType: string, balance: TransactionArgument): {
|
|
45
|
+
$kind: "NestedResult";
|
|
46
|
+
NestedResult: [number, number];
|
|
47
|
+
};
|
|
48
|
+
transferOrDestroyZeroCoin(tx: Transaction, coinType: string, coin: TransactionArgument, to?: string): void;
|
|
36
49
|
};
|
|
37
50
|
export {};
|
|
38
51
|
//# sourceMappingURL=sui.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../../../src/utils/sui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACL,UAAU,EAEV,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAK5B,KAAK,QAAQ,CAAC,CAAC,IAAI;IACjB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,KAAK,cAAc,GAAG,KAAK,GAAG,SAAS,CAAC;AAExC,eAAO,MAAM,QAAQ;uBAET,MAAM,GAAG,mBAAmB,OAC/B,WAAW,GACf,mBAAmB;4BAMP,KAAK,CAAC,MAAM,GAAG,mBAAmB,CAAC,OAC3C,WAAW,GACf,mBAAmB,GAAG,SAAS;2BAsBtB,MAAM,cACJ,MAAM,GAAG,mBAAmB,OACnC,WAAW,GACf,mBAAmB;mCAYV,MAAM,SACT;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,UACtC,MAAM,OACT,WAAW;;;;gCAoBgB,MAAM,iBAAiB,MAAM;qCAoCtD,UAAU,EAAE,YACT,MAAM,OACX,WAAW;uCAsBuB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;sCA8BhE,MAAM,SACP;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE;iCA6BvC,MAAM,SACN,sBAAsB,mBACb,cAAc,GAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;4BAyBD,MAAM;
|
|
1
|
+
{"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../../../src/utils/sui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACL,UAAU,EAEV,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAK5B,KAAK,QAAQ,CAAC,CAAC,IAAI;IACjB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,KAAK,cAAc,GAAG,KAAK,GAAG,SAAS,CAAC;AAExC,eAAO,MAAM,QAAQ;uBAET,MAAM,GAAG,mBAAmB,OAC/B,WAAW,GACf,mBAAmB;4BAMP,KAAK,CAAC,MAAM,GAAG,mBAAmB,CAAC,OAC3C,WAAW,GACf,mBAAmB,GAAG,SAAS;2BAsBtB,MAAM,cACJ,MAAM,GAAG,mBAAmB,OACnC,WAAW,GACf,mBAAmB;mCAYV,MAAM,SACT;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,UACtC,MAAM,OACT,WAAW;;;;gCAoBgB,MAAM,iBAAiB,MAAM;qCAoCtD,UAAU,EAAE,YACT,MAAM,OACX,WAAW;uCAsBuB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;sCA8BhE,MAAM,SACP;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE;iCA6BvC,MAAM,SACN,sBAAsB,mBACb,cAAc,GAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;4BAyBD,MAAM;oBAQd,WAAW,YAAY,MAAM;;;;wBASvC,WAAW,YACL,MAAM,cACJ,mBAAmB;;;;wBAU3B,WAAW,YACL,MAAM,WACP,mBAAmB;;;;kCAUxB,WAAW,YACL,MAAM,QACV,mBAAmB,OACpB,MAAM;CAUd,CAAC"}
|
package/lib/esm/utils/sui.js
CHANGED
|
@@ -163,4 +163,32 @@ export const SuiUtils = {
|
|
|
163
163
|
return false;
|
|
164
164
|
}
|
|
165
165
|
},
|
|
166
|
+
zeroBalance(tx, coinType) {
|
|
167
|
+
return tx.moveCall({
|
|
168
|
+
target: `0x2::balance::zero`,
|
|
169
|
+
typeArguments: [coinType],
|
|
170
|
+
arguments: [],
|
|
171
|
+
})[0];
|
|
172
|
+
},
|
|
173
|
+
coinIntoBalance(tx, coinType, coinObject) {
|
|
174
|
+
return tx.moveCall({
|
|
175
|
+
target: `0x2::coin::into_balance`,
|
|
176
|
+
typeArguments: [coinType],
|
|
177
|
+
arguments: [coinObject],
|
|
178
|
+
})[0];
|
|
179
|
+
},
|
|
180
|
+
coinFromBalance(tx, coinType, balance) {
|
|
181
|
+
return tx.moveCall({
|
|
182
|
+
target: `0x2::coin::from_balance`,
|
|
183
|
+
typeArguments: [coinType],
|
|
184
|
+
arguments: [balance],
|
|
185
|
+
})[0];
|
|
186
|
+
},
|
|
187
|
+
transferOrDestroyZeroCoin(tx, coinType, coin, to) {
|
|
188
|
+
tx.moveCall({
|
|
189
|
+
target: `0x6f5e582ede61fe5395b50c4a449ec11479a54d7ff8e0158247adfda60d98970b::utils::${to ? "send_coin" : "transfer_coin_to_sender"}`,
|
|
190
|
+
typeArguments: [coinType],
|
|
191
|
+
arguments: [coin, ...(to ? [tx.pure.address(to)] : [])],
|
|
192
|
+
});
|
|
193
|
+
},
|
|
166
194
|
};
|