@7kprotocol/sdk-ts 3.5.4 → 3.6.1-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 (379) hide show
  1. package/README.md +1 -11
  2. package/lib/cjs/config/fetchClient.js +1 -9
  3. package/lib/cjs/constants/_7k.js +13 -10
  4. package/lib/cjs/constants/apiEndpoints.js +1 -1
  5. package/lib/cjs/features/metaAg/common.js +103 -0
  6. package/lib/cjs/features/metaAg/error.js +31 -0
  7. package/lib/cjs/features/metaAg/index.js +96 -117
  8. package/lib/cjs/features/metaAg/providers/bluefin7k.js +57 -0
  9. package/lib/cjs/features/metaAg/providers/cetus.js +7 -7
  10. package/lib/cjs/features/metaAg/providers/flowx.js +6 -6
  11. package/lib/cjs/features/metaAg/providers/okx.js +182 -0
  12. package/lib/cjs/features/prices/index.js +51 -20
  13. package/lib/cjs/index.js +1 -35
  14. package/lib/cjs/types/config/fetchClient.d.ts.map +1 -1
  15. package/lib/cjs/types/constants/_7k.d.ts +0 -3
  16. package/lib/cjs/types/constants/_7k.d.ts.map +1 -1
  17. package/lib/cjs/types/features/metaAg/common.d.ts +24 -0
  18. package/lib/cjs/types/features/metaAg/common.d.ts.map +1 -0
  19. package/lib/cjs/types/features/metaAg/error.d.ts +54 -0
  20. package/lib/cjs/types/features/metaAg/error.d.ts.map +1 -0
  21. package/lib/cjs/types/features/metaAg/index.d.ts +11 -2
  22. package/lib/cjs/types/features/metaAg/index.d.ts.map +1 -1
  23. package/lib/cjs/types/features/metaAg/providers/bluefin7k.d.ts +11 -0
  24. package/lib/cjs/types/features/metaAg/providers/bluefin7k.d.ts.map +1 -0
  25. package/lib/cjs/types/features/metaAg/providers/cetus.d.ts +4 -5
  26. package/lib/cjs/types/features/metaAg/providers/cetus.d.ts.map +1 -1
  27. package/lib/cjs/types/features/metaAg/providers/flowx.d.ts +3 -3
  28. package/lib/cjs/types/features/metaAg/providers/flowx.d.ts.map +1 -1
  29. package/lib/cjs/types/features/metaAg/providers/okx.d.ts +21 -0
  30. package/lib/cjs/types/features/metaAg/providers/okx.d.ts.map +1 -0
  31. package/lib/cjs/types/features/prices/index.d.ts +16 -2
  32. package/lib/cjs/types/features/prices/index.d.ts.map +1 -1
  33. package/lib/cjs/types/index.d.ts +1 -30
  34. package/lib/cjs/types/index.d.ts.map +1 -1
  35. package/lib/cjs/types/metaAg.js +8 -4
  36. package/lib/cjs/types/okx.js +6 -0
  37. package/lib/cjs/types/types/metaAg.d.ts +50 -12
  38. package/lib/cjs/types/types/metaAg.d.ts.map +1 -1
  39. package/lib/cjs/types/types/okx.d.ts +206 -0
  40. package/lib/cjs/types/types/okx.d.ts.map +1 -0
  41. package/lib/cjs/types/utils/sui.d.ts +1 -31
  42. package/lib/cjs/types/utils/sui.d.ts.map +1 -1
  43. package/lib/cjs/types/utils/swap.d.ts +15 -0
  44. package/lib/cjs/types/utils/swap.d.ts.map +1 -0
  45. package/lib/cjs/utils/sui.js +19 -146
  46. package/lib/cjs/utils/swap.js +37 -0
  47. package/lib/esm/config/fetchClient.js +1 -9
  48. package/lib/esm/constants/_7k.js +12 -9
  49. package/lib/esm/constants/apiEndpoints.js +1 -1
  50. package/lib/esm/features/metaAg/common.js +96 -0
  51. package/lib/esm/features/metaAg/error.js +29 -0
  52. package/lib/esm/features/metaAg/index.js +96 -117
  53. package/lib/esm/features/metaAg/providers/{bluefin.js → bluefin7k.js} +12 -23
  54. package/lib/esm/features/metaAg/providers/cetus.js +7 -7
  55. package/lib/esm/features/metaAg/providers/flowx.js +6 -6
  56. package/lib/esm/features/metaAg/providers/okx.js +147 -0
  57. package/lib/esm/features/prices/index.js +52 -21
  58. package/lib/esm/index.mjs +3 -31
  59. package/lib/esm/types/config/fetchClient.d.ts.map +1 -1
  60. package/lib/esm/types/constants/_7k.d.ts +0 -3
  61. package/lib/esm/types/constants/_7k.d.ts.map +1 -1
  62. package/lib/esm/types/features/metaAg/common.d.ts +24 -0
  63. package/lib/esm/types/features/metaAg/common.d.ts.map +1 -0
  64. package/lib/esm/types/features/metaAg/error.d.ts +54 -0
  65. package/lib/esm/types/features/metaAg/error.d.ts.map +1 -0
  66. package/lib/esm/types/features/metaAg/index.d.ts +11 -2
  67. package/lib/esm/types/features/metaAg/index.d.ts.map +1 -1
  68. package/lib/esm/types/features/metaAg/providers/bluefin7k.d.ts +11 -0
  69. package/lib/esm/types/features/metaAg/providers/bluefin7k.d.ts.map +1 -0
  70. package/lib/esm/types/features/metaAg/providers/cetus.d.ts +4 -5
  71. package/lib/esm/types/features/metaAg/providers/cetus.d.ts.map +1 -1
  72. package/lib/esm/types/features/metaAg/providers/flowx.d.ts +3 -3
  73. package/lib/esm/types/features/metaAg/providers/flowx.d.ts.map +1 -1
  74. package/lib/esm/types/features/metaAg/providers/okx.d.ts +21 -0
  75. package/lib/esm/types/features/metaAg/providers/okx.d.ts.map +1 -0
  76. package/lib/esm/types/features/prices/index.d.ts +16 -2
  77. package/lib/esm/types/features/prices/index.d.ts.map +1 -1
  78. package/lib/esm/types/index.d.ts +1 -30
  79. package/lib/esm/types/index.d.ts.map +1 -1
  80. package/lib/esm/types/metaAg.js +5 -2
  81. package/lib/esm/types/okx.js +5 -0
  82. package/lib/esm/types/types/metaAg.d.ts +50 -12
  83. package/lib/esm/types/types/metaAg.d.ts.map +1 -1
  84. package/lib/esm/types/types/okx.d.ts +206 -0
  85. package/lib/esm/types/types/okx.d.ts.map +1 -0
  86. package/lib/esm/types/utils/sui.d.ts +1 -31
  87. package/lib/esm/types/utils/sui.d.ts.map +1 -1
  88. package/lib/esm/types/utils/swap.d.ts +15 -0
  89. package/lib/esm/types/utils/swap.d.ts.map +1 -0
  90. package/lib/esm/utils/sui.js +19 -147
  91. package/lib/esm/utils/swap.js +33 -0
  92. package/package.json +3 -1
  93. package/lib/cjs/config/index.js +0 -58
  94. package/lib/cjs/features/metaAg/providers/bluefin.js +0 -68
  95. package/lib/cjs/features/swap/buildTx.js +0 -195
  96. package/lib/cjs/features/swap/buildTxV2.js +0 -225
  97. package/lib/cjs/features/swap/config.js +0 -153
  98. package/lib/cjs/features/swap/estimateGasFee.js +0 -44
  99. package/lib/cjs/features/swap/executeTx.js +0 -52
  100. package/lib/cjs/features/swap/getQuote.js +0 -94
  101. package/lib/cjs/features/swap/getSwapHistory.js +0 -21
  102. package/lib/cjs/features/swap/index.js +0 -22
  103. package/lib/cjs/libs/groupSwapRoutes.js +0 -60
  104. package/lib/cjs/libs/protocols/aftermath/index.js +0 -35
  105. package/lib/cjs/libs/protocols/base.js +0 -41
  106. package/lib/cjs/libs/protocols/bluefin/index.js +0 -38
  107. package/lib/cjs/libs/protocols/bluefinx/client.js +0 -41
  108. package/lib/cjs/libs/protocols/bluefinx/index.js +0 -48
  109. package/lib/cjs/libs/protocols/bluefinx/types.js +0 -10
  110. package/lib/cjs/libs/protocols/bluemove/index.js +0 -24
  111. package/lib/cjs/libs/protocols/cetus/index.js +0 -44
  112. package/lib/cjs/libs/protocols/cetus_dlmm.js +0 -48
  113. package/lib/cjs/libs/protocols/constants.js +0 -5
  114. package/lib/cjs/libs/protocols/deepbookV3/sponsored.js +0 -30
  115. package/lib/cjs/libs/protocols/ferra_clmm.js +0 -44
  116. package/lib/cjs/libs/protocols/ferra_dlmm.js +0 -30
  117. package/lib/cjs/libs/protocols/flowx/index.js +0 -18
  118. package/lib/cjs/libs/protocols/flowxV3/index.js +0 -36
  119. package/lib/cjs/libs/protocols/fullsail/index.js +0 -39
  120. package/lib/cjs/libs/protocols/haedal_pmm/index.js +0 -31
  121. package/lib/cjs/libs/protocols/index.js +0 -55
  122. package/lib/cjs/libs/protocols/kriya/index.js +0 -30
  123. package/lib/cjs/libs/protocols/kriyaV3/index.js +0 -65
  124. package/lib/cjs/libs/protocols/magma/index.js +0 -40
  125. package/lib/cjs/libs/protocols/momentum/index.js +0 -49
  126. package/lib/cjs/libs/protocols/obric/index.js +0 -28
  127. package/lib/cjs/libs/protocols/sevenk/index.js +0 -55
  128. package/lib/cjs/libs/protocols/springsui/index.js +0 -24
  129. package/lib/cjs/libs/protocols/steamm/index.js +0 -160
  130. package/lib/cjs/libs/protocols/stsui/index.js +0 -24
  131. package/lib/cjs/libs/protocols/suiswap/index.js +0 -34
  132. package/lib/cjs/libs/protocols/turbos/index.js +0 -36
  133. package/lib/cjs/libs/protocols/utils.js +0 -7
  134. package/lib/cjs/libs/swapWithRoute.js +0 -22
  135. package/lib/cjs/types/aggregator.js +0 -19
  136. package/lib/cjs/types/config/index.d.ts +0 -26
  137. package/lib/cjs/types/config/index.d.ts.map +0 -1
  138. package/lib/cjs/types/features/metaAg/providers/bluefin.d.ts +0 -11
  139. package/lib/cjs/types/features/metaAg/providers/bluefin.d.ts.map +0 -1
  140. package/lib/cjs/types/features/swap/buildTx.d.ts +0 -17
  141. package/lib/cjs/types/features/swap/buildTx.d.ts.map +0 -1
  142. package/lib/cjs/types/features/swap/buildTxV2.d.ts +0 -20
  143. package/lib/cjs/types/features/swap/buildTxV2.d.ts.map +0 -1
  144. package/lib/cjs/types/features/swap/config.d.ts +0 -4
  145. package/lib/cjs/types/features/swap/config.d.ts.map +0 -1
  146. package/lib/cjs/types/features/swap/estimateGasFee.d.ts +0 -3
  147. package/lib/cjs/types/features/swap/estimateGasFee.d.ts.map +0 -1
  148. package/lib/cjs/types/features/swap/executeTx.d.ts +0 -24
  149. package/lib/cjs/types/features/swap/executeTx.d.ts.map +0 -1
  150. package/lib/cjs/types/features/swap/getQuote.d.ts +0 -29
  151. package/lib/cjs/types/features/swap/getQuote.d.ts.map +0 -1
  152. package/lib/cjs/types/features/swap/getSwapHistory.d.ts +0 -22
  153. package/lib/cjs/types/features/swap/getSwapHistory.d.ts.map +0 -1
  154. package/lib/cjs/types/features/swap/index.d.ts +0 -7
  155. package/lib/cjs/types/features/swap/index.d.ts.map +0 -1
  156. package/lib/cjs/types/libs/groupSwapRoutes.d.ts +0 -3
  157. package/lib/cjs/types/libs/groupSwapRoutes.d.ts.map +0 -1
  158. package/lib/cjs/types/libs/protocols/aftermath/index.d.ts +0 -9
  159. package/lib/cjs/types/libs/protocols/aftermath/index.d.ts.map +0 -1
  160. package/lib/cjs/types/libs/protocols/base.d.ts +0 -24
  161. package/lib/cjs/types/libs/protocols/base.d.ts.map +0 -1
  162. package/lib/cjs/types/libs/protocols/bluefin/index.d.ts +0 -9
  163. package/lib/cjs/types/libs/protocols/bluefin/index.d.ts.map +0 -1
  164. package/lib/cjs/types/libs/protocols/bluefinx/client.d.ts +0 -13
  165. package/lib/cjs/types/libs/protocols/bluefinx/client.d.ts.map +0 -1
  166. package/lib/cjs/types/libs/protocols/bluefinx/index.d.ts +0 -17
  167. package/lib/cjs/types/libs/protocols/bluefinx/index.d.ts.map +0 -1
  168. package/lib/cjs/types/libs/protocols/bluefinx/types.d.ts +0 -34
  169. package/lib/cjs/types/libs/protocols/bluefinx/types.d.ts.map +0 -1
  170. package/lib/cjs/types/libs/protocols/bluemove/index.d.ts +0 -9
  171. package/lib/cjs/types/libs/protocols/bluemove/index.d.ts.map +0 -1
  172. package/lib/cjs/types/libs/protocols/cetus/index.d.ts +0 -9
  173. package/lib/cjs/types/libs/protocols/cetus/index.d.ts.map +0 -1
  174. package/lib/cjs/types/libs/protocols/cetus_dlmm.d.ts +0 -9
  175. package/lib/cjs/types/libs/protocols/cetus_dlmm.d.ts.map +0 -1
  176. package/lib/cjs/types/libs/protocols/constants.d.ts +0 -3
  177. package/lib/cjs/types/libs/protocols/constants.d.ts.map +0 -1
  178. package/lib/cjs/types/libs/protocols/deepbookV3/sponsored.d.ts +0 -7
  179. package/lib/cjs/types/libs/protocols/deepbookV3/sponsored.d.ts.map +0 -1
  180. package/lib/cjs/types/libs/protocols/ferra_clmm.d.ts +0 -9
  181. package/lib/cjs/types/libs/protocols/ferra_clmm.d.ts.map +0 -1
  182. package/lib/cjs/types/libs/protocols/ferra_dlmm.d.ts +0 -9
  183. package/lib/cjs/types/libs/protocols/ferra_dlmm.d.ts.map +0 -1
  184. package/lib/cjs/types/libs/protocols/flowx/index.d.ts +0 -9
  185. package/lib/cjs/types/libs/protocols/flowx/index.d.ts.map +0 -1
  186. package/lib/cjs/types/libs/protocols/flowxV3/index.d.ts +0 -9
  187. package/lib/cjs/types/libs/protocols/flowxV3/index.d.ts.map +0 -1
  188. package/lib/cjs/types/libs/protocols/fullsail/index.d.ts +0 -9
  189. package/lib/cjs/types/libs/protocols/fullsail/index.d.ts.map +0 -1
  190. package/lib/cjs/types/libs/protocols/haedal_pmm/index.d.ts +0 -14
  191. package/lib/cjs/types/libs/protocols/haedal_pmm/index.d.ts.map +0 -1
  192. package/lib/cjs/types/libs/protocols/index.d.ts +0 -53
  193. package/lib/cjs/types/libs/protocols/index.d.ts.map +0 -1
  194. package/lib/cjs/types/libs/protocols/kriya/index.d.ts +0 -9
  195. package/lib/cjs/types/libs/protocols/kriya/index.d.ts.map +0 -1
  196. package/lib/cjs/types/libs/protocols/kriyaV3/index.d.ts +0 -9
  197. package/lib/cjs/types/libs/protocols/kriyaV3/index.d.ts.map +0 -1
  198. package/lib/cjs/types/libs/protocols/magma/index.d.ts +0 -9
  199. package/lib/cjs/types/libs/protocols/magma/index.d.ts.map +0 -1
  200. package/lib/cjs/types/libs/protocols/momentum/index.d.ts +0 -9
  201. package/lib/cjs/types/libs/protocols/momentum/index.d.ts.map +0 -1
  202. package/lib/cjs/types/libs/protocols/obric/index.d.ts +0 -14
  203. package/lib/cjs/types/libs/protocols/obric/index.d.ts.map +0 -1
  204. package/lib/cjs/types/libs/protocols/sevenk/index.d.ts +0 -18
  205. package/lib/cjs/types/libs/protocols/sevenk/index.d.ts.map +0 -1
  206. package/lib/cjs/types/libs/protocols/springsui/index.d.ts +0 -9
  207. package/lib/cjs/types/libs/protocols/springsui/index.d.ts.map +0 -1
  208. package/lib/cjs/types/libs/protocols/steamm/index.d.ts +0 -28
  209. package/lib/cjs/types/libs/protocols/steamm/index.d.ts.map +0 -1
  210. package/lib/cjs/types/libs/protocols/stsui/index.d.ts +0 -9
  211. package/lib/cjs/types/libs/protocols/stsui/index.d.ts.map +0 -1
  212. package/lib/cjs/types/libs/protocols/suiswap/index.d.ts +0 -9
  213. package/lib/cjs/types/libs/protocols/suiswap/index.d.ts.map +0 -1
  214. package/lib/cjs/types/libs/protocols/turbos/index.d.ts +0 -9
  215. package/lib/cjs/types/libs/protocols/turbos/index.d.ts.map +0 -1
  216. package/lib/cjs/types/libs/protocols/utils.d.ts +0 -2
  217. package/lib/cjs/types/libs/protocols/utils.d.ts.map +0 -1
  218. package/lib/cjs/types/libs/swapWithRoute.d.ts +0 -12
  219. package/lib/cjs/types/libs/swapWithRoute.d.ts.map +0 -1
  220. package/lib/cjs/types/sui.js +0 -2
  221. package/lib/cjs/types/tx.js +0 -2
  222. package/lib/cjs/types/types/aggregator.d.ts +0 -173
  223. package/lib/cjs/types/types/aggregator.d.ts.map +0 -1
  224. package/lib/cjs/types/types/sui.d.ts +0 -4
  225. package/lib/cjs/types/types/sui.d.ts.map +0 -1
  226. package/lib/cjs/types/types/tx.d.ts +0 -67
  227. package/lib/cjs/types/types/tx.d.ts.map +0 -1
  228. package/lib/cjs/types/types/utilities.d.ts +0 -5
  229. package/lib/cjs/types/types/utilities.d.ts.map +0 -1
  230. package/lib/cjs/types/utilities.js +0 -2
  231. package/lib/cjs/types/utils/condition.d.ts +0 -2
  232. package/lib/cjs/types/utils/condition.d.ts.map +0 -1
  233. package/lib/cjs/types/utils/number.d.ts +0 -2
  234. package/lib/cjs/types/utils/number.d.ts.map +0 -1
  235. package/lib/cjs/utils/condition.js +0 -8
  236. package/lib/cjs/utils/number.js +0 -9
  237. package/lib/esm/config/index.js +0 -55
  238. package/lib/esm/features/swap/buildTx.js +0 -185
  239. package/lib/esm/features/swap/buildTxV2.js +0 -219
  240. package/lib/esm/features/swap/config.js +0 -149
  241. package/lib/esm/features/swap/estimateGasFee.js +0 -41
  242. package/lib/esm/features/swap/executeTx.js +0 -48
  243. package/lib/esm/features/swap/getQuote.js +0 -90
  244. package/lib/esm/features/swap/getSwapHistory.js +0 -18
  245. package/lib/esm/features/swap/index.js +0 -6
  246. package/lib/esm/libs/groupSwapRoutes.js +0 -57
  247. package/lib/esm/libs/protocols/aftermath/index.js +0 -31
  248. package/lib/esm/libs/protocols/base.js +0 -42
  249. package/lib/esm/libs/protocols/bluefin/index.js +0 -34
  250. package/lib/esm/libs/protocols/bluefinx/client.js +0 -36
  251. package/lib/esm/libs/protocols/bluefinx/index.js +0 -44
  252. package/lib/esm/libs/protocols/bluefinx/types.js +0 -8
  253. package/lib/esm/libs/protocols/bluemove/index.js +0 -20
  254. package/lib/esm/libs/protocols/cetus/index.js +0 -40
  255. package/lib/esm/libs/protocols/cetus_dlmm.js +0 -44
  256. package/lib/esm/libs/protocols/constants.js +0 -2
  257. package/lib/esm/libs/protocols/deepbookV3/sponsored.js +0 -26
  258. package/lib/esm/libs/protocols/ferra_clmm.js +0 -40
  259. package/lib/esm/libs/protocols/ferra_dlmm.js +0 -26
  260. package/lib/esm/libs/protocols/flowx/index.js +0 -14
  261. package/lib/esm/libs/protocols/flowxV3/index.js +0 -32
  262. package/lib/esm/libs/protocols/fullsail/index.js +0 -35
  263. package/lib/esm/libs/protocols/haedal_pmm/index.js +0 -27
  264. package/lib/esm/libs/protocols/index.js +0 -52
  265. package/lib/esm/libs/protocols/kriya/index.js +0 -26
  266. package/lib/esm/libs/protocols/kriyaV3/index.js +0 -61
  267. package/lib/esm/libs/protocols/magma/index.js +0 -36
  268. package/lib/esm/libs/protocols/momentum/index.js +0 -45
  269. package/lib/esm/libs/protocols/obric/index.js +0 -24
  270. package/lib/esm/libs/protocols/sevenk/index.js +0 -51
  271. package/lib/esm/libs/protocols/springsui/index.js +0 -20
  272. package/lib/esm/libs/protocols/steamm/index.js +0 -156
  273. package/lib/esm/libs/protocols/stsui/index.js +0 -20
  274. package/lib/esm/libs/protocols/suiswap/index.js +0 -30
  275. package/lib/esm/libs/protocols/turbos/index.js +0 -32
  276. package/lib/esm/libs/protocols/utils.js +0 -4
  277. package/lib/esm/libs/swapWithRoute.js +0 -19
  278. package/lib/esm/types/aggregator.js +0 -14
  279. package/lib/esm/types/config/index.d.ts +0 -26
  280. package/lib/esm/types/config/index.d.ts.map +0 -1
  281. package/lib/esm/types/features/metaAg/providers/bluefin.d.ts +0 -11
  282. package/lib/esm/types/features/metaAg/providers/bluefin.d.ts.map +0 -1
  283. package/lib/esm/types/features/swap/buildTx.d.ts +0 -17
  284. package/lib/esm/types/features/swap/buildTx.d.ts.map +0 -1
  285. package/lib/esm/types/features/swap/buildTxV2.d.ts +0 -20
  286. package/lib/esm/types/features/swap/buildTxV2.d.ts.map +0 -1
  287. package/lib/esm/types/features/swap/config.d.ts +0 -4
  288. package/lib/esm/types/features/swap/config.d.ts.map +0 -1
  289. package/lib/esm/types/features/swap/estimateGasFee.d.ts +0 -3
  290. package/lib/esm/types/features/swap/estimateGasFee.d.ts.map +0 -1
  291. package/lib/esm/types/features/swap/executeTx.d.ts +0 -24
  292. package/lib/esm/types/features/swap/executeTx.d.ts.map +0 -1
  293. package/lib/esm/types/features/swap/getQuote.d.ts +0 -29
  294. package/lib/esm/types/features/swap/getQuote.d.ts.map +0 -1
  295. package/lib/esm/types/features/swap/getSwapHistory.d.ts +0 -22
  296. package/lib/esm/types/features/swap/getSwapHistory.d.ts.map +0 -1
  297. package/lib/esm/types/features/swap/index.d.ts +0 -7
  298. package/lib/esm/types/features/swap/index.d.ts.map +0 -1
  299. package/lib/esm/types/libs/groupSwapRoutes.d.ts +0 -3
  300. package/lib/esm/types/libs/groupSwapRoutes.d.ts.map +0 -1
  301. package/lib/esm/types/libs/protocols/aftermath/index.d.ts +0 -9
  302. package/lib/esm/types/libs/protocols/aftermath/index.d.ts.map +0 -1
  303. package/lib/esm/types/libs/protocols/base.d.ts +0 -24
  304. package/lib/esm/types/libs/protocols/base.d.ts.map +0 -1
  305. package/lib/esm/types/libs/protocols/bluefin/index.d.ts +0 -9
  306. package/lib/esm/types/libs/protocols/bluefin/index.d.ts.map +0 -1
  307. package/lib/esm/types/libs/protocols/bluefinx/client.d.ts +0 -13
  308. package/lib/esm/types/libs/protocols/bluefinx/client.d.ts.map +0 -1
  309. package/lib/esm/types/libs/protocols/bluefinx/index.d.ts +0 -17
  310. package/lib/esm/types/libs/protocols/bluefinx/index.d.ts.map +0 -1
  311. package/lib/esm/types/libs/protocols/bluefinx/types.d.ts +0 -34
  312. package/lib/esm/types/libs/protocols/bluefinx/types.d.ts.map +0 -1
  313. package/lib/esm/types/libs/protocols/bluemove/index.d.ts +0 -9
  314. package/lib/esm/types/libs/protocols/bluemove/index.d.ts.map +0 -1
  315. package/lib/esm/types/libs/protocols/cetus/index.d.ts +0 -9
  316. package/lib/esm/types/libs/protocols/cetus/index.d.ts.map +0 -1
  317. package/lib/esm/types/libs/protocols/cetus_dlmm.d.ts +0 -9
  318. package/lib/esm/types/libs/protocols/cetus_dlmm.d.ts.map +0 -1
  319. package/lib/esm/types/libs/protocols/constants.d.ts +0 -3
  320. package/lib/esm/types/libs/protocols/constants.d.ts.map +0 -1
  321. package/lib/esm/types/libs/protocols/deepbookV3/sponsored.d.ts +0 -7
  322. package/lib/esm/types/libs/protocols/deepbookV3/sponsored.d.ts.map +0 -1
  323. package/lib/esm/types/libs/protocols/ferra_clmm.d.ts +0 -9
  324. package/lib/esm/types/libs/protocols/ferra_clmm.d.ts.map +0 -1
  325. package/lib/esm/types/libs/protocols/ferra_dlmm.d.ts +0 -9
  326. package/lib/esm/types/libs/protocols/ferra_dlmm.d.ts.map +0 -1
  327. package/lib/esm/types/libs/protocols/flowx/index.d.ts +0 -9
  328. package/lib/esm/types/libs/protocols/flowx/index.d.ts.map +0 -1
  329. package/lib/esm/types/libs/protocols/flowxV3/index.d.ts +0 -9
  330. package/lib/esm/types/libs/protocols/flowxV3/index.d.ts.map +0 -1
  331. package/lib/esm/types/libs/protocols/fullsail/index.d.ts +0 -9
  332. package/lib/esm/types/libs/protocols/fullsail/index.d.ts.map +0 -1
  333. package/lib/esm/types/libs/protocols/haedal_pmm/index.d.ts +0 -14
  334. package/lib/esm/types/libs/protocols/haedal_pmm/index.d.ts.map +0 -1
  335. package/lib/esm/types/libs/protocols/index.d.ts +0 -53
  336. package/lib/esm/types/libs/protocols/index.d.ts.map +0 -1
  337. package/lib/esm/types/libs/protocols/kriya/index.d.ts +0 -9
  338. package/lib/esm/types/libs/protocols/kriya/index.d.ts.map +0 -1
  339. package/lib/esm/types/libs/protocols/kriyaV3/index.d.ts +0 -9
  340. package/lib/esm/types/libs/protocols/kriyaV3/index.d.ts.map +0 -1
  341. package/lib/esm/types/libs/protocols/magma/index.d.ts +0 -9
  342. package/lib/esm/types/libs/protocols/magma/index.d.ts.map +0 -1
  343. package/lib/esm/types/libs/protocols/momentum/index.d.ts +0 -9
  344. package/lib/esm/types/libs/protocols/momentum/index.d.ts.map +0 -1
  345. package/lib/esm/types/libs/protocols/obric/index.d.ts +0 -14
  346. package/lib/esm/types/libs/protocols/obric/index.d.ts.map +0 -1
  347. package/lib/esm/types/libs/protocols/sevenk/index.d.ts +0 -18
  348. package/lib/esm/types/libs/protocols/sevenk/index.d.ts.map +0 -1
  349. package/lib/esm/types/libs/protocols/springsui/index.d.ts +0 -9
  350. package/lib/esm/types/libs/protocols/springsui/index.d.ts.map +0 -1
  351. package/lib/esm/types/libs/protocols/steamm/index.d.ts +0 -28
  352. package/lib/esm/types/libs/protocols/steamm/index.d.ts.map +0 -1
  353. package/lib/esm/types/libs/protocols/stsui/index.d.ts +0 -9
  354. package/lib/esm/types/libs/protocols/stsui/index.d.ts.map +0 -1
  355. package/lib/esm/types/libs/protocols/suiswap/index.d.ts +0 -9
  356. package/lib/esm/types/libs/protocols/suiswap/index.d.ts.map +0 -1
  357. package/lib/esm/types/libs/protocols/turbos/index.d.ts +0 -9
  358. package/lib/esm/types/libs/protocols/turbos/index.d.ts.map +0 -1
  359. package/lib/esm/types/libs/protocols/utils.d.ts +0 -2
  360. package/lib/esm/types/libs/protocols/utils.d.ts.map +0 -1
  361. package/lib/esm/types/libs/swapWithRoute.d.ts +0 -12
  362. package/lib/esm/types/libs/swapWithRoute.d.ts.map +0 -1
  363. package/lib/esm/types/sui.js +0 -1
  364. package/lib/esm/types/tx.js +0 -1
  365. package/lib/esm/types/types/aggregator.d.ts +0 -173
  366. package/lib/esm/types/types/aggregator.d.ts.map +0 -1
  367. package/lib/esm/types/types/sui.d.ts +0 -4
  368. package/lib/esm/types/types/sui.d.ts.map +0 -1
  369. package/lib/esm/types/types/tx.d.ts +0 -67
  370. package/lib/esm/types/types/tx.d.ts.map +0 -1
  371. package/lib/esm/types/types/utilities.d.ts +0 -5
  372. package/lib/esm/types/types/utilities.d.ts.map +0 -1
  373. package/lib/esm/types/utilities.js +0 -1
  374. package/lib/esm/types/utils/condition.d.ts +0 -2
  375. package/lib/esm/types/utils/condition.d.ts.map +0 -1
  376. package/lib/esm/types/utils/number.d.ts +0 -2
  377. package/lib/esm/types/utils/number.d.ts.map +0 -1
  378. package/lib/esm/utils/condition.js +0 -5
  379. package/lib/esm/utils/number.js +0 -6
