@7kprotocol/sdk-ts 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/lib/cjs/buildTx.js +6 -7
- package/lib/cjs/constants/_7k.js +8 -0
- package/lib/cjs/libs/protocols/deepbook/index.js +2 -2
- package/lib/cjs/types/buildTx.d.ts.map +1 -1
- package/lib/cjs/types/constants/_7k.d.ts +5 -0
- package/lib/cjs/types/constants/_7k.d.ts.map +1 -0
- package/lib/cjs/types/libs/protocols/deepbook/index.d.ts.map +1 -1
- package/lib/esm/buildTx.js +1 -2
- package/lib/esm/constants/_7k.js +5 -0
- package/lib/esm/libs/protocols/deepbook/index.js +1 -1
- package/lib/esm/types/buildTx.d.ts.map +1 -1
- package/lib/esm/types/constants/_7k.d.ts +5 -0
- package/lib/esm/types/constants/_7k.d.ts.map +1 -0
- package/lib/esm/types/libs/protocols/deepbook/index.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ const tx = await buildTx({
|
|
|
44
44
|
accountAddress: "0xSenderAddress",
|
|
45
45
|
slippage: 0.01, // 1%
|
|
46
46
|
commission: {
|
|
47
|
-
partner: "<address to receive
|
|
47
|
+
partner: "<address to receive fee if any>",
|
|
48
48
|
commissionBps: 0, // 0 means no fee, 1bps = 0.01%, for example, 20bps = 0.2%
|
|
49
49
|
},
|
|
50
50
|
});
|
|
@@ -64,7 +64,7 @@ await buildTx({
|
|
|
64
64
|
accountAddress: "0xSenderAddress",
|
|
65
65
|
slippage: 0.01, // 1%
|
|
66
66
|
commission: {
|
|
67
|
-
partner: "<address to receive
|
|
67
|
+
partner: "<address to receive fee if any>",
|
|
68
68
|
commissionBps: 0, // 0 means no fee, 1bps = 0.01%, for example, 20bps = 0.2%
|
|
69
69
|
},
|
|
70
70
|
});
|
|
@@ -92,7 +92,7 @@ const tx = await buildTx({
|
|
|
92
92
|
accountAddress: "0xSenderAddress",
|
|
93
93
|
slippage: 0.01, // 1%
|
|
94
94
|
commission: {
|
|
95
|
-
partner: "<address to receive
|
|
95
|
+
partner: "<address to receive fee if any>",
|
|
96
96
|
commissionBps: 0, // 0 means no fee, 1bps = 0.01%, for example, 20bps = 0.2%
|
|
97
97
|
},
|
|
98
98
|
});
|
|
@@ -110,7 +110,7 @@ const feeInUsd = await estimateGasFee({
|
|
|
110
110
|
accountAddress: "0xSenderAddress",
|
|
111
111
|
slippage: 0.01, // 1%
|
|
112
112
|
commission: {
|
|
113
|
-
partner: "<address to receive
|
|
113
|
+
partner: "<address to receive fee if any>",
|
|
114
114
|
commissionBps: 0, // 0 means no fee, 1bps = 0.01%, for example, 20bps = 0.2%
|
|
115
115
|
},
|
|
116
116
|
});
|
|
@@ -130,7 +130,7 @@ const feeInUsd = await estimateGasFee({
|
|
|
130
130
|
slippage: 0.01, // 1%
|
|
131
131
|
suiPrice,
|
|
132
132
|
commission: {
|
|
133
|
-
partner: "<address to receive
|
|
133
|
+
partner: "<address to receive fee if any>",
|
|
134
134
|
commissionBps: 0, // 0 means no fee, 1bps = 0.01%, for example, 20bps = 0.2%
|
|
135
135
|
},
|
|
136
136
|
});
|
package/lib/cjs/buildTx.js
CHANGED
|
@@ -20,8 +20,7 @@ const groupSwapRoutes_1 = require("./libs/groupSwapRoutes");
|
|
|
20
20
|
const swapWithRoute_1 = require("./libs/swapWithRoute");
|
|
21
21
|
const token_1 = require("./utils/token");
|
|
22
22
|
const sui_1 = require("./utils/sui");
|
|
23
|
-
const
|
|
24
|
-
const _7K_CONFIG = "0xc31272d90e0c36181b0153776c9d7c1516d4c1eca50fc2eb01f36d3f457ea90d";
|
|
23
|
+
const _7k_1 = require("./constants/_7k");
|
|
25
24
|
const buildTx = (_a) => __awaiter(void 0, [_a], void 0, function* ({ quoteResponse, accountAddress, slippage, tx: _tx, commission: _commission, }) {
|
|
26
25
|
if (!accountAddress || !quoteResponse.routes)
|
|
27
26
|
return;
|
|
@@ -52,10 +51,10 @@ const buildTx = (_a) => __awaiter(void 0, [_a], void 0, function* ({ quoteRespon
|
|
|
52
51
|
.toFixed(0);
|
|
53
52
|
const commission = getCommission(tx, _commission);
|
|
54
53
|
tx.moveCall({
|
|
55
|
-
target: `${_7K_PACKAGE_ID}::settle::settle`,
|
|
54
|
+
target: `${_7k_1._7K_PACKAGE_ID}::settle::settle`,
|
|
56
55
|
typeArguments: [quoteResponse.tokenIn, quoteResponse.tokenOut],
|
|
57
56
|
arguments: [
|
|
58
|
-
tx.object(_7K_CONFIG),
|
|
57
|
+
tx.object(_7k_1._7K_CONFIG),
|
|
59
58
|
tx.pure.u64(quoteResponse.swapAmountWithDecimal),
|
|
60
59
|
mergeCoin,
|
|
61
60
|
tx.pure.u64(minReceived),
|
|
@@ -71,7 +70,7 @@ exports.buildTx = buildTx;
|
|
|
71
70
|
const getCommission = (tx, commission) => {
|
|
72
71
|
if (commission) {
|
|
73
72
|
const [commissionInner] = tx.moveCall({
|
|
74
|
-
target: `${_7K_PACKAGE_ID}::commission::new`,
|
|
73
|
+
target: `${_7k_1._7K_PACKAGE_ID}::commission::new`,
|
|
75
74
|
typeArguments: [],
|
|
76
75
|
arguments: [
|
|
77
76
|
tx.pure.address(commission.partner),
|
|
@@ -80,14 +79,14 @@ const getCommission = (tx, commission) => {
|
|
|
80
79
|
});
|
|
81
80
|
const [result] = tx.moveCall({
|
|
82
81
|
target: "0x1::option::some",
|
|
83
|
-
typeArguments: [`${_7K_PACKAGE_ID}::commission::Commission`],
|
|
82
|
+
typeArguments: [`${_7k_1._7K_PACKAGE_ID}::commission::Commission`],
|
|
84
83
|
arguments: [commissionInner],
|
|
85
84
|
});
|
|
86
85
|
return result;
|
|
87
86
|
}
|
|
88
87
|
return tx.moveCall({
|
|
89
88
|
target: "0x1::option::none",
|
|
90
|
-
typeArguments: [`${_7K_PACKAGE_ID}::commission::Commission`],
|
|
89
|
+
typeArguments: [`${_7k_1._7K_PACKAGE_ID}::commission::Commission`],
|
|
91
90
|
arguments: [],
|
|
92
91
|
})[0];
|
|
93
92
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._7K_COMMISSION_BPS = exports._7K_COMMISSION_PARTNER = exports._7K_CONFIG = exports._7K_PACKAGE_ID = void 0;
|
|
4
|
+
exports._7K_PACKAGE_ID = "0xa13447019cd982d6bef91cf7b46ad384a52583b1dfc2bdecf31ef0c4bd787a0f";
|
|
5
|
+
//V1: "0xd48e7cdc9e92bec69ce3baa75578010458a0c5b2733d661a84971e8cef6806bc";
|
|
6
|
+
exports._7K_CONFIG = "0xc31272d90e0c36181b0153776c9d7c1516d4c1eca50fc2eb01f36d3f457ea90d";
|
|
7
|
+
exports._7K_COMMISSION_PARTNER = "0x8bd5bf35fee1343cbb6c11b55f5ae234f96cf630778b53ecbae68b4a33423dbb";
|
|
8
|
+
exports._7K_COMMISSION_BPS = "0";
|
|
@@ -12,9 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.DeepBookContract = void 0;
|
|
13
13
|
const utils_1 = require("@mysten/sui.js/utils");
|
|
14
14
|
const base_1 = require("../base");
|
|
15
|
+
const _7k_1 = require("../../../constants/_7k");
|
|
15
16
|
const PACKAGE_ID = "0xdee9";
|
|
16
17
|
const MODULE_NAME = "clob_v2";
|
|
17
|
-
const _7K_PACKAGE_ID = "0xd48e7cdc9e92bec69ce3baa75578010458a0c5b2733d661a84971e8cef6806bc";
|
|
18
18
|
class DeepBookContract extends base_1.BaseContract {
|
|
19
19
|
swap(tx) {
|
|
20
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -31,7 +31,7 @@ class DeepBookContract extends base_1.BaseContract {
|
|
|
31
31
|
let result;
|
|
32
32
|
if (swapXtoY) {
|
|
33
33
|
const amountInRound = tx.moveCall({
|
|
34
|
-
target: `${_7K_PACKAGE_ID}::math::m_round_down`,
|
|
34
|
+
target: `${_7k_1._7K_PACKAGE_ID}::math::m_round_down`,
|
|
35
35
|
arguments: [
|
|
36
36
|
amountIn, // input coin value
|
|
37
37
|
tx.pure.u64(lotSize), // lot size
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildTx.d.ts","sourceRoot":"","sources":["../../../src/buildTx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAEjB,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"buildTx.d.ts","sourceRoot":"","sources":["../../../src/buildTx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAEjB,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,eAAO,MAAM,OAAO,mFAMjB,aAAa,0CA2Df,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const _7K_PACKAGE_ID = "0xa13447019cd982d6bef91cf7b46ad384a52583b1dfc2bdecf31ef0c4bd787a0f";
|
|
2
|
+
export declare const _7K_CONFIG = "0xc31272d90e0c36181b0153776c9d7c1516d4c1eca50fc2eb01f36d3f457ea90d";
|
|
3
|
+
export declare const _7K_COMMISSION_PARTNER = "0x8bd5bf35fee1343cbb6c11b55f5ae234f96cf630778b53ecbae68b4a33423dbb";
|
|
4
|
+
export declare const _7K_COMMISSION_BPS = "0";
|
|
5
|
+
//# sourceMappingURL=_7k.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_7k.d.ts","sourceRoot":"","sources":["../../../../src/constants/_7k.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,uEAC2C,CAAC;AAEvE,eAAO,MAAM,UAAU,uEAC+C,CAAC;AAEvE,eAAO,MAAM,sBAAsB,uEACmC,CAAC;AACvE,eAAO,MAAM,kBAAkB,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/deepbook/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,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,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMvC,qBAAa,gBAAiB,SAAQ,YAAY;IAC1C,IAAI,CAAC,EAAE,EAAE,gBAAgB;;;;;IA+D/B,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,gBAAgB;CAMzB"}
|
package/lib/esm/buildTx.js
CHANGED
|
@@ -5,8 +5,7 @@ import { groupSwapRoutes } from "./libs/groupSwapRoutes";
|
|
|
5
5
|
import { swapWithRoute } from "./libs/swapWithRoute";
|
|
6
6
|
import { denormalizeTokenType } from "./utils/token";
|
|
7
7
|
import { SuiUtils } from "./utils/sui";
|
|
8
|
-
|
|
9
|
-
const _7K_CONFIG = "0xc31272d90e0c36181b0153776c9d7c1516d4c1eca50fc2eb01f36d3f457ea90d";
|
|
8
|
+
import { _7K_CONFIG, _7K_PACKAGE_ID } from "./constants/_7k";
|
|
10
9
|
export const buildTx = async ({ quoteResponse, accountAddress, slippage, tx: _tx, commission: _commission, }) => {
|
|
11
10
|
if (!accountAddress || !quoteResponse.routes)
|
|
12
11
|
return;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const _7K_PACKAGE_ID = "0xa13447019cd982d6bef91cf7b46ad384a52583b1dfc2bdecf31ef0c4bd787a0f";
|
|
2
|
+
//V1: "0xd48e7cdc9e92bec69ce3baa75578010458a0c5b2733d661a84971e8cef6806bc";
|
|
3
|
+
export const _7K_CONFIG = "0xc31272d90e0c36181b0153776c9d7c1516d4c1eca50fc2eb01f36d3f457ea90d";
|
|
4
|
+
export const _7K_COMMISSION_PARTNER = "0x8bd5bf35fee1343cbb6c11b55f5ae234f96cf630778b53ecbae68b4a33423dbb";
|
|
5
|
+
export const _7K_COMMISSION_BPS = "0";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui.js/utils";
|
|
2
2
|
import { BaseContract } from "../base";
|
|
3
|
+
import { _7K_PACKAGE_ID } from "../../../constants/_7k";
|
|
3
4
|
const PACKAGE_ID = "0xdee9";
|
|
4
5
|
const MODULE_NAME = "clob_v2";
|
|
5
|
-
const _7K_PACKAGE_ID = "0xd48e7cdc9e92bec69ce3baa75578010458a0c5b2733d661a84971e8cef6806bc";
|
|
6
6
|
export class DeepBookContract extends BaseContract {
|
|
7
7
|
async swap(tx) {
|
|
8
8
|
const swapXtoY = this.swapInfo.swapXtoY;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildTx.d.ts","sourceRoot":"","sources":["../../../src/buildTx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAEjB,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"buildTx.d.ts","sourceRoot":"","sources":["../../../src/buildTx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAEjB,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,eAAO,MAAM,OAAO,mFAMjB,aAAa,0CA2Df,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const _7K_PACKAGE_ID = "0xa13447019cd982d6bef91cf7b46ad384a52583b1dfc2bdecf31ef0c4bd787a0f";
|
|
2
|
+
export declare const _7K_CONFIG = "0xc31272d90e0c36181b0153776c9d7c1516d4c1eca50fc2eb01f36d3f457ea90d";
|
|
3
|
+
export declare const _7K_COMMISSION_PARTNER = "0x8bd5bf35fee1343cbb6c11b55f5ae234f96cf630778b53ecbae68b4a33423dbb";
|
|
4
|
+
export declare const _7K_COMMISSION_BPS = "0";
|
|
5
|
+
//# sourceMappingURL=_7k.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_7k.d.ts","sourceRoot":"","sources":["../../../../src/constants/_7k.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,uEAC2C,CAAC;AAEvE,eAAO,MAAM,UAAU,uEAC+C,CAAC;AAEvE,eAAO,MAAM,sBAAsB,uEACmC,CAAC;AACvE,eAAO,MAAM,kBAAkB,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/deepbook/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,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,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMvC,qBAAa,gBAAiB,SAAQ,YAAY;IAC1C,IAAI,CAAC,EAAE,EAAE,gBAAgB;;;;;IA+D/B,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,gBAAgB;CAMzB"}
|