@7kprotocol/sdk-ts 2.3.7 → 2.4.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.
Files changed (115) hide show
  1. package/README.md +31 -3
  2. package/lib/cjs/config/fetchClient.js +24 -0
  3. package/lib/cjs/{suiClient.js → config/index.js} +15 -2
  4. package/lib/cjs/constants/apiEndpoints.js +9 -0
  5. package/lib/cjs/features/limitDca/constants.js +2 -1
  6. package/lib/cjs/features/limitDca/getClosedDcaOrders.js +2 -1
  7. package/lib/cjs/features/limitDca/getClosedLimitOrders.js +2 -1
  8. package/lib/cjs/features/limitDca/getDcaOrderExecutions.js +2 -1
  9. package/lib/cjs/features/limitDca/getOpenDcaOrders.js +2 -1
  10. package/lib/cjs/features/limitDca/getOpenLimitOrders.js +2 -1
  11. package/lib/cjs/features/prices/index.js +4 -4
  12. package/lib/cjs/features/swap/buildTx.js +2 -2
  13. package/lib/cjs/features/swap/config.js +3 -1
  14. package/lib/cjs/features/swap/estimateGasFee.js +2 -2
  15. package/lib/cjs/features/swap/getQuote.js +3 -1
  16. package/lib/cjs/features/swap/getSwapHistory.js +3 -1
  17. package/lib/cjs/index.js +12 -6
  18. package/lib/cjs/libs/getCoinOjectIdsByAmount.js +2 -2
  19. package/lib/cjs/libs/getSplitCoinForTx.js +2 -2
  20. package/lib/cjs/types/config/fetchClient.d.ts +2 -0
  21. package/lib/cjs/types/config/fetchClient.d.ts.map +1 -0
  22. package/lib/cjs/types/config/index.d.ts +13 -0
  23. package/lib/cjs/types/config/index.d.ts.map +1 -0
  24. package/lib/cjs/types/constants/apiEndpoints.d.ts +7 -0
  25. package/lib/cjs/types/constants/apiEndpoints.d.ts.map +1 -0
  26. package/lib/cjs/types/features/limitDca/constants.d.ts +1 -1
  27. package/lib/cjs/types/features/limitDca/constants.d.ts.map +1 -1
  28. package/lib/cjs/types/features/limitDca/getClosedDcaOrders.d.ts.map +1 -1
  29. package/lib/cjs/types/features/limitDca/getClosedLimitOrders.d.ts.map +1 -1
  30. package/lib/cjs/types/features/limitDca/getDcaOrderExecutions.d.ts.map +1 -1
  31. package/lib/cjs/types/features/limitDca/getOpenDcaOrders.d.ts.map +1 -1
  32. package/lib/cjs/types/features/limitDca/getOpenLimitOrders.d.ts.map +1 -1
  33. package/lib/cjs/types/features/prices/index.d.ts +0 -1
  34. package/lib/cjs/types/features/prices/index.d.ts.map +1 -1
  35. package/lib/cjs/types/features/swap/buildTx.d.ts +1 -1
  36. package/lib/cjs/types/features/swap/buildTx.d.ts.map +1 -1
  37. package/lib/cjs/types/features/swap/config.d.ts.map +1 -1
  38. package/lib/cjs/types/features/swap/getQuote.d.ts.map +1 -1
  39. package/lib/cjs/types/features/swap/getSwapHistory.d.ts.map +1 -1
  40. package/lib/cjs/types/index.d.ts +13 -5
  41. package/lib/cjs/types/index.d.ts.map +1 -1
  42. package/lib/cjs/types/libs/getSplitCoinForTx.d.ts +1 -1
  43. package/lib/cjs/types/libs/getSplitCoinForTx.d.ts.map +1 -1
  44. package/lib/cjs/types/types/tx.d.ts +0 -35
  45. package/lib/cjs/types/types/tx.d.ts.map +1 -1
  46. package/lib/cjs/types/utils/token.d.ts +0 -2
  47. package/lib/cjs/types/utils/token.d.ts.map +1 -1
  48. package/lib/cjs/utils/sui.js +3 -3
  49. package/lib/cjs/utils/token.js +0 -21
  50. package/lib/esm/config/fetchClient.js +13 -0
  51. package/lib/esm/config/index.js +24 -0
  52. package/lib/esm/constants/apiEndpoints.js +6 -0
  53. package/lib/esm/features/limitDca/constants.js +2 -1
  54. package/lib/esm/features/limitDca/getClosedDcaOrders.js +2 -1
  55. package/lib/esm/features/limitDca/getClosedLimitOrders.js +2 -1
  56. package/lib/esm/features/limitDca/getDcaOrderExecutions.js +2 -1
  57. package/lib/esm/features/limitDca/getOpenDcaOrders.js +2 -1
  58. package/lib/esm/features/limitDca/getOpenLimitOrders.js +2 -1
  59. package/lib/esm/features/prices/index.js +4 -3
  60. package/lib/esm/features/swap/buildTx.js +2 -2
  61. package/lib/esm/features/swap/config.js +3 -1
  62. package/lib/esm/features/swap/estimateGasFee.js +2 -2
  63. package/lib/esm/features/swap/getQuote.js +3 -1
  64. package/lib/esm/features/swap/getSwapHistory.js +3 -1
  65. package/lib/esm/index.mjs +8 -1
  66. package/lib/esm/libs/getCoinOjectIdsByAmount.js +2 -2
  67. package/lib/esm/libs/getSplitCoinForTx.js +2 -2
  68. package/lib/esm/types/config/fetchClient.d.ts +2 -0
  69. package/lib/esm/types/config/fetchClient.d.ts.map +1 -0
  70. package/lib/esm/types/config/index.d.ts +13 -0
  71. package/lib/esm/types/config/index.d.ts.map +1 -0
  72. package/lib/esm/types/constants/apiEndpoints.d.ts +7 -0
  73. package/lib/esm/types/constants/apiEndpoints.d.ts.map +1 -0
  74. package/lib/esm/types/features/limitDca/constants.d.ts +1 -1
  75. package/lib/esm/types/features/limitDca/constants.d.ts.map +1 -1
  76. package/lib/esm/types/features/limitDca/getClosedDcaOrders.d.ts.map +1 -1
  77. package/lib/esm/types/features/limitDca/getClosedLimitOrders.d.ts.map +1 -1
  78. package/lib/esm/types/features/limitDca/getDcaOrderExecutions.d.ts.map +1 -1
  79. package/lib/esm/types/features/limitDca/getOpenDcaOrders.d.ts.map +1 -1
  80. package/lib/esm/types/features/limitDca/getOpenLimitOrders.d.ts.map +1 -1
  81. package/lib/esm/types/features/prices/index.d.ts +0 -1
  82. package/lib/esm/types/features/prices/index.d.ts.map +1 -1
  83. package/lib/esm/types/features/swap/buildTx.d.ts +1 -1
  84. package/lib/esm/types/features/swap/buildTx.d.ts.map +1 -1
  85. package/lib/esm/types/features/swap/config.d.ts.map +1 -1
  86. package/lib/esm/types/features/swap/getQuote.d.ts.map +1 -1
  87. package/lib/esm/types/features/swap/getSwapHistory.d.ts.map +1 -1
  88. package/lib/esm/types/index.d.ts +13 -5
  89. package/lib/esm/types/index.d.ts.map +1 -1
  90. package/lib/esm/types/libs/getSplitCoinForTx.d.ts +1 -1
  91. package/lib/esm/types/libs/getSplitCoinForTx.d.ts.map +1 -1
  92. package/lib/esm/types/types/tx.d.ts +0 -35
  93. package/lib/esm/types/types/tx.d.ts.map +1 -1
  94. package/lib/esm/types/utils/token.d.ts +0 -2
  95. package/lib/esm/types/utils/token.d.ts.map +1 -1
  96. package/lib/esm/utils/sui.js +3 -3
  97. package/lib/esm/utils/token.js +0 -9
  98. package/package.json +1 -1
  99. package/lib/cjs/constants/explorer.js +0 -6
  100. package/lib/cjs/types/constants/explorer.d.ts +0 -4
  101. package/lib/cjs/types/constants/explorer.d.ts.map +0 -1
  102. package/lib/cjs/types/suiClient.d.ts +0 -4
  103. package/lib/cjs/types/suiClient.d.ts.map +0 -1
  104. package/lib/cjs/types/token.js +0 -2
  105. package/lib/cjs/types/types/token.d.ts +0 -30
  106. package/lib/cjs/types/types/token.d.ts.map +0 -1
  107. package/lib/esm/constants/explorer.js +0 -3
  108. package/lib/esm/suiClient.js +0 -10
  109. package/lib/esm/types/constants/explorer.d.ts +0 -4
  110. package/lib/esm/types/constants/explorer.d.ts.map +0 -1
  111. package/lib/esm/types/suiClient.d.ts +0 -4
  112. package/lib/esm/types/suiClient.d.ts.map +0 -1
  113. package/lib/esm/types/token.js +0 -1
  114. package/lib/esm/types/types/token.d.ts +0 -30
  115. package/lib/esm/types/types/token.d.ts.map +0 -1
