@7kprotocol/sdk-ts 3.6.1-beta.1 → 3.6.1-beta.2

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 (234) hide show
  1. package/README.md +13 -10
  2. package/dist/bluefin7k-I6ZCDWDN.js +2 -0
  3. package/dist/bluefin7k-I6ZCDWDN.js.map +1 -0
  4. package/dist/bluefin7k-TERLUCNL.mjs +2 -0
  5. package/dist/bluefin7k-TERLUCNL.mjs.map +1 -0
  6. package/dist/cetus-AU3OMWOY.mjs +2 -0
  7. package/dist/cetus-AU3OMWOY.mjs.map +1 -0
  8. package/dist/cetus-SIPX6FYL.js +2 -0
  9. package/dist/cetus-SIPX6FYL.js.map +1 -0
  10. package/dist/chunk-ETQEI4QC.mjs +2 -0
  11. package/dist/chunk-ETQEI4QC.mjs.map +1 -0
  12. package/dist/chunk-KVGSSW22.js +2 -0
  13. package/dist/chunk-KVGSSW22.js.map +1 -0
  14. package/dist/flowx-6M54WFWO.js +2 -0
  15. package/dist/flowx-6M54WFWO.js.map +1 -0
  16. package/dist/flowx-OXZZX5FD.mjs +2 -0
  17. package/dist/flowx-OXZZX5FD.mjs.map +1 -0
  18. package/dist/index.d.mts +536 -0
  19. package/dist/index.d.ts +536 -0
  20. package/dist/index.js +2 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/index.mjs +2 -0
  23. package/dist/index.mjs.map +1 -0
  24. package/package.json +12 -20
  25. package/lib/cjs/config/fetchClient.js +0 -12
  26. package/lib/cjs/constants/_7k.js +0 -20
  27. package/lib/cjs/constants/apiEndpoints.js +0 -9
  28. package/lib/cjs/constants/sui.js +0 -4
  29. package/lib/cjs/constants/tokens.js +0 -7
  30. package/lib/cjs/features/limitDca/cancelDcaOrder.js +0 -14
  31. package/lib/cjs/features/limitDca/cancelLimitOrder.js +0 -14
  32. package/lib/cjs/features/limitDca/claimExpiredLimitOrder.js +0 -14
  33. package/lib/cjs/features/limitDca/constants.js +0 -13
  34. package/lib/cjs/features/limitDca/getClosedDcaOrders.js +0 -23
  35. package/lib/cjs/features/limitDca/getClosedLimitOrders.js +0 -22
  36. package/lib/cjs/features/limitDca/getDcaOrderExecutions.js +0 -23
  37. package/lib/cjs/features/limitDca/getOpenDcaOrders.js +0 -22
  38. package/lib/cjs/features/limitDca/getOpenLimitOrders.js +0 -22
  39. package/lib/cjs/features/limitDca/index.js +0 -26
  40. package/lib/cjs/features/limitDca/placeDcaOrder.js +0 -33
  41. package/lib/cjs/features/limitDca/placeLimitOrder.js +0 -27
  42. package/lib/cjs/features/limitDca/types.js +0 -16
  43. package/lib/cjs/features/metaAg/common.js +0 -103
  44. package/lib/cjs/features/metaAg/error.js +0 -31
  45. package/lib/cjs/features/metaAg/index.js +0 -268
  46. package/lib/cjs/features/metaAg/providers/bluefin7k.js +0 -57
  47. package/lib/cjs/features/metaAg/providers/cetus.js +0 -59
  48. package/lib/cjs/features/metaAg/providers/flowx.js +0 -52
  49. package/lib/cjs/features/metaAg/providers/okx.js +0 -182
  50. package/lib/cjs/features/prices/index.js +0 -99
  51. package/lib/cjs/index.js +0 -55
  52. package/lib/cjs/libs/url.js +0 -17
  53. package/lib/cjs/types/config/fetchClient.d.ts +0 -2
  54. package/lib/cjs/types/config/fetchClient.d.ts.map +0 -1
  55. package/lib/cjs/types/constants/_7k.d.ts +0 -6
  56. package/lib/cjs/types/constants/_7k.d.ts.map +0 -1
  57. package/lib/cjs/types/constants/apiEndpoints.d.ts +0 -7
  58. package/lib/cjs/types/constants/apiEndpoints.d.ts.map +0 -1
  59. package/lib/cjs/types/constants/sui.d.ts +0 -2
  60. package/lib/cjs/types/constants/sui.d.ts.map +0 -1
  61. package/lib/cjs/types/constants/tokens.d.ts +0 -5
  62. package/lib/cjs/types/constants/tokens.d.ts.map +0 -1
  63. package/lib/cjs/types/features/limitDca/cancelDcaOrder.d.ts +0 -9
  64. package/lib/cjs/types/features/limitDca/cancelDcaOrder.d.ts.map +0 -1
  65. package/lib/cjs/types/features/limitDca/cancelLimitOrder.d.ts +0 -9
  66. package/lib/cjs/types/features/limitDca/cancelLimitOrder.d.ts.map +0 -1
  67. package/lib/cjs/types/features/limitDca/claimExpiredLimitOrder.d.ts +0 -9
  68. package/lib/cjs/types/features/limitDca/claimExpiredLimitOrder.d.ts.map +0 -1
  69. package/lib/cjs/types/features/limitDca/constants.d.ts +0 -10
  70. package/lib/cjs/types/features/limitDca/constants.d.ts.map +0 -1
  71. package/lib/cjs/types/features/limitDca/getClosedDcaOrders.d.ts +0 -10
  72. package/lib/cjs/types/features/limitDca/getClosedDcaOrders.d.ts.map +0 -1
  73. package/lib/cjs/types/features/limitDca/getClosedLimitOrders.d.ts +0 -10
  74. package/lib/cjs/types/features/limitDca/getClosedLimitOrders.d.ts.map +0 -1
  75. package/lib/cjs/types/features/limitDca/getDcaOrderExecutions.d.ts +0 -10
  76. package/lib/cjs/types/features/limitDca/getDcaOrderExecutions.d.ts.map +0 -1
  77. package/lib/cjs/types/features/limitDca/getOpenDcaOrders.d.ts +0 -10
  78. package/lib/cjs/types/features/limitDca/getOpenDcaOrders.d.ts.map +0 -1
  79. package/lib/cjs/types/features/limitDca/getOpenLimitOrders.d.ts +0 -10
  80. package/lib/cjs/types/features/limitDca/getOpenLimitOrders.d.ts.map +0 -1
  81. package/lib/cjs/types/features/limitDca/index.d.ts +0 -11
  82. package/lib/cjs/types/features/limitDca/index.d.ts.map +0 -1
  83. package/lib/cjs/types/features/limitDca/placeDcaOrder.d.ts +0 -14
  84. package/lib/cjs/types/features/limitDca/placeDcaOrder.d.ts.map +0 -1
  85. package/lib/cjs/types/features/limitDca/placeLimitOrder.d.ts +0 -13
  86. package/lib/cjs/types/features/limitDca/placeLimitOrder.d.ts.map +0 -1
  87. package/lib/cjs/types/features/limitDca/types.d.ts +0 -98
  88. package/lib/cjs/types/features/limitDca/types.d.ts.map +0 -1
  89. package/lib/cjs/types/features/metaAg/common.d.ts +0 -24
  90. package/lib/cjs/types/features/metaAg/common.d.ts.map +0 -1
  91. package/lib/cjs/types/features/metaAg/error.d.ts +0 -54
  92. package/lib/cjs/types/features/metaAg/error.d.ts.map +0 -1
  93. package/lib/cjs/types/features/metaAg/index.d.ts +0 -42
  94. package/lib/cjs/types/features/metaAg/index.d.ts.map +0 -1
  95. package/lib/cjs/types/features/metaAg/providers/bluefin7k.d.ts +0 -11
  96. package/lib/cjs/types/features/metaAg/providers/bluefin7k.d.ts.map +0 -1
  97. package/lib/cjs/types/features/metaAg/providers/cetus.d.ts +0 -11
  98. package/lib/cjs/types/features/metaAg/providers/cetus.d.ts.map +0 -1
  99. package/lib/cjs/types/features/metaAg/providers/flowx.d.ts +0 -13
  100. package/lib/cjs/types/features/metaAg/providers/flowx.d.ts.map +0 -1
  101. package/lib/cjs/types/features/metaAg/providers/okx.d.ts +0 -21
  102. package/lib/cjs/types/features/metaAg/providers/okx.d.ts.map +0 -1
  103. package/lib/cjs/types/features/prices/index.d.ts +0 -18
  104. package/lib/cjs/types/features/prices/index.d.ts.map +0 -1
  105. package/lib/cjs/types/index.d.ts +0 -23
  106. package/lib/cjs/types/index.d.ts.map +0 -1
  107. package/lib/cjs/types/libs/url.d.ts +0 -2
  108. package/lib/cjs/types/libs/url.d.ts.map +0 -1
  109. package/lib/cjs/types/metaAg.js +0 -16
  110. package/lib/cjs/types/okx.js +0 -6
  111. package/lib/cjs/types/types/metaAg.d.ts +0 -165
  112. package/lib/cjs/types/types/metaAg.d.ts.map +0 -1
  113. package/lib/cjs/types/types/okx.d.ts +0 -206
  114. package/lib/cjs/types/types/okx.d.ts.map +0 -1
  115. package/lib/cjs/types/utils/ObjectCache.d.ts +0 -87
  116. package/lib/cjs/types/utils/ObjectCache.d.ts.map +0 -1
  117. package/lib/cjs/types/utils/SuiClientUtils.d.ts +0 -15
  118. package/lib/cjs/types/utils/SuiClientUtils.d.ts.map +0 -1
  119. package/lib/cjs/types/utils/sui.d.ts +0 -27
  120. package/lib/cjs/types/utils/sui.d.ts.map +0 -1
  121. package/lib/cjs/types/utils/swap.d.ts +0 -15
  122. package/lib/cjs/types/utils/swap.d.ts.map +0 -1
  123. package/lib/cjs/types/utils/token.d.ts +0 -4
  124. package/lib/cjs/types/utils/token.d.ts.map +0 -1
  125. package/lib/cjs/utils/ObjectCache.js +0 -273
  126. package/lib/cjs/utils/SuiClientUtils.js +0 -50
  127. package/lib/cjs/utils/sui.js +0 -96
  128. package/lib/cjs/utils/swap.js +0 -37
  129. package/lib/cjs/utils/token.js +0 -15
  130. package/lib/esm/config/fetchClient.js +0 -9
  131. package/lib/esm/constants/_7k.js +0 -17
  132. package/lib/esm/constants/apiEndpoints.js +0 -6
  133. package/lib/esm/constants/sui.js +0 -1
  134. package/lib/esm/constants/tokens.js +0 -4
  135. package/lib/esm/features/limitDca/cancelDcaOrder.js +0 -11
  136. package/lib/esm/features/limitDca/cancelLimitOrder.js +0 -11
  137. package/lib/esm/features/limitDca/claimExpiredLimitOrder.js +0 -11
  138. package/lib/esm/features/limitDca/constants.js +0 -10
  139. package/lib/esm/features/limitDca/getClosedDcaOrders.js +0 -20
  140. package/lib/esm/features/limitDca/getClosedLimitOrders.js +0 -19
  141. package/lib/esm/features/limitDca/getDcaOrderExecutions.js +0 -20
  142. package/lib/esm/features/limitDca/getOpenDcaOrders.js +0 -19
  143. package/lib/esm/features/limitDca/getOpenLimitOrders.js +0 -19
  144. package/lib/esm/features/limitDca/index.js +0 -10
  145. package/lib/esm/features/limitDca/placeDcaOrder.js +0 -30
  146. package/lib/esm/features/limitDca/placeLimitOrder.js +0 -24
  147. package/lib/esm/features/limitDca/types.js +0 -13
  148. package/lib/esm/features/metaAg/common.js +0 -96
  149. package/lib/esm/features/metaAg/error.js +0 -29
  150. package/lib/esm/features/metaAg/index.js +0 -234
  151. package/lib/esm/features/metaAg/providers/bluefin7k.js +0 -55
  152. package/lib/esm/features/metaAg/providers/cetus.js +0 -57
  153. package/lib/esm/features/metaAg/providers/flowx.js +0 -51
  154. package/lib/esm/features/metaAg/providers/okx.js +0 -147
  155. package/lib/esm/features/prices/index.js +0 -94
  156. package/lib/esm/index.mjs +0 -31
  157. package/lib/esm/libs/url.js +0 -14
  158. package/lib/esm/types/config/fetchClient.d.ts +0 -2
  159. package/lib/esm/types/config/fetchClient.d.ts.map +0 -1
  160. package/lib/esm/types/constants/_7k.d.ts +0 -6
  161. package/lib/esm/types/constants/_7k.d.ts.map +0 -1
  162. package/lib/esm/types/constants/apiEndpoints.d.ts +0 -7
  163. package/lib/esm/types/constants/apiEndpoints.d.ts.map +0 -1
  164. package/lib/esm/types/constants/sui.d.ts +0 -2
  165. package/lib/esm/types/constants/sui.d.ts.map +0 -1
  166. package/lib/esm/types/constants/tokens.d.ts +0 -5
  167. package/lib/esm/types/constants/tokens.d.ts.map +0 -1
  168. package/lib/esm/types/features/limitDca/cancelDcaOrder.d.ts +0 -9
  169. package/lib/esm/types/features/limitDca/cancelDcaOrder.d.ts.map +0 -1
  170. package/lib/esm/types/features/limitDca/cancelLimitOrder.d.ts +0 -9
  171. package/lib/esm/types/features/limitDca/cancelLimitOrder.d.ts.map +0 -1
  172. package/lib/esm/types/features/limitDca/claimExpiredLimitOrder.d.ts +0 -9
  173. package/lib/esm/types/features/limitDca/claimExpiredLimitOrder.d.ts.map +0 -1
  174. package/lib/esm/types/features/limitDca/constants.d.ts +0 -10
  175. package/lib/esm/types/features/limitDca/constants.d.ts.map +0 -1
  176. package/lib/esm/types/features/limitDca/getClosedDcaOrders.d.ts +0 -10
  177. package/lib/esm/types/features/limitDca/getClosedDcaOrders.d.ts.map +0 -1
  178. package/lib/esm/types/features/limitDca/getClosedLimitOrders.d.ts +0 -10
  179. package/lib/esm/types/features/limitDca/getClosedLimitOrders.d.ts.map +0 -1
  180. package/lib/esm/types/features/limitDca/getDcaOrderExecutions.d.ts +0 -10
  181. package/lib/esm/types/features/limitDca/getDcaOrderExecutions.d.ts.map +0 -1
  182. package/lib/esm/types/features/limitDca/getOpenDcaOrders.d.ts +0 -10
  183. package/lib/esm/types/features/limitDca/getOpenDcaOrders.d.ts.map +0 -1
  184. package/lib/esm/types/features/limitDca/getOpenLimitOrders.d.ts +0 -10
  185. package/lib/esm/types/features/limitDca/getOpenLimitOrders.d.ts.map +0 -1
  186. package/lib/esm/types/features/limitDca/index.d.ts +0 -11
  187. package/lib/esm/types/features/limitDca/index.d.ts.map +0 -1
  188. package/lib/esm/types/features/limitDca/placeDcaOrder.d.ts +0 -14
  189. package/lib/esm/types/features/limitDca/placeDcaOrder.d.ts.map +0 -1
  190. package/lib/esm/types/features/limitDca/placeLimitOrder.d.ts +0 -13
  191. package/lib/esm/types/features/limitDca/placeLimitOrder.d.ts.map +0 -1
  192. package/lib/esm/types/features/limitDca/types.d.ts +0 -98
  193. package/lib/esm/types/features/limitDca/types.d.ts.map +0 -1
  194. package/lib/esm/types/features/metaAg/common.d.ts +0 -24
  195. package/lib/esm/types/features/metaAg/common.d.ts.map +0 -1
  196. package/lib/esm/types/features/metaAg/error.d.ts +0 -54
  197. package/lib/esm/types/features/metaAg/error.d.ts.map +0 -1
  198. package/lib/esm/types/features/metaAg/index.d.ts +0 -42
  199. package/lib/esm/types/features/metaAg/index.d.ts.map +0 -1
  200. package/lib/esm/types/features/metaAg/providers/bluefin7k.d.ts +0 -11
  201. package/lib/esm/types/features/metaAg/providers/bluefin7k.d.ts.map +0 -1
  202. package/lib/esm/types/features/metaAg/providers/cetus.d.ts +0 -11
  203. package/lib/esm/types/features/metaAg/providers/cetus.d.ts.map +0 -1
  204. package/lib/esm/types/features/metaAg/providers/flowx.d.ts +0 -13
  205. package/lib/esm/types/features/metaAg/providers/flowx.d.ts.map +0 -1
  206. package/lib/esm/types/features/metaAg/providers/okx.d.ts +0 -21
  207. package/lib/esm/types/features/metaAg/providers/okx.d.ts.map +0 -1
  208. package/lib/esm/types/features/prices/index.d.ts +0 -18
  209. package/lib/esm/types/features/prices/index.d.ts.map +0 -1
  210. package/lib/esm/types/index.d.ts +0 -23
  211. package/lib/esm/types/index.d.ts.map +0 -1
  212. package/lib/esm/types/libs/url.d.ts +0 -2
  213. package/lib/esm/types/libs/url.d.ts.map +0 -1
  214. package/lib/esm/types/metaAg.js +0 -11
  215. package/lib/esm/types/okx.js +0 -5
  216. package/lib/esm/types/types/metaAg.d.ts +0 -165
  217. package/lib/esm/types/types/metaAg.d.ts.map +0 -1
  218. package/lib/esm/types/types/okx.d.ts +0 -206
  219. package/lib/esm/types/types/okx.d.ts.map +0 -1
  220. package/lib/esm/types/utils/ObjectCache.d.ts +0 -87
  221. package/lib/esm/types/utils/ObjectCache.d.ts.map +0 -1
  222. package/lib/esm/types/utils/SuiClientUtils.d.ts +0 -15
  223. package/lib/esm/types/utils/SuiClientUtils.d.ts.map +0 -1
  224. package/lib/esm/types/utils/sui.d.ts +0 -27
  225. package/lib/esm/types/utils/sui.d.ts.map +0 -1
  226. package/lib/esm/types/utils/swap.d.ts +0 -15
  227. package/lib/esm/types/utils/swap.d.ts.map +0 -1
  228. package/lib/esm/types/utils/token.d.ts +0 -4
  229. package/lib/esm/types/utils/token.d.ts.map +0 -1
  230. package/lib/esm/utils/ObjectCache.js +0 -250
  231. package/lib/esm/utils/SuiClientUtils.js +0 -34
  232. package/lib/esm/utils/sui.js +0 -92
  233. package/lib/esm/utils/swap.js +0 -33
  234. package/lib/esm/utils/token.js +0 -10
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _SuiClientUtils_devInspectCache;
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.SuiClientUtils = void 0;
16
- const transactions_1 = require("@mysten/sui/transactions");
17
- const ObjectCache_1 = require("./ObjectCache");
18
- /**
19
- * Utility class for interacting with Sui blockchain coins
20
- */
21
- class SuiClientUtils {
22
- /**
23
- * Creates a new instance of SuiClientUtils
24
- * @param client - The Sui client instance to use for blockchain interactions
25
- */
26
- constructor(client) {
27
- this.client = client;
28
- _SuiClientUtils_devInspectCache.set(this, void 0);
29
- this.devInspectTransactionBlock = async (params) => {
30
- if (params.transactionBlock instanceof transactions_1.Transaction) {
31
- params.transactionBlock.addBuildPlugin(__classPrivateFieldGet(this, _SuiClientUtils_devInspectCache, "f").asPlugin());
32
- }
33
- try {
34
- const res = await this.client.devInspectTransactionBlock(params);
35
- return res;
36
- }
37
- catch (error) {
38
- // clear all cache if devInspectTransactionBlock fails
39
- await __classPrivateFieldGet(this, _SuiClientUtils_devInspectCache, "f").clear();
40
- throw error;
41
- }
42
- finally {
43
- await __classPrivateFieldGet(this, _SuiClientUtils_devInspectCache, "f").clearOwnedObjects();
44
- }
45
- };
46
- __classPrivateFieldSet(this, _SuiClientUtils_devInspectCache, new ObjectCache_1.CustomObjectCache({ client: this.client }), "f");
47
- }
48
- }
49
- exports.SuiClientUtils = SuiClientUtils;
50
- _SuiClientUtils_devInspectCache = new WeakMap();
@@ -1,96 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isSystemAddress = exports.SuiUtils = void 0;
4
- const utils_1 = require("@mysten/sui/utils");
5
- const _7k_1 = require("../constants/_7k");
6
- exports.SuiUtils = {
7
- getSuiCoin(amount, txb) {
8
- const [coin] = txb.splitCoins(txb.gas, [amount]);
9
- return coin;
10
- },
11
- getCoinValue(coinType, coinObject, txb) {
12
- const inputCoinObject = typeof coinObject == "string" ? txb.object(coinObject) : coinObject;
13
- const [value] = txb.moveCall({
14
- target: `0x2::coin::value`,
15
- typeArguments: [coinType],
16
- arguments: [inputCoinObject],
17
- });
18
- return value;
19
- },
20
- isValidStructTag(value) {
21
- try {
22
- return !!(0, utils_1.parseStructTag)(value);
23
- }
24
- catch (_) {
25
- return false;
26
- }
27
- },
28
- zeroBalance(tx, coinType) {
29
- return tx.moveCall({
30
- target: `0x2::balance::zero`,
31
- typeArguments: [coinType],
32
- arguments: [],
33
- })[0];
34
- },
35
- zeroCoin(tx, coinType) {
36
- return tx.moveCall({
37
- target: `0x2::coin::zero`,
38
- typeArguments: [coinType],
39
- arguments: [],
40
- })[0];
41
- },
42
- coinIntoBalance(tx, coinType, coinObject) {
43
- return tx.moveCall({
44
- target: `0x2::coin::into_balance`,
45
- typeArguments: [coinType],
46
- arguments: [coinObject],
47
- })[0];
48
- },
49
- coinFromBalance(tx, coinType, balance) {
50
- return tx.moveCall({
51
- target: `0x2::coin::from_balance`,
52
- typeArguments: [coinType],
53
- arguments: [balance],
54
- })[0];
55
- },
56
- balanceDestroyZero(tx, coinType, balance) {
57
- tx.moveCall({
58
- target: `0x2::balance::destroy_zero`,
59
- typeArguments: [coinType],
60
- arguments: [balance],
61
- });
62
- },
63
- collectDust(tx, coinType, coin) {
64
- tx.moveCall({
65
- target: `${_7k_1._7K_META_PACKAGE_ID}::vault::collect_dust`,
66
- typeArguments: [coinType],
67
- arguments: [tx.object(_7k_1._7K_META_VAULT), tx.object(_7k_1._7K_META_CONFIG), coin],
68
- });
69
- },
70
- transferOrDestroyZeroCoin(tx, coinType, coin, address) {
71
- tx.moveCall({
72
- target: `${_7k_1._7K_META_PACKAGE_ID}::utils::transfer_or_destroy`,
73
- typeArguments: [coinType],
74
- arguments: [coin, tx.pure.address(address)],
75
- });
76
- },
77
- };
78
- const isSystemAddress = (address) => {
79
- const addr = (0, utils_1.normalizeSuiAddress)(address);
80
- const addresses = [
81
- "0x0", // zero
82
- "0x1", // std
83
- "0x2", // sui framework
84
- "0x3", // unkown but we reserved to be safe
85
- "0x4", // unknown but we reserved to be safe
86
- "0x5", // system state
87
- "0x6", // time
88
- "0x7", // unknown but we reserved to be safe
89
- "0x8", // random
90
- "0x9", // unknown but we reserved to be safe
91
- "0x403", // coin deny list
92
- "0xc", // coin registry
93
- ].map((v) => (0, utils_1.normalizeSuiAddress)(v));
94
- return addresses.includes(addr);
95
- };
96
- exports.isSystemAddress = isSystemAddress;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getExpectedReturn = void 0;
4
- /**
5
- * Calculate expected return amount after applying slippage, commission, and tip
6
- * @param returnAmount - The raw return amount (with decimals)
7
- * @param slippageBps - Slippage in basis points (1 bps = 0.01%)
8
- * @param commissionBps - Commission in basis points
9
- * @param tipBps - Tip in basis points (default: 0)
10
- * @returns Object containing tipAmount, minAmount, commissionAmount, and expectedAmount
11
- */
12
- const getExpectedReturn = (returnAmount, slippageBps, commissionBps, tipBps = 0) => {
13
- if (slippageBps > 10000) {
14
- throw new Error("Slippage must be less than 100%");
15
- }
16
- if (commissionBps > 10000) {
17
- throw new Error("Commission must be less than 100%");
18
- }
19
- if (tipBps > 10000) {
20
- throw new Error("Tip must be less than 100%");
21
- }
22
- const returnAmountWithDecimal = BigInt(returnAmount);
23
- const tipAmountWithDecimal = (returnAmountWithDecimal * BigInt(tipBps || 0)) / 10000n;
24
- const commissionAmountWithDecimal = ((returnAmountWithDecimal - tipAmountWithDecimal) * BigInt(commissionBps)) /
25
- 10000n;
26
- const expectedReturnWithDecimal = returnAmountWithDecimal -
27
- tipAmountWithDecimal -
28
- commissionAmountWithDecimal;
29
- const minAmountWithDecimal = (expectedReturnWithDecimal * BigInt(1e4 - slippageBps)) / 10000n;
30
- return {
31
- tipAmount: tipAmountWithDecimal,
32
- minAmount: minAmountWithDecimal,
33
- commissionAmount: commissionAmountWithDecimal,
34
- expectedAmount: expectedReturnWithDecimal.toString(10),
35
- };
36
- };
37
- exports.getExpectedReturn = getExpectedReturn;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeTokenType = normalizeTokenType;
4
- exports.denormalizeTokenType = denormalizeTokenType;
5
- exports.checkIsSui = checkIsSui;
6
- const tokens_1 = require("../constants/tokens");
7
- function normalizeTokenType(type) {
8
- return type === tokens_1.SUI_TYPE ? tokens_1.SUI_FULL_TYPE : type;
9
- }
10
- function denormalizeTokenType(type) {
11
- return type === tokens_1.SUI_FULL_TYPE ? tokens_1.SUI_TYPE : type;
12
- }
13
- function checkIsSui(type) {
14
- return type === tokens_1.SUI_FULL_TYPE || type === tokens_1.SUI_TYPE;
15
- }
@@ -1,9 +0,0 @@
1
- export async function fetchClient(input, init) {
2
- const headers = new Headers(init?.headers);
3
- // intercept the request and add the headers go here...
4
- const modifiedInit = {
5
- ...init,
6
- headers,
7
- };
8
- return fetch(input, modifiedInit);
9
- }
@@ -1,17 +0,0 @@
1
- // export const _7K_PACKAGE_ID =
2
- // "0x62412b7268c35f3808336aee57a52836501f40b8ba5d936f8ad275e672befd04";
3
- // //legacy V4: "0xe8f996ea6ff38c557c253d3b93cfe2ebf393816487266786371aa4532a9229f2";
4
- // //legacy V3: "0x7ea6e27ad7af6f3b8671d59df1aaebd7c03dddab893e52a714227b2f4fe91519";
5
- // //legacy V2: "0xa13447019cd982d6bef91cf7b46ad384a52583b1dfc2bdecf31ef0c4bd787a0f";
6
- // //legacy V1: "0xd48e7cdc9e92bec69ce3baa75578010458a0c5b2733d661a84971e8cef6806bc";
7
- // export const _7K_CONFIG =
8
- // "0x47442a93f7727d188ba7cb71031170d1786af70013cb7ad5115f3fe877ff0c54";
9
- // //legacy v3: "0x0f8fc23dbcc9362b72c7a4c5aa53fcefa02ebfbb83a812c8c262ccd2c076d9ee";
10
- // export const _7K_VAULT =
11
- // "0x442ad50389ed5cda6f7a6f5a7ae6361a4c05ef1d9fb2e54fbba5a268d690bfe6";
12
- // //legacy v3: "0x39a3c55742c0e011b6f65548e73cf589e1ae5e82dbfab449ca57f24c3bcd9514";
13
- export const _7K_META_PUBLISHED_AT = "0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302";
14
- export const _7K_META_PACKAGE_ID = "0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302";
15
- export const _7K_META_VAULT = "0x9a8abd32fe5721307ce3b697cf982ee84e9ffbd58d667a4a199f1683c1a3d23c";
16
- export const _7K_META_CONFIG = "0xbbb3a51877ed9b492f26f4e2181811cfb2bd70c532f6f7621263d122d5e96b56";
17
- export const _7K_PARTNER_ADDRESS = "0x93ead46c1e48a9b62e25b6787f2ea6f75caedabb21726f12431acc4381f5f4c5";
@@ -1,6 +0,0 @@
1
- export const API_ENDPOINTS = {
2
- MAIN: "https://api.7k.ag",
3
- LO_DCA: "https://lod-dca.7k.ag",
4
- PRICES: "https://lp-pro-api.7k.ag/price",
5
- STATISTIC: "https://statistic.7k.ag",
6
- };
@@ -1 +0,0 @@
1
- export const SUI_ADDRESS_ZERO = "0x0000000000000000000000000000000000000000000000000000000000000000";
@@ -1,4 +0,0 @@
1
- export const SUI_TYPE = "0x2::sui::SUI";
2
- export const SUI_FULL_TYPE = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
3
- export const USDC_TOKEN_TYPE = "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN";
4
- export const NATIVE_USDC_TOKEN_TYPE = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
@@ -1,11 +0,0 @@
1
- import { Transaction } from "@mysten/sui/transactions";
2
- import { DCA_ORDER_MODULE_ID } from "./constants";
3
- export async function cancelDcaOrder({ orderId, payCoinType, targetCoinType, }) {
4
- const tx = new Transaction();
5
- tx.moveCall({
6
- target: `${DCA_ORDER_MODULE_ID}::cancel_dca_order`,
7
- arguments: [tx.object(orderId), tx.object.clock()],
8
- typeArguments: [payCoinType, targetCoinType],
9
- });
10
- return tx;
11
- }
@@ -1,11 +0,0 @@
1
- import { Transaction } from "@mysten/sui/transactions";
2
- import { LIMIT_ORDER_MODULE_ID } from "./constants";
3
- export async function cancelLimitOrder({ orderId, payCoinType, targetCoinType, }) {
4
- const tx = new Transaction();
5
- tx.moveCall({
6
- target: `${LIMIT_ORDER_MODULE_ID}::cancel_limit_order`,
7
- typeArguments: [payCoinType, targetCoinType],
8
- arguments: [tx.object(orderId), tx.object.clock()],
9
- });
10
- return tx;
11
- }
@@ -1,11 +0,0 @@
1
- import { Transaction } from "@mysten/sui/transactions";
2
- import { LIMIT_ORDER_MODULE_ID } from "./constants";
3
- export async function claimExpiredLimitOrder({ orderId, payCoinType, targetCoinType, }) {
4
- const tx = new Transaction();
5
- tx.moveCall({
6
- target: `${LIMIT_ORDER_MODULE_ID}::claim_expired_order`,
7
- typeArguments: [payCoinType, targetCoinType],
8
- arguments: [tx.object(orderId), tx.object.clock()],
9
- });
10
- return tx;
11
- }
@@ -1,10 +0,0 @@
1
- import { API_ENDPOINTS } from "../../constants/apiEndpoints";
2
- export const GLOBAL_CONFIG_ID = "0xffc7f420b481ed7a012b42e125fd7e5716b5673759cf4629e5fcfebce970a72d";
3
- export const RATE_SCALE = BigInt("1000000000000");
4
- export const SLIPPAGE_SCALE = BigInt("10000");
5
- export const PACKAGE = "0x0ef0f805710cf53c10f29c4f73e1144a662747e1839689a846e2520cae122adc";
6
- export const LIMIT_ORDER_MODULE_ID = `${PACKAGE}::limit_order`;
7
- export const DCA_ORDER_MODULE_ID = `${PACKAGE}::dca_order`;
8
- export const CONFIG_MODULE_ID = `${PACKAGE}::config`;
9
- export const DCA_MAX_RATE = BigInt("18446744073709551615");
10
- export const LO_DCA_API = `${API_ENDPOINTS.LO_DCA}/api`;
@@ -1,20 +0,0 @@
1
- import { fetchClient } from "../../config/fetchClient";
2
- import { formatQueryParams } from "../../libs/url";
3
- import { LO_DCA_API } from "./constants";
4
- export async function getClosedDcaOrders({ owner, offset = 0, limit = 10, tokenPair, }) {
5
- const queryParams = {
6
- owner,
7
- statuses: ["SUCCESS"],
8
- offset,
9
- limit,
10
- orderType: "DCA",
11
- tokenPair,
12
- };
13
- const paramsStr = formatQueryParams(queryParams);
14
- const response = await fetchClient(`${LO_DCA_API}/order-executions?${paramsStr}`);
15
- if (!response.ok) {
16
- throw new Error("Failed to fetch closed dca orders");
17
- }
18
- const orders = (await response.json());
19
- return orders;
20
- }
@@ -1,19 +0,0 @@
1
- import { fetchClient } from "../../config/fetchClient";
2
- import { formatQueryParams } from "../../libs/url";
3
- import { LO_DCA_API } from "./constants";
4
- export async function getClosedLimitOrders({ owner, offset = 0, limit = 10, tokenPair, }) {
5
- const queryParams = {
6
- owner,
7
- statuses: ["CLOSED"],
8
- offset,
9
- limit,
10
- tokenPair,
11
- };
12
- const paramsStr = formatQueryParams(queryParams);
13
- const response = await fetchClient(`${LO_DCA_API}/limit-orders?${paramsStr}`);
14
- if (!response.ok) {
15
- throw new Error("Failed to fetch closed limit orders");
16
- }
17
- const orders = (await response.json());
18
- return orders;
19
- }
@@ -1,20 +0,0 @@
1
- import { fetchClient } from "../../config/fetchClient";
2
- import { formatQueryParams } from "../../libs/url";
3
- import { LO_DCA_API } from "./constants";
4
- export async function getDcaOrderExecutions({ owner, orderId, offset = 0, limit = 10, }) {
5
- const queryParams = {
6
- owner,
7
- orderId,
8
- statuses: ["SUCCESS"],
9
- offset,
10
- limit,
11
- orderType: "DCA",
12
- };
13
- const paramsStr = formatQueryParams(queryParams);
14
- const response = await fetchClient(`${LO_DCA_API}/order-executions?${paramsStr}`);
15
- if (!response.ok) {
16
- throw new Error("Failed to fetch dca order executions");
17
- }
18
- const orders = (await response.json());
19
- return orders;
20
- }
@@ -1,19 +0,0 @@
1
- import { fetchClient } from "../../config/fetchClient";
2
- import { formatQueryParams } from "../../libs/url";
3
- import { LO_DCA_API } from "./constants";
4
- export async function getOpenDcaOrders({ owner, offset = 0, limit = 10, tokenPair, }) {
5
- const queryParams = {
6
- owner,
7
- statuses: ["ACTIVE", "EXPIRED"],
8
- offset,
9
- limit,
10
- tokenPair,
11
- };
12
- const paramsStr = formatQueryParams(queryParams);
13
- const response = await fetchClient(`${LO_DCA_API}/dca-orders?${paramsStr}`);
14
- if (!response.ok) {
15
- throw new Error("Failed to fetch open dca orders");
16
- }
17
- const orders = (await response.json());
18
- return orders;
19
- }
@@ -1,19 +0,0 @@
1
- import { fetchClient } from "../../config/fetchClient";
2
- import { formatQueryParams } from "../../libs/url";
3
- import { LO_DCA_API } from "./constants";
4
- export async function getOpenLimitOrders({ owner, offset = 0, limit = 10, tokenPair, }) {
5
- const queryParams = {
6
- owner,
7
- statuses: ["ACTIVE", "EXPIRED"],
8
- offset,
9
- limit,
10
- tokenPair,
11
- };
12
- const paramsStr = formatQueryParams(queryParams);
13
- const response = await fetchClient(`${LO_DCA_API}/limit-orders?${paramsStr}`);
14
- if (!response.ok) {
15
- throw new Error("Failed to fetch open limit orders");
16
- }
17
- const orders = (await response.json());
18
- return orders;
19
- }
@@ -1,10 +0,0 @@
1
- export * from "./placeLimitOrder";
2
- export * from "./cancelLimitOrder";
3
- export * from "./claimExpiredLimitOrder";
4
- export * from "./getOpenLimitOrders";
5
- export * from "./getClosedLimitOrders";
6
- export * from "./placeDcaOrder";
7
- export * from "./cancelDcaOrder";
8
- export * from "./getOpenDcaOrders";
9
- export * from "./getClosedDcaOrders";
10
- export * from "./getDcaOrderExecutions";
@@ -1,30 +0,0 @@
1
- import { DCA_ORDER_MODULE_ID, GLOBAL_CONFIG_ID } from "./constants";
2
- import { coinWithBalance, Transaction, } from "@mysten/sui/transactions";
3
- export async function placeDcaOrder({ payCoinType, targetCoinType, payCoinAmountEach, numOrders, interval, slippage, minRate, maxRate, }) {
4
- const tx = new Transaction();
5
- const coinElements = [];
6
- for (let i = 0; i < numOrders; i++) {
7
- const coin = coinWithBalance({
8
- type: payCoinType,
9
- balance: payCoinAmountEach,
10
- });
11
- coinElements.push(coin);
12
- }
13
- const vectorCoin = tx.makeMoveVec({
14
- elements: coinElements,
15
- });
16
- tx.moveCall({
17
- target: `${DCA_ORDER_MODULE_ID}::place_dca_order`,
18
- arguments: [
19
- tx.object(GLOBAL_CONFIG_ID),
20
- vectorCoin,
21
- tx.pure.u64(interval),
22
- tx.pure.u64(slippage),
23
- tx.pure.u64(minRate),
24
- tx.pure.u64(maxRate),
25
- tx.object.clock(),
26
- ],
27
- typeArguments: [payCoinType, targetCoinType],
28
- });
29
- return tx;
30
- }
@@ -1,24 +0,0 @@
1
- import { coinWithBalance, Transaction } from "@mysten/sui/transactions";
2
- import { GLOBAL_CONFIG_ID, LIMIT_ORDER_MODULE_ID } from "./constants";
3
- export async function placeLimitOrder({ accountAddress, payCoinType, targetCoinType, payCoinAmount, rate, slippage, expireTs, devInspect, }) {
4
- const tx = new Transaction();
5
- const payCoin = tx.add(coinWithBalance({
6
- type: payCoinType,
7
- balance: payCoinAmount,
8
- useGasCoin: !devInspect,
9
- }));
10
- tx.moveCall({
11
- target: `${LIMIT_ORDER_MODULE_ID}::place_limit_order`,
12
- arguments: [
13
- tx.object(GLOBAL_CONFIG_ID),
14
- payCoin,
15
- tx.pure.u64(rate),
16
- tx.pure.u64(slippage),
17
- tx.pure.u64(expireTs),
18
- tx.object.clock(),
19
- ],
20
- typeArguments: [payCoinType, targetCoinType],
21
- });
22
- tx.setSenderIfNotSet(accountAddress);
23
- return tx;
24
- }
@@ -1,13 +0,0 @@
1
- export var LoDcaOrderStatus;
2
- (function (LoDcaOrderStatus) {
3
- LoDcaOrderStatus["PENDING"] = "PENDING";
4
- LoDcaOrderStatus["ACTIVE"] = "ACTIVE";
5
- LoDcaOrderStatus["EXPIRED"] = "EXPIRED";
6
- LoDcaOrderStatus["CANCELED"] = "CANCELED";
7
- })(LoDcaOrderStatus || (LoDcaOrderStatus = {}));
8
- export var LoDcaOrderExecutionStatus;
9
- (function (LoDcaOrderExecutionStatus) {
10
- LoDcaOrderExecutionStatus["PENDING"] = "PENDING";
11
- LoDcaOrderExecutionStatus["SUCCESS"] = "SUCCESS";
12
- LoDcaOrderExecutionStatus["FAILED"] = "FAILED";
13
- })(LoDcaOrderExecutionStatus || (LoDcaOrderExecutionStatus = {}));
@@ -1,96 +0,0 @@
1
- import { coinWithBalance, Transaction, } from "@mysten/sui/transactions";
2
- import { _7K_META_CONFIG, _7K_META_PACKAGE_ID, _7K_META_PUBLISHED_AT, _7K_META_VAULT, } from "../../constants/_7k";
3
- import { getExpectedReturn } from "../../utils/swap";
4
- import { MetaAgError, MetaAgErrorCode } from "./error";
5
- export const simulateSwapTx = async (tx, inspector, simulation) => {
6
- const res = await timeout(() => inspector.devInspectTransactionBlock({
7
- sender: simulation.sender,
8
- transactionBlock: tx,
9
- }), simulation.timeout ?? 2000);
10
- if (res.effects.status.status === "failure") {
11
- throw new MetaAgError(res.error ?? "Simulation failed", MetaAgErrorCode.SIMULATION_FAILED, { error: res.error });
12
- }
13
- const amountOut = extractAmountOutWrapper(res.events);
14
- return {
15
- simulatedAmountOut: amountOut,
16
- gasUsed: res.effects.gasUsed,
17
- };
18
- };
19
- export const simulateAggregator = async (provider, quote, simulation, inspector, options) => {
20
- const tx = new Transaction();
21
- const coinOut = await provider.swap({
22
- quote,
23
- coinIn: coinWithBalance({
24
- balance: BigInt(quote.amountIn),
25
- type: quote.coinTypeIn,
26
- useGasCoin: false,
27
- }),
28
- signer: simulation.sender,
29
- tx,
30
- });
31
- tx.add(metaSettle(quote, coinOut, 10000, options.tipBps, options.partner, options.partnerCommissionBps));
32
- tx.transferObjects([coinOut], simulation.sender);
33
- const res = await simulateSwapTx(tx, inspector, simulation);
34
- return {
35
- id: quote.id,
36
- provider: provider.kind,
37
- ...res,
38
- };
39
- };
40
- /**
41
- * this settlement does not charge commission fee for partner, since all integrated aggregators already charge commission fee for partner
42
- * @param quote Meta Aggregator Quote
43
- * @param coinOut Coin Out Object
44
- * @param slippageBps Slippage Bps
45
- * @param tipBps Tip Bps default = 0
46
- * @param partner address of partner for analytic default is zero address
47
- */
48
- export const metaSettle = (quote, coinOut, slippageBps = 100, tipBps = 0, partner, commissionBps = 0) => {
49
- return (tx) => {
50
- const { minAmount, expectedAmount } = getExpectedReturn(quote.rawAmountOut, slippageBps, commissionBps, tipBps);
51
- if (tipBps > 0) {
52
- tx.moveCall({
53
- target: `${_7K_META_PUBLISHED_AT}::vault::collect_tip`,
54
- typeArguments: [quote.coinTypeOut],
55
- arguments: [
56
- tx.object(_7K_META_VAULT),
57
- tx.object(_7K_META_CONFIG),
58
- coinOut,
59
- tx.pure.u64(tipBps),
60
- ],
61
- });
62
- }
63
- tx.moveCall({
64
- target: `${_7K_META_PUBLISHED_AT}::settle::settle`,
65
- typeArguments: [quote.coinTypeIn, quote.coinTypeOut],
66
- arguments: [
67
- tx.object(_7K_META_CONFIG),
68
- tx.object(_7K_META_VAULT),
69
- tx.pure.u64(quote.amountIn),
70
- coinOut,
71
- tx.pure.u64(minAmount),
72
- tx.pure.u64(expectedAmount),
73
- tx.pure.option("address", partner),
74
- tx.pure.u64(commissionBps),
75
- tx.pure.u64(0), // ps
76
- ],
77
- });
78
- };
79
- };
80
- const extractAmountOutWrapper = (events) => {
81
- const swapEvent = events
82
- .filter((event) => event.type === `${_7K_META_PACKAGE_ID}::settle::Swap`)
83
- ?.pop();
84
- return swapEvent?.parsedJson?.amount_out;
85
- };
86
- export const timeout = async (fn, timeout, msg) => {
87
- if (timeout <= 0)
88
- return fn();
89
- return new Promise((resolve, reject) => {
90
- const timer = setTimeout(() => reject(new MetaAgError(`Timeout ${msg ?? "operation"}`, MetaAgErrorCode.TIMEOUT, { timeout })), timeout);
91
- fn()
92
- .then(resolve)
93
- .catch(reject)
94
- .finally(() => clearTimeout(timer));
95
- });
96
- };
@@ -1,29 +0,0 @@
1
- export var MetaAgErrorCode;
2
- (function (MetaAgErrorCode) {
3
- MetaAgErrorCode[MetaAgErrorCode["UNKNOWN"] = 1000] = "UNKNOWN";
4
- MetaAgErrorCode[MetaAgErrorCode["TIMEOUT"] = 1001] = "TIMEOUT";
5
- MetaAgErrorCode[MetaAgErrorCode["PROVIDER_NOT_FOUND"] = 1002] = "PROVIDER_NOT_FOUND";
6
- MetaAgErrorCode[MetaAgErrorCode["PROVIDER_NOT_SUPPORTED"] = 1003] = "PROVIDER_NOT_SUPPORTED";
7
- MetaAgErrorCode[MetaAgErrorCode["INVALID_QUOTE"] = 1004] = "INVALID_QUOTE";
8
- MetaAgErrorCode[MetaAgErrorCode["QUOTE_NOT_FOUND"] = 1005] = "QUOTE_NOT_FOUND";
9
- MetaAgErrorCode[MetaAgErrorCode["INVALID_SIGNER_ADDRESS"] = 1006] = "INVALID_SIGNER_ADDRESS";
10
- MetaAgErrorCode[MetaAgErrorCode["PROVIDER_NOT_SUPPORT_SWAP"] = 1007] = "PROVIDER_NOT_SUPPORT_SWAP";
11
- MetaAgErrorCode[MetaAgErrorCode["SIMULATION_FAILED"] = 1008] = "SIMULATION_FAILED";
12
- // OKX error
13
- MetaAgErrorCode[MetaAgErrorCode["OKX_FINALIZE_COMMAND_NOT_FOUND"] = 1100] = "OKX_FINALIZE_COMMAND_NOT_FOUND";
14
- })(MetaAgErrorCode || (MetaAgErrorCode = {}));
15
- export class MetaAgError extends Error {
16
- code;
17
- details;
18
- constructor(message, code, details) {
19
- super(message);
20
- this.name = "MetaAgError";
21
- this.code = code ?? MetaAgErrorCode.UNKNOWN;
22
- this.details = details;
23
- }
24
- static assert(condition, message, code, details) {
25
- if (!condition) {
26
- throw new MetaAgError(message ?? "Assertion failed", code, details);
27
- }
28
- }
29
- }