@7kprotocol/sdk-ts 2.4.1 → 2.4.2-beta.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 (205) hide show
  1. package/README.md +30 -3
  2. package/lib/cjs/config/fetchClient.js +11 -19
  3. package/lib/cjs/config/index.js +22 -0
  4. package/lib/cjs/constants/_7k.js +6 -3
  5. package/lib/cjs/features/limitDca/cancelDcaOrder.js +7 -18
  6. package/lib/cjs/features/limitDca/cancelLimitOrder.js +7 -18
  7. package/lib/cjs/features/limitDca/claimExpiredLimitOrder.js +7 -18
  8. package/lib/cjs/features/limitDca/constants.js +1 -5
  9. package/lib/cjs/features/limitDca/getClosedDcaOrders.js +16 -27
  10. package/lib/cjs/features/limitDca/getClosedLimitOrders.js +15 -26
  11. package/lib/cjs/features/limitDca/getDcaOrderExecutions.js +16 -27
  12. package/lib/cjs/features/limitDca/getOpenDcaOrders.js +15 -26
  13. package/lib/cjs/features/limitDca/getOpenLimitOrders.js +15 -26
  14. package/lib/cjs/features/limitDca/placeDcaOrder.js +25 -36
  15. package/lib/cjs/features/limitDca/placeLimitOrder.js +14 -25
  16. package/lib/cjs/features/prices/index.js +47 -64
  17. package/lib/cjs/features/swap/buildTx.js +88 -39
  18. package/lib/cjs/features/swap/config.js +32 -32
  19. package/lib/cjs/features/swap/estimateGasFee.js +36 -46
  20. package/lib/cjs/features/swap/executeTx.js +52 -0
  21. package/lib/cjs/features/swap/getQuote.js +41 -31
  22. package/lib/cjs/features/swap/getSwapHistory.js +14 -25
  23. package/lib/cjs/features/swap/index.js +1 -0
  24. package/lib/cjs/index.js +16 -9
  25. package/lib/cjs/libs/getCoinOjectIdsByAmount.js +15 -24
  26. package/lib/cjs/libs/getSplitCoinForTx.js +8 -15
  27. package/lib/cjs/libs/groupSwapRoutes.js +10 -12
  28. package/lib/cjs/libs/protocols/aftermath/index.js +25 -36
  29. package/lib/cjs/libs/protocols/base.js +10 -3
  30. package/lib/cjs/libs/protocols/bluefin/index.js +26 -43
  31. package/lib/cjs/libs/protocols/bluefinx/client.js +35 -0
  32. package/lib/cjs/libs/protocols/bluefinx/index.js +48 -0
  33. package/lib/cjs/libs/protocols/bluefinx/types.js +10 -0
  34. package/lib/cjs/libs/protocols/bluemove/index.js +14 -25
  35. package/lib/cjs/libs/protocols/cetus/index.js +32 -43
  36. package/lib/cjs/libs/protocols/deepbookV3/sponsored.js +19 -30
  37. package/lib/cjs/libs/protocols/flowx/index.js +9 -20
  38. package/lib/cjs/libs/protocols/flowxV3/index.js +25 -39
  39. package/lib/cjs/libs/protocols/haedal_pmm/index.js +33 -0
  40. package/lib/cjs/libs/protocols/index.js +7 -2
  41. package/lib/cjs/libs/protocols/kriya/index.js +20 -31
  42. package/lib/cjs/libs/protocols/kriyaV3/index.js +54 -65
  43. package/lib/cjs/libs/protocols/magma/index.js +28 -40
  44. package/lib/cjs/libs/protocols/momentum/index.js +49 -0
  45. package/lib/cjs/libs/protocols/obric/index.js +20 -31
  46. package/lib/cjs/libs/protocols/springsui/index.js +14 -25
  47. package/lib/cjs/libs/protocols/steamm/index.js +57 -58
  48. package/lib/cjs/libs/protocols/stsui/index.js +14 -25
  49. package/lib/cjs/libs/protocols/suiswap/index.js +23 -34
  50. package/lib/cjs/libs/protocols/turbos/index.js +23 -38
  51. package/lib/cjs/libs/protocols/utils.js +1 -5
  52. package/lib/cjs/libs/swapWithRoute.js +17 -27
  53. package/lib/cjs/types/aggregator.js +17 -0
  54. package/lib/cjs/types/config/index.d.ts +9 -0
  55. package/lib/cjs/types/config/index.d.ts.map +1 -1
  56. package/lib/cjs/types/constants/_7k.d.ts +3 -3
  57. package/lib/cjs/types/constants/_7k.d.ts.map +1 -1
  58. package/lib/cjs/types/features/limitDca/constants.d.ts +1 -2
  59. package/lib/cjs/types/features/limitDca/constants.d.ts.map +1 -1
  60. package/lib/cjs/types/features/swap/buildTx.d.ts +2 -5
  61. package/lib/cjs/types/features/swap/buildTx.d.ts.map +1 -1
  62. package/lib/cjs/types/features/swap/config.d.ts.map +1 -1
  63. package/lib/cjs/types/features/swap/estimateGasFee.d.ts.map +1 -1
  64. package/lib/cjs/types/features/swap/executeTx.d.ts +24 -0
  65. package/lib/cjs/types/features/swap/executeTx.d.ts.map +1 -0
  66. package/lib/cjs/types/features/swap/getQuote.d.ts +8 -1
  67. package/lib/cjs/types/features/swap/getQuote.d.ts.map +1 -1
  68. package/lib/cjs/types/features/swap/index.d.ts +1 -0
  69. package/lib/cjs/types/features/swap/index.d.ts.map +1 -1
  70. package/lib/cjs/types/index.d.ts +13 -8
  71. package/lib/cjs/types/index.d.ts.map +1 -1
  72. package/lib/cjs/types/libs/getCoinOjectIdsByAmount.d.ts.map +1 -1
  73. package/lib/cjs/types/libs/getSplitCoinForTx.d.ts.map +1 -1
  74. package/lib/cjs/types/libs/groupSwapRoutes.d.ts.map +1 -1
  75. package/lib/cjs/types/libs/protocols/base.d.ts +6 -2
  76. package/lib/cjs/types/libs/protocols/base.d.ts.map +1 -1
  77. package/lib/cjs/types/libs/protocols/bluefin/index.d.ts.map +1 -1
  78. package/lib/cjs/types/libs/protocols/bluefinx/client.d.ts +13 -0
  79. package/lib/cjs/types/libs/protocols/bluefinx/client.d.ts.map +1 -0
  80. package/lib/cjs/types/libs/protocols/bluefinx/index.d.ts +17 -0
  81. package/lib/cjs/types/libs/protocols/bluefinx/index.d.ts.map +1 -0
  82. package/lib/cjs/types/libs/protocols/bluefinx/types.d.ts +34 -0
  83. package/lib/cjs/types/libs/protocols/bluefinx/types.d.ts.map +1 -0
  84. package/lib/cjs/types/libs/protocols/cetus/index.d.ts.map +1 -1
  85. package/lib/cjs/types/libs/protocols/deepbookV3/sponsored.d.ts.map +1 -1
  86. package/lib/cjs/types/libs/protocols/flowxV3/index.d.ts.map +1 -1
  87. package/lib/{esm/types/libs/protocols/deepbook → cjs/types/libs/protocols/haedal_pmm}/index.d.ts +1 -3
  88. package/lib/cjs/types/libs/protocols/haedal_pmm/index.d.ts.map +1 -0
  89. package/lib/cjs/types/libs/protocols/index.d.ts +7 -2
  90. package/lib/cjs/types/libs/protocols/index.d.ts.map +1 -1
  91. package/lib/cjs/types/libs/protocols/magma/index.d.ts.map +1 -1
  92. package/lib/cjs/types/libs/protocols/{deepbook → momentum}/index.d.ts +1 -3
  93. package/lib/cjs/types/libs/protocols/momentum/index.d.ts.map +1 -0
  94. package/lib/cjs/types/libs/protocols/steamm/index.d.ts +13 -2
  95. package/lib/cjs/types/libs/protocols/steamm/index.d.ts.map +1 -1
  96. package/lib/cjs/types/libs/protocols/suiswap/index.d.ts.map +1 -1
  97. package/lib/cjs/types/libs/protocols/turbos/index.d.ts.map +1 -1
  98. package/lib/cjs/types/libs/protocols/utils.d.ts +1 -2
  99. package/lib/cjs/types/libs/protocols/utils.d.ts.map +1 -1
  100. package/lib/cjs/types/libs/swapWithRoute.d.ts +3 -1
  101. package/lib/cjs/types/libs/swapWithRoute.d.ts.map +1 -1
  102. package/lib/cjs/types/types/aggregator.d.ts +36 -2
  103. package/lib/cjs/types/types/aggregator.d.ts.map +1 -1
  104. package/lib/cjs/types/types/tx.d.ts +1 -2
  105. package/lib/cjs/types/types/tx.d.ts.map +1 -1
  106. package/lib/cjs/types/utils/number.d.ts +1 -3
  107. package/lib/cjs/types/utils/number.d.ts.map +1 -1
  108. package/lib/cjs/types/utils/sui.d.ts +1 -1
  109. package/lib/cjs/types/utils/sui.d.ts.map +1 -1
  110. package/lib/cjs/utils/number.js +4 -10
  111. package/lib/cjs/utils/sui.js +71 -80
  112. package/lib/esm/config/index.js +22 -0
  113. package/lib/esm/constants/_7k.js +6 -3
  114. package/lib/esm/features/limitDca/constants.js +1 -2
  115. package/lib/esm/features/swap/buildTx.js +81 -20
  116. package/lib/esm/features/swap/config.js +19 -8
  117. package/lib/esm/features/swap/estimateGasFee.js +13 -9
  118. package/lib/esm/features/swap/executeTx.js +48 -0
  119. package/lib/esm/features/swap/getQuote.js +24 -3
  120. package/lib/esm/features/swap/index.js +1 -0
  121. package/lib/esm/index.mjs +8 -4
  122. package/lib/esm/libs/getCoinOjectIdsByAmount.js +7 -7
  123. package/lib/esm/libs/getSplitCoinForTx.js +4 -2
  124. package/lib/esm/libs/groupSwapRoutes.js +1 -2
  125. package/lib/esm/libs/protocols/base.js +10 -1
  126. package/lib/esm/libs/protocols/bluefin/index.js +2 -5
  127. package/lib/esm/libs/protocols/bluefinx/client.js +30 -0
  128. package/lib/esm/libs/protocols/bluefinx/index.js +44 -0
  129. package/lib/esm/libs/protocols/bluefinx/types.js +8 -0
  130. package/lib/esm/libs/protocols/cetus/index.js +1 -1
  131. package/lib/esm/libs/protocols/deepbookV3/sponsored.js +1 -1
  132. package/lib/esm/libs/protocols/flowxV3/index.js +1 -4
  133. package/lib/esm/libs/protocols/haedal_pmm/index.js +29 -0
  134. package/lib/esm/libs/protocols/index.js +7 -2
  135. package/lib/esm/libs/protocols/magma/index.js +1 -2
  136. package/lib/esm/libs/protocols/momentum/index.js +45 -0
  137. package/lib/esm/libs/protocols/steamm/index.js +58 -48
  138. package/lib/esm/libs/protocols/suiswap/index.js +1 -1
  139. package/lib/esm/libs/protocols/turbos/index.js +2 -6
  140. package/lib/esm/libs/protocols/utils.js +1 -2
  141. package/lib/esm/libs/swapWithRoute.js +2 -1
  142. package/lib/esm/types/aggregator.js +14 -1
  143. package/lib/esm/types/config/index.d.ts +9 -0
  144. package/lib/esm/types/config/index.d.ts.map +1 -1
  145. package/lib/esm/types/constants/_7k.d.ts +3 -3
  146. package/lib/esm/types/constants/_7k.d.ts.map +1 -1
  147. package/lib/esm/types/features/limitDca/constants.d.ts +1 -2
  148. package/lib/esm/types/features/limitDca/constants.d.ts.map +1 -1
  149. package/lib/esm/types/features/swap/buildTx.d.ts +2 -5
  150. package/lib/esm/types/features/swap/buildTx.d.ts.map +1 -1
  151. package/lib/esm/types/features/swap/config.d.ts.map +1 -1
  152. package/lib/esm/types/features/swap/estimateGasFee.d.ts.map +1 -1
  153. package/lib/esm/types/features/swap/executeTx.d.ts +24 -0
  154. package/lib/esm/types/features/swap/executeTx.d.ts.map +1 -0
  155. package/lib/esm/types/features/swap/getQuote.d.ts +8 -1
  156. package/lib/esm/types/features/swap/getQuote.d.ts.map +1 -1
  157. package/lib/esm/types/features/swap/index.d.ts +1 -0
  158. package/lib/esm/types/features/swap/index.d.ts.map +1 -1
  159. package/lib/esm/types/index.d.ts +13 -8
  160. package/lib/esm/types/index.d.ts.map +1 -1
  161. package/lib/esm/types/libs/getCoinOjectIdsByAmount.d.ts.map +1 -1
  162. package/lib/esm/types/libs/getSplitCoinForTx.d.ts.map +1 -1
  163. package/lib/esm/types/libs/groupSwapRoutes.d.ts.map +1 -1
  164. package/lib/esm/types/libs/protocols/base.d.ts +6 -2
  165. package/lib/esm/types/libs/protocols/base.d.ts.map +1 -1
  166. package/lib/esm/types/libs/protocols/bluefin/index.d.ts.map +1 -1
  167. package/lib/esm/types/libs/protocols/bluefinx/client.d.ts +13 -0
  168. package/lib/esm/types/libs/protocols/bluefinx/client.d.ts.map +1 -0
  169. package/lib/esm/types/libs/protocols/bluefinx/index.d.ts +17 -0
  170. package/lib/esm/types/libs/protocols/bluefinx/index.d.ts.map +1 -0
  171. package/lib/esm/types/libs/protocols/bluefinx/types.d.ts +34 -0
  172. package/lib/esm/types/libs/protocols/bluefinx/types.d.ts.map +1 -0
  173. package/lib/esm/types/libs/protocols/cetus/index.d.ts.map +1 -1
  174. package/lib/esm/types/libs/protocols/deepbookV3/sponsored.d.ts.map +1 -1
  175. package/lib/esm/types/libs/protocols/flowxV3/index.d.ts.map +1 -1
  176. package/lib/esm/types/libs/protocols/haedal_pmm/index.d.ts +9 -0
  177. package/lib/esm/types/libs/protocols/haedal_pmm/index.d.ts.map +1 -0
  178. package/lib/esm/types/libs/protocols/index.d.ts +7 -2
  179. package/lib/esm/types/libs/protocols/index.d.ts.map +1 -1
  180. package/lib/esm/types/libs/protocols/magma/index.d.ts.map +1 -1
  181. package/lib/esm/types/libs/protocols/momentum/index.d.ts +9 -0
  182. package/lib/esm/types/libs/protocols/momentum/index.d.ts.map +1 -0
  183. package/lib/esm/types/libs/protocols/steamm/index.d.ts +13 -2
  184. package/lib/esm/types/libs/protocols/steamm/index.d.ts.map +1 -1
  185. package/lib/esm/types/libs/protocols/suiswap/index.d.ts.map +1 -1
  186. package/lib/esm/types/libs/protocols/turbos/index.d.ts.map +1 -1
  187. package/lib/esm/types/libs/protocols/utils.d.ts +1 -2
  188. package/lib/esm/types/libs/protocols/utils.d.ts.map +1 -1
  189. package/lib/esm/types/libs/swapWithRoute.d.ts +3 -1
  190. package/lib/esm/types/libs/swapWithRoute.d.ts.map +1 -1
  191. package/lib/esm/types/types/aggregator.d.ts +36 -2
  192. package/lib/esm/types/types/aggregator.d.ts.map +1 -1
  193. package/lib/esm/types/types/tx.d.ts +1 -2
  194. package/lib/esm/types/types/tx.d.ts.map +1 -1
  195. package/lib/esm/types/utils/number.d.ts +1 -3
  196. package/lib/esm/types/utils/number.d.ts.map +1 -1
  197. package/lib/esm/types/utils/sui.d.ts +1 -1
  198. package/lib/esm/types/utils/sui.d.ts.map +1 -1
  199. package/lib/esm/utils/number.js +4 -6
  200. package/lib/esm/utils/sui.js +4 -3
  201. package/package.json +14 -15
  202. package/lib/cjs/libs/protocols/deepbook/index.js +0 -96
  203. package/lib/cjs/types/libs/protocols/deepbook/index.d.ts.map +0 -1
  204. package/lib/esm/libs/protocols/deepbook/index.js +0 -80
  205. package/lib/esm/types/libs/protocols/deepbook/index.d.ts.map +0 -1