@@ -2,54 +2,19 @@ import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions
2
2
  import { Commission, QuoteResponse } from "./aggregator";
3
3
  import BigNumber from "bignumber.js";
4
4
  export interface CommonParams {
5
- /** Quote response from 7k api */
6
5
  quoteResponse: QuoteResponse;
7
- /** User address */
8
6
  accountAddress: string;
9
- /** Slippage tolerance, ex: 0.01 (1%) */
10
7
  slippage: BigNumber.Value;
11
- /** Commission for partner */
12
8
  commission: Commission;
13
- /**
14
- * Give Flexibility to insert custom commands before or after swap
15
- * @example
16
- * ```typescript
17
- * const rawTx = new Transaction();
18
- * // Add custom commands to rawTx
19
- * rawTx.moveCall({
20
- * target: "0x2222222::example::claim",
21
- * arguments: [],
22
- * });
23
- * const { tx, coinOut } = await buildTx({
24
- * quoteResponse,
25
- * accountAddress,
26
- * slippage,
27
- * commission,
28
- * extendTx: {
29
- * tx: rawTx,
30
- * coinIn: rawTx.object(coinObjectId),
31
- * },
32
- * });
33
- * // add more commands after the swap if needed, and remember to consume the coinOut object
34
- * tx.transferObjects([coinOut], tx.pure.address(accountAddress));
35
- * ```
36
- */
37
9
  extendTx?: {
38
10
  tx: Transaction;
39
11
  coinIn?: TransactionObjectArgument;
40
12
  };
41
- /**
42
- * If true, indicates that the transaction is sponsored and its gas object should not be modified.
43
- * In this case, the gas object is expected to be already set up correctly for the sponsored transaction.
44
- */
45
- isSponsored?: boolean;
46
13
  }
47
14
  export interface BuildTxParams extends CommonParams {
48
- /** Developer inspection mode */
49
15
  devInspect?: boolean;
50
16
  }
51
17
  export interface EstimateGasFeeParams extends CommonParams {
52
- /** Sui price in usd for gas estimation */
53
18
  suiPrice?: number;
54
19
  }
55
20
  //# sourceMappingURL=tx.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../../../src/types/tx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,MAAM,WAAW,YAAY;IAC3B,iCAAiC;IACjC,aAAa,EAAE,aAAa,CAAC;IAC7B,mBAAmB;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,wCAAwC;IACxC,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC;IAC1B,6BAA6B;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,QAAQ,CAAC,EAAE;QACT,EAAE,EAAE,WAAW,CAAC;QAChB,MAAM,CAAC,EAAE,yBAAyB,CAAC;KACpC,CAAC;IACF;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,gCAAgC;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
