@7kprotocol/sdk-ts 2.1.0 → 2.1.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/lib/cjs/buildTx.js +8 -25
- package/lib/cjs/constants/_7k.js +6 -4
- package/lib/cjs/types/buildTx.d.ts.map +1 -1
- package/lib/cjs/types/constants/_7k.d.ts +3 -2
- package/lib/cjs/types/constants/_7k.d.ts.map +1 -1
- package/lib/esm/buildTx.js +9 -26
- package/lib/esm/constants/_7k.js +5 -3
- package/lib/esm/types/buildTx.d.ts.map +1 -1
- package/lib/esm/types/constants/_7k.d.ts +3 -2
- package/lib/esm/types/constants/_7k.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/cjs/buildTx.js
CHANGED
|
@@ -67,17 +67,23 @@ const buildTx = (_a) => __awaiter(void 0, [_a], void 0, function* ({ quoteRespon
|
|
|
67
67
|
.minus(slippage)
|
|
68
68
|
.multipliedBy(quoteResponse.returnAmountWithDecimal)
|
|
69
69
|
.toFixed(0);
|
|
70
|
-
const
|
|
70
|
+
const [partner] = tx.moveCall({
|
|
71
|
+
target: "0x1::option::some",
|
|
72
|
+
typeArguments: [`address`],
|
|
73
|
+
arguments: [tx.pure.address(_commission.partner)],
|
|
74
|
+
});
|
|
71
75
|
tx.moveCall({
|
|
72
76
|
target: `${_7k_1._7K_PACKAGE_ID}::settle::settle`,
|
|
73
77
|
typeArguments: [quoteResponse.tokenIn, quoteResponse.tokenOut],
|
|
74
78
|
arguments: [
|
|
75
79
|
tx.object(_7k_1._7K_CONFIG),
|
|
80
|
+
tx.object(_7k_1._7K_VAULT),
|
|
76
81
|
tx.pure.u64(quoteResponse.swapAmountWithDecimal),
|
|
77
82
|
mergeCoin,
|
|
78
83
|
tx.pure.u64(minReceived),
|
|
79
84
|
tx.pure.u64(quoteResponse.returnAmountWithDecimal),
|
|
80
|
-
|
|
85
|
+
partner,
|
|
86
|
+
tx.pure.u64(_commission.commissionBps),
|
|
81
87
|
],
|
|
82
88
|
});
|
|
83
89
|
if (!extendTx) {
|
|
@@ -87,26 +93,3 @@ const buildTx = (_a) => __awaiter(void 0, [_a], void 0, function* ({ quoteRespon
|
|
|
87
93
|
return { tx, coinOut };
|
|
88
94
|
});
|
|
89
95
|
exports.buildTx = buildTx;
|
|
90
|
-
const getCommission = (tx, commission) => {
|
|
91
|
-
if (commission) {
|
|
92
|
-
const [commissionInner] = tx.moveCall({
|
|
93
|
-
target: `${_7k_1._7K_PACKAGE_ID}::commission::new`,
|
|
94
|
-
typeArguments: [],
|
|
95
|
-
arguments: [
|
|
96
|
-
tx.pure.address(commission.partner),
|
|
97
|
-
tx.pure.u64(commission.commissionBps),
|
|
98
|
-
],
|
|
99
|
-
});
|
|
100
|
-
const [result] = tx.moveCall({
|
|
101
|
-
target: "0x1::option::some",
|
|
102
|
-
typeArguments: [`${_7k_1._7K_PACKAGE_ID}::commission::Commission`],
|
|
103
|
-
arguments: [commissionInner],
|
|
104
|
-
});
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
107
|
-
return tx.moveCall({
|
|
108
|
-
target: "0x1::option::none",
|
|
109
|
-
typeArguments: [`${_7k_1._7K_PACKAGE_ID}::commission::Commission`],
|
|
110
|
-
arguments: [],
|
|
111
|
-
})[0];
|
|
112
|
-
};
|
package/lib/cjs/constants/_7k.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._7K_CONFIG = exports._7K_PACKAGE_ID = void 0;
|
|
4
|
-
exports._7K_PACKAGE_ID = "
|
|
5
|
-
//
|
|
6
|
-
|
|
3
|
+
exports._7K_VAULT = exports._7K_CONFIG = exports._7K_PACKAGE_ID = void 0;
|
|
4
|
+
exports._7K_PACKAGE_ID = "0x7ea6e27ad7af6f3b8671d59df1aaebd7c03dddab893e52a714227b2f4fe91519";
|
|
5
|
+
//legacy V2: "0xa13447019cd982d6bef91cf7b46ad384a52583b1dfc2bdecf31ef0c4bd787a0f";
|
|
6
|
+
//legacy V1: "0xd48e7cdc9e92bec69ce3baa75578010458a0c5b2733d661a84971e8cef6806bc";
|
|
7
|
+
exports._7K_CONFIG = "0x0f8fc23dbcc9362b72c7a4c5aa53fcefa02ebfbb83a812c8c262ccd2c076d9ee";
|
|
8
|
+
exports._7K_VAULT = "0x39a3c55742c0e011b6f65548e73cf589e1ae5e82dbfab449ca57f24c3bcd9514";
|
|
@@ -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;;;EA2Ff,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export declare const _7K_PACKAGE_ID = "
|
|
2
|
-
export declare const _7K_CONFIG = "
|
|
1
|
+
export declare const _7K_PACKAGE_ID = "0x7ea6e27ad7af6f3b8671d59df1aaebd7c03dddab893e52a714227b2f4fe91519";
|
|
2
|
+
export declare const _7K_CONFIG = "0x0f8fc23dbcc9362b72c7a4c5aa53fcefa02ebfbb83a812c8c262ccd2c076d9ee";
|
|
3
|
+
export declare const _7K_VAULT = "0x39a3c55742c0e011b6f65548e73cf589e1ae5e82dbfab449ca57f24c3bcd9514";
|
|
3
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;AAGvE,eAAO,MAAM,UAAU,uEAC+C,CAAC;AAEvE,eAAO,MAAM,SAAS,uEACgD,CAAC"}
|
package/lib/esm/buildTx.js
CHANGED
|
@@ -5,7 +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
|
-
import { _7K_CONFIG, _7K_PACKAGE_ID } from "./constants/_7k";
|
|
8
|
+
import { _7K_CONFIG, _7K_PACKAGE_ID, _7K_VAULT } from "./constants/_7k";
|
|
9
9
|
import { isValidSuiAddress } from "@mysten/sui/utils";
|
|
10
10
|
export const buildTx = async ({ quoteResponse, accountAddress, slippage, commission: _commission, devInspect, extendTx, }) => {
|
|
11
11
|
const { tx: _tx, coinIn } = extendTx || {};
|
|
@@ -52,17 +52,23 @@ export const buildTx = async ({ quoteResponse, accountAddress, slippage, commiss
|
|
|
52
52
|
.minus(slippage)
|
|
53
53
|
.multipliedBy(quoteResponse.returnAmountWithDecimal)
|
|
54
54
|
.toFixed(0);
|
|
55
|
-
const
|
|
55
|
+
const [partner] = tx.moveCall({
|
|
56
|
+
target: "0x1::option::some",
|
|
57
|
+
typeArguments: [`address`],
|
|
58
|
+
arguments: [tx.pure.address(_commission.partner)],
|
|
59
|
+
});
|
|
56
60
|
tx.moveCall({
|
|
57
61
|
target: `${_7K_PACKAGE_ID}::settle::settle`,
|
|
58
62
|
typeArguments: [quoteResponse.tokenIn, quoteResponse.tokenOut],
|
|
59
63
|
arguments: [
|
|
60
64
|
tx.object(_7K_CONFIG),
|
|
65
|
+
tx.object(_7K_VAULT),
|
|
61
66
|
tx.pure.u64(quoteResponse.swapAmountWithDecimal),
|
|
62
67
|
mergeCoin,
|
|
63
68
|
tx.pure.u64(minReceived),
|
|
64
69
|
tx.pure.u64(quoteResponse.returnAmountWithDecimal),
|
|
65
|
-
|
|
70
|
+
partner,
|
|
71
|
+
tx.pure.u64(_commission.commissionBps),
|
|
66
72
|
],
|
|
67
73
|
});
|
|
68
74
|
if (!extendTx) {
|
|
@@ -71,26 +77,3 @@ export const buildTx = async ({ quoteResponse, accountAddress, slippage, commiss
|
|
|
71
77
|
}
|
|
72
78
|
return { tx, coinOut };
|
|
73
79
|
};
|
|
74
|
-
const getCommission = (tx, commission) => {
|
|
75
|
-
if (commission) {
|
|
76
|
-
const [commissionInner] = tx.moveCall({
|
|
77
|
-
target: `${_7K_PACKAGE_ID}::commission::new`,
|
|
78
|
-
typeArguments: [],
|
|
79
|
-
arguments: [
|
|
80
|
-
tx.pure.address(commission.partner),
|
|
81
|
-
tx.pure.u64(commission.commissionBps),
|
|
82
|
-
],
|
|
83
|
-
});
|
|
84
|
-
const [result] = tx.moveCall({
|
|
85
|
-
target: "0x1::option::some",
|
|
86
|
-
typeArguments: [`${_7K_PACKAGE_ID}::commission::Commission`],
|
|
87
|
-
arguments: [commissionInner],
|
|
88
|
-
});
|
|
89
|
-
return result;
|
|
90
|
-
}
|
|
91
|
-
return tx.moveCall({
|
|
92
|
-
target: "0x1::option::none",
|
|
93
|
-
typeArguments: [`${_7K_PACKAGE_ID}::commission::Commission`],
|
|
94
|
-
arguments: [],
|
|
95
|
-
})[0];
|
|
96
|
-
};
|
package/lib/esm/constants/_7k.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export const _7K_PACKAGE_ID = "
|
|
2
|
-
//
|
|
3
|
-
|
|
1
|
+
export const _7K_PACKAGE_ID = "0x7ea6e27ad7af6f3b8671d59df1aaebd7c03dddab893e52a714227b2f4fe91519";
|
|
2
|
+
//legacy V2: "0xa13447019cd982d6bef91cf7b46ad384a52583b1dfc2bdecf31ef0c4bd787a0f";
|
|
3
|
+
//legacy V1: "0xd48e7cdc9e92bec69ce3baa75578010458a0c5b2733d661a84971e8cef6806bc";
|
|
4
|
+
export const _7K_CONFIG = "0x0f8fc23dbcc9362b72c7a4c5aa53fcefa02ebfbb83a812c8c262ccd2c076d9ee";
|
|
5
|
+
export const _7K_VAULT = "0x39a3c55742c0e011b6f65548e73cf589e1ae5e82dbfab449ca57f24c3bcd9514";
|
|
@@ -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;;;EA2Ff,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export declare const _7K_PACKAGE_ID = "
|
|
2
|
-
export declare const _7K_CONFIG = "
|
|
1
|
+
export declare const _7K_PACKAGE_ID = "0x7ea6e27ad7af6f3b8671d59df1aaebd7c03dddab893e52a714227b2f4fe91519";
|
|
2
|
+
export declare const _7K_CONFIG = "0x0f8fc23dbcc9362b72c7a4c5aa53fcefa02ebfbb83a812c8c262ccd2c076d9ee";
|
|
3
|
+
export declare const _7K_VAULT = "0x39a3c55742c0e011b6f65548e73cf589e1ae5e82dbfab449ca57f24c3bcd9514";
|
|
3
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;AAGvE,eAAO,MAAM,UAAU,uEAC+C,CAAC;AAEvE,eAAO,MAAM,SAAS,uEACgD,CAAC"}
|