@7kprotocol/sdk-ts 1.2.2 → 1.2.4

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.
@@ -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 _7K_PACKAGE_ID = "0xd48e7cdc9e92bec69ce3baa75578010458a0c5b2733d661a84971e8cef6806bc";
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,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._7K_CONFIG = exports._7K_PACKAGE_ID = void 0;
4
+ exports._7K_PACKAGE_ID = "0xa13447019cd982d6bef91cf7b46ad384a52583b1dfc2bdecf31ef0c4bd787a0f";
5
+ //V1: "0xd48e7cdc9e92bec69ce3baa75578010458a0c5b2733d661a84971e8cef6806bc";
6
+ exports._7K_CONFIG = "0xc31272d90e0c36181b0153776c9d7c1516d4c1eca50fc2eb01f36d3f457ea90d";
@@ -8,22 +8,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
12
  exports.getSplitCoinForTx = void 0;
16
13
  const transactions_1 = require("@mysten/sui.js/transactions");
17
14
  const getCoinOjectIdsByAmount_1 = require("./getCoinOjectIdsByAmount");
18
- const bignumber_js_1 = __importDefault(require("bignumber.js"));
19
15
  const tokens_1 = require("../constants/tokens");
20
16
  const getSplitCoinForTx = (account, amount, splits, coinType, inheritTx, inspecTransaction) => __awaiter(void 0, void 0, void 0, function* () {
21
17
  const tx = inheritTx !== null && inheritTx !== void 0 ? inheritTx : new transactions_1.TransactionBlock();
22
18
  const { objectIds } = yield (0, getCoinOjectIdsByAmount_1.getCoinOjectIdsByAmount)(account, amount, coinType);
23
19
  const coinObjectId = objectIds[0];
24
- // TODO: find out why the tx.gas is limited at 950 sui
25
- if (coinType === tokens_1.SUI_TYPE &&
26
- new bignumber_js_1.default(amount).lt(new bignumber_js_1.default("950e9"))) {
20
+ if (coinType === tokens_1.SUI_TYPE) {
27
21
  const pureAmount = [];
28
22
  for (const split of splits) {
29
23
  pureAmount.push(tx.pure(split));
@@ -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;AAO3C,eAAO,MAAM,OAAO,mFAMjB,aAAa,0CA2Df,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,3 @@
1
+ export declare const _7K_PACKAGE_ID = "0xa13447019cd982d6bef91cf7b46ad384a52583b1dfc2bdecf31ef0c4bd787a0f";
2
+ export declare const _7K_CONFIG = "0xc31272d90e0c36181b0153776c9d7c1516d4c1eca50fc2eb01f36d3f457ea90d";
3
+ //# 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"}
@@ -1 +1 @@
1
- {"version":3,"file":"getSplitCoinForTx.d.ts","sourceRoot":"","sources":["../../../../src/libs/getSplitCoinForTx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AAKrC,eAAO,MAAM,iBAAiB,YACnB,MAAM,UACP,MAAM,UACN,MAAM,EAAE,YACN,MAAM,cACJ,gBAAgB,sBACR,OAAO,KAC1B,OAAO,CAAC;IACT,EAAE,EAAE,gBAAgB,CAAC;IACrB,QAAQ,EAAE,iBAAiB,CAAC;CAC7B,CAgDA,CAAC"}
1
+ {"version":3,"file":"getSplitCoinForTx.d.ts","sourceRoot":"","sources":["../../../../src/libs/getSplitCoinForTx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AAKrC,eAAO,MAAM,iBAAiB,YACnB,MAAM,UACP,MAAM,UACN,MAAM,EAAE,YACN,MAAM,cACJ,gBAAgB,sBACR,OAAO,KAC1B,OAAO,CAAC;IACT,EAAE,EAAE,gBAAgB,CAAC;IACrB,QAAQ,EAAE,iBAAiB,CAAC;CAC7B,CA4CA,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;AAOvC,qBAAa,gBAAiB,SAAQ,YAAY;IAC1C,IAAI,CAAC,EAAE,EAAE,gBAAgB;;;;;IA+D/B,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,gBAAgB;CAMzB"}
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"}
@@ -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
- const _7K_PACKAGE_ID = "0xd48e7cdc9e92bec69ce3baa75578010458a0c5b2733d661a84971e8cef6806bc";
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,3 @@
1
+ export const _7K_PACKAGE_ID = "0xa13447019cd982d6bef91cf7b46ad384a52583b1dfc2bdecf31ef0c4bd787a0f";
2
+ //V1: "0xd48e7cdc9e92bec69ce3baa75578010458a0c5b2733d661a84971e8cef6806bc";
3
+ export const _7K_CONFIG = "0xc31272d90e0c36181b0153776c9d7c1516d4c1eca50fc2eb01f36d3f457ea90d";
@@ -1,14 +1,11 @@
1
1
  import { TransactionBlock, } from "@mysten/sui.js/transactions";
2
2
  import { getCoinOjectIdsByAmount } from "./getCoinOjectIdsByAmount";
3
- import BigNumber from "bignumber.js";
4
3
  import { SUI_TYPE } from "../constants/tokens";
5
4
  export const getSplitCoinForTx = async (account, amount, splits, coinType, inheritTx, inspecTransaction) => {
6
5
  const tx = inheritTx ?? new TransactionBlock();
7
6
  const { objectIds } = await getCoinOjectIdsByAmount(account, amount, coinType);
8
7
  const coinObjectId = objectIds[0];
9
- // TODO: find out why the tx.gas is limited at 950 sui
10
- if (coinType === SUI_TYPE &&
11
- new BigNumber(amount).lt(new BigNumber("950e9"))) {
8
+ if (coinType === SUI_TYPE) {
12
9
  const pureAmount = [];
13
10
  for (const split of splits) {
14
11
  pureAmount.push(tx.pure(split));
@@ -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;AAO3C,eAAO,MAAM,OAAO,mFAMjB,aAAa,0CA2Df,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,3 @@
1
+ export declare const _7K_PACKAGE_ID = "0xa13447019cd982d6bef91cf7b46ad384a52583b1dfc2bdecf31ef0c4bd787a0f";
2
+ export declare const _7K_CONFIG = "0xc31272d90e0c36181b0153776c9d7c1516d4c1eca50fc2eb01f36d3f457ea90d";
3
+ //# 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"}
@@ -1 +1 @@
1
- {"version":3,"file":"getSplitCoinForTx.d.ts","sourceRoot":"","sources":["../../../../src/libs/getSplitCoinForTx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AAKrC,eAAO,MAAM,iBAAiB,YACnB,MAAM,UACP,MAAM,UACN,MAAM,EAAE,YACN,MAAM,cACJ,gBAAgB,sBACR,OAAO,KAC1B,OAAO,CAAC;IACT,EAAE,EAAE,gBAAgB,CAAC;IACrB,QAAQ,EAAE,iBAAiB,CAAC;CAC7B,CAgDA,CAAC"}
1
+ {"version":3,"file":"getSplitCoinForTx.d.ts","sourceRoot":"","sources":["../../../../src/libs/getSplitCoinForTx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AAKrC,eAAO,MAAM,iBAAiB,YACnB,MAAM,UACP,MAAM,UACN,MAAM,EAAE,YACN,MAAM,cACJ,gBAAgB,sBACR,OAAO,KAC1B,OAAO,CAAC;IACT,EAAE,EAAE,gBAAgB,CAAC;IACrB,QAAQ,EAAE,iBAAiB,CAAC;CAC7B,CA4CA,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;AAOvC,qBAAa,gBAAiB,SAAQ,YAAY;IAC1C,IAAI,CAAC,EAAE,EAAE,gBAAgB;;;;;IA+D/B,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,gBAAgB;CAMzB"}
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@7kprotocol/sdk-ts",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "",
5
5
  "exports": {
6
6
  ".": {