package/README.md CHANGED
@@ -29,8 +29,6 @@ Key features:
29
29
  - **Limit Orders**: Place and manage limit orders for token swaps
30
30
  - **DCA Orders**: Set up dollar-cost averaging strategies for automated
31
31
  recurring purchases
32
- - **BluefinX Integration**: Access RFQ-based trading with sponsored transactions
33
- and MEV protection
34
32
  - **Type Safety**: Full TypeScript support with comprehensive type definitions
35
33
  - **Mainnet Support**: Production-ready SDK for Sui mainnet
36
34
  - **Flexible Configuration**: Customize API keys, slippage, commissions, and
@@ -112,7 +110,7 @@ import SevenK from "@7kprotocol/sdk-ts";
112
110
  or import specific functions as needed:
113
111
 
114
112
  ```typescript
115
- import { getQuote, buildTx } from "@7kprotocol/sdk-ts";
113
+ import { MetaAg, getTokenPrice } from "@7kprotocol/sdk-ts";
116
114
  ```
117
115
 
118
116
  Note: this package only supports **mainnet**.
@@ -121,14 +119,6 @@ Note: this package only supports **mainnet**.
121
119
 
122
120
  See [Meta Aggregator](docs/META_AG.md).
123
121
 
124
- ## Swap
125
-
126
- See [Swap](docs/SWAP.md).
127
-
128
- ## BluefinX
129
-
130
- See [BluefinX](docs/BLUEFINX.md).
131
-
132
122
  ## Limit Orders