package/README.md CHANGED
@@ -6,6 +6,13 @@
6
6
  npm i @7kprotocol/sdk-ts
7
7
  ```
8
8
 
9
+ This package requires `@pythnetwork/pyth-sui-js` as a peer dependency. If your
10
+ project does not have it, you need to install it.
11
+
12
+ ```bash
13
+ npm i @pythnetwork/pyth-sui-js
14
+ ```
15
+
9
16
  ## Usage
10
17
 
11
18
  You can import the entire SDK as a module:
@@ -27,8 +34,24 @@ SDK functions.
27
34
 
28
35
  ### Set API Key
29
36
 
30
- If you’re calling our API from your server, contact us to request dedicated API
31
- keys and minimize the risk of rate limiting.
37
+ You can use our SDK with a default rate limit of **5 requests per second**
38
+ without needing an API key.
39
+
40
+ - For **frontend (in-browser) usage**, no API key is required, and the rate
41
+ limit cannot be increased.
42
+
43
+ - For **backend (server-side) usage**, the API key is **optional** for default
44
+ usage. However, to request a **higher rate limit**, you must provide both an
45
+ **API key** and **partner information**.
46
+
47
+ To request a rate limit increase, please submit your request at:
48
+
49
+ 🔗 <https://7k.ag/collab> and select **"SDK - increase request rate"**.
50
+
51
+ | Usage | API Key Required | Default Rate Limit | Can Request Higher Rate Limit |
52
+ | -------- | ------------------------------------- | ------------------------------- | -------------------------------------------- |
53
+ | Frontend | No | 5 requests/second | No |
54
+ | Backend | Optional (required to increase limit) | 5 requests/second (without key) | Yes (requires API Key & partner information) |
32
55
 
33
56
  ```typescript
