@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,26 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./placeLimitOrder"), exports);
18
- __exportStar(require("./cancelLimitOrder"), exports);
19
- __exportStar(require("./claimExpiredLimitOrder"), exports);
20
- __exportStar(require("./getOpenLimitOrders"), exports);
21
- __exportStar(require("./getClosedLimitOrders"), exports);
22
- __exportStar(require("./placeDcaOrder"), exports);
23
- __exportStar(require("./cancelDcaOrder"), exports);
24
- __exportStar(require("./getOpenDcaOrders"), exports);
25
- __exportStar(require("./getClosedDcaOrders"), exports);
26
- __exportStar(require("./getDcaOrderExecutions"), exports);
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.placeDcaOrder = placeDcaOrder;
4
- const constants_1 = require("./constants");
5
- const transactions_1 = require("@mysten/sui/transactions");
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,
13
- });
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],
31
- });
32
- return tx;
33
- }
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.placeLimitOrder = placeLimitOrder;
4
- const transactions_1 = require("@mysten/sui/transactions");
5
- const constants_1 = require("./constants");
6
- async function placeLimitOrder({ accountAddress, payCoinType, targetCoinType, payCoinAmount, rate, slippage, expireTs, devInspect, }) {
7
- const tx = new transactions_1.Transaction();
8
- const payCoin = tx.add((0, transactions_1.coinWithBalance)({
9
- type: payCoinType,
10
- balance: payCoinAmount,
11
- useGasCoin: !devInspect,
12
- }));
13
- tx.moveCall({
14
- target: `${constants_1.LIMIT_ORDER_MODULE_ID}::place_limit_order`,
15
- arguments: [
16
- tx.object(constants_1.GLOBAL_CONFIG_ID),
17
- payCoin,
18
- tx.pure.u64(rate),
19
- tx.pure.u64(slippage),
20
- tx.pure.u64(expireTs),
21
- tx.object.clock(),
22
- ],
23
- typeArguments: [payCoinType, targetCoinType],
24
- });
25
- tx.setSenderIfNotSet(accountAddress);
26
- return tx;
27
- }
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LoDcaOrderExecutionStatus = exports.LoDcaOrderStatus = void 0;
4
- var LoDcaOrderStatus;
5
- (function (LoDcaOrderStatus) {
6
- LoDcaOrderStatus["PENDING"] = "PENDING";
7
- LoDcaOrderStatus["ACTIVE"] = "ACTIVE";
8
- LoDcaOrderStatus["EXPIRED"] = "EXPIRED";
9
- LoDcaOrderStatus["CANCELED"] = "CANCELED";
10
- })(LoDcaOrderStatus || (exports.LoDcaOrderStatus = LoDcaOrderStatus = {}));
11
- var LoDcaOrderExecutionStatus;
12
- (function (LoDcaOrderExecutionStatus) {
13
- LoDcaOrderExecutionStatus["PENDING"] = "PENDING";
14
- LoDcaOrderExecutionStatus["SUCCESS"] = "SUCCESS";
15
- LoDcaOrderExecutionStatus["FAILED"] = "FAILED";
16
- })(LoDcaOrderExecutionStatus || (exports.LoDcaOrderExecutionStatus = LoDcaOrderExecutionStatus = {}));
@@ -1,103 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.timeout = exports.metaSettle = exports.simulateAggregator = exports.simulateSwapTx = void 0;
4
- const transactions_1 = require("@mysten/sui/transactions");
5
- const _7k_1 = require("../../constants/_7k");
6
- const swap_1 = require("../../utils/swap");
7
- const error_1 = require("./error");
8
- const simulateSwapTx = async (tx, inspector, simulation) => {
9
- const res = await (0, exports.timeout)(() => inspector.devInspectTransactionBlock({
10
- sender: simulation.sender,
11
- transactionBlock: tx,
12
- }), simulation.timeout ?? 2000);
13
- if (res.effects.status.status === "failure") {
14
- throw new error_1.MetaAgError(res.error ?? "Simulation failed", error_1.MetaAgErrorCode.SIMULATION_FAILED, { error: res.error });
15
- }
16
- const amountOut = extractAmountOutWrapper(res.events);
17
- return {
18
- simulatedAmountOut: amountOut,
19
- gasUsed: res.effects.gasUsed,
20
- };
21
- };
22
- exports.simulateSwapTx = simulateSwapTx;
23
- const simulateAggregator = async (provider, quote, simulation, inspector, options) => {
24
- const tx = new transactions_1.Transaction();
25
- const coinOut = await provider.swap({
26
- quote,
27
- coinIn: (0, transactions_1.coinWithBalance)({
28
- balance: BigInt(quote.amountIn),
29
- type: quote.coinTypeIn,
30
- useGasCoin: false,
31
- }),
32
- signer: simulation.sender,
33
- tx,
34
- });
35
- tx.add((0, exports.metaSettle)(quote, coinOut, 10000, options.tipBps, options.partner, options.partnerCommissionBps));
36
- tx.transferObjects([coinOut], simulation.sender);
37
- const res = await (0, exports.simulateSwapTx)(tx, inspector, simulation);
38
- return {
39
- id: quote.id,
40
- provider: provider.kind,
41
- ...res,
42
- };
43
- };
44
- exports.simulateAggregator = simulateAggregator;
45
- /**
46
- * this settlement does not charge commission fee for partner, since all integrated aggregators already charge commission fee for partner
47
- * @param quote Meta Aggregator Quote
48
- * @param coinOut Coin Out Object
49
- * @param slippageBps Slippage Bps
50
- * @param tipBps Tip Bps default = 0
51
- * @param partner address of partner for analytic default is zero address
52
- */
53
- const metaSettle = (quote, coinOut, slippageBps = 100, tipBps = 0, partner, commissionBps = 0) => {
54
- return (tx) => {
55
- const { minAmount, expectedAmount } = (0, swap_1.getExpectedReturn)(quote.rawAmountOut, slippageBps, commissionBps, tipBps);
56
- if (tipBps > 0) {
57
- tx.moveCall({
58
- target: `${_7k_1._7K_META_PUBLISHED_AT}::vault::collect_tip`,
59
- typeArguments: [quote.coinTypeOut],
60
- arguments: [
61
- tx.object(_7k_1._7K_META_VAULT),
62
- tx.object(_7k_1._7K_META_CONFIG),
63
- coinOut,
64
- tx.pure.u64(tipBps),
65
- ],
66
- });
67
- }
68
- tx.moveCall({
69
- target: `${_7k_1._7K_META_PUBLISHED_AT}::settle::settle`,
70
- typeArguments: [quote.coinTypeIn, quote.coinTypeOut],
71
- arguments: [
72
- tx.object(_7k_1._7K_META_CONFIG),
73
- tx.object(_7k_1._7K_META_VAULT),
74
- tx.pure.u64(quote.amountIn),
75
- coinOut,
76
- tx.pure.u64(minAmount),
77
- tx.pure.u64(expectedAmount),
78
- tx.pure.option("address", partner),
79
- tx.pure.u64(commissionBps),
80
- tx.pure.u64(0), // ps
81
- ],
82
- });
83
- };
84
- };
85
- exports.metaSettle = metaSettle;
86
- const extractAmountOutWrapper = (events) => {
87
- const swapEvent = events
88
- .filter((event) => event.type === `${_7k_1._7K_META_PACKAGE_ID}::settle::Swap`)
89
- ?.pop();
90
- return swapEvent?.parsedJson?.amount_out;
91
- };
92
- const timeout = async (fn, timeout, msg) => {
93
- if (timeout <= 0)
94
- return fn();
95
- return new Promise((resolve, reject) => {
96
- const timer = setTimeout(() => reject(new error_1.MetaAgError(`Timeout ${msg ?? "operation"}`, error_1.MetaAgErrorCode.TIMEOUT, { timeout })), timeout);
97
- fn()
98
- .then(resolve)
99
- .catch(reject)
100
- .finally(() => clearTimeout(timer));
101
- });
102
- };
103
- exports.timeout = timeout;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MetaAgError = exports.MetaAgErrorCode = void 0;
4
- var MetaAgErrorCode;
5
- (function (MetaAgErrorCode) {
6
- MetaAgErrorCode[MetaAgErrorCode["UNKNOWN"] = 1000] = "UNKNOWN";
7
- MetaAgErrorCode[MetaAgErrorCode["TIMEOUT"] = 1001] = "TIMEOUT";
8
- MetaAgErrorCode[MetaAgErrorCode["PROVIDER_NOT_FOUND"] = 1002] = "PROVIDER_NOT_FOUND";
9
- MetaAgErrorCode[MetaAgErrorCode["PROVIDER_NOT_SUPPORTED"] = 1003] = "PROVIDER_NOT_SUPPORTED";
10
- MetaAgErrorCode[MetaAgErrorCode["INVALID_QUOTE"] = 1004] = "INVALID_QUOTE";
11
- MetaAgErrorCode[MetaAgErrorCode["QUOTE_NOT_FOUND"] = 1005] = "QUOTE_NOT_FOUND";
12
- MetaAgErrorCode[MetaAgErrorCode["INVALID_SIGNER_ADDRESS"] = 1006] = "INVALID_SIGNER_ADDRESS";
13
- MetaAgErrorCode[MetaAgErrorCode["PROVIDER_NOT_SUPPORT_SWAP"] = 1007] = "PROVIDER_NOT_SUPPORT_SWAP";
14
- MetaAgErrorCode[MetaAgErrorCode["SIMULATION_FAILED"] = 1008] = "SIMULATION_FAILED";
15
- // OKX error
16
- MetaAgErrorCode[MetaAgErrorCode["OKX_FINALIZE_COMMAND_NOT_FOUND"] = 1100] = "OKX_FINALIZE_COMMAND_NOT_FOUND";
17
- })(MetaAgErrorCode || (exports.MetaAgErrorCode = MetaAgErrorCode = {}));
18
- class MetaAgError extends Error {
19
- constructor(message, code, details) {
20
- super(message);
21
- this.name = "MetaAgError";
22
- this.code = code ?? MetaAgErrorCode.UNKNOWN;
23
- this.details = details;
24
- }
25
- static assert(condition, message, code, details) {
26
- if (!condition) {
27
- throw new MetaAgError(message ?? "Assertion failed", code, details);
28
- }
29
- }
30
- }
31
- exports.MetaAgError = MetaAgError;
@@ -1,268 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.MetaAg = void 0;
37
- const client_1 = require("@mysten/sui/client");
38
- const transactions_1 = require("@mysten/sui/transactions");
39
- const utils_1 = require("@mysten/sui/utils");
40
- const sui_1 = require("../../constants/sui");
41
- const metaAg_1 = require("../../types/metaAg");
42
- const sui_2 = require("../../utils/sui");
43
- const SuiClientUtils_1 = require("../../utils/SuiClientUtils");
44
- const swap_1 = require("../../utils/swap");
45
- const common_1 = require("./common");
46
- const error_1 = require("./error");
47
- const okx_1 = require("./providers/okx");
48
- const HERMES_API = "https://hermes.pyth.network";
49
- const DEFAULT_PROVIDERS = {
50
- [metaAg_1.EProvider.BLUEFIN7K]: {},
51
- [metaAg_1.EProvider.FLOWX]: {},
52
- [metaAg_1.EProvider.CETUS]: {},
53
- };
54
- class MetaAg {
55
- constructor(options) {
56
- this.providers = {};
57
- this.options = {
58
- providers: { ...DEFAULT_PROVIDERS, ...options?.providers },
59
- slippageBps: options?.slippageBps ?? 100,
60
- fullnodeUrl: options?.fullnodeUrl ?? (0, client_1.getFullnodeUrl)("mainnet"),
61
- hermesApi: options?.hermesApi ?? HERMES_API,
62
- partner: options?.partner ?? sui_1.SUI_ADDRESS_ZERO,
63
- partnerCommissionBps: options?.partnerCommissionBps ?? 0,
64
- tipBps: options?.tipBps ?? 0,
65
- };
66
- this.client = new client_1.SuiClient({
67
- url: this.options.fullnodeUrl,
68
- });
69
- this.inspector = new SuiClientUtils_1.SuiClientUtils(this.client);
70
- }
71
- async _getProvider(provider) {
72
- const p = this.providers[provider];
73
- if (p)
74
- return p;
75
- const providerOptions = this.options.providers[provider];
76
- error_1.MetaAgError.assert(!!providerOptions, `Provider not found: ${provider}`, error_1.MetaAgErrorCode.PROVIDER_NOT_FOUND, { provider });
77
- switch (provider) {
78
- case metaAg_1.EProvider.BLUEFIN7K:
79
- const { Bluefin7kProvider } = await Promise.resolve().then(() => __importStar(require("./providers/bluefin7k"))).catch(catchImportError(metaAg_1.EProvider.BLUEFIN7K));
80
- this.providers[metaAg_1.EProvider.BLUEFIN7K] = new Bluefin7kProvider(providerOptions, this.options, this.client);
81
- break;
82
- case metaAg_1.EProvider.FLOWX:
83
- const { FlowxProvider } = await Promise.resolve().then(() => __importStar(require("./providers/flowx"))).catch(catchImportError(metaAg_1.EProvider.FLOWX));
84
- this.providers[metaAg_1.EProvider.FLOWX] = new FlowxProvider(providerOptions, this.client);
85
- break;
86
- case metaAg_1.EProvider.CETUS:
87
- const { CetusProvider } = await Promise.resolve().then(() => __importStar(require("./providers/cetus"))).catch(catchImportError(metaAg_1.EProvider.CETUS));
88
- this.providers[metaAg_1.EProvider.CETUS] = new CetusProvider(providerOptions, this.options, this.client);
89
- break;
90
- case metaAg_1.EProvider.OKX:
91
- this.providers[metaAg_1.EProvider.OKX] = new okx_1.OkxProvider(providerOptions, this.options, this.client);
92
- break;
93
- default:
94
- throw new error_1.MetaAgError(`Provider not supported: ${provider}`, error_1.MetaAgErrorCode.PROVIDER_NOT_SUPPORTED, { provider });
95
- }
96
- return this.providers[provider];
97
- }
98
- async _simulate(provider, quote, simulation) {
99
- try {
100
- if ((0, metaAg_1.isAggregatorProvider)(provider)) {
101
- return (0, common_1.simulateAggregator)(provider, quote, simulation, this.inspector, this.options);
102
- }
103
- switch (quote.provider) {
104
- case metaAg_1.EProvider.OKX:
105
- return (0, okx_1.simulateOKXSwap)(quote, this.inspector, simulation, this.options);
106
- default:
107
- throw new error_1.MetaAgError(`Provider not supported: ${provider.kind}`, error_1.MetaAgErrorCode.PROVIDER_NOT_SUPPORTED, { provider: provider.kind });
108
- }
109
- }
110
- catch (error) {
111
- console.warn(error, { provider: provider.kind, quote: quote.id });
112
- }
113
- }
114
- async _quote(provider, options) {
115
- const quote = await (0, common_1.timeout)(async () => {
116
- const quote = await provider.quote(options);
117
- if (!quote)
118
- return null;
119
- const { expectedAmount } = (0, swap_1.getExpectedReturn)(quote.rawAmountOut, 0, this.options.partnerCommissionBps, this.options.tipBps);
120
- quote.amountOut = expectedAmount;
121
- return quote;
122
- }, options.timeout ?? 2000, `quote for ${provider.kind} provider from ${options.coinTypeIn} to ${options.coinTypeOut}`);
123
- return quote;
124
- }
125
- async _fastSwap({ quote, signer, useGasCoin, signTransaction }, getTransactionBlockParams) {
126
- const tx = new transactions_1.Transaction();
127
- const coin = await this.swap({
128
- quote,
129
- signer,
130
- tx,
131
- coinIn: (0, transactions_1.coinWithBalance)({
132
- type: quote.coinTypeIn,
133
- balance: BigInt(quote.amountIn),
134
- useGasCoin,
135
- }),
136
- });
137
- tx.transferObjects([coin], signer);
138
- tx.setSenderIfNotSet(signer);
139
- const txBytes = await tx.build({ client: this.client });
140
- const { signature, bytes } = await signTransaction((0, utils_1.toBase64)(txBytes));
141
- return this.client.executeTransactionBlock({
142
- transactionBlock: bytes,
143
- signature,
144
- options: getTransactionBlockParams?.options,
145
- signal: getTransactionBlockParams?.signal,
146
- });
147
- }
148
- /**
149
- * Get quotes from all providers
150
- * @param options - quote options
151
- * @param simulation - if present, the quote will be simulated
152
- * @returns quotes from all providers
153
- */
154
- async quote(options, simulation) {
155
- const opts = {
156
- ...options,
157
- coinTypeIn: (0, utils_1.normalizeStructTag)(options.coinTypeIn),
158
- coinTypeOut: (0, utils_1.normalizeStructTag)(options.coinTypeOut),
159
- };
160
- const quotes = await Promise.allSettled(Object.entries(this.options.providers)
161
- .filter(([_k, v]) => !v.disabled)
162
- .map(async ([provider]) => {
163
- const p = await this._getProvider(provider);
164
- return this._quote(p, opts);
165
- }));
166
- const result = quotes
167
- .map((quote) => quote.status === "fulfilled"
168
- ? quote.value
169
- : (console.log(quote.reason), null))
170
- .filter((quote) => quote !== null);
171
- if (simulation) {
172
- const requests = result.map(async (quote) => {
173
- const provider = await this._getProvider(quote.provider);
174
- const updated = await this._simulate(provider, quote, simulation);
175
- quote.simulatedAmountOut = updated?.simulatedAmountOut;
176
- quote.gasUsed = updated?.gasUsed;
177
- simulation?.onSimulated?.({ ...quote });
178
- });
179
- if (!simulation.onSimulated) {
180
- await Promise.all(requests);
181
- }
182
- }
183
- return result;
184
- }
185
- /**
186
- * Build transaction from quote
187
- * @info Use this function to build composable transaction (ie: add more commands after the swap, consume the coin out object)
188
- * @warning Providers that build transaction on the fly (typically RFQ, Swap-API providers ie: Okx, ...) are not supported, please use `fastSwap` instead
189
- * @param options - build tx options
190
- * @param slippageBps - slippage bps if not specified, fallback to global slippage bps, if none of them specified, default to 100
191
- * @returns coin out object, you must consume it by transferObjects, or other sub sequence commands
192
- */
193
- async swap(options, slippageBps) {
194
- const provider = await this._getProvider(options.quote.provider);
195
- error_1.MetaAgError.assert(!!provider, `Provider not found: ${options.quote.provider}`, error_1.MetaAgErrorCode.PROVIDER_NOT_FOUND, { provider: options.quote.provider });
196
- error_1.MetaAgError.assert((0, metaAg_1.isAggregatorProvider)(provider), `Provider does not support swap: ${provider.kind}, use fastSwap instead`, error_1.MetaAgErrorCode.PROVIDER_NOT_SUPPORT_SWAP, { provider: provider.kind });
197
- error_1.MetaAgError.assert(!(0, sui_2.isSystemAddress)(options.signer), "Invalid signer address", error_1.MetaAgErrorCode.INVALID_SIGNER_ADDRESS, { signer: options.signer });
198
- const coinOut = await provider.swap(options);
199
- options.tx.add((0, common_1.metaSettle)(options.quote, coinOut, slippageBps ?? this.options.slippageBps ?? 100, this.options.tipBps, this.options.partner, this.options.partnerCommissionBps));
200
- options.tx.setSenderIfNotSet(options.signer);
201
- return coinOut;
202
- }
203
- /**
204
- * Build, Sign, and Execute transaction in one step
205
- * @param options - fast swap options
206
- * @returns - txDigest of the transaction
207
- */
208
- async fastSwap(options, getTransactionBlockParams) {
209
- error_1.MetaAgError.assert(!(0, sui_2.isSystemAddress)(options.signer), "Invalid signer address", error_1.MetaAgErrorCode.INVALID_SIGNER_ADDRESS, { signer: options.signer });
210
- const provider = await this._getProvider(options.quote.provider);
211
- if ((0, metaAg_1.isAggregatorProvider)(provider)) {
212
- return this._fastSwap(options, getTransactionBlockParams);
213
- }
214
- else if ((0, metaAg_1.isSwapAPIProvider)(provider)) {
215
- return this.client.waitForTransaction({
216
- ...getTransactionBlockParams,
217
- digest: await provider.fastSwap(options),
218
- });
219
- }
220
- else {
221
- throw new error_1.MetaAgError(`Provider not supported: ${provider.kind}`, error_1.MetaAgErrorCode.PROVIDER_NOT_SUPPORTED, { provider: provider.kind });
222
- }
223
- }
224
- /**
225
- * Update meta aggregator options
226
- * @param options - update options payload
227
- */
228
- updateMetaAgOptions(options) {
229
- if (Object.keys(options).length === 0)
230
- return;
231
- this.options.slippageBps = options.slippageBps ?? this.options.slippageBps;
232
- this.options.partner = options.partner ?? this.options.partner;
233
- this.options.partnerCommissionBps =
234
- options.partnerCommissionBps ?? this.options.partnerCommissionBps;
235
- this.options.tipBps = options.tipBps ?? this.options.tipBps;
236
- if (options.fullnodeUrl &&
237
- options.fullnodeUrl !== this.options.fullnodeUrl) {
238
- this.client = new client_1.SuiClient({ url: options.fullnodeUrl });
239
- this.inspector = new SuiClientUtils_1.SuiClientUtils(this.client);
240
- this.options.fullnodeUrl = options.fullnodeUrl;
241
- }
242
- if (options.hermesApi && options.hermesApi !== this.options.hermesApi) {
243
- this.providers = {};
244
- this.options.hermesApi = options.hermesApi;
245
- }
246
- // if update provider's options, we need to re-initialize the provider
247
- for (const [provider, opt] of Object.entries(options.providers || {})) {
248
- this.options.providers[provider] = {
249
- ...opt,
250
- ...this.options.providers[provider],
251
- };
252
- delete this.providers[provider];
253
- }
254
- }
255
- }
256
- exports.MetaAg = MetaAg;
257
- const catchImportError = (provider) => {
258
- return (e) => {
259
- const map = {
260
- [metaAg_1.EProvider.CETUS]: "@cetusprotocol/aggregator-sdk",
261
- [metaAg_1.EProvider.FLOWX]: "@flowx-finance/sdk",
262
- [metaAg_1.EProvider.BLUEFIN7K]: "@bluefin-exchange/bluefin7k-aggregator-sdk",
263
- [metaAg_1.EProvider.OKX]: "",
264
- };
265
- console.warn(`Please install ${map[provider]} to use ${provider} provider`);
266
- throw e;
267
- };
268
- };
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Bluefin7kProvider = void 0;
4
- const bluefin7k_aggregator_sdk_1 = require("@bluefin-exchange/bluefin7k-aggregator-sdk");
5
- const uuid_1 = require("uuid");
6
- const _7k_1 = require("../../../constants/_7k");
7
- const metaAg_1 = require("../../../types/metaAg");
8
- const error_1 = require("../error");
9
- class Bluefin7kProvider {
10
- constructor(options, metaOptions, client) {
11
- this.options = options;
12
- this.metaOptions = metaOptions;
13
- this.kind = metaAg_1.EProvider.BLUEFIN7K;
14
- if (options.apiKey)
15
- bluefin7k_aggregator_sdk_1.Config.setApiKey(options.apiKey);
16
- bluefin7k_aggregator_sdk_1.Config.setSuiClient(client);
17
- }
18
- async quote(quoteOptions) {
19
- const quote = await (0, bluefin7k_aggregator_sdk_1.getQuote)({
20
- tokenIn: quoteOptions.coinTypeIn,
21
- tokenOut: quoteOptions.coinTypeOut,
22
- amountIn: quoteOptions.amountIn,
23
- sources: this.options.sources,
24
- excludedPools: this.options.excludedPools,
25
- targetPools: this.options.targetPools,
26
- });
27
- error_1.MetaAgError.assert(!!quote, "No quote found", error_1.MetaAgErrorCode.QUOTE_NOT_FOUND, { provider: this.kind });
28
- return {
29
- id: (0, uuid_1.v4)(),
30
- provider: metaAg_1.EProvider.BLUEFIN7K,
31
- quote,
32
- amountIn: quote.swapAmountWithDecimal,
33
- rawAmountOut: quote.returnAmountWithDecimal,
34
- amountOut: quote.returnAmountWithDecimal,
35
- coinTypeIn: quoteOptions.coinTypeIn,
36
- coinTypeOut: quoteOptions.coinTypeOut,
37
- };
38
- }
39
- async swap({ quote, signer, tx, coinIn }) {
40
- error_1.MetaAgError.assert(quote.provider === metaAg_1.EProvider.BLUEFIN7K, "Invalid quote", error_1.MetaAgErrorCode.INVALID_QUOTE, { quote, expectedProvider: metaAg_1.EProvider.BLUEFIN7K });
41
- const { coinOut } = await (0, bluefin7k_aggregator_sdk_1.buildTx)({
42
- quoteResponse: quote.quote,
43
- accountAddress: signer,
44
- commission: {
45
- commissionBps: 0,
46
- partner: _7k_1._7K_PARTNER_ADDRESS,
47
- },
48
- slippage: 1,
49
- extendTx: {
50
- tx,
51
- coinIn,
52
- },
53
- });
54
- return coinOut;
55
- }
56
- }
57
- exports.Bluefin7kProvider = Bluefin7kProvider;
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CetusProvider = void 0;
4
- const aggregator_sdk_1 = require("@cetusprotocol/aggregator-sdk");
5
- const uuid_1 = require("uuid");
6
- const _7k_1 = require("../../../constants/_7k");
7
- const metaAg_1 = require("../../../types/metaAg");
8
- const error_1 = require("../error");
9
- class CetusProvider {
10
- constructor(options, metaOptions, client) {
11
- this.options = options;
12
- this.kind = metaAg_1.EProvider.CETUS;
13
- this.cetusClient = new aggregator_sdk_1.AggregatorClient({
14
- apiKey: options.apiKey,
15
- client,
16
- endpoint: options.api,
17
- env: aggregator_sdk_1.Env.Mainnet,
18
- pythUrls: metaOptions.hermesApi ? [metaOptions.hermesApi] : [],
19
- overlayFeeRate: 0,
20
- overlayFeeReceiver: _7k_1._7K_PARTNER_ADDRESS,
21
- });
22
- }
23
- async quote(quoteOptions) {
24
- const quote = await this.cetusClient.findRouters({
25
- amount: quoteOptions.amountIn,
26
- byAmountIn: true,
27
- from: quoteOptions.coinTypeIn,
28
- target: quoteOptions.coinTypeOut,
29
- providers: this.options.sources,
30
- splitCount: this.options.splitCount,
31
- splitAlgorithm: this.options.splitAlgorithm,
32
- splitFactor: this.options.splitFactor,
33
- depth: this.options.depth,
34
- liquidityChanges: this.options.liquidityChanges,
35
- });
36
- error_1.MetaAgError.assert(!!quote, "No quote found", error_1.MetaAgErrorCode.QUOTE_NOT_FOUND, { provider: this.kind });
37
- return {
38
- id: (0, uuid_1.v4)(),
39
- provider: metaAg_1.EProvider.CETUS,
40
- quote,
41
- amountIn: quote.amountIn.toString() || "0",
42
- rawAmountOut: quote.amountOut.toString() || "0",
43
- amountOut: quote.amountOut.toString() || "0",
44
- coinTypeIn: quoteOptions.coinTypeIn,
45
- coinTypeOut: quoteOptions.coinTypeOut,
46
- };
47
- }
48
- async swap(options) {
49
- error_1.MetaAgError.assert(options.quote.provider === metaAg_1.EProvider.CETUS, "Expect Cetus quote", error_1.MetaAgErrorCode.INVALID_QUOTE, { quote: options.quote, expectedProvider: metaAg_1.EProvider.CETUS });
50
- const coinOut = await this.cetusClient.routerSwap({
51
- inputCoin: options.coinIn,
52
- router: options.quote.quote,
53
- slippage: 1,
54
- txb: options.tx,
55
- });
56
- return coinOut;
57
- }
58
- }
59
- exports.CetusProvider = CetusProvider;