133
123
 
134
124
  See [Limit Orders](docs/LIMIT.md).
@@ -1,17 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fetchClient = fetchClient;
4
- const index_1 = require("./index");
5
4
  async function fetchClient(input, init) {
6
5
  const headers = new Headers(init?.headers);
7
- const apiKey = (index_1.Config.getApiKey() || "").trim();
8
- const bluefinXApiKey = (index_1.Config.getBluefinXApiKey() || "").trim();
9
- if (apiKey) {
10
- headers.set("apiKey", apiKey);
11
- }
12
- if (bluefinXApiKey) {
13
- headers.set("Bluefin-X-API-Key", bluefinXApiKey);
14
- }
6
+ // intercept the request and add the headers go here...
15
7
  const modifiedInit = {
16
8
  ...init,
17
9
  headers,
@@ -1,15 +1,18 @@
1
1
  "use strict";
2
+ // export const _7K_PACKAGE_ID =
3
+ // "0x62412b7268c35f3808336aee57a52836501f40b8ba5d936f8ad275e672befd04";
4
+ // //legacy V4: "0xe8f996ea6ff38c557c253d3b93cfe2ebf393816487266786371aa4532a9229f2";
5
+ // //legacy V3: "0x7ea6e27ad7af6f3b8671d59df1aaebd7c03dddab893e52a714227b2f4fe91519";
6
+ // //legacy V2: "0xa13447019cd982d6bef91cf7b46ad384a52583b1dfc2bdecf31ef0c4bd787a0f";
7
+ // //legacy V1: "0xd48e7cdc9e92bec69ce3baa75578010458a0c5b2733d661a84971e8cef6806bc";
8
+ // export const _7K_CONFIG =
9
+ // "0x47442a93f7727d188ba7cb71031170d1786af70013cb7ad5115f3fe877ff0c54";
10
+ // //legacy v3: "0x0f8fc23dbcc9362b72c7a4c5aa53fcefa02ebfbb83a812c8c262ccd2c076d9ee";
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._7K_PARTNER_ADDRESS = exports._7K_META_CONFIG = exports._7K_META_VAULT = exports._7K_META_PACKAGE_ID = exports._7K_META_PUBLISHED_AT = exports._7K_VAULT = exports._7K_CONFIG = exports._7K_PACKAGE_ID = void 0;
4
- exports._7K_PACKAGE_ID = "0x62412b7268c35f3808336aee57a52836501f40b8ba5d936f8ad275e672befd04";
5
- //legacy V4: "0xe8f996ea6ff38c557c253d3b93cfe2ebf393816487266786371aa4532a9229f2";
6
- //legacy V3: "0x7ea6e27ad7af6f3b8671d59df1aaebd7c03dddab893e52a714227b2f4fe91519";
7
- //legacy V2: "0xa13447019cd982d6bef91cf7b46ad384a52583b1dfc2bdecf31ef0c4bd787a0f";
8
- //legacy V1: "0xd48e7cdc9e92bec69ce3baa75578010458a0c5b2733d661a84971e8cef6806bc";
9
- exports._7K_CONFIG = "0x47442a93f7727d188ba7cb71031170d1786af70013cb7ad5115f3fe877ff0c54";
10
- //legacy v3: "0x0f8fc23dbcc9362b72c7a4c5aa53fcefa02ebfbb83a812c8c262ccd2c076d9ee";
11
- exports._7K_VAULT = "0x442ad50389ed5cda6f7a6f5a7ae6361a4c05ef1d9fb2e54fbba5a268d690bfe6";
12
- //legacy v3: "0x39a3c55742c0e011b6f65548e73cf589e1ae5e82dbfab449ca57f24c3bcd9514";
12
+ exports._7K_PARTNER_ADDRESS = exports._7K_META_CONFIG = exports._7K_META_VAULT = exports._7K_META_PACKAGE_ID = exports._7K_META_PUBLISHED_AT = void 0;
13
+ // export const _7K_VAULT =
14
+ // "0x442ad50389ed5cda6f7a6f5a7ae6361a4c05ef1d9fb2e54fbba5a268d690bfe6";
15
+ // //legacy v3: "0x39a3c55742c0e011b6f65548e73cf589e1ae5e82dbfab449ca57f24c3bcd9514";
13
16
  exports._7K_META_PUBLISHED_AT = "0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302";
14
17
  exports._7K_META_PACKAGE_ID = "0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302";
15
18
  exports._7K_META_VAULT = "0x9a8abd32fe5721307ce3b697cf982ee84e9ffbd58d667a4a199f1683c1a3d23c";
@@ -4,6 +4,6 @@ exports.API_ENDPOINTS = void 0;
4
4
  exports.API_ENDPOINTS = {
5
5
  MAIN: "https://api.7k.ag",
6
6
  LO_DCA: "https://lod-dca.7k.ag",
7
- PRICES: "https://prices.7k.ag",
7
+ PRICES: "https://lp-pro-api.7k.ag/price",
8
8
  STATISTIC: "https://statistic.7k.ag",
9
9
  };
@@ -0,0 +1,103 @@
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;
@@ -0,0 +1,31 @@
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;
@@ -37,13 +37,14 @@ exports.MetaAg = void 0;
37
37
  const client_1 = require("@mysten/sui/client");
38
38
  const transactions_1 = require("@mysten/sui/transactions");
39
39
  const utils_1 = require("@mysten/sui/utils");
40
- const _7k_1 = require("../../constants/_7k");
41
40
  const sui_1 = require("../../constants/sui");
42
41
  const metaAg_1 = require("../../types/metaAg");
43
- const condition_1 = require("../../utils/condition");
42
+ const sui_2 = require("../../utils/sui");
44
43
  const SuiClientUtils_1 = require("../../utils/SuiClientUtils");
45
- const buildTx_1 = require("../swap/buildTx");
46
- const bluefin_1 = require("./providers/bluefin");
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");
47
48
  const HERMES_API = "https://hermes.pyth.network";
48
49
  const DEFAULT_PROVIDERS = {
49
50
  [metaAg_1.EProvider.BLUEFIN7K]: {},
@@ -72,10 +73,11 @@ class MetaAg {
72
73
  if (p)
73
74
  return p;
74
75
  const providerOptions = this.options.providers[provider];
75
- (0, condition_1.assert)(!!providerOptions, `Provider not found: ${provider}`);
76
+ error_1.MetaAgError.assert(!!providerOptions, `Provider not found: ${provider}`, error_1.MetaAgErrorCode.PROVIDER_NOT_FOUND, { provider });
76
77
  switch (provider) {
77
78
  case metaAg_1.EProvider.BLUEFIN7K:
78
- this.providers[metaAg_1.EProvider.BLUEFIN7K] = new bluefin_1.BluefinProvider(providerOptions, this.options, this.client);
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);
79
81
  break;
80
82
  case metaAg_1.EProvider.FLOWX:
81
83
  const { FlowxProvider } = await Promise.resolve().then(() => __importStar(require("./providers/flowx"))).catch(catchImportError(metaAg_1.EProvider.FLOWX));
@@ -85,69 +87,64 @@ class MetaAg {
85
87
  const { CetusProvider } = await Promise.resolve().then(() => __importStar(require("./providers/cetus"))).catch(catchImportError(metaAg_1.EProvider.CETUS));
86
88
  this.providers[metaAg_1.EProvider.CETUS] = new CetusProvider(providerOptions, this.options, this.client);
87
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;
88
93
  default:
89
- throw new Error(`Provider not supported: ${provider}`);
94
+ throw new error_1.MetaAgError(`Provider not supported: ${provider}`, error_1.MetaAgErrorCode.PROVIDER_NOT_SUPPORTED, { provider });
90
95
  }
91
96
  return this.providers[provider];
92
97
  }
93
98
  async _simulate(provider, quote, simulation) {
94
99
  try {
95
- const tx = new transactions_1.Transaction();
96
- const id = quote.id;
97
- const coinOut = await provider.swap({
98
- quote,
99
- coinIn: (0, transactions_1.coinWithBalance)({
100
- balance: BigInt(quote.amountIn),
101
- type: quote.coinTypeIn,
102
- useGasCoin: false,
103
- }),
104
- signer: simulation.sender,
105
- tx,
106
- });
107
- tx.add(metaSettle(quote, coinOut, 10000, this.options.tipBps, this.options.partner, this.options.partnerCommissionBps));
108
- tx.transferObjects([coinOut], simulation.sender);
109
- const res = await timeout(() => this.inspector.devInspectTransactionBlock({
110
- sender: simulation.sender,
111
- transactionBlock: tx,
112
- }), simulation.timeout ?? 2000, `simulation for ${provider.kind} provider with id ${id}`);
113
- if (res.effects.status.status === "failure") {
114
- throw new Error(res.error ?? "Simulation failed");
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 });
115
108
  }
116
- const amountOut = extractAmountOutWrapper(res.events);
117
- return {
118
- id,
119
- simulatedAmountOut: amountOut,
120
- gasUsed: res.effects.gasUsed,
121
- provider: provider.kind,
122
- };
123
109
  }
124
110
  catch (error) {
125
- console.warn(`Failed to simulate ${provider.kind}: `, error);
111
+ console.warn(error, { provider: provider.kind, quote: quote.id });
126
112
  }
127
113
  }
128
- async _quote(provider, options, simulation) {
129
- const quote = await timeout(async () => {
114
+ async _quote(provider, options) {
115
+ const quote = await (0, common_1.timeout)(async () => {
130
116
  const quote = await provider.quote(options);
131
- const { expectedAmount } = (0, buildTx_1.getExpectedReturn)(quote.rawAmountOut, 0, this.options.partnerCommissionBps, this.options.tipBps);
117
+ if (!quote)
118
+ return null;
119
+ const { expectedAmount } = (0, swap_1.getExpectedReturn)(quote.rawAmountOut, 0, this.options.partnerCommissionBps, this.options.tipBps);
132
120
  quote.amountOut = expectedAmount;
133
121
  return quote;
134
- }, options.timeout ?? 2000, `quote for ${provider.kind} provider from ${options.coinInType} to ${options.coinOutType}`);
135
- if (simulation) {
136
- if (simulation.onSimulated) {
137
- this._simulate(provider, quote, simulation).then((payload) => {
138
- if (payload) {
139
- simulation.onSimulated?.(payload);
140
- }
141
- });
142
- }
143
- else {
144
- const updated = await this._simulate(provider, quote, simulation);
145
- quote.simulatedAmountOut = updated?.simulatedAmountOut;
146
- quote.gasUsed = updated?.gasUsed;
147
- }
148
- }
122
+ }, options.timeout ?? 2000, `quote for ${provider.kind} provider from ${options.coinTypeIn} to ${options.coinTypeOut}`);
149
123
  return quote;
150
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
+ }
151
148
  /**
152
149
  * Get quotes from all providers
153
150
  * @param options - quote options
@@ -157,35 +154,73 @@ class MetaAg {
157
154
  async quote(options, simulation) {
158
155
  const opts = {
159
156
  ...options,
160
- coinInType: (0, utils_1.normalizeStructTag)(options.coinInType),
161
- coinOutType: (0, utils_1.normalizeStructTag)(options.coinOutType),
157
+ coinTypeIn: (0, utils_1.normalizeStructTag)(options.coinTypeIn),
158
+ coinTypeOut: (0, utils_1.normalizeStructTag)(options.coinTypeOut),
162
159
  };
163
160
  const quotes = await Promise.allSettled(Object.entries(this.options.providers)
164
161
  .filter(([_k, v]) => !v.disabled)
165
162
  .map(async ([provider]) => {
166
163
  const p = await this._getProvider(provider);
167
- return this._quote(p, opts, simulation);
164
+ return this._quote(p, opts);
168
165
  }));
169
- return quotes
166
+ const result = quotes
170
167
  .map((quote) => quote.status === "fulfilled"
171
168
  ? quote.value
172
169
  : (console.log(quote.reason), null))
173
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;
174
184
  }
175
185
  /**
176
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
177
189
  * @param options - build tx options
178
190
  * @param slippageBps - slippage bps if not specified, fallback to global slippage bps, if none of them specified, default to 100
179
191
  * @returns coin out object, you must consume it by transferObjects, or other sub sequence commands
180
192
  */
181
193
  async swap(options, slippageBps) {
182
194
  const provider = await this._getProvider(options.quote.provider);
183
- (0, condition_1.assert)(!!provider, `Provider not found: ${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 });
184
198
  const coinOut = await provider.swap(options);
185
- options.tx.add(metaSettle(options.quote, coinOut, slippageBps ?? this.options.slippageBps ?? 100, this.options.tipBps, this.options.partner, this.options.partnerCommissionBps));
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));
186
200
  options.tx.setSenderIfNotSet(options.signer);
187
201
  return coinOut;
188
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
+ }
189
224
  /**
190
225
  * Update meta aggregator options
191
226
  * @param options - update options payload
@@ -219,71 +254,15 @@ class MetaAg {
219
254
  }
220
255
  }
221
256
  exports.MetaAg = MetaAg;
222
- /**
223
- * this settlement does not charge commission fee for partner, since all integrated aggregators already charge commission fee for partner
224
- * @param quote Meta Aggregator Quote
225
- * @param coinOut Coin Out Object
226
- * @param slippageBps Slippage Bps
227
- * @param tipBps Tip Bps default = 0
228
- * @param partner address of partner for analytic default is zero address
229
- */
230
- const metaSettle = (quote, coinOut, slippageBps = 100, tipBps = 0, partner, commissionBps = 0) => {
231
- return (tx) => {
232
- const { minAmount, expectedAmount } = (0, buildTx_1.getExpectedReturn)(quote.rawAmountOut, slippageBps, commissionBps, tipBps);
233
- if (tipBps > 0) {
234
- tx.moveCall({
235
- target: `${_7k_1._7K_META_PUBLISHED_AT}::vault::collect_tip`,
236
- typeArguments: [quote.coinTypeOut],
237
- arguments: [
238
- tx.object(_7k_1._7K_META_VAULT),
239
- tx.object(_7k_1._7K_META_CONFIG),
240
- coinOut,
241
- tx.pure.u64(tipBps),
242
- ],
243
- });
244
- }
245
- tx.moveCall({
246
- target: `${_7k_1._7K_META_PUBLISHED_AT}::settle::settle`,
247
- typeArguments: [quote.coinTypeIn, quote.coinTypeOut],
248
- arguments: [
249
- tx.object(_7k_1._7K_META_CONFIG),
250
- tx.object(_7k_1._7K_META_VAULT),
251
- tx.pure.u64(quote.amountIn),
252
- coinOut,
253
- tx.pure.u64(minAmount),
254
- tx.pure.u64(expectedAmount),
255
- tx.pure.option("address", partner),
256
- tx.pure.u64(commissionBps),
257
- tx.pure.u64(0), // ps
258
- ],
259
- });
260
- };
261
- };
262
- const extractAmountOutWrapper = (events) => {
263
- const swapEvent = events
264
- .filter((event) => event.type === `${_7k_1._7K_META_PACKAGE_ID}::settle::Swap`)
265
- ?.pop();
266
- return swapEvent?.parsedJson?.amount_out;
267
- };
268
257
  const catchImportError = (provider) => {
269
258
  return (e) => {
270
259
  const map = {
271
260
  [metaAg_1.EProvider.CETUS]: "@cetusprotocol/aggregator-sdk",
272
261
  [metaAg_1.EProvider.FLOWX]: "@flowx-finance/sdk",
273
- [metaAg_1.EProvider.BLUEFIN7K]: "@7kprotocol/sdk-ts",
262
+ [metaAg_1.EProvider.BLUEFIN7K]: "@bluefin-exchange/bluefin7k-aggregator-sdk",
263
+ [metaAg_1.EProvider.OKX]: "",
274
264
  };
275
265
  console.warn(`Please install ${map[provider]} to use ${provider} provider`);
276
266
  throw e;
277
267
  };
278
268
  };
279
- const timeout = async (fn, timeout, msg) => {
280
- if (timeout <= 0)
281
- return fn();
282
- return new Promise((resolve, reject) => {
283
- const timer = setTimeout(() => reject(new Error(`Timeout ${msg ?? "operation"}`)), timeout);
284
- fn()
285
- .then(resolve)
286
- .catch(reject)
287
- .finally(() => clearTimeout(timer));
288
- });
289
- };
@@ -0,0 +1,57 @@
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;
@@ -5,7 +5,7 @@ const aggregator_sdk_1 = require("@cetusprotocol/aggregator-sdk");
5
5
  const uuid_1 = require("uuid");
6
6
  const _7k_1 = require("../../../constants/_7k");
7
7
  const metaAg_1 = require("../../../types/metaAg");
8
- const condition_1 = require("../../../utils/condition");
8
+ const error_1 = require("../error");
9
9
  class CetusProvider {
10
10
  constructor(options, metaOptions, client) {
11
11
  this.options = options;
@@ -24,8 +24,8 @@ class CetusProvider {
24
24
  const quote = await this.cetusClient.findRouters({
25
25
  amount: quoteOptions.amountIn,
26
26
  byAmountIn: true,
27
- from: quoteOptions.coinInType,
28
- target: quoteOptions.coinOutType,
27
+ from: quoteOptions.coinTypeIn,
28
+ target: quoteOptions.coinTypeOut,
29
29
  providers: this.options.sources,
30
30
  splitCount: this.options.splitCount,
31
31
  splitAlgorithm: this.options.splitAlgorithm,
@@ -33,7 +33,7 @@ class CetusProvider {
33
33
  depth: this.options.depth,
34
34
  liquidityChanges: this.options.liquidityChanges,
35
35
  });
36
- (0, condition_1.assert)(!!quote, "No quote found");
36
+ error_1.MetaAgError.assert(!!quote, "No quote found", error_1.MetaAgErrorCode.QUOTE_NOT_FOUND, { provider: this.kind });
37
37
  return {
38
38
  id: (0, uuid_1.v4)(),
39
39
  provider: metaAg_1.EProvider.CETUS,
@@ -41,12 +41,12 @@ class CetusProvider {
41
41
  amountIn: quote.amountIn.toString() || "0",
42
42
  rawAmountOut: quote.amountOut.toString() || "0",
43
43
  amountOut: quote.amountOut.toString() || "0",
44
- coinTypeIn: quoteOptions.coinInType,
45
- coinTypeOut: quoteOptions.coinOutType,
44
+ coinTypeIn: quoteOptions.coinTypeIn,
45
+ coinTypeOut: quoteOptions.coinTypeOut,
46
46
  };
47
47
  }
48
48
  async swap(options) {
49
- (0, condition_1.assert)(options.quote.provider === metaAg_1.EProvider.CETUS, "Expect Cetus quote");
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
50
  const coinOut = await this.cetusClient.routerSwap({
51
51
  inputCoin: options.coinIn,
52
52
  router: options.quote.quote,