@7kprotocol/sdk-ts 2.4.1 → 2.4.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/README.md +30 -3
  2. package/lib/cjs/config/fetchClient.js +11 -19
  3. package/lib/cjs/config/index.js +22 -0
  4. package/lib/cjs/constants/_7k.js +6 -3
  5. package/lib/cjs/features/limitDca/cancelDcaOrder.js +7 -18
  6. package/lib/cjs/features/limitDca/cancelLimitOrder.js +7 -18
  7. package/lib/cjs/features/limitDca/claimExpiredLimitOrder.js +7 -18
  8. package/lib/cjs/features/limitDca/constants.js +1 -5
  9. package/lib/cjs/features/limitDca/getClosedDcaOrders.js +16 -27
  10. package/lib/cjs/features/limitDca/getClosedLimitOrders.js +15 -26
  11. package/lib/cjs/features/limitDca/getDcaOrderExecutions.js +16 -27
  12. package/lib/cjs/features/limitDca/getOpenDcaOrders.js +15 -26
  13. package/lib/cjs/features/limitDca/getOpenLimitOrders.js +15 -26
  14. package/lib/cjs/features/limitDca/placeDcaOrder.js +25 -36
  15. package/lib/cjs/features/limitDca/placeLimitOrder.js +14 -25
  16. package/lib/cjs/features/prices/index.js +47 -64
  17. package/lib/cjs/features/swap/buildTx.js +88 -39
  18. package/lib/cjs/features/swap/config.js +32 -32
  19. package/lib/cjs/features/swap/estimateGasFee.js +36 -46
  20. package/lib/cjs/features/swap/executeTx.js +52 -0
  21. package/lib/cjs/features/swap/getQuote.js +41 -31
  22. package/lib/cjs/features/swap/getSwapHistory.js +14 -25
  23. package/lib/cjs/features/swap/index.js +1 -0
  24. package/lib/cjs/index.js +16 -9
  25. package/lib/cjs/libs/getCoinOjectIdsByAmount.js +15 -24
  26. package/lib/cjs/libs/getSplitCoinForTx.js +8 -15
  27. package/lib/cjs/libs/groupSwapRoutes.js +10 -12
  28. package/lib/cjs/libs/protocols/aftermath/index.js +25 -36
  29. package/lib/cjs/libs/protocols/base.js +10 -3
  30. package/lib/cjs/libs/protocols/bluefin/index.js +26 -43
  31. package/lib/cjs/libs/protocols/bluefinx/client.js +35 -0
  32. package/lib/cjs/libs/protocols/bluefinx/index.js +48 -0
  33. package/lib/cjs/libs/protocols/bluefinx/types.js +10 -0
  34. package/lib/cjs/libs/protocols/bluemove/index.js +14 -25
  35. package/lib/cjs/libs/protocols/cetus/index.js +32 -43
  36. package/lib/cjs/libs/protocols/deepbookV3/sponsored.js +19 -30
  37. package/lib/cjs/libs/protocols/flowx/index.js +9 -20
  38. package/lib/cjs/libs/protocols/flowxV3/index.js +25 -39
  39. package/lib/cjs/libs/protocols/haedal_pmm/index.js +33 -0
  40. package/lib/cjs/libs/protocols/index.js +7 -2
  41. package/lib/cjs/libs/protocols/kriya/index.js +20 -31
  42. package/lib/cjs/libs/protocols/kriyaV3/index.js +54 -65
  43. package/lib/cjs/libs/protocols/magma/index.js +28 -40
  44. package/lib/cjs/libs/protocols/momentum/index.js +49 -0
  45. package/lib/cjs/libs/protocols/obric/index.js +20 -31
  46. package/lib/cjs/libs/protocols/springsui/index.js +14 -25
  47. package/lib/cjs/libs/protocols/steamm/index.js +57 -58
  48. package/lib/cjs/libs/protocols/stsui/index.js +14 -25
  49. package/lib/cjs/libs/protocols/suiswap/index.js +23 -34
  50. package/lib/cjs/libs/protocols/turbos/index.js +23 -38
  51. package/lib/cjs/libs/protocols/utils.js +1 -5
  52. package/lib/cjs/libs/swapWithRoute.js +17 -27
  53. package/lib/cjs/types/aggregator.js +17 -0
  54. package/lib/cjs/types/config/index.d.ts +9 -0
  55. package/lib/cjs/types/config/index.d.ts.map +1 -1
  56. package/lib/cjs/types/constants/_7k.d.ts +3 -3
  57. package/lib/cjs/types/constants/_7k.d.ts.map +1 -1
  58. package/lib/cjs/types/features/limitDca/constants.d.ts +1 -2
  59. package/lib/cjs/types/features/limitDca/constants.d.ts.map +1 -1
  60. package/lib/cjs/types/features/swap/buildTx.d.ts +2 -5
  61. package/lib/cjs/types/features/swap/buildTx.d.ts.map +1 -1
  62. package/lib/cjs/types/features/swap/config.d.ts.map +1 -1
  63. package/lib/cjs/types/features/swap/estimateGasFee.d.ts.map +1 -1
  64. package/lib/cjs/types/features/swap/executeTx.d.ts +24 -0
  65. package/lib/cjs/types/features/swap/executeTx.d.ts.map +1 -0
  66. package/lib/cjs/types/features/swap/getQuote.d.ts +8 -1
  67. package/lib/cjs/types/features/swap/getQuote.d.ts.map +1 -1
  68. package/lib/cjs/types/features/swap/index.d.ts +1 -0
  69. package/lib/cjs/types/features/swap/index.d.ts.map +1 -1
  70. package/lib/cjs/types/index.d.ts +13 -8
  71. package/lib/cjs/types/index.d.ts.map +1 -1
  72. package/lib/cjs/types/libs/getCoinOjectIdsByAmount.d.ts.map +1 -1
  73. package/lib/cjs/types/libs/getSplitCoinForTx.d.ts.map +1 -1
  74. package/lib/cjs/types/libs/groupSwapRoutes.d.ts.map +1 -1
  75. package/lib/cjs/types/libs/protocols/base.d.ts +6 -2
  76. package/lib/cjs/types/libs/protocols/base.d.ts.map +1 -1
  77. package/lib/cjs/types/libs/protocols/bluefin/index.d.ts.map +1 -1
  78. package/lib/cjs/types/libs/protocols/bluefinx/client.d.ts +13 -0
  79. package/lib/cjs/types/libs/protocols/bluefinx/client.d.ts.map +1 -0
  80. package/lib/cjs/types/libs/protocols/bluefinx/index.d.ts +17 -0
  81. package/lib/cjs/types/libs/protocols/bluefinx/index.d.ts.map +1 -0
  82. package/lib/cjs/types/libs/protocols/bluefinx/types.d.ts +34 -0
  83. package/lib/cjs/types/libs/protocols/bluefinx/types.d.ts.map +1 -0
  84. package/lib/cjs/types/libs/protocols/cetus/index.d.ts.map +1 -1
  85. package/lib/cjs/types/libs/protocols/deepbookV3/sponsored.d.ts.map +1 -1
  86. package/lib/cjs/types/libs/protocols/flowxV3/index.d.ts.map +1 -1
  87. package/lib/{esm/types/libs/protocols/deepbook → cjs/types/libs/protocols/haedal_pmm}/index.d.ts +1 -3
  88. package/lib/cjs/types/libs/protocols/haedal_pmm/index.d.ts.map +1 -0
  89. package/lib/cjs/types/libs/protocols/index.d.ts +7 -2
  90. package/lib/cjs/types/libs/protocols/index.d.ts.map +1 -1
  91. package/lib/cjs/types/libs/protocols/magma/index.d.ts.map +1 -1
  92. package/lib/cjs/types/libs/protocols/{deepbook → momentum}/index.d.ts +1 -3
  93. package/lib/cjs/types/libs/protocols/momentum/index.d.ts.map +1 -0
  94. package/lib/cjs/types/libs/protocols/steamm/index.d.ts +13 -2
  95. package/lib/cjs/types/libs/protocols/steamm/index.d.ts.map +1 -1
  96. package/lib/cjs/types/libs/protocols/suiswap/index.d.ts.map +1 -1
  97. package/lib/cjs/types/libs/protocols/turbos/index.d.ts.map +1 -1
  98. package/lib/cjs/types/libs/protocols/utils.d.ts +1 -2
  99. package/lib/cjs/types/libs/protocols/utils.d.ts.map +1 -1
  100. package/lib/cjs/types/libs/swapWithRoute.d.ts +3 -1
  101. package/lib/cjs/types/libs/swapWithRoute.d.ts.map +1 -1
  102. package/lib/cjs/types/types/aggregator.d.ts +36 -2
  103. package/lib/cjs/types/types/aggregator.d.ts.map +1 -1
  104. package/lib/cjs/types/types/tx.d.ts +1 -2
  105. package/lib/cjs/types/types/tx.d.ts.map +1 -1
  106. package/lib/cjs/types/utils/number.d.ts +1 -3
  107. package/lib/cjs/types/utils/number.d.ts.map +1 -1
  108. package/lib/cjs/types/utils/sui.d.ts +1 -1
  109. package/lib/cjs/types/utils/sui.d.ts.map +1 -1
  110. package/lib/cjs/utils/number.js +4 -10
  111. package/lib/cjs/utils/sui.js +71 -80
  112. package/lib/esm/config/index.js +22 -0
  113. package/lib/esm/constants/_7k.js +6 -3
  114. package/lib/esm/features/limitDca/constants.js +1 -2
  115. package/lib/esm/features/swap/buildTx.js +81 -20
  116. package/lib/esm/features/swap/config.js +19 -8
  117. package/lib/esm/features/swap/estimateGasFee.js +13 -9
  118. package/lib/esm/features/swap/executeTx.js +48 -0
  119. package/lib/esm/features/swap/getQuote.js +24 -3
  120. package/lib/esm/features/swap/index.js +1 -0
  121. package/lib/esm/index.mjs +8 -4
  122. package/lib/esm/libs/getCoinOjectIdsByAmount.js +7 -7
  123. package/lib/esm/libs/getSplitCoinForTx.js +4 -2
  124. package/lib/esm/libs/groupSwapRoutes.js +1 -2
  125. package/lib/esm/libs/protocols/base.js +10 -1
  126. package/lib/esm/libs/protocols/bluefin/index.js +2 -5
  127. package/lib/esm/libs/protocols/bluefinx/client.js +30 -0
  128. package/lib/esm/libs/protocols/bluefinx/index.js +44 -0
  129. package/lib/esm/libs/protocols/bluefinx/types.js +8 -0
  130. package/lib/esm/libs/protocols/cetus/index.js +1 -1
  131. package/lib/esm/libs/protocols/deepbookV3/sponsored.js +1 -1
  132. package/lib/esm/libs/protocols/flowxV3/index.js +1 -4
  133. package/lib/esm/libs/protocols/haedal_pmm/index.js +29 -0
  134. package/lib/esm/libs/protocols/index.js +7 -2
  135. package/lib/esm/libs/protocols/magma/index.js +1 -2
  136. package/lib/esm/libs/protocols/momentum/index.js +45 -0
  137. package/lib/esm/libs/protocols/steamm/index.js +58 -48
  138. package/lib/esm/libs/protocols/suiswap/index.js +1 -1
  139. package/lib/esm/libs/protocols/turbos/index.js +2 -6
  140. package/lib/esm/libs/protocols/utils.js +1 -2
  141. package/lib/esm/libs/swapWithRoute.js +2 -1
  142. package/lib/esm/types/aggregator.js +14 -1
  143. package/lib/esm/types/config/index.d.ts +9 -0
  144. package/lib/esm/types/config/index.d.ts.map +1 -1
  145. package/lib/esm/types/constants/_7k.d.ts +3 -3
  146. package/lib/esm/types/constants/_7k.d.ts.map +1 -1
  147. package/lib/esm/types/features/limitDca/constants.d.ts +1 -2
  148. package/lib/esm/types/features/limitDca/constants.d.ts.map +1 -1
  149. package/lib/esm/types/features/swap/buildTx.d.ts +2 -5
  150. package/lib/esm/types/features/swap/buildTx.d.ts.map +1 -1
  151. package/lib/esm/types/features/swap/config.d.ts.map +1 -1
  152. package/lib/esm/types/features/swap/estimateGasFee.d.ts.map +1 -1
  153. package/lib/esm/types/features/swap/executeTx.d.ts +24 -0
  154. package/lib/esm/types/features/swap/executeTx.d.ts.map +1 -0
  155. package/lib/esm/types/features/swap/getQuote.d.ts +8 -1
  156. package/lib/esm/types/features/swap/getQuote.d.ts.map +1 -1
  157. package/lib/esm/types/features/swap/index.d.ts +1 -0
  158. package/lib/esm/types/features/swap/index.d.ts.map +1 -1
  159. package/lib/esm/types/index.d.ts +13 -8
  160. package/lib/esm/types/index.d.ts.map +1 -1
  161. package/lib/esm/types/libs/getCoinOjectIdsByAmount.d.ts.map +1 -1
  162. package/lib/esm/types/libs/getSplitCoinForTx.d.ts.map +1 -1
  163. package/lib/esm/types/libs/groupSwapRoutes.d.ts.map +1 -1
  164. package/lib/esm/types/libs/protocols/base.d.ts +6 -2
  165. package/lib/esm/types/libs/protocols/base.d.ts.map +1 -1
  166. package/lib/esm/types/libs/protocols/bluefin/index.d.ts.map +1 -1
  167. package/lib/esm/types/libs/protocols/bluefinx/client.d.ts +13 -0
  168. package/lib/esm/types/libs/protocols/bluefinx/client.d.ts.map +1 -0
  169. package/lib/esm/types/libs/protocols/bluefinx/index.d.ts +17 -0
  170. package/lib/esm/types/libs/protocols/bluefinx/index.d.ts.map +1 -0
  171. package/lib/esm/types/libs/protocols/bluefinx/types.d.ts +34 -0
  172. package/lib/esm/types/libs/protocols/bluefinx/types.d.ts.map +1 -0
  173. package/lib/esm/types/libs/protocols/cetus/index.d.ts.map +1 -1
  174. package/lib/esm/types/libs/protocols/deepbookV3/sponsored.d.ts.map +1 -1
  175. package/lib/esm/types/libs/protocols/flowxV3/index.d.ts.map +1 -1
  176. package/lib/esm/types/libs/protocols/haedal_pmm/index.d.ts +9 -0
  177. package/lib/esm/types/libs/protocols/haedal_pmm/index.d.ts.map +1 -0
  178. package/lib/esm/types/libs/protocols/index.d.ts +7 -2
  179. package/lib/esm/types/libs/protocols/index.d.ts.map +1 -1
  180. package/lib/esm/types/libs/protocols/magma/index.d.ts.map +1 -1
  181. package/lib/esm/types/libs/protocols/momentum/index.d.ts +9 -0
  182. package/lib/esm/types/libs/protocols/momentum/index.d.ts.map +1 -0
  183. package/lib/esm/types/libs/protocols/steamm/index.d.ts +13 -2
  184. package/lib/esm/types/libs/protocols/steamm/index.d.ts.map +1 -1
  185. package/lib/esm/types/libs/protocols/suiswap/index.d.ts.map +1 -1
  186. package/lib/esm/types/libs/protocols/turbos/index.d.ts.map +1 -1
  187. package/lib/esm/types/libs/protocols/utils.d.ts +1 -2
  188. package/lib/esm/types/libs/protocols/utils.d.ts.map +1 -1
  189. package/lib/esm/types/libs/swapWithRoute.d.ts +3 -1
  190. package/lib/esm/types/libs/swapWithRoute.d.ts.map +1 -1
  191. package/lib/esm/types/types/aggregator.d.ts +36 -2
  192. package/lib/esm/types/types/aggregator.d.ts.map +1 -1
  193. package/lib/esm/types/types/tx.d.ts +1 -2
  194. package/lib/esm/types/types/tx.d.ts.map +1 -1
  195. package/lib/esm/types/utils/number.d.ts +1 -3
  196. package/lib/esm/types/utils/number.d.ts.map +1 -1
  197. package/lib/esm/types/utils/sui.d.ts +1 -1
  198. package/lib/esm/types/utils/sui.d.ts.map +1 -1
  199. package/lib/esm/utils/number.js +4 -6
  200. package/lib/esm/utils/sui.js +4 -3
  201. package/package.json +14 -15
  202. package/lib/cjs/libs/protocols/deepbook/index.js +0 -96
  203. package/lib/cjs/types/libs/protocols/deepbook/index.d.ts.map +0 -1
  204. package/lib/esm/libs/protocols/deepbook/index.js +0 -80
  205. package/lib/esm/types/libs/protocols/deepbook/index.d.ts.map +0 -1