34
57
  import { Config } from "@7kprotocol/sdk-ts";
@@ -49,12 +72,16 @@ Config.setSuiClient(suiClient);
49
72
  console.log("Sui client", Config.getSuiClient());
50
73
  ```
51
74
 
52
- Note: this package only supports **mainnet** for now.
75
+ Note: this package only supports **mainnet**.
53
76
 
54
77
  ## Swap
55
78
 
56
79
  See [Swap](docs/SWAP.md).
57
80
 
81
+ ## BluefinX
82
+
83
+ See [BluefinX](docs/BLUEFINX.md).
84
+
58
85
  ## Limit Orders
59
86
 
60
87
  See [Limit Orders](docs/LIMIT.md).
@@ -1,24 +1,16 @@
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.fetchClient = fetchClient;
13
4
  const index_1 = require("./index");
14
- function fetchClient(input, init) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- const headers = new Headers(init === null || init === void 0 ? void 0 : init.headers);
17
- const apiKey = (index_1.Config.getApiKey() || "").trim();
18
- if (apiKey) {
19
- headers.set("apiKey", apiKey);
20
- }
21
- const modifiedInit = Object.assign(Object.assign({}, init), { headers });
22
- return fetch(input, modifiedInit);
23
- });
5
+ async function fetchClient(input, init) {
6
+ const headers = new Headers(init?.headers);
7
+ const apiKey = (index_1.Config.getApiKey() || "").trim();
8
+ if (apiKey) {
9
+ headers.set("apiKey", apiKey);
10
+ }
11
+ const modifiedInit = {
12
+ ...init,
13
+ headers,
14
+ };
15
+ return fetch(input, modifiedInit);
24
16
  }
@@ -2,10 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Config = void 0;
4
4
  const client_1 = require("@mysten/sui/client");
5
+ const pyth_sui_js_1 = require("@pythnetwork/pyth-sui-js");
6
+ const HERMES_API = "https://hermes.pyth.network";
7
+ const WORMHOLE_STATE_ID = "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c";
8
+ const PYTH_STATE_ID = "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8";
5
9
  let apiKey = "";
6
10
  let suiClient = new client_1.SuiClient({
7
11
  url: (0, client_1.getFullnodeUrl)("mainnet"),
8
12
  });
13
+ let pythClient = new pyth_sui_js_1.SuiPythClient(suiClient, PYTH_STATE_ID, WORMHOLE_STATE_ID);
14
+ let pythConnection = new pyth_sui_js_1.SuiPriceServiceConnection(HERMES_API);
9
15
  function setApiKey(key) {
10
16
  apiKey = key;
11
17
  }
@@ -18,10 +24,26 @@ function getSuiClient() {
18
24
  function setSuiClient(client) {
19
25
  suiClient = client;
20
26
  }
27
+ function setPythClient(client) {
28
+ pythClient = client;
29
+ }
30
+ function getPythClient() {
31
+ return pythClient;
32
+ }
33
+ function setPythConnection(connection) {
34
+ pythConnection = connection;
35
+ }
36
+ function getPythConnection() {
37
+ return pythConnection;
38
+ }
21
39
  const Config = {
22
40
  setApiKey,
23
41
  getApiKey,
24
42
  setSuiClient,
25
43
  getSuiClient,
44
+ setPythClient,
45
+ getPythClient,
46
+ setPythConnection,
47
+ getPythConnection,
26
48
  };
27
49
  exports.Config = Config;
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports._7K_VAULT = exports._7K_CONFIG = exports._7K_PACKAGE_ID = void 0;
4
- exports._7K_PACKAGE_ID = "0x7ea6e27ad7af6f3b8671d59df1aaebd7c03dddab893e52a714227b2f4fe91519";
4
+ exports._7K_PACKAGE_ID = "0xe8f996ea6ff38c557c253d3b93cfe2ebf393816487266786371aa4532a9229f2";
5
+ //legacy V3: "0x7ea6e27ad7af6f3b8671d59df1aaebd7c03dddab893e52a714227b2f4fe91519";
5
6
  //legacy V2: "0xa13447019cd982d6bef91cf7b46ad384a52583b1dfc2bdecf31ef0c4bd787a0f";
6
7
  //legacy V1: "0xd48e7cdc9e92bec69ce3baa75578010458a0c5b2733d661a84971e8cef6806bc";
7
- exports._7K_CONFIG = "0x0f8fc23dbcc9362b72c7a4c5aa53fcefa02ebfbb83a812c8c262ccd2c076d9ee";
8
- exports._7K_VAULT = "0x39a3c55742c0e011b6f65548e73cf589e1ae5e82dbfab449ca57f24c3bcd9514";
8
+ exports._7K_CONFIG = "0x47442a93f7727d188ba7cb71031170d1786af70013cb7ad5115f3fe877ff0c54";
9
+ //legacy v3: "0x0f8fc23dbcc9362b72c7a4c5aa53fcefa02ebfbb83a812c8c262ccd2c076d9ee";
10
+ exports._7K_VAULT = "0x442ad50389ed5cda6f7a6f5a7ae6361a4c05ef1d9fb2e54fbba5a268d690bfe6";
11
+ //legacy v3: "0x39a3c55742c0e011b6f65548e73cf589e1ae5e82dbfab449ca57f24c3bcd9514";
@@ -1,25 +1,14 @@
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.cancelDcaOrder = cancelDcaOrder;
13
4
  const transactions_1 = require("@mysten/sui/transactions");
14
5
  const constants_1 = require("./constants");
15
- function cancelDcaOrder(_a) {
16
- return __awaiter(this, arguments, void 0, function* ({ orderId, payCoinType, targetCoinType, }) {
17
- const tx = new transactions_1.Transaction();
18
- tx.moveCall({
19
- target: `${constants_1.DCA_ORDER_MODULE_ID}::cancel_dca_order`,
20
- arguments: [tx.object(orderId), tx.object.clock()],
21
- typeArguments: [payCoinType, targetCoinType],
22
- });
23
- return tx;
6
+ async function cancelDcaOrder({ orderId, payCoinType, targetCoinType, }) {
7
+ const tx = new transactions_1.Transaction();
8
+ tx.moveCall({
9
+ target: `${constants_1.DCA_ORDER_MODULE_ID}::cancel_dca_order`,
10
+ arguments: [tx.object(orderId), tx.object.clock()],
11
+ typeArguments: [payCoinType, targetCoinType],
24
12
  });
13
+ return tx;
25
14
  }
@@ -1,25 +1,14 @@
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.cancelLimitOrder = cancelLimitOrder;
13
4
  const transactions_1 = require("@mysten/sui/transactions");
14
5
  const constants_1 = require("./constants");
15
- function cancelLimitOrder(_a) {
16
- return __awaiter(this, arguments, void 0, function* ({ orderId, payCoinType, targetCoinType, }) {
17
- const tx = new transactions_1.Transaction();
18
- tx.moveCall({
19
- target: `${constants_1.LIMIT_ORDER_MODULE_ID}::cancel_limit_order`,
20
- typeArguments: [payCoinType, targetCoinType],
21
- arguments: [tx.object(orderId), tx.object.clock()],
22
- });
23
- return tx;
6
+ async function cancelLimitOrder({ orderId, payCoinType, targetCoinType, }) {
7
+ const tx = new transactions_1.Transaction();
8
+ tx.moveCall({
9
+ target: `${constants_1.LIMIT_ORDER_MODULE_ID}::cancel_limit_order`,
10
+ typeArguments: [payCoinType, targetCoinType],
11
+ arguments: [tx.object(orderId), tx.object.clock()],
24
12
  });
13
+ return tx;
25
14
  }
@@ -1,25 +1,14 @@
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.claimExpiredLimitOrder = claimExpiredLimitOrder;
13
4
  const transactions_1 = require("@mysten/sui/transactions");
14
5
  const constants_1 = require("./constants");
15
- function claimExpiredLimitOrder(_a) {
16
- return __awaiter(this, arguments, void 0, function* ({ orderId, payCoinType, targetCoinType, }) {
17
- const tx = new transactions_1.Transaction();
18
- tx.moveCall({
19
- target: `${constants_1.LIMIT_ORDER_MODULE_ID}::claim_expired_order`,
20
- typeArguments: [payCoinType, targetCoinType],
21
- arguments: [tx.object(orderId), tx.object.clock()],
22
- });
23
- return tx;
6
+ async function claimExpiredLimitOrder({ orderId, payCoinType, targetCoinType, }) {
7
+ const tx = new transactions_1.Transaction();
8
+ tx.moveCall({
9
+ target: `${constants_1.LIMIT_ORDER_MODULE_ID}::claim_expired_order`,
10
+ typeArguments: [payCoinType, targetCoinType],
11
+ arguments: [tx.object(orderId), tx.object.clock()],
24
12
  });
13
+ return tx;
25
14
  }
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.LO_DCA_API = exports.DCA_MAX_RATE = exports.CONFIG_MODULE_ID = exports.DCA_ORDER_MODULE_ID = exports.LIMIT_ORDER_MODULE_ID = exports.PACKAGE = exports.SLIPPAGE_SCALE = exports.RATE_SCALE = exports.GLOBAL_CONFIG_ID = void 0;
7
- const bignumber_js_1 = __importDefault(require("bignumber.js"));
8
4
  const apiEndpoints_1 = require("../../constants/apiEndpoints");
9
5
  exports.GLOBAL_CONFIG_ID = "0xffc7f420b481ed7a012b42e125fd7e5716b5673759cf4629e5fcfebce970a72d";
10
6
  exports.RATE_SCALE = BigInt("1000000000000");
@@ -13,5 +9,5 @@ exports.PACKAGE = "0x0ef0f805710cf53c10f29c4f73e1144a662747e1839689a846e2520cae1
13
9
  exports.LIMIT_ORDER_MODULE_ID = `${exports.PACKAGE}::limit_order`;
14
10
  exports.DCA_ORDER_MODULE_ID = `${exports.PACKAGE}::dca_order`;
15
11
  exports.CONFIG_MODULE_ID = `${exports.PACKAGE}::config`;
16
- exports.DCA_MAX_RATE = new bignumber_js_1.default("18446744073709551615");
12
+ exports.DCA_MAX_RATE = BigInt("18446744073709551615");
17
13
  exports.LO_DCA_API = `${apiEndpoints_1.API_ENDPOINTS.LO_DCA}/api`;
@@ -1,34 +1,23 @@
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.getClosedDcaOrders = getClosedDcaOrders;
13
4
  const fetchClient_1 = require("../../config/fetchClient");
14
5
  const url_1 = require("../../libs/url");
15
6
  const constants_1 = require("./constants");
16
- function getClosedDcaOrders(_a) {
17
- return __awaiter(this, arguments, void 0, function* ({ owner, offset = 0, limit = 10, tokenPair, }) {
18
- const queryParams = {
19
- owner,
20
- statuses: ["SUCCESS"],
21
- offset,
22
- limit,
23
- orderType: "DCA",
24
- tokenPair,
25
- };
26
- const paramsStr = (0, url_1.formatQueryParams)(queryParams);
27
- const response = yield (0, fetchClient_1.fetchClient)(`${constants_1.LO_DCA_API}/order-executions?${paramsStr}`);
28
- if (!response.ok) {
29
- throw new Error("Failed to fetch closed dca orders");
30
- }
31
- const orders = (yield response.json());
32
- return orders;
33
- });
7
+ async function getClosedDcaOrders({ owner, offset = 0, limit = 10, tokenPair, }) {
8
+ const queryParams = {
9
+ owner,
10
+ statuses: ["SUCCESS"],
11
+ offset,
12
+ limit,
13
+ orderType: "DCA",
14
+ tokenPair,
15
+ };
16
+ const paramsStr = (0, url_1.formatQueryParams)(queryParams);
17
+ const response = await (0, fetchClient_1.fetchClient)(`${constants_1.LO_DCA_API}/order-executions?${paramsStr}`);
18
+ if (!response.ok) {
19
+ throw new Error("Failed to fetch closed dca orders");
20
+ }
21
+ const orders = (await response.json());
22
+ return orders;
34
23
  }
@@ -1,33 +1,22 @@
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.getClosedLimitOrders = getClosedLimitOrders;
13
4
  const fetchClient_1 = require("../../config/fetchClient");
14
5
  const url_1 = require("../../libs/url");
15
6
  const constants_1 = require("./constants");
16
- function getClosedLimitOrders(_a) {
17
- return __awaiter(this, arguments, void 0, function* ({ owner, offset = 0, limit = 10, tokenPair, }) {
18
- const queryParams = {
19
- owner,
20
- statuses: ["CLOSED"],
21
- offset,
22
- limit,
23
- tokenPair,
24
- };
25
- const paramsStr = (0, url_1.formatQueryParams)(queryParams);
26
- const response = yield (0, fetchClient_1.fetchClient)(`${constants_1.LO_DCA_API}/limit-orders?${paramsStr}`);
27
- if (!response.ok) {
28
- throw new Error("Failed to fetch closed limit orders");
29
- }
30
- const orders = (yield response.json());
31
- return orders;
32
- });
7
+ async function getClosedLimitOrders({ owner, offset = 0, limit = 10, tokenPair, }) {
8
+ const queryParams = {
9
+ owner,
10
+ statuses: ["CLOSED"],
11
+ offset,
12
+ limit,
13
+ tokenPair,
14
+ };
15
+ const paramsStr = (0, url_1.formatQueryParams)(queryParams);
16
+ const response = await (0, fetchClient_1.fetchClient)(`${constants_1.LO_DCA_API}/limit-orders?${paramsStr}`);
17
+ if (!response.ok) {
18
+ throw new Error("Failed to fetch closed limit orders");
19
+ }
20
+ const orders = (await response.json());
21
+ return orders;
33
22
  }
@@ -1,34 +1,23 @@
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.getDcaOrderExecutions = getDcaOrderExecutions;
13
4
  const fetchClient_1 = require("../../config/fetchClient");
14
5
  const url_1 = require("../../libs/url");
15
6
  const constants_1 = require("./constants");
16
- function getDcaOrderExecutions(_a) {
17
- return __awaiter(this, arguments, void 0, function* ({ owner, orderId, offset = 0, limit = 10, }) {
18
- const queryParams = {
19
- owner,
20
- orderId,
21
- statuses: ["SUCCESS"],
22
- offset,
23
- limit,
24
- orderType: "DCA",
25
- };
26
- const paramsStr = (0, url_1.formatQueryParams)(queryParams);
27
- const response = yield (0, fetchClient_1.fetchClient)(`${constants_1.LO_DCA_API}/order-executions?${paramsStr}`);
28
- if (!response.ok) {
29
- throw new Error("Failed to fetch dca order executions");
30
- }
31
- const orders = (yield response.json());
32
- return orders;
33
- });
7
+ async function getDcaOrderExecutions({ owner, orderId, offset = 0, limit = 10, }) {
8
+ const queryParams = {
9
+ owner,
10
+ orderId,
11
+ statuses: ["SUCCESS"],
12
+ offset,
13
+ limit,
14
+ orderType: "DCA",
15
+ };
16
+ const paramsStr = (0, url_1.formatQueryParams)(queryParams);
17
+ const response = await (0, fetchClient_1.fetchClient)(`${constants_1.LO_DCA_API}/order-executions?${paramsStr}`);
18
+ if (!response.ok) {
19
+ throw new Error("Failed to fetch dca order executions");
20
+ }
21
+ const orders = (await response.json());
22
+ return orders;
34
23
  }
@@ -1,33 +1,22 @@
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.getOpenDcaOrders = getOpenDcaOrders;
13
4
  const fetchClient_1 = require("../../config/fetchClient");
14
5
  const url_1 = require("../../libs/url");
15
6
  const constants_1 = require("./constants");
16
- function getOpenDcaOrders(_a) {
17
- return __awaiter(this, arguments, void 0, function* ({ owner, offset = 0, limit = 10, tokenPair, }) {
18
- const queryParams = {
19
- owner,
20
- statuses: ["ACTIVE", "EXPIRED"],
21
- offset,
22
- limit,
23
- tokenPair,
24
- };
25
- const paramsStr = (0, url_1.formatQueryParams)(queryParams);
26
- const response = yield (0, fetchClient_1.fetchClient)(`${constants_1.LO_DCA_API}/dca-orders?${paramsStr}`);
27
- if (!response.ok) {
28
- throw new Error("Failed to fetch open dca orders");
29
- }
30
- const orders = (yield response.json());
31
- return orders;
32
- });
7
+ async function getOpenDcaOrders({ owner, offset = 0, limit = 10, tokenPair, }) {
8
+ const queryParams = {
9
+ owner,
10
+ statuses: ["ACTIVE", "EXPIRED"],
11
+ offset,
12
+ limit,
13
+ tokenPair,
14
+ };
15
+ const paramsStr = (0, url_1.formatQueryParams)(queryParams);
16
+ const response = await (0, fetchClient_1.fetchClient)(`${constants_1.LO_DCA_API}/dca-orders?${paramsStr}`);
17
+ if (!response.ok) {
18
+ throw new Error("Failed to fetch open dca orders");
19
+ }
20
+ const orders = (await response.json());
21
+ return orders;
33
22
  }
@@ -1,33 +1,22 @@
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.getOpenLimitOrders = getOpenLimitOrders;
13
4
  const fetchClient_1 = require("../../config/fetchClient");
14
5
  const url_1 = require("../../libs/url");
15
6
  const constants_1 = require("./constants");
16
- function getOpenLimitOrders(_a) {
17
- return __awaiter(this, arguments, void 0, function* ({ owner, offset = 0, limit = 10, tokenPair, }) {
18
- const queryParams = {
19
- owner,
20
- statuses: ["ACTIVE", "EXPIRED"],
21
- offset,
22
- limit,
23
- tokenPair,
24
- };
25
- const paramsStr = (0, url_1.formatQueryParams)(queryParams);
26
- const response = yield (0, fetchClient_1.fetchClient)(`${constants_1.LO_DCA_API}/limit-orders?${paramsStr}`);
27
- if (!response.ok) {
28
- throw new Error("Failed to fetch open limit orders");
29
- }
30
- const orders = (yield response.json());
31
- return orders;
32
- });
7
+ async function getOpenLimitOrders({ owner, offset = 0, limit = 10, tokenPair, }) {
8
+ const queryParams = {
9
+ owner,
10
+ statuses: ["ACTIVE", "EXPIRED"],
11
+ offset,
12
+ limit,
13
+ tokenPair,
14
+ };
15
+ const paramsStr = (0, url_1.formatQueryParams)(queryParams);
16
+ const response = await (0, fetchClient_1.fetchClient)(`${constants_1.LO_DCA_API}/limit-orders?${paramsStr}`);
17
+ if (!response.ok) {
18
+ throw new Error("Failed to fetch open limit orders");
19
+ }
20
+ const orders = (await response.json());
21
+ return orders;
33
22
  }
@@ -1,44 +1,33 @@
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.placeDcaOrder = placeDcaOrder;
13
4
  const constants_1 = require("./constants");
14
5
  const transactions_1 = require("@mysten/sui/transactions");
15
- function placeDcaOrder(_a) {
16
- return __awaiter(this, arguments, void 0, function* ({ payCoinType, targetCoinType, payCoinAmountEach, numOrders, interval, slippage, minRate, maxRate, }) {
17
- const tx = new transactions_1.Transaction();
18
- const coinElements = [];
19
- for (let i = 0; i < numOrders; i++) {
20
- const coin = (0, transactions_1.coinWithBalance)({
21
- type: payCoinType,
22
- balance: payCoinAmountEach,
23
- });
24
- coinElements.push(coin);
25
- }
26
- const vectorCoin = tx.makeMoveVec({
27
- elements: coinElements,
28
- });
29
- tx.moveCall({
30
- target: `${constants_1.DCA_ORDER_MODULE_ID}::place_dca_order`,
31
- arguments: [
32
- tx.object(constants_1.GLOBAL_CONFIG_ID),
33
- vectorCoin,
34
- tx.pure.u64(interval),
35
- tx.pure.u64(slippage),
36
- tx.pure.u64(minRate),
37
- tx.pure.u64(maxRate),
38
- tx.object.clock(),
39
- ],
40
- typeArguments: [payCoinType, targetCoinType],
6
+ async function placeDcaOrder({ payCoinType, targetCoinType, payCoinAmountEach, numOrders, interval, slippage, minRate, maxRate, }) {
7
+ const tx = new transactions_1.Transaction();
8
+ const coinElements = [];
9
+ for (let i = 0; i < numOrders; i++) {
10
+ const coin = (0, transactions_1.coinWithBalance)({
11
+ type: payCoinType,
12
+ balance: payCoinAmountEach,
41
13
  });
42
- return tx;
14
+ coinElements.push(coin);
15
+ }
16
+ const vectorCoin = tx.makeMoveVec({
17
+ elements: coinElements,
18
+ });
19
+ tx.moveCall({
20
+ target: `${constants_1.DCA_ORDER_MODULE_ID}::place_dca_order`,
21
+ arguments: [
22
+ tx.object(constants_1.GLOBAL_CONFIG_ID),
23
+ vectorCoin,
24
+ tx.pure.u64(interval),
25
+ tx.pure.u64(slippage),
26
+ tx.pure.u64(minRate),
27
+ tx.pure.u64(maxRate),
28
+ tx.object.clock(),
29
+ ],
30
+ typeArguments: [payCoinType, targetCoinType],
43
31
  });
32
+ return tx;
44
33
  }