1
+ {"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../../../src/types/tx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,aAAa,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC;IAC1B,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,CAAC,EAAE;QACT,EAAE,EAAE,WAAW,CAAC;QAChB,MAAM,CAAC,EAAE,yBAAyB,CAAC;KACpC,CAAC;CACH;AAED,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
@@ -1,6 +1,4 @@
1
- import { SuiscanToken } from "../types/token";
2
1
  export declare function normalizeTokenType(type: string): string;
3
2
  export declare function denormalizeTokenType(type: string): string;
4
3
  export declare function checkIsSui(type: string): type is "0x2::sui::SUI" | "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
5
- export declare function getSuiscanTokenMetadata(type: string): Promise<SuiscanToken>;
6
4
  //# sourceMappingURL=token.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../../src/utils/token.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,UAE9C;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,UAEhD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,4GAEtC;AAED,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,MAAM,yBASzD"}
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../../src/utils/token.ts"],"names":[],"mappings":"AAEA,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,UAE9C;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,UAEhD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,4GAEtC"}
@@ -13,7 +13,7 @@ exports.SuiUtils = void 0;
13
13
  const transactions_1 = require("@mysten/sui/transactions");
14
14
  const utils_1 = require("@mysten/sui/utils");
15
15
  const token_1 = require("./token");
16
- const suiClient_1 = require("../suiClient");
16
+ const config_1 = require("../config");
17
17
  exports.SuiUtils = {
18
18
  getSuiCoin(amount, txb) {
19
19
  const [coin] = txb.splitCoins(txb.gas, [amount]);
@@ -107,7 +107,7 @@ exports.SuiUtils = {
107
107
  let iter = 0;
108
108
  do {
109
109
  try {
110
- const res = yield (0, suiClient_1.getSuiClient)().getCoins({
110
+ const res = yield config_1.Config.getSuiClient().getCoins({
111
111
  owner: address,
112
112
  coinType: type,
113
113
  cursor: cursor,
@@ -155,7 +155,7 @@ exports.SuiUtils = {
155
155
  const queryAll = paginationArgs === "all";
156
156
  let nextCursor = queryAll ? null : paginationArgs.cursor;
157
157
  do {
158
- const res = yield (0, suiClient_1.getSuiClient)().getOwnedObjects(Object.assign(Object.assign({ owner }, query), { cursor: nextCursor, limit: queryAll ? null : paginationArgs.limit }));
158
+ const res = yield config_1.Config.getSuiClient().getOwnedObjects(Object.assign(Object.assign({ owner }, query), { cursor: nextCursor, limit: queryAll ? null : paginationArgs.limit }));
159
159
  if (res.data) {
160
160
  result = [...result, ...res.data];
161
161
  hasNextPage = res.hasNextPage;
@@ -1,19 +1,8 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.normalizeTokenType = normalizeTokenType;
13
4
  exports.denormalizeTokenType = denormalizeTokenType;
14
5
  exports.checkIsSui = checkIsSui;
15
- exports.getSuiscanTokenMetadata = getSuiscanTokenMetadata;
16
- const explorer_1 = require("../constants/explorer");
17
6
  const tokens_1 = require("../constants/tokens");
18
7
  function normalizeTokenType(type) {
19
8
  return type === tokens_1.SUI_TYPE ? tokens_1.SUI_FULL_TYPE : type;
@@ -24,13 +13,3 @@ function denormalizeTokenType(type) {
24
13
  function checkIsSui(type) {
25
14
  return type === tokens_1.SUI_FULL_TYPE || type === tokens_1.SUI_TYPE;
26
15
  }
27
- function getSuiscanTokenMetadata(type) {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- const response = yield fetch(`${explorer_1.EXPLORER.ADDRESS}/api/sui-backend/mainnet/api/coins/${denormalizeTokenType(type)}`);
30
- if (!response.ok) {
31
- throw new Error("Failed to fetch token metadata");
32
- }
33
- const data = yield response.json();
34
- return Object.assign(Object.assign({}, data), { type: normalizeTokenType(data.type || "") });
35
- });
36
- }
@@ -0,0 +1,13 @@
1
+ import { Config } from "./index";
2
+ export async function fetchClient(input, init) {
3
+ const headers = new Headers(init?.headers);
4
+ const apiKey = (Config.getApiKey() || "").trim();
5
+ if (apiKey) {
6
+ headers.set("apiKey", apiKey);
7
+ }
8
+ const modifiedInit = {
9
+ ...init,
10
+ headers,
11
+ };
12
+ return fetch(input, modifiedInit);
13
+ }
@@ -0,0 +1,24 @@
1
+ import { SuiClient, getFullnodeUrl } from "@mysten/sui/client";
2
+ let apiKey = "";
3
+ let suiClient = new SuiClient({
4
+ url: getFullnodeUrl("mainnet"),
5
+ });
6
+ function setApiKey(key) {
7
+ apiKey = key;
8
+ }
9
+ function getApiKey() {
10
+ return apiKey;
11
+ }
12
+ function getSuiClient() {
13
+ return suiClient;
14
+ }
15
+ function setSuiClient(client) {
16
+ suiClient = client;
17
+ }
18
+ const Config = {
19
+ setApiKey,
20
+ getApiKey,
21
+ setSuiClient,
22
+ getSuiClient,
23
+ };
24
+ export { Config };
@@ -0,0 +1,6 @@
1
+ export const API_ENDPOINTS = {
2
+ MAIN: "https://api.7k.ag",
3
+ LO_DCA: "https://lod-dca.7k.ag",
4
+ PRICES: "https://prices.7k.ag",
5
+ STATISTIC: "https://statistic.7k.ag",
6
+ };
@@ -1,4 +1,5 @@
1
1
  import BigNumber from "bignumber.js";
2
+ import { API_ENDPOINTS } from "../../constants/apiEndpoints";
2
3
  export const GLOBAL_CONFIG_ID = "0xffc7f420b481ed7a012b42e125fd7e5716b5673759cf4629e5fcfebce970a72d";
3
4
  export const RATE_SCALE = BigInt("1000000000000");
4
5
  export const SLIPPAGE_SCALE = BigInt("10000");
@@ -7,4 +8,4 @@ export const LIMIT_ORDER_MODULE_ID = `${PACKAGE}::limit_order`;
7
8
  export const DCA_ORDER_MODULE_ID = `${PACKAGE}::dca_order`;
8
9
  export const CONFIG_MODULE_ID = `${PACKAGE}::config`;
9
10
  export const DCA_MAX_RATE = new BigNumber("18446744073709551615");
10
- export const LO_DCA_API = "https://lod-dca.7k.ag/api";
11
+ export const LO_DCA_API = `${API_ENDPOINTS.LO_DCA}/api`;
@@ -1,3 +1,4 @@
1
+ import { fetchClient } from "../../config/fetchClient";
1
2
  import { formatQueryParams } from "../../libs/url";
2
3
  import { LO_DCA_API } from "./constants";
3
4
  export async function getClosedDcaOrders({ owner, offset = 0, limit = 10, tokenPair, }) {
@@ -10,7 +11,7 @@ export async function getClosedDcaOrders({ owner, offset = 0, limit = 10, tokenP
10
11
  tokenPair,
11
12
  };
12
13
  const paramsStr = formatQueryParams(queryParams);
13
- const response = await fetch(`${LO_DCA_API}/order-executions?${paramsStr}`);
14
+ const response = await fetchClient(`${LO_DCA_API}/order-executions?${paramsStr}`);
14
15
  if (!response.ok) {
15
16
  throw new Error("Failed to fetch closed dca orders");
16
17
  }
@@ -1,3 +1,4 @@
1
+ import { fetchClient } from "../../config/fetchClient";
1
2
  import { formatQueryParams } from "../../libs/url";
2
3
  import { LO_DCA_API } from "./constants";
3
4
  export async function getClosedLimitOrders({ owner, offset = 0, limit = 10, tokenPair, }) {
@@ -9,7 +10,7 @@ export async function getClosedLimitOrders({ owner, offset = 0, limit = 10, toke
9
10
  tokenPair,
10
11
  };
11
12
  const paramsStr = formatQueryParams(queryParams);
12
- const response = await fetch(`${LO_DCA_API}/limit-orders?${paramsStr}`);
13
+ const response = await fetchClient(`${LO_DCA_API}/limit-orders?${paramsStr}`);
13
14
  if (!response.ok) {
14
15
  throw new Error("Failed to fetch closed limit orders");
15
16
  }
@@ -1,3 +1,4 @@
1
+ import { fetchClient } from "../../config/fetchClient";
1
2
  import { formatQueryParams } from "../../libs/url";
2
3
  import { LO_DCA_API } from "./constants";
3
4
  export async function getDcaOrderExecutions({ owner, orderId, offset = 0, limit = 10, }) {
@@ -10,7 +11,7 @@ export async function getDcaOrderExecutions({ owner, orderId, offset = 0, limit
10
11
  orderType: "DCA",
11
12
  };
12
13
  const paramsStr = formatQueryParams(queryParams);
13
- const response = await fetch(`${LO_DCA_API}/order-executions?${paramsStr}`);
14
+ const response = await fetchClient(`${LO_DCA_API}/order-executions?${paramsStr}`);
14
15
  if (!response.ok) {
15
16
  throw new Error("Failed to fetch dca order executions");
16
17
  }
@@ -1,3 +1,4 @@
1
+ import { fetchClient } from "../../config/fetchClient";
1
2
  import { formatQueryParams } from "../../libs/url";
2
3
  import { LO_DCA_API } from "./constants";
3
4
  export async function getOpenDcaOrders({ owner, offset = 0, limit = 10, tokenPair, }) {
@@ -9,7 +10,7 @@ export async function getOpenDcaOrders({ owner, offset = 0, limit = 10, tokenPai
9
10
  tokenPair,
10
11
  };
11
12
  const paramsStr = formatQueryParams(queryParams);
12
- const response = await fetch(`${LO_DCA_API}/dca-orders?${paramsStr}`);
13
+ const response = await fetchClient(`${LO_DCA_API}/dca-orders?${paramsStr}`);
13
14
  if (!response.ok) {
14
15
  throw new Error("Failed to fetch open dca orders");
15
16
  }
@@ -1,3 +1,4 @@
1
+ import { fetchClient } from "../../config/fetchClient";
1
2
  import { formatQueryParams } from "../../libs/url";
2
3
  import { LO_DCA_API } from "./constants";
3
4
  export async function getOpenLimitOrders({ owner, offset = 0, limit = 10, tokenPair, }) {
@@ -9,7 +10,7 @@ export async function getOpenLimitOrders({ owner, offset = 0, limit = 10, tokenP
9
10
  tokenPair,
10
11
  };
11
12
  const paramsStr = formatQueryParams(queryParams);
12
- const response = await fetch(`${LO_DCA_API}/limit-orders?${paramsStr}`);
13
+ const response = await fetchClient(`${LO_DCA_API}/limit-orders?${paramsStr}`);
13
14
  if (!response.ok) {
14
15
  throw new Error("Failed to fetch open limit orders");
15
16
  }
@@ -1,9 +1,10 @@
1
+ import { fetchClient } from "../../config/fetchClient";
2
+ import { API_ENDPOINTS } from "../../constants/apiEndpoints";
1
3
  import { NATIVE_USDC_TOKEN_TYPE, SUI_FULL_TYPE } from "../../constants/tokens";
2
4
  import { normalizeTokenType } from "../../utils/token";
3
- export const PRICES_API = "https://prices.7k.ag";
4
5
  export async function getTokenPrice(id, vsCoin = NATIVE_USDC_TOKEN_TYPE) {
5
6
  try {
6
- const response = await fetch(`${PRICES_API}/price?ids=${normalizeTokenType(id)}&vsCoin=${vsCoin}`);
7
+ const response = await fetchClient(`${API_ENDPOINTS.PRICES}/price?ids=${normalizeTokenType(id)}&vsCoin=${vsCoin}`);
7
8
  const pricesRes = (await response.json());
8
9
  return Number(pricesRes?.[id]?.price || 0);
9
10
  }
@@ -25,7 +26,7 @@ export async function getTokenPrices(ids, vsCoin = NATIVE_USDC_TOKEN_TYPE) {
25
26
  const limitedIds = ids.slice(0, MAX_TOTAL_IDS).map(normalizeTokenType);
26
27
  const idChunks = chunkArray(limitedIds, MAX_IDS_PER_REQUEST);
27
28
  const responses = await Promise.all(idChunks.map(async (chunk) => {
28
- const response = await fetch(`${PRICES_API}/price`, {
29
+ const response = await fetchClient(`${API_ENDPOINTS.PRICES}/price`, {
29
30
  method: "POST",
30
31
  headers: {
31
32
  "Content-Type": "application/json",
@@ -8,7 +8,7 @@ import { SuiUtils } from "../../utils/sui";
8
8
  import { _7K_CONFIG, _7K_PACKAGE_ID, _7K_VAULT } from "../../constants/_7k";
9
9
  import { isValidSuiAddress } from "@mysten/sui/utils";
10
10
  import { getConfig } from "./config";
11
- export const buildTx = async ({ quoteResponse, accountAddress, slippage, commission: _commission, devInspect, extendTx, isSponsored }) => {
11
+ export const buildTx = async ({ quoteResponse, accountAddress, slippage, commission: _commission, devInspect, extendTx, }) => {
12
12
  const { tx: _tx, coinIn } = extendTx || {};
13
13
  let coinOut;
14
14
  if (!accountAddress) {
@@ -29,7 +29,7 @@ export const buildTx = async ({ quoteResponse, accountAddress, slippage, commiss
29
29
  SuiUtils.transferOrDestroyZeroCoin(tx, quoteResponse.tokenIn, coinIn, accountAddress);
30
30
  }
31
31
  else {
32
- const { coinData: _data } = await getSplitCoinForTx(accountAddress, quoteResponse.swapAmountWithDecimal, splits, denormalizeTokenType(quoteResponse.tokenIn), tx, devInspect, isSponsored);
32
+ const { coinData: _data } = await getSplitCoinForTx(accountAddress, quoteResponse.swapAmountWithDecimal, splits, denormalizeTokenType(quoteResponse.tokenIn), tx, devInspect);
33
33
  coinData = _data;
34
34
  }
35
35
  const coinObjects = [];
@@ -1,3 +1,5 @@
1
+ import { fetchClient } from "../../config/fetchClient";
2
+ import { API_ENDPOINTS } from "../../constants/apiEndpoints";
1
3
  let config = null;
2
4
  let configTs = 0;
3
5
  export const DEFAULT_CONFIG = {
@@ -94,7 +96,7 @@ export async function getConfig() {
94
96
  return config;
95
97
  }
96
98
  try {
97
- const response = await fetch(`https://api.7k.ag/config`);
99
+ const response = await fetchClient(`${API_ENDPOINTS.MAIN}/config`);
98
100
  const quoteResponse = (await response.json());
99
101
  config = quoteResponse;
100
102
  configTs = Date.now();
@@ -2,8 +2,8 @@ import BigNumber from "bignumber.js";
2
2
  import { SUI_DECIMALS } from "@mysten/sui/utils";
3
3
  import { buildTx } from "./buildTx";
4
4
  import { formatBalance } from "../../utils/number";
5
- import { getSuiClient } from "../../suiClient";
6
5
  import { getSuiPrice } from "../prices";
6
+ import { Config } from "../../config";
7
7
  export async function estimateGasFee({ quoteResponse, accountAddress, slippage, suiPrice: _suiPrice, extendTx, commission, }) {
8
8
  if (!accountAddress)
9
9
  return 0;
@@ -23,7 +23,7 @@ export async function estimateGasFee({ quoteResponse, accountAddress, slippage,
23
23
  return 0;
24
24
  const suiPrice = _suiPrice || (await getSuiPrice());
25
25
  const suiDecimals = SUI_DECIMALS;
26
- const { effects: { gasUsed, status }, } = await getSuiClient().devInspectTransactionBlock({
26
+ const { effects: { gasUsed, status }, } = await Config.getSuiClient().devInspectTransactionBlock({
27
27
  sender: accountAddress,
28
28
  transactionBlock: tx,
29
29
  });
@@ -1,4 +1,6 @@
1
1
  import { normalizeStructTag, normalizeSuiObjectId } from "@mysten/sui/utils";
2
+ import { API_ENDPOINTS } from "../../constants/apiEndpoints";
3
+ import { fetchClient } from "../../config/fetchClient";
2
4
  export const DEFAULT_SOURCES = [
3
5
  "suiswap",
4
6
  "turbos",
@@ -31,7 +33,7 @@ export async function getQuote({ tokenIn, tokenOut, amountIn, sources = DEFAULT_
31
33
  if (excludedPools?.length) {
32
34
  params.append("excluded_pools", excludedPools.map((v) => normalizeSuiObjectId(v)).join(","));
33
35
  }
34
- const response = await fetch(`https://api.7k.ag/quote?${params}`);
36
+ const response = await fetchClient(`${API_ENDPOINTS.MAIN}/quote?${params}`);
35
37
  if (!response.ok) {
36
38
  throw new Error("Failed to fetch aggregator quote");
37
39
  }
@@ -1,3 +1,5 @@
1
+ import { fetchClient } from "../../config/fetchClient";
2
+ import { API_ENDPOINTS } from "../../constants/apiEndpoints";
1
3
  import { formatQueryParams } from "../../libs/url";
2
4
  export async function getSwapHistory({ owner, offset = 0, limit = 10, tokenPair, }) {
3
5
  const queryParams = {
@@ -7,7 +9,7 @@ export async function getSwapHistory({ owner, offset = 0, limit = 10, tokenPair,
7
9
  token_pair: tokenPair,
8
10
  };
9
11
  const paramsStr = formatQueryParams(queryParams);
10
- const response = await fetch(`https://statistic.7k.ag/trading-history?${paramsStr}`);
12
+ const response = await fetchClient(`${API_ENDPOINTS.STATISTIC}/trading-history?${paramsStr}`);
11
13
  if (!response.ok) {
12
14
  throw new Error("Failed to fetch open limit orders");
13
15
  }
package/lib/esm/index.mjs CHANGED
@@ -1,9 +1,14 @@
1
1
  export * from "./types/aggregator";
2
- import { getSuiClient, setSuiClient } from "./suiClient";
2
+ import { Config } from "./config";
3
3
  import { getTokenPrice, getTokenPrices, getSuiPrice } from "./features/prices";
4
4
  import { buildTx, getQuote, estimateGasFee, getSwapHistory, } from "./features/swap";
5
5
  import { placeLimitOrder, getOpenLimitOrders, cancelLimitOrder, claimExpiredLimitOrder, getClosedLimitOrders, placeDcaOrder, getOpenDcaOrders, cancelDcaOrder, getClosedDcaOrders, getDcaOrderExecutions, } from "./features/limitDca";
6
+ // avoid breaking changes
7
+ const getSuiClient = Config.getSuiClient;
8
+ const setSuiClient = Config.setSuiClient;
6
9
  export {
10
+ // config
11
+ Config,
7
12
  // sui client
8
13
  getSuiClient, setSuiClient,
9
14
  // prices
@@ -15,6 +20,8 @@ placeLimitOrder, getOpenLimitOrders, cancelLimitOrder, claimExpiredLimitOrder, g
15
20
  // dca
16
21
  placeDcaOrder, getOpenDcaOrders, cancelDcaOrder, getClosedDcaOrders, getDcaOrderExecutions, };
17
22
  export default {
23
+ // config
24
+ Config,
18
25
  // sui client
19
26
  getSuiClient,
20
27
  setSuiClient,
@@ -1,5 +1,5 @@
1
1
  import BigNumber from "bignumber.js";
2
- import { getSuiClient } from "../suiClient";
2
+ import { Config } from "../config";
3
3
  const orderByKey = (array, key, sortBy) => {
4
4
  if (!array?.length) {
5
5
  return;
@@ -25,7 +25,7 @@ export const getCoinOjectIdsByAmount = async (address, amount, coinType) => {
25
25
  let nextCursor = undefined;
26
26
  while (hasNextPage) {
27
27
  try {
28
- const coins = await getSuiClient().getCoins({
28
+ const coins = await Config.getSuiClient().getCoins({
29
29
  owner: address,
30
30
  coinType,
31
31
  cursor: nextCursor,
@@ -1,11 +1,11 @@
1
1
  import { Transaction } from "@mysten/sui/transactions";
2
2
  import { getCoinOjectIdsByAmount } from "./getCoinOjectIdsByAmount";
3
3
  import { SUI_TYPE } from "../constants/tokens";
4
- export const getSplitCoinForTx = async (account, amount, splits, coinType, inheritTx, inspecTransaction, isSponsored = false) => {
4
+ export const getSplitCoinForTx = async (account, amount, splits, coinType, inheritTx, inspecTransaction) => {
5
5
  const tx = inheritTx ?? new Transaction();
6
6
  const { objectIds } = await getCoinOjectIdsByAmount(account, amount, coinType);
7
7
  const coinObjectId = objectIds[0];
8
- if (coinType === SUI_TYPE && !isSponsored) {
8
+ if (coinType === SUI_TYPE) {
9
9
  let coin;
10
10
  if (inspecTransaction) {
11
11
  if (objectIds.length > 1) {
@@ -0,0 +1,2 @@
1
+ export declare function fetchClient(input: string, init?: RequestInit): Promise<Response>;
2
+ //# sourceMappingURL=fetchClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchClient.d.ts","sourceRoot":"","sources":["../../../../src/config/fetchClient.ts"],"names":[],"mappings":"AAEA,wBAAsB,WAAW,CAC/B,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,QAAQ,CAAC,CAanB"}
@@ -0,0 +1,13 @@
1
+ import { SuiClient } from "@mysten/sui/client";
2
+ declare function setApiKey(key: string): void;
3
+ declare function getApiKey(): string;
4
+ declare function getSuiClient(): SuiClient;
5
+ declare function setSuiClient(client: SuiClient): void;
6
+ declare const Config: {
7
+ setApiKey: typeof setApiKey;
8
+ getApiKey: typeof getApiKey;
9
+ setSuiClient: typeof setSuiClient;
10
+ getSuiClient: typeof getSuiClient;
11
+ };
12
+ export { Config };
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,MAAM,oBAAoB,CAAC;AAO/D,iBAAS,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEpC;AAED,iBAAS,SAAS,IAAI,MAAM,CAE3B;AAED,iBAAS,YAAY,IAAI,SAAS,CAEjC;AAED,iBAAS,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAE7C;AAED,QAAA,MAAM,MAAM;;;;;CAKX,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare const API_ENDPOINTS: {
2
+ MAIN: string;
3
+ LO_DCA: string;
4
+ PRICES: string;
5
+ STATISTIC: string;
6
+ };
7
+ //# sourceMappingURL=apiEndpoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiEndpoints.d.ts","sourceRoot":"","sources":["../../../../src/constants/apiEndpoints.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;;;CAKzB,CAAC"}
@@ -7,5 +7,5 @@ export declare const LIMIT_ORDER_MODULE_ID = "0x0ef0f805710cf53c10f29c4f73e1144a
7
7
  export declare const DCA_ORDER_MODULE_ID = "0x0ef0f805710cf53c10f29c4f73e1144a662747e1839689a846e2520cae122adc::dca_order";
8
8
  export declare const CONFIG_MODULE_ID = "0x0ef0f805710cf53c10f29c4f73e1144a662747e1839689a846e2520cae122adc::config";
9
9
  export declare const DCA_MAX_RATE: BigNumber;
10
- export declare const LO_DCA_API = "https://lod-dca.7k.ag/api";
10
+ export declare const LO_DCA_API: string;
11
11
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/features/limitDca/constants.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,eAAO,MAAM,gBAAgB,uEACyC,CAAC;AACvE,eAAO,MAAM,UAAU,QAA0B,CAAC;AAClD,eAAO,MAAM,cAAc,QAAkB,CAAC;AAC9C,eAAO,MAAM,OAAO,uEACkD,CAAC;AACvE,eAAO,MAAM,qBAAqB,oFAA4B,CAAC;AAC/D,eAAO,MAAM,mBAAmB,kFAA0B,CAAC;AAC3D,eAAO,MAAM,gBAAgB,+EAAuB,CAAC;AACrD,eAAO,MAAM,YAAY,WAAwC,CAAC;AAClE,eAAO,MAAM,UAAU,8BAA8B,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/features/limitDca/constants.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAGrC,eAAO,MAAM,gBAAgB,uEACyC,CAAC;AACvE,eAAO,MAAM,UAAU,QAA0B,CAAC;AAClD,eAAO,MAAM,cAAc,QAAkB,CAAC;AAC9C,eAAO,MAAM,OAAO,uEACkD,CAAC;AACvE,eAAO,MAAM,qBAAqB,oFAA4B,CAAC;AAC/D,eAAO,MAAM,mBAAmB,kFAA0B,CAAC;AAC3D,eAAO,MAAM,gBAAgB,+EAAuB,CAAC;AACrD,eAAO,MAAM,YAAY,WAAwC,CAAC;AAClE,eAAO,MAAM,UAAU,QAAgC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getClosedDcaOrders.d.ts","sourceRoot":"","sources":["../../../../../src/features/limitDca/getClosedDcaOrders.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAoB,MAAM,SAAS,CAAC;AAEhE,UAAU,MAAM;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,kBAAkB,CAAC,EACvC,KAAK,EACL,MAAU,EACV,KAAU,EACV,SAAS,GACV,EAAE,MAAM,kCAmBR"}
1
+ {"version":3,"file":"getClosedDcaOrders.d.ts","sourceRoot":"","sources":["../../../../../src/features/limitDca/getClosedDcaOrders.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAoB,MAAM,SAAS,CAAC;AAEhE,UAAU,MAAM;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,kBAAkB,CAAC,EACvC,KAAK,EACL,MAAU,EACV,KAAU,EACV,SAAS,GACV,EAAE,MAAM,kCAqBR"}
@@ -1 +1 @@
1
- {"version":3,"file":"getClosedLimitOrders.d.ts","sourceRoot":"","sources":["../../../../../src/features/limitDca/getClosedLimitOrders.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAoB,MAAM,SAAS,CAAC;AAEvD,UAAU,MAAM;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,oBAAoB,CAAC,EACzC,KAAK,EACL,MAAU,EACV,KAAU,EACV,SAAS,GACV,EAAE,MAAM,yBAkBR"}
1
+ {"version":3,"file":"getClosedLimitOrders.d.ts","sourceRoot":"","sources":["../../../../../src/features/limitDca/getClosedLimitOrders.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAoB,MAAM,SAAS,CAAC;AAEvD,UAAU,MAAM;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,oBAAoB,CAAC,EACzC,KAAK,EACL,MAAU,EACV,KAAU,EACV,SAAS,GACV,EAAE,MAAM,yBAkBR"}
@@ -1 +1 @@
1
- {"version":3,"file":"getDcaOrderExecutions.d.ts","sourceRoot":"","sources":["../../../../../src/features/limitDca/getDcaOrderExecutions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAoB,MAAM,SAAS,CAAC;AAEhE,UAAU,MAAM;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,qBAAqB,CAAC,EAC1C,KAAK,EACL,OAAO,EACP,MAAU,EACV,KAAU,GACX,EAAE,MAAM,kCAmBR"}
1
+ {"version":3,"file":"getDcaOrderExecutions.d.ts","sourceRoot":"","sources":["../../../../../src/features/limitDca/getDcaOrderExecutions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAoB,MAAM,SAAS,CAAC;AAEhE,UAAU,MAAM;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,qBAAqB,CAAC,EAC1C,KAAK,EACL,OAAO,EACP,MAAU,EACV,KAAU,GACX,EAAE,MAAM,kCAqBR"}
@@ -1 +1 @@
1
- {"version":3,"file":"getOpenDcaOrders.d.ts","sourceRoot":"","sources":["../../../../../src/features/limitDca/getOpenDcaOrders.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAoB,MAAM,SAAS,CAAC;AAErD,UAAU,MAAM;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,gBAAgB,CAAC,EACrC,KAAK,EACL,MAAU,EACV,KAAU,EACV,SAAS,GACV,EAAE,MAAM,uBAkBR"}
1
+ {"version":3,"file":"getOpenDcaOrders.d.ts","sourceRoot":"","sources":["../../../../../src/features/limitDca/getOpenDcaOrders.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAoB,MAAM,SAAS,CAAC;AAErD,UAAU,MAAM;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,gBAAgB,CAAC,EACrC,KAAK,EACL,MAAU,EACV,KAAU,EACV,SAAS,GACV,EAAE,MAAM,uBAkBR"}
@@ -1 +1 @@
1
- {"version":3,"file":"getOpenLimitOrders.d.ts","sourceRoot":"","sources":["../../../../../src/features/limitDca/getOpenLimitOrders.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAoB,MAAM,SAAS,CAAC;AAEvD,UAAU,MAAM;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,kBAAkB,CAAC,EACvC,KAAK,EACL,MAAU,EACV,KAAU,EACV,SAAS,GACV,EAAE,MAAM,yBAkBR"}
1
+ {"version":3,"file":"getOpenLimitOrders.d.ts","sourceRoot":"","sources":["../../../../../src/features/limitDca/getOpenLimitOrders.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAoB,MAAM,SAAS,CAAC;AAEvD,UAAU,MAAM;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,kBAAkB,CAAC,EACvC,KAAK,EACL,MAAU,EACV,KAAU,EACV,SAAS,GACV,EAAE,MAAM,yBAkBR"}
@@ -1,4 +1,3 @@
1
- export declare const PRICES_API = "https://prices.7k.ag";
2
1
  export declare function getTokenPrice(id: string, vsCoin?: string): Promise<number>;
3
2
  export declare function getTokenPrices(ids: string[], vsCoin?: string): Promise<Record<string, number>>;
4
3
  export declare function getSuiPrice(): Promise<number>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/prices/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,yBAAyB,CAAC;AAOjD,wBAAsB,aAAa,CACjC,EAAE,EAAE,MAAM,EACV,MAAM,SAAyB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAUjB;AAYD,wBAAsB,cAAc,CAClC,GAAG,EAAE,MAAM,EAAE,EACb,MAAM,SAAyB,GAC9B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAkDjC;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,CAEnD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/prices/index.ts"],"names":[],"mappings":"AAUA,wBAAsB,aAAa,CACjC,EAAE,EAAE,MAAM,EACV,MAAM,SAAyB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAUjB;AAYD,wBAAsB,cAAc,CAClC,GAAG,EAAE,MAAM,EAAE,EACb,MAAM,SAAyB,GAC9B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAkDjC;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,CAEnD"}
@@ -1,6 +1,6 @@
1
1
  import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
2
2
  import { BuildTxParams } from "../../types/tx";
3
- export declare const buildTx: ({ quoteResponse, accountAddress, slippage, commission: _commission, devInspect, extendTx, isSponsored }: BuildTxParams) => Promise<{
3
+ export declare const buildTx: ({ quoteResponse, accountAddress, slippage, commission: _commission, devInspect, extendTx, }: BuildTxParams) => Promise<{
4
4
  tx: Transaction;
5
5
  coinOut: TransactionObjectArgument | undefined;
6
6
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"buildTx.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/buildTx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,yBAAyB,EAE1B,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAK/C,eAAO,MAAM,OAAO,4GAQjB,aAAa;;;EAoGf,CAAC"}
1
+ {"version":3,"file":"buildTx.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/buildTx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,yBAAyB,EAE1B,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAK/C,eAAO,MAAM,OAAO,gGAOjB,aAAa;;;EAmGf,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGhD,eAAO,MAAM,cAAc,EAAE,MAwH5B,CAAC;AAEF,wBAAsB,SAAS,oBAe9B"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAIhD,eAAO,MAAM,cAAc,EAAE,MAwH5B,CAAC;AAEF,wBAAsB,SAAS,oBAe9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"getQuote.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/getQuote.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAElE,UAAU,MAAM;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;IACtB,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,qDAAqD;IACrD,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,eAAO,MAAM,eAAe,EAAE,SAAS,EAkBtC,CAAC;AAEF,wBAAsB,QAAQ,CAAC,EAC7B,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,OAAyB,EACzB,WAAW,EACX,aAAa,GACd,EAAE,MAAM,0BA2BR"}
1
+ {"version":3,"file":"getQuote.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/getQuote.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAIlE,UAAU,MAAM;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;IACtB,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,qDAAqD;IACrD,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,eAAO,MAAM,eAAe,EAAE,SAAS,EAkBtC,CAAC;AAEF,wBAAsB,QAAQ,CAAC,EAC7B,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,OAAyB,EACzB,WAAW,EACX,aAAa,GACd,EAAE,MAAM,0BA2BR"}
@@ -1 +1 @@
1
- {"version":3,"file":"getSwapHistory.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/getSwapHistory.ts"],"names":[],"mappings":"AAEA,UAAU,MAAM;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AASD,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,UAAU,sBAAsB;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,kBAAkB,EAAE,CAAC;CAC/B;AAED,wBAAsB,cAAc,CAAC,EACnC,KAAK,EACL,MAAU,EACV,KAAU,EACV,SAAS,GACV,EAAE,MAAM,mCAmBR"}
1
+ {"version":3,"file":"getSwapHistory.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/getSwapHistory.ts"],"names":[],"mappings":"AAIA,UAAU,MAAM;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AASD,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,UAAU,sBAAsB;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,kBAAkB,EAAE,CAAC;CAC/B;AAED,wBAAsB,cAAc,CAAC,EACnC,KAAK,EACL,MAAU,EACV,KAAU,EACV,SAAS,GACV,EAAE,MAAM,mCAmBR"}
@@ -1,18 +1,26 @@
1
1
  export * from "./types/aggregator";
2
- import { getSuiClient, setSuiClient } from "./suiClient";
2
+ import { Config } from "./config";
3
3
  import { getTokenPrice, getTokenPrices, getSuiPrice } from "./features/prices";
4
4
  import { buildTx, getQuote, estimateGasFee, getSwapHistory } from "./features/swap";
5
5
  import { placeLimitOrder, getOpenLimitOrders, cancelLimitOrder, claimExpiredLimitOrder, getClosedLimitOrders, placeDcaOrder, getOpenDcaOrders, cancelDcaOrder, getClosedDcaOrders, getDcaOrderExecutions } from "./features/limitDca";
6
- export { getSuiClient, setSuiClient, getTokenPrice, getTokenPrices, getSuiPrice, getQuote, estimateGasFee, buildTx, getSwapHistory, placeLimitOrder, getOpenLimitOrders, cancelLimitOrder, claimExpiredLimitOrder, getClosedLimitOrders, placeDcaOrder, getOpenDcaOrders, cancelDcaOrder, getClosedDcaOrders, getDcaOrderExecutions, };
6
+ declare const getSuiClient: () => import("@mysten/sui/dist/cjs/client").SuiClient;
7
+ declare const setSuiClient: (client: import("@mysten/sui/dist/cjs/client").SuiClient) => void;
8
+ export { Config, getSuiClient, setSuiClient, getTokenPrice, getTokenPrices, getSuiPrice, getQuote, estimateGasFee, buildTx, getSwapHistory, placeLimitOrder, getOpenLimitOrders, cancelLimitOrder, claimExpiredLimitOrder, getClosedLimitOrders, placeDcaOrder, getOpenDcaOrders, cancelDcaOrder, getClosedDcaOrders, getDcaOrderExecutions, };
7
9
  declare const _default: {
8
- getSuiClient: typeof getSuiClient;
9
- setSuiClient: typeof setSuiClient;
10
+ Config: {
11
+ setApiKey: (key: string) => void;
12
+ getApiKey: () => string;
13
+ setSuiClient: (client: import("@mysten/sui/dist/cjs/client").SuiClient) => void;
14
+ getSuiClient: () => import("@mysten/sui/dist/cjs/client").SuiClient;
15
+ };
16
+ getSuiClient: () => import("@mysten/sui/dist/cjs/client").SuiClient;
17
+ setSuiClient: (client: import("@mysten/sui/dist/cjs/client").SuiClient) => void;
10
18
  getTokenPrice: typeof getTokenPrice;
11
19
  getTokenPrices: typeof getTokenPrices;
12
20
  getSuiPrice: typeof getSuiPrice;
13
21
  getQuote: typeof getQuote;
14
22
  estimateGasFee: typeof estimateGasFee;
15
- buildTx: ({ quoteResponse, accountAddress, slippage, commission: _commission, devInspect, extendTx, isSponsored }: import("./types/tx").BuildTxParams) => Promise<{
23
+ buildTx: ({ quoteResponse, accountAddress, slippage, commission: _commission, devInspect, extendTx, }: import("./types/tx").BuildTxParams) => Promise<{
16
24
  tx: import("@mysten/sui/dist/cjs/transactions").Transaction;
17
25
  coinOut: import("@mysten/sui/dist/cjs/transactions").TransactionObjectArgument | undefined;
18
26
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE/E,OAAO,EACL,OAAO,EACP,QAAQ,EACR,cAAc,EACd,cAAc,EACf,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAEL,YAAY,EACZ,YAAY,EAGZ,aAAa,EACb,cAAc,EACd,WAAW,EAGX,QAAQ,EACR,cAAc,EACd,OAAO,EACP,cAAc,EAGd,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EAGpB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,qBAAqB,GACtB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,wBA6BE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE/E,OAAO,EACL,OAAO,EACP,QAAQ,EACR,cAAc,EACd,cAAc,EACf,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,qBAAqB,CAAC;AAG7B,QAAA,MAAM,YAAY,uDAAsB,CAAC;AACzC,QAAA,MAAM,YAAY,mEAAsB,CAAC;AAEzC,OAAO,EAEL,MAAM,EAGN,YAAY,EACZ,YAAY,EAGZ,aAAa,EACb,cAAc,EACd,WAAW,EAGX,QAAQ,EACR,cAAc,EACd,OAAO,EACP,cAAc,EAGd,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EAGpB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,qBAAqB,GACtB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,wBAgCE"}