@@ -0,0 +1,9 @@
1
+ import { Transaction } from "@mysten/sui/transactions";
2
+ import { BaseContract } from "../base";
3
+ export declare class HaedalPMMContract extends BaseContract {
4
+ swap(tx: Transaction): Promise<{
5
+ $kind: "NestedResult";
6
+ NestedResult: [number, number];
7
+ }>;
8
+ }
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/haedal_pmm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAOvC,qBAAa,iBAAkB,SAAQ,YAAY;IAC3C,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CA4B3B"}
@@ -1,7 +1,6 @@
1
1
  import { FlowXContract } from "./flowx";
2
2
  import { AfterMathContract } from "./aftermath";
3
3
  import { CetusContract } from "./cetus";
4
- import { DeepBookContract } from "./deepbook";
5
4
  import { KriyaContract } from "./kriya";
6
5
  import { TurbosContract } from "./turbos";
7
6
  import { SuiswapContract } from "./suiswap";
@@ -15,6 +14,9 @@ import { StSuiContract } from "./stsui";
15
14
  import { FlowxV3Contract } from "./flowxV3";
16
15
  import { SteammContract } from "./steamm";
17
16
  import { MagmaContract } from "./magma";
17
+ import { HaedalPMMContract } from "./haedal_pmm";
18
+ import { MomentumContract } from "./momentum";
19
+ import { BluefinXContract } from "./bluefinx";
18
20
  export declare const ProtocolContract: {
19
21
  cetus: typeof CetusContract;
20
22
  turbos: typeof TurbosContract;
@@ -22,7 +24,6 @@ export declare const ProtocolContract: {
22
24
  kriya: typeof KriyaContract;
23
25
  suiswap: typeof SuiswapContract;
24
26
  aftermath: typeof AfterMathContract;
25
- deepbook: typeof DeepBookContract;
26
27
  deepbook_v3: typeof SponsoredDeepBookV3Contract;
27
28
  flowx: typeof FlowXContract;
28
29
  flowx_v3: typeof FlowxV3Contract;
@@ -32,6 +33,10 @@ export declare const ProtocolContract: {
32
33
  obric: typeof ObricContract;
33
34
  stsui: typeof StSuiContract;
34
35
  steamm: typeof SteammContract;
36
+ steamm_oracle_quoter: typeof SteammContract;
35
37
  magma: typeof MagmaContract;
38
+ haedal_pmm: typeof HaedalPMMContract;
39
+ momentum: typeof MomentumContract;
40
+ bluefinx: typeof BluefinXContract;
36
41
  };
37
42
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/libs/protocols/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;CAkB5B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/libs/protocols/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;CAqB5B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/magma/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMvC,qBAAa,aAAc,SAAQ,YAAY;IACvC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CAyC3B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/magma/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMvC,qBAAa,aAAc,SAAQ,YAAY;IACvC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CAuC3B"}
@@ -0,0 +1,9 @@
1
+ import { Transaction } from "@mysten/sui/transactions";
2
+ import { BaseContract } from "../base";
3
+ export declare class MomentumContract extends BaseContract {
4
+ swap(tx: Transaction): Promise<{
5
+ $kind: "NestedResult";
6
+ NestedResult: [number, number];
7
+ }>;
8
+ }
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/momentum/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMvC,qBAAa,gBAAiB,SAAQ,YAAY;IAC1C,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CA4C3B"}
@@ -1,5 +1,6 @@
1
1
  import { Transaction } from "@mysten/sui/transactions";
2
2
  import { BaseContract } from "../base";
3
+ import { ExtraOracle } from "../../../types/aggregator";
3
4
  export type SteamExtra = {
4
5
  bankAStructTag: string;
5
6
  bankBStructTag: string;
@@ -8,8 +9,11 @@ export type SteamExtra = {
8
9
  bankB: string;
9
10
  lendingMarketA: string;
10
11
  lendingMarketB: string;
12
+ oracleRegistry?: string;
13
+ oracles?: ExtraOracle[];
14
+ oracleIndexes?: number[];
11
15
  };
12
- export declare class SteammContract extends BaseContract {
16
+ export declare class SteammContract extends BaseContract<SteamExtra> {
13
17
  swap(tx: Transaction): Promise<{
14
18
  $kind: "NestedResult";
15
19
  NestedResult: [number, number];
@@ -18,9 +22,16 @@ export declare class SteammContract extends BaseContract {
18
22
  $kind: "NestedResult";
19
23
  NestedResult: [number, number];
20
24
  };
21
- cpmmSwapV2(tx: Transaction): {
25
+ ommSwap(tx: Transaction): {
22
26
  $kind: "NestedResult";
23
27
  NestedResult: [number, number];
24
28
  };
29
+ getOraclePriceUpdate(tx: Transaction): readonly [{
30
+ $kind: "NestedResult";
31
+ NestedResult: [number, number];
32
+ }, {
33
+ $kind: "NestedResult";
34
+ NestedResult: [number, number];
35
+ }];
25
36
  }
26
37
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/steamm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQvC,MAAM,MAAM,UAAU,GAAG;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AACF,qBAAa,cAAe,SAAQ,YAAY;IACxC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;IAI1B,QAAQ,CAAC,EAAE,EAAE,WAAW;;;;IAuExB,UAAU,CAAC,EAAE,EAAE,WAAW;;;;CAiI3B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/steamm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQvC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,MAAM,UAAU,GAAG;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B,CAAC;AACF,qBAAa,cAAe,SAAQ,YAAY,CAAC,UAAU,CAAC;IACpD,IAAI,CAAC,EAAE,EAAE,WAAW;;;;IAS1B,QAAQ,CAAC,EAAE,EAAE,WAAW;;;;IAmExB,OAAO,CAAC,EAAE,EAAE,WAAW;;;;IAqEvB,oBAAoB,CAAC,EAAE,EAAE,WAAW;;;;;;;CA8BrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/suiswap/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,qBAAa,eAAgB,SAAQ,YAAY;IACzC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CAgC3B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/suiswap/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,qBAAa,eAAgB,SAAQ,YAAY;IACzC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CA2B3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/turbos/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMvC,qBAAa,cAAe,SAAQ,YAAY;IACxC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CAwC3B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/turbos/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMvC,qBAAa,cAAe,SAAQ,YAAY;IACxC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CA+B3B"}
@@ -1,3 +1,2 @@
1
- import BN from "bn.js";
2
- export declare function getDefaultSqrtPriceLimit(a2b: boolean): BN;
1
+ export declare function getDefaultSqrtPriceLimit(a2b: boolean): bigint;
3
2
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/libs/protocols/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,OAAO,CAAC;AAGvB,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,EAAE,CAEzD"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/libs/protocols/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAE7D"}
@@ -1,11 +1,13 @@
1
1
  import { Transaction } from "@mysten/sui/transactions";
2
2
  import { Config, TxSorSwap } from "../types/aggregator";
3
3
  import { TransactionResultItem } from "../types/sui";
4
- export declare function swapWithRoute({ route, inputCoinObject, currentAccount, config, tx, }: {
4
+ export declare function swapWithRoute({ route, inputCoinObject, currentAccount, config, pythMap, tx, }: {
5
5
  route: TxSorSwap[];
6
6
  inputCoinObject: TransactionResultItem;
7
7
  currentAccount: string;
8
8
  config: Config;
9
+ /** map price feed id to onchain priceInfoObject id */
10
+ pythMap: Record<string, string>;
9
11
  tx: Transaction;
10
12
  }): Promise<TransactionResultItem | undefined>;
11
13
  //# sourceMappingURL=swapWithRoute.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"swapWithRoute.d.ts","sourceRoot":"","sources":["../../../../src/libs/swapWithRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,wBAAsB,aAAa,CAAC,EAClC,KAAK,EACL,eAAe,EACf,cAAc,EACd,MAAM,EACN,EAAE,GACH,EAAE;IACD,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,eAAe,EAAE,qBAAqB,CAAC;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,WAAW,CAAC;CACjB,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAkB7C"}
1
+ {"version":3,"file":"swapWithRoute.d.ts","sourceRoot":"","sources":["../../../../src/libs/swapWithRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,wBAAsB,aAAa,CAAC,EAClC,KAAK,EACL,eAAe,EACf,cAAc,EACd,MAAM,EACN,OAAO,EACP,EAAE,GACH,EAAE;IACD,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,eAAe,EAAE,qBAAqB,CAAC;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,EAAE,EAAE,WAAW,CAAC;CACjB,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAmB7C"}
@@ -1,4 +1,7 @@
1
- export type SourceDex = "suiswap" | "turbos" | "cetus" | "bluemove" | "kriya" | "kriya_v3" | "aftermath" | "deepbook" | "deepbook_v3" | "flowx" | "flowx_v3" | "bluefin" | "springsui" | "obric" | "stsui" | "steamm" | "magma";
1
+ import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
2
+ import { BluefinXTx } from "../libs/protocols/bluefinx/types";
3
+ export { BluefinXTx };
4
+ export type SourceDex = "suiswap" | "turbos" | "cetus" | "bluemove" | "kriya" | "kriya_v3" | "aftermath" | "deepbook_v3" | "flowx" | "flowx_v3" | "bluefin" | "bluefinx" | "springsui" | "obric" | "stsui" | "steamm" | "steamm_oracle_quoter" | "magma" | "haedal_pmm" | "momentum";
2
5
  export type SorSwap = {
3
6
  poolId: string;
4
7
  assetInIndex: number;
@@ -41,6 +44,8 @@ export type QuoteResponse = {
41
44
  swapAmount: string;
42
45
  returnAmount: string;
43
46
  returnAmountWithDecimal: string;
47
+ returnAmountAfterCommission: string;
48
+ returnAmountAfterCommissionWithDecimal: string;
44
49
  returnAmountConsiderGasFees?: string;
45
50
  returnAmountWithoutSwapFees?: string;
46
51
  swapAmountWithDecimal: string;
@@ -83,13 +88,15 @@ export interface Config {
83
88
  bluefin: DexConfig & {
84
89
  globalConfig: string;
85
90
  };
91
+ bluefinx: DexConfig & {
92
+ globalConfig: string;
93
+ };
86
94
  bluemove: DexConfig & {
87
95
  dexInfo: string;
88
96
  };
89
97
  cetus: DexConfig & {
90
98
  globalConfig: string;
91
99
  };
92
- deepbook: DexConfig;
93
100
  deepbook_v3: DexConfig & {
94
101
  sponsor: string;
95
102
  sponsorFund: string;
@@ -116,9 +123,36 @@ export interface Config {
116
123
  };
117
124
  steamm: DexConfig & {
118
125
  script: string;
126
+ oracle: string;
119
127
  };
120
128
  magma: DexConfig & {
121
129
  globalConfig: string;
122
130
  };
131
+ haedal_pmm: DexConfig;
132
+ momentum: DexConfig & {
133
+ version: string;
134
+ };
123
135
  }
136
+ export type ExtraOracle = {
137
+ Pyth?: {
138
+ price_identifier: {
139
+ bytes: number[];
140
+ };
141
+ };
142
+ Switchboard?: {
143
+ object_id: string;
144
+ };
145
+ };
146
+ export type AggregatorTx = Transaction | BluefinXTx;
147
+ export declare const isSuiTransaction: (tx: AggregatorTx) => tx is Transaction;
148
+ /**
149
+ * Check if the sor response is a bluefinx routing
150
+ * @param sor
151
+ * @returns boolean
152
+ */
153
+ export declare const isBluefinXRouting: (sor: QuoteResponse) => boolean;
154
+ export type BuildTxResult = {
155
+ tx: AggregatorTx;
156
+ coinOut?: TransactionObjectArgument;
157
+ };
124
158
  //# sourceMappingURL=aggregator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"aggregator.d.ts","sourceRoot":"","sources":["../../../../src/types/aggregator.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,QAAQ,GACR,OAAO,GACP,UAAU,GACV,OAAO,GACP,UAAU,GACV,WAAW,GACX,UAAU,GACV,aAAa,GACb,OAAO,GACP,UAAU,GACV,SAAS,GACT,WAAW,GACX,OAAO,GACP,OAAO,GACP,QAAQ,GACR,OAAO,CAAC;AAEZ,MAAM,MAAM,OAAO,GAAG;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,GAAG,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAA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EAAE,EAAE,YAAY,CAAC;IACjB,OAAO,CAAC,EAAE,yBAAyB,CAAC;CACrC,CAAC"}
@@ -1,13 +1,12 @@
1
1
  import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
2
2
  import { Commission, QuoteResponse } from "./aggregator";
3
- import BigNumber from "bignumber.js";
4
3
  export interface CommonParams {
5
4
  /** Quote response from 7k api */
6
5
  quoteResponse: QuoteResponse;
7
6
  /** User address */
8
7
  accountAddress: string;
9
8
  /** Slippage tolerance, ex: 0.01 (1%) */
10
- slippage: BigNumber.Value;
9
+ slippage: number | string;
11
10
  /** Commission for partner */
12
11
  commission: Commission;
13
12
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../../../src/types/tx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,MAAM,WAAW,YAAY;IAC3B,iCAAiC;IACjC,aAAa,EAAE,aAAa,CAAC;IAC7B,mBAAmB;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,wCAAwC;IACxC,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC;IAC1B,6BAA6B;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,QAAQ,CAAC,EAAE;QACT,EAAE,EAAE,WAAW,CAAC;QAChB,MAAM,CAAC,EAAE,yBAAyB,CAAC;KACpC,CAAC;IACF;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,gCAAgC;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
1
+ {"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../../../src/types/tx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,WAAW,YAAY;IAC3B,iCAAiC;IACjC,aAAa,EAAE,aAAa,CAAC;IAC7B,mBAAmB;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,wCAAwC;IACxC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,6BAA6B;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,QAAQ,CAAC,EAAE;QACT,EAAE,EAAE,WAAW,CAAC;QAChB,MAAM,CAAC,EAAE,yBAAyB,CAAC;KACpC,CAAC;IACF;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,gCAAgC;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
@@ -1,4 +1,2 @@
1
- import BigNumber from "bignumber.js";
2
- export declare function formatBalance(balance: BigNumber.Value, decimals: number): BigNumber;
3
- export declare function formatRawBalance(balance: BigNumber.Value, decimals: number): BigNumber;
1
+ export declare function formatBalance(balance: bigint, decimals: number): number;
4
2
  //# sourceMappingURL=number.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../../../src/utils/number.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,wBAAgB,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,aAEvE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,aAK1E"}
1
+ {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../../../src/utils/number.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAK9D"}
@@ -49,7 +49,7 @@ export declare const SuiUtils: {
49
49
  $kind: "NestedResult";
50
50
  NestedResult: [number, number];
51
51
  };
52
- transferOrDestroyZeroCoin(tx: Transaction, coinType: string, coin: TransactionArgument, to?: string): void;
52
+ collectDust(tx: Transaction, coinType: string, coin: TransactionArgument): void;
53
53
  };
54
54
  export {};
55
55
  //# sourceMappingURL=sui.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../../../src/utils/sui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACL,UAAU,EAEV,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAK5B,KAAK,QAAQ,CAAC,CAAC,IAAI;IACjB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,KAAK,cAAc,GAAG,KAAK,GAAG,SAAS,CAAC;AAExC,eAAO,MAAM,QAAQ;uBAET,MAAM,GAAG,mBAAmB,OAC/B,WAAW,GACf,mBAAmB;4BAMP,KAAK,CAAC,MAAM,GAAG,mBAAmB,CAAC,OAC3C,WAAW,GACf,mBAAmB,GAAG,SAAS;2BAsBtB,MAAM,cACJ,MAAM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CAAC;AAExC,eAAO,MAAM,QAAQ;uBAET,MAAM,GAAG,mBAAmB,OAC/B,WAAW,GACf,mBAAmB;4BAMP,KAAK,CAAC,MAAM,GAAG,mBAAmB,CAAC,OAC3C,WAAW,GACf,mBAAmB,GAAG,SAAS;2BAsBtB,MAAM,cACJ,MAAM,GAAG,mBAAmB,OACnC,WAAW,GACf,mBAAmB;mCAYV,MAAM,SACT;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,UACtC,MAAM,OACT,WAAW;;;;gCAoBgB,MAAM,iBAAiB,MAAM;qCAoCtD,UAAU,EAAE,YACT,MAAM,OACX,WAAW;uCAsBuB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;sCA8BhE,MAAM,SACP;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE;iCA6BvC,MAAM,SACN,sBAAsB,mBACb,cAAc,GAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;4BAyBD,MAAM;oBAQd,WAAW,YAAY,MAAM;;;;iBAQhC,WAAW,YAAY,MAAM;;;;wBASpC,WAAW,YACL,MAAM,cACJ,mBAAmB;;;;wBAU3B,WAAW,YACL,MAAM,WACP,mBAAmB;;;;oBASd,WAAW,YAAY,MAAM,QAAQ,mBAAmB;CAOzE,CAAC"}
@@ -1,8 +1,6 @@
1
- import BigNumber from "bignumber.js";
2
1
  export function formatBalance(balance, decimals) {
3
- return new BigNumber(balance).dividedBy(new BigNumber(10).pow(decimals));
4
- }
5
- export function formatRawBalance(balance, decimals) {
6
- const rawBalance = new BigNumber(balance).multipliedBy(new BigNumber(10).pow(decimals));
7
- return new BigNumber(rawBalance.toFixed(0));
2
+ const exp = BigInt(Math.pow(10, decimals));
3
+ const whole = balance / exp;
4
+ const remain = balance % exp;
5
+ return Number(whole) + Number(remain) / Number(exp);
8
6
  }
@@ -2,6 +2,7 @@ import { Transaction } from "@mysten/sui/transactions";
2
2
  import { parseStructTag } from "@mysten/sui/utils";
3
3
  import { checkIsSui } from "./token";
4
4
  import { Config } from "../config";
5
+ import { _7K_CONFIG, _7K_PACKAGE_ID, _7K_VAULT } from "../constants/_7k";
5
6
  export const SuiUtils = {
6
7
  getSuiCoin(amount, txb) {
7
8
  const [coin] = txb.splitCoins(txb.gas, [amount]);
@@ -191,11 +192,11 @@ export const SuiUtils = {
191
192
  arguments: [balance],
192
193
  })[0];
193
194
  },
194
- transferOrDestroyZeroCoin(tx, coinType, coin, to) {
195
+ collectDust(tx, coinType, coin) {
195
196
  tx.moveCall({
196
- target: `0x6f5e582ede61fe5395b50c4a449ec11479a54d7ff8e0158247adfda60d98970b::utils::${to ? "send_coin" : "transfer_coin_to_sender"}`,
197
+ target: `${_7K_PACKAGE_ID}::vault::collect_dust`,
197
198
  typeArguments: [coinType],
198
- arguments: [coin, ...(to ? [tx.pure.address(to)] : [])],
199
+ arguments: [tx.object(_7K_VAULT), tx.object(_7K_CONFIG), coin],
199
200
  });
200
201
  },
201
202
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@7kprotocol/sdk-ts",
3
- "version": "2.4.1",
3
+ "version": "2.4.2-beta.0",
4
4
  "description": "",
5
5
  "exports": {
6
6
  ".": {
@@ -43,7 +43,8 @@
43
43
  "test": "mocha --timeout 5000",
44
44
  "publish:patch": "npm version patch --no-git-tag-version && npm publish --access public",
45
45
  "publish:minor": "npm version minor --no-git-tag-version && npm publish --access public",
46
- "publish:major": "npm version major --no-git-tag-version && npm publish --access public"
46
+ "publish:major": "npm version major --no-git-tag-version && npm publish --access public",
47
+ "publish:beta": "npm version prerelease --preid=beta --no-git-tag-version && npm publish --tag beta --access public"
47
48
  },
48
49
  "keywords": [
49
50
  "7k Protocol",
@@ -57,22 +58,20 @@
57
58
  "author": "7k Protocol",
58
59
  "license": "MIT",
59
60
  "devDependencies": {
60
- "@eslint/js": "^9.6.0",
61
- "@types/bn.js": "^5.1.5",
62
- "@types/chai": "^4.3.3",
61
+ "@eslint/js": "^9.26.0",
62
+ "@types/chai": "^5.2.2",
63
63
  "@types/eslint__js": "^8.42.3",
64
- "@types/mocha": "^9.1.1",
65
- "chai": "^4.3.6",
66
- "eslint": "^8.57.0",
67
- "husky": "^9.0.11",
68
- "mocha": "^10.0.0",
64
+ "@types/mocha": "^10.0.10",
65
+ "chai": "^5.2.0",
66
+ "eslint": "^9.26.0",
67
+ "husky": "^9.1.7",
68
+ "mocha": "^11.2.2",
69
69
  "ts-node": "^10.9.2",
70
- "typescript": "^5.5.3",
71
- "typescript-eslint": "^7.15.0"
70
+ "typescript": "^5.8.3",
71
+ "typescript-eslint": "^8.32.0"
72
72
  },
73
73
  "peerDependencies": {
74
- "@mysten/sui": "^1.17.0",
75
- "bignumber.js": "^9.1.2",
76
- "bn.js": "^5.2.1"
74
+ "@mysten/sui": "^1.29.1",
75
+ "@pythnetwork/pyth-sui-js": "^2.1.0"
77
76
  }
78
77
  }
@@ -1,96 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.DeepBookContract = void 0;
13
- const utils_1 = require("@mysten/sui/utils");
14
- const base_1 = require("../base");
15
- const _7k_1 = require("../../../constants/_7k");
16
- const sui_1 = require("../../../utils/sui");
17
- const MODULE_NAME = "clob_v2";
18
- class DeepBookContract extends base_1.BaseContract {
19
- swap(tx) {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- var _a;
22
- const swapXtoY = this.swapInfo.swapXtoY;
23
- const poolId = this.swapInfo.poolId;
24
- const clientOrderId = Date.now();
25
- const typeArgs = this.getTypeParams();
26
- const lotSize = (_a = this.swapInfo.extra) === null || _a === void 0 ? void 0 : _a.lotSize;
27
- const [baseAsset, quoteAsset] = typeArgs;
28
- const accountCap = this.createAccountCap(tx);
29
- const amountIn = this.getInputCoinValue(tx);
30
- const config = this.config.deepbook;
31
- let result;
32
- if (swapXtoY) {
33
- const amountInRound = tx.moveCall({
34
- target: `${_7k_1._7K_PACKAGE_ID}::math::m_round_down`,
35
- arguments: [
36
- amountIn, // input coin value
37
- tx.pure.u64(lotSize), // lot size
38
- ],
39
- });
40
- const [base_coin_ret, quote_coin_ret] = tx.moveCall({
41
- target: `${config.package}::${MODULE_NAME}::swap_exact_base_for_quote`,
42
- typeArguments: [baseAsset, quoteAsset],
43
- arguments: [
44
- tx.object(poolId),
45
- tx.pure.u64(clientOrderId),
46
- accountCap,
47
- amountInRound,
48
- this.inputCoinObject, // coin 0 ~ base
49
- tx.moveCall({
50
- typeArguments: [quoteAsset],
51
- target: `0x2::coin::zero`,
52
- arguments: [],
53
- }), // coin 1 ~ quote
54
- tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
55
- ],
56
- });
57
- this.deleteAccountCap(tx, accountCap);
58
- sui_1.SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, base_coin_ret, this.currentAccount);
59
- result = quote_coin_ret;
60
- }
61
- else {
62
- const [base_coin_ret, quote_coin_ret] = tx.moveCall({
63
- target: `${config.package}::${MODULE_NAME}::swap_exact_quote_for_base`,
64
- typeArguments: [baseAsset, quoteAsset],
65
- arguments: [
66
- tx.object(poolId),
67
- tx.pure.u64(clientOrderId),
68
- accountCap,
69
- amountIn,
70
- tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
71
- this.inputCoinObject, // coin 1 ~ quote
72
- ],
73
- });
74
- this.deleteAccountCap(tx, accountCap);
75
- sui_1.SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, quote_coin_ret, this.currentAccount);
76
- result = base_coin_ret;
77
- }
78
- return result;
79
- });
80
- }
81
- createAccountCap(tx) {
82
- const [cap] = tx.moveCall({
83
- typeArguments: [],
84
- target: `${this.config.deepbook.package}::${MODULE_NAME}::create_account`,
85
- arguments: [],
86
- });
87
- return cap;
88
- }
89
- deleteAccountCap(tx, accountCap) {
90
- tx.moveCall({
91
- target: `${this.config.deepbook.package}::custodian_v2::delete_account_cap`,
92
- arguments: [accountCap],
93
- });
94
- }
95
- }
96
- exports.DeepBookContract = DeepBookContract;
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/deepbook/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMvC,qBAAa,gBAAiB,SAAQ,YAAY;IAC1C,IAAI,CAAC,EAAE,EAAE,WAAW;;;;IAyE1B,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,gBAAgB;CAMzB"}
@@ -1,80 +0,0 @@
1
- import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
2
- import { BaseContract } from "../base";
3
- import { _7K_PACKAGE_ID } from "../../../constants/_7k";
4
- import { SuiUtils } from "../../../utils/sui";
5
- const MODULE_NAME = "clob_v2";
6
- export class DeepBookContract extends BaseContract {
7
- async swap(tx) {
8
- const swapXtoY = this.swapInfo.swapXtoY;
9
- const poolId = this.swapInfo.poolId;
10
- const clientOrderId = Date.now();
11
- const typeArgs = this.getTypeParams();
12
- const lotSize = this.swapInfo.extra?.lotSize;
13
- const [baseAsset, quoteAsset] = typeArgs;
14
- const accountCap = this.createAccountCap(tx);
15
- const amountIn = this.getInputCoinValue(tx);
16
- const config = this.config.deepbook;
17
- let result;
18
- if (swapXtoY) {
19
- const amountInRound = tx.moveCall({
20
- target: `${_7K_PACKAGE_ID}::math::m_round_down`,
21
- arguments: [
22
- amountIn, // input coin value
23
- tx.pure.u64(lotSize), // lot size
24
- ],
25
- });
26
- const [base_coin_ret, quote_coin_ret] = tx.moveCall({
27
- target: `${config.package}::${MODULE_NAME}::swap_exact_base_for_quote`,
28
- typeArguments: [baseAsset, quoteAsset],
29
- arguments: [
30
- tx.object(poolId),
31
- tx.pure.u64(clientOrderId),
32
- accountCap,
33
- amountInRound,
34
- this.inputCoinObject, // coin 0 ~ base
35
- tx.moveCall({
36
- typeArguments: [quoteAsset],
37
- target: `0x2::coin::zero`,
38
- arguments: [],
39
- }), // coin 1 ~ quote
40
- tx.object(SUI_CLOCK_OBJECT_ID),
41
- ],
42
- });
43
- this.deleteAccountCap(tx, accountCap);
44
- SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, base_coin_ret, this.currentAccount);
45
- result = quote_coin_ret;
46
- }
47
- else {
48
- const [base_coin_ret, quote_coin_ret] = tx.moveCall({
49
- target: `${config.package}::${MODULE_NAME}::swap_exact_quote_for_base`,
50
- typeArguments: [baseAsset, quoteAsset],
51
- arguments: [
52
- tx.object(poolId),
53
- tx.pure.u64(clientOrderId),
54
- accountCap,
55
- amountIn,
56
- tx.object(SUI_CLOCK_OBJECT_ID),
57
- this.inputCoinObject, // coin 1 ~ quote
58
- ],
59
- });
60
- this.deleteAccountCap(tx, accountCap);
61
- SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, quote_coin_ret, this.currentAccount);
62
- result = base_coin_ret;
63
- }
64
- return result;
65
- }
66
- createAccountCap(tx) {
67
- const [cap] = tx.moveCall({
68
- typeArguments: [],
69
- target: `${this.config.deepbook.package}::${MODULE_NAME}::create_account`,
70
- arguments: [],
71
- });
72
- return cap;
73
- }
74
- deleteAccountCap(tx, accountCap) {
75
- tx.moveCall({
76
- target: `${this.config.deepbook.package}::custodian_v2::delete_account_cap`,
77
- arguments: [accountCap],
78
- });
79
- }
80
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/deepbook/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMvC,qBAAa,gBAAiB,SAAQ,YAAY;IAC1C,IAAI,CAAC,EAAE,EAAE,WAAW;;;;IAyE1B,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,gBAAgB;CAMzB"}