@7kprotocol/sdk-ts 2.4.0 → 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 (207) 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 +1 -1
  74. package/lib/cjs/types/libs/getSplitCoinForTx.d.ts.map +1 -1
  75. package/lib/cjs/types/libs/groupSwapRoutes.d.ts.map +1 -1
  76. package/lib/cjs/types/libs/protocols/base.d.ts +6 -2
  77. package/lib/cjs/types/libs/protocols/base.d.ts.map +1 -1
  78. package/lib/cjs/types/libs/protocols/bluefin/index.d.ts.map +1 -1
  79. package/lib/cjs/types/libs/protocols/bluefinx/client.d.ts +13 -0
  80. package/lib/cjs/types/libs/protocols/bluefinx/client.d.ts.map +1 -0
  81. package/lib/cjs/types/libs/protocols/bluefinx/index.d.ts +17 -0
  82. package/lib/cjs/types/libs/protocols/bluefinx/index.d.ts.map +1 -0
  83. package/lib/cjs/types/libs/protocols/bluefinx/types.d.ts +34 -0
  84. package/lib/cjs/types/libs/protocols/bluefinx/types.d.ts.map +1 -0
  85. package/lib/cjs/types/libs/protocols/cetus/index.d.ts.map +1 -1
  86. package/lib/cjs/types/libs/protocols/deepbookV3/sponsored.d.ts.map +1 -1
  87. package/lib/cjs/types/libs/protocols/flowxV3/index.d.ts.map +1 -1
  88. package/lib/{esm/types/libs/protocols/deepbook → cjs/types/libs/protocols/haedal_pmm}/index.d.ts +1 -3
  89. package/lib/cjs/types/libs/protocols/haedal_pmm/index.d.ts.map +1 -0
  90. package/lib/cjs/types/libs/protocols/index.d.ts +7 -2
  91. package/lib/cjs/types/libs/protocols/index.d.ts.map +1 -1
  92. package/lib/cjs/types/libs/protocols/magma/index.d.ts.map +1 -1
  93. package/lib/cjs/types/libs/protocols/{deepbook → momentum}/index.d.ts +1 -3
  94. package/lib/cjs/types/libs/protocols/momentum/index.d.ts.map +1 -0
  95. package/lib/cjs/types/libs/protocols/steamm/index.d.ts +13 -2
  96. package/lib/cjs/types/libs/protocols/steamm/index.d.ts.map +1 -1
  97. package/lib/cjs/types/libs/protocols/suiswap/index.d.ts.map +1 -1
  98. package/lib/cjs/types/libs/protocols/turbos/index.d.ts.map +1 -1
  99. package/lib/cjs/types/libs/protocols/utils.d.ts +1 -2
  100. package/lib/cjs/types/libs/protocols/utils.d.ts.map +1 -1
  101. package/lib/cjs/types/libs/swapWithRoute.d.ts +3 -1
  102. package/lib/cjs/types/libs/swapWithRoute.d.ts.map +1 -1
  103. package/lib/cjs/types/types/aggregator.d.ts +36 -2
  104. package/lib/cjs/types/types/aggregator.d.ts.map +1 -1
  105. package/lib/cjs/types/types/tx.d.ts +36 -2
  106. package/lib/cjs/types/types/tx.d.ts.map +1 -1
  107. package/lib/cjs/types/utils/number.d.ts +1 -3
  108. package/lib/cjs/types/utils/number.d.ts.map +1 -1
  109. package/lib/cjs/types/utils/sui.d.ts +1 -1
  110. package/lib/cjs/types/utils/sui.d.ts.map +1 -1
  111. package/lib/cjs/utils/number.js +4 -10
  112. package/lib/cjs/utils/sui.js +71 -80
  113. package/lib/esm/config/index.js +22 -0
  114. package/lib/esm/constants/_7k.js +6 -3
  115. package/lib/esm/features/limitDca/constants.js +1 -2
  116. package/lib/esm/features/swap/buildTx.js +81 -20
  117. package/lib/esm/features/swap/config.js +19 -8
  118. package/lib/esm/features/swap/estimateGasFee.js +13 -9
  119. package/lib/esm/features/swap/executeTx.js +48 -0
  120. package/lib/esm/features/swap/getQuote.js +24 -3
  121. package/lib/esm/features/swap/index.js +1 -0
  122. package/lib/esm/index.mjs +8 -4
  123. package/lib/esm/libs/getCoinOjectIdsByAmount.js +7 -7
  124. package/lib/esm/libs/getSplitCoinForTx.js +5 -3
  125. package/lib/esm/libs/groupSwapRoutes.js +1 -2
  126. package/lib/esm/libs/protocols/base.js +10 -1
  127. package/lib/esm/libs/protocols/bluefin/index.js +2 -5
  128. package/lib/esm/libs/protocols/bluefinx/client.js +30 -0
  129. package/lib/esm/libs/protocols/bluefinx/index.js +44 -0
  130. package/lib/esm/libs/protocols/bluefinx/types.js +8 -0
  131. package/lib/esm/libs/protocols/cetus/index.js +1 -1
  132. package/lib/esm/libs/protocols/deepbookV3/sponsored.js +1 -1
  133. package/lib/esm/libs/protocols/flowxV3/index.js +1 -4
  134. package/lib/esm/libs/protocols/haedal_pmm/index.js +29 -0
  135. package/lib/esm/libs/protocols/index.js +7 -2
  136. package/lib/esm/libs/protocols/magma/index.js +1 -2
  137. package/lib/esm/libs/protocols/momentum/index.js +45 -0
  138. package/lib/esm/libs/protocols/steamm/index.js +58 -48
  139. package/lib/esm/libs/protocols/suiswap/index.js +1 -1
  140. package/lib/esm/libs/protocols/turbos/index.js +2 -6
  141. package/lib/esm/libs/protocols/utils.js +1 -2
  142. package/lib/esm/libs/swapWithRoute.js +2 -1
  143. package/lib/esm/types/aggregator.js +14 -1
  144. package/lib/esm/types/config/index.d.ts +9 -0
  145. package/lib/esm/types/config/index.d.ts.map +1 -1
  146. package/lib/esm/types/constants/_7k.d.ts +3 -3
  147. package/lib/esm/types/constants/_7k.d.ts.map +1 -1
  148. package/lib/esm/types/features/limitDca/constants.d.ts +1 -2
  149. package/lib/esm/types/features/limitDca/constants.d.ts.map +1 -1
  150. package/lib/esm/types/features/swap/buildTx.d.ts +2 -5
  151. package/lib/esm/types/features/swap/buildTx.d.ts.map +1 -1
  152. package/lib/esm/types/features/swap/config.d.ts.map +1 -1
  153. package/lib/esm/types/features/swap/estimateGasFee.d.ts.map +1 -1
  154. package/lib/esm/types/features/swap/executeTx.d.ts +24 -0
  155. package/lib/esm/types/features/swap/executeTx.d.ts.map +1 -0
  156. package/lib/esm/types/features/swap/getQuote.d.ts +8 -1
  157. package/lib/esm/types/features/swap/getQuote.d.ts.map +1 -1
  158. package/lib/esm/types/features/swap/index.d.ts +1 -0
  159. package/lib/esm/types/features/swap/index.d.ts.map +1 -1
  160. package/lib/esm/types/index.d.ts +13 -8
  161. package/lib/esm/types/index.d.ts.map +1 -1
  162. package/lib/esm/types/libs/getCoinOjectIdsByAmount.d.ts.map +1 -1
  163. package/lib/esm/types/libs/getSplitCoinForTx.d.ts +1 -1
  164. package/lib/esm/types/libs/getSplitCoinForTx.d.ts.map +1 -1
  165. package/lib/esm/types/libs/groupSwapRoutes.d.ts.map +1 -1
  166. package/lib/esm/types/libs/protocols/base.d.ts +6 -2
  167. package/lib/esm/types/libs/protocols/base.d.ts.map +1 -1
  168. package/lib/esm/types/libs/protocols/bluefin/index.d.ts.map +1 -1
  169. package/lib/esm/types/libs/protocols/bluefinx/client.d.ts +13 -0
  170. package/lib/esm/types/libs/protocols/bluefinx/client.d.ts.map +1 -0
  171. package/lib/esm/types/libs/protocols/bluefinx/index.d.ts +17 -0
  172. package/lib/esm/types/libs/protocols/bluefinx/index.d.ts.map +1 -0
  173. package/lib/esm/types/libs/protocols/bluefinx/types.d.ts +34 -0
  174. package/lib/esm/types/libs/protocols/bluefinx/types.d.ts.map +1 -0
  175. package/lib/esm/types/libs/protocols/cetus/index.d.ts.map +1 -1
  176. package/lib/esm/types/libs/protocols/deepbookV3/sponsored.d.ts.map +1 -1
  177. package/lib/esm/types/libs/protocols/flowxV3/index.d.ts.map +1 -1
  178. package/lib/esm/types/libs/protocols/haedal_pmm/index.d.ts +9 -0
  179. package/lib/esm/types/libs/protocols/haedal_pmm/index.d.ts.map +1 -0
  180. package/lib/esm/types/libs/protocols/index.d.ts +7 -2
  181. package/lib/esm/types/libs/protocols/index.d.ts.map +1 -1
  182. package/lib/esm/types/libs/protocols/magma/index.d.ts.map +1 -1
  183. package/lib/esm/types/libs/protocols/momentum/index.d.ts +9 -0
  184. package/lib/esm/types/libs/protocols/momentum/index.d.ts.map +1 -0
  185. package/lib/esm/types/libs/protocols/steamm/index.d.ts +13 -2
  186. package/lib/esm/types/libs/protocols/steamm/index.d.ts.map +1 -1
  187. package/lib/esm/types/libs/protocols/suiswap/index.d.ts.map +1 -1
  188. package/lib/esm/types/libs/protocols/turbos/index.d.ts.map +1 -1
  189. package/lib/esm/types/libs/protocols/utils.d.ts +1 -2
  190. package/lib/esm/types/libs/protocols/utils.d.ts.map +1 -1
  191. package/lib/esm/types/libs/swapWithRoute.d.ts +3 -1
  192. package/lib/esm/types/libs/swapWithRoute.d.ts.map +1 -1
  193. package/lib/esm/types/types/aggregator.d.ts +36 -2
  194. package/lib/esm/types/types/aggregator.d.ts.map +1 -1
  195. package/lib/esm/types/types/tx.d.ts +36 -2
  196. package/lib/esm/types/types/tx.d.ts.map +1 -1
  197. package/lib/esm/types/utils/number.d.ts +1 -3
  198. package/lib/esm/types/utils/number.d.ts.map +1 -1
  199. package/lib/esm/types/utils/sui.d.ts +1 -1
  200. package/lib/esm/types/utils/sui.d.ts.map +1 -1
  201. package/lib/esm/utils/number.js +4 -6
  202. package/lib/esm/utils/sui.js +4 -3
  203. package/package.json +14 -15
  204. package/lib/cjs/libs/protocols/deepbook/index.js +0 -96
  205. package/lib/cjs/types/libs/protocols/deepbook/index.d.ts.map +0 -1
  206. package/lib/esm/libs/protocols/deepbook/index.js +0 -80
  207. package/lib/esm/types/libs/protocols/deepbook/index.d.ts.map +0 -1
@@ -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,G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C,UAAU,EAAE,SAAS,CAAC;IACtB,QAAQ,EAAE,SAAS,GAAG;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3C;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE;QAAE,gBAAgB,EAAE;YAAE,KAAK,EAAE,MAAM,EAAE,CAAA;SAAE,CAAA;KAAE,CAAC;IACjD,WAAW,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,UAAU,CAAC;AAEpD,eAAO,MAAM,gBAAgB,GAAI,IAAI,YAAY,KAAG,EAAE,IAAI,WAC/B,CAAC;AAE5B;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,aAAa,YAMnD,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,YAAY,CAAC;IACjB,OAAO,CAAC,EAAE,yBAAyB,CAAC;CACrC,CAAC"}
@@ -1,20 +1,54 @@
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 {
4
+ /** Quote response from 7k api */
5
5
  quoteResponse: QuoteResponse;
6
+ /** User address */
6
7
  accountAddress: string;
7
- slippage: BigNumber.Value;
8
+ /** Slippage tolerance, ex: 0.01 (1%) */
9
+ slippage: number | string;
10
+ /** Commission for partner */
8
11
  commission: Commission;
12
+ /**
13
+ * Give Flexibility to insert custom commands before or after swap
14
+ * @example
15
+ * ```typescript
16
+ * const rawTx = new Transaction();
17
+ * // Add custom commands to rawTx
18
+ * rawTx.moveCall({
19
+ * target: "0x2222222::example::claim",
20
+ * arguments: [],
21
+ * });
22
+ * const { tx, coinOut } = await buildTx({
23
+ * quoteResponse,
24
+ * accountAddress,
25
+ * slippage,
26
+ * commission,
27
+ * extendTx: {
28
+ * tx: rawTx,
29
+ * coinIn: rawTx.object(coinObjectId),
30
+ * },
31
+ * });
32
+ * // add more commands after the swap if needed, and remember to consume the coinOut object
33
+ * tx.transferObjects([coinOut], tx.pure.address(accountAddress));
34
+ * ```
35
+ */
9
36
  extendTx?: {
10
37
  tx: Transaction;
11
38
  coinIn?: TransactionObjectArgument;
12
39
  };
40
+ /**
41
+ * If true, indicates that the transaction is sponsored and its gas object should not be modified.
42
+ * In this case, the gas object is expected to be already set up correctly for the sponsored transaction.
43
+ */
44
+ isSponsored?: boolean;
13
45
  }
14
46
  export interface BuildTxParams extends CommonParams {
47
+ /** Developer inspection mode */
15
48
  devInspect?: boolean;
16
49
  }
17
50
  export interface EstimateGasFeeParams extends CommonParams {
51
+ /** Sui price in usd for gas estimation */
18
52
  suiPrice?: number;
19
53
  }
20
54
  //# sourceMappingURL=tx.d.ts.map
@@ -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,aAAa,EAAE,aAAa,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC;IAC1B,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,CAAC,EAAE;QACT,EAAE,EAAE,WAAW,CAAC;QAChB,MAAM,CAAC,EAAE,yBAAyB,CAAC;KACpC,CAAC;CACH;AAED,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,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,GAAG,mBAAmB,OACnC,WAAW,GACf,mBAAmB;mCAYV,MAA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AAmB,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,15 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.formatBalance = formatBalance;
7
- exports.formatRawBalance = formatRawBalance;
8
- const bignumber_js_1 = __importDefault(require("bignumber.js"));
9
4
  function formatBalance(balance, decimals) {
10
- return new bignumber_js_1.default(balance).dividedBy(new bignumber_js_1.default(10).pow(decimals));
11
- }
12
- function formatRawBalance(balance, decimals) {
13
- const rawBalance = new bignumber_js_1.default(balance).multipliedBy(new bignumber_js_1.default(10).pow(decimals));
14
- return new bignumber_js_1.default(rawBalance.toFixed(0));
5
+ const exp = BigInt(Math.pow(10, decimals));
6
+ const whole = balance / exp;
7
+ const remain = balance % exp;
8
+ return Number(whole) + Number(remain) / Number(exp);
15
9
  }
@@ -1,19 +1,11 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.SuiUtils = void 0;
13
4
  const transactions_1 = require("@mysten/sui/transactions");
14
5
  const utils_1 = require("@mysten/sui/utils");
15
6
  const token_1 = require("./token");
16
7
  const config_1 = require("../config");
8
+ const _7k_1 = require("../constants/_7k");
17
9
  exports.SuiUtils = {
18
10
  getSuiCoin(amount, txb) {
19
11
  const [coin] = txb.splitCoins(txb.gas, [amount]);
@@ -59,32 +51,30 @@ exports.SuiUtils = {
59
51
  return coinA;
60
52
  }
61
53
  },
62
- mergeAllUserCoins(coinType, signerAddress) {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- try {
65
- const coins = yield exports.SuiUtils.getAllUserCoins({
66
- address: signerAddress,
67
- type: coinType,
68
- });
69
- let totalBalance = BigInt(0);
70
- coins.forEach((coin) => {
71
- totalBalance += BigInt(coin.balance);
72
- });
73
- const txb = new transactions_1.Transaction();
74
- if ((0, token_1.checkIsSui)(coinType)) {
75
- totalBalance = totalBalance - BigInt("1000");
76
- txb.splitCoins(txb.gas, [totalBalance]);
77
- }
78
- const coinObjectsIds = coins.map((coin) => coin.coinObjectId);
79
- if (coins.length > 1) {
80
- txb.mergeCoins(txb.object(coinObjectsIds[0]), coinObjectsIds.slice(1).map((coin) => txb.object(coin)));
81
- }
82
- return txb;
54
+ async mergeAllUserCoins(coinType, signerAddress) {
55
+ try {
56
+ const coins = await exports.SuiUtils.getAllUserCoins({
57
+ address: signerAddress,
58
+ type: coinType,
59
+ });
60
+ let totalBalance = BigInt(0);
61
+ coins.forEach((coin) => {
62
+ totalBalance += BigInt(coin.balance);
63
+ });
64
+ const txb = new transactions_1.Transaction();
65
+ if ((0, token_1.checkIsSui)(coinType)) {
66
+ totalBalance = totalBalance - BigInt("1000");
67
+ txb.splitCoins(txb.gas, [totalBalance]);
83
68
  }
84
- catch (error) {
85
- console.log(error);
69
+ const coinObjectsIds = coins.map((coin) => coin.coinObjectId);
70
+ if (coins.length > 1) {
71
+ txb.mergeCoins(txb.object(coinObjectsIds[0]), coinObjectsIds.slice(1).map((coin) => txb.object(coin)));
86
72
  }
87
- });
73
+ return txb;
74
+ }
75
+ catch (error) {
76
+ console.log(error);
77
+ }
88
78
  },
89
79
  mergeAllCoinsWithoutFetch(coins, coinType, txb) {
90
80
  let totalBalance = BigInt(0);
@@ -100,33 +90,31 @@ exports.SuiUtils = {
100
90
  txb.mergeCoins(txb.object(coinObjectsIds[0]), coinObjectsIds.slice(1).map((coin) => txb.object(coin)));
101
91
  }
102
92
  },
103
- getAllUserCoins(_a) {
104
- return __awaiter(this, arguments, void 0, function* ({ address, type }) {
105
- let cursor = undefined;
106
- let coins = [];
107
- let iter = 0;
108
- do {
109
- try {
110
- const res = yield config_1.Config.getSuiClient().getCoins({
111
- owner: address,
112
- coinType: type,
113
- cursor: cursor,
114
- limit: 50,
115
- });
116
- coins = coins.concat(res.data);
117
- cursor = res.nextCursor;
118
- if (!res.hasNextPage || iter === 8) {
119
- cursor = null;
120
- }
121
- }
122
- catch (error) {
123
- console.log(error);
93
+ async getAllUserCoins({ address, type }) {
94
+ let cursor = undefined;
95
+ let coins = [];
96
+ let iter = 0;
97
+ do {
98
+ try {
99
+ const res = await config_1.Config.getSuiClient().getCoins({
100
+ owner: address,
101
+ coinType: type,
102
+ cursor: cursor,
103
+ limit: 50,
104
+ });
105
+ coins = coins.concat(res.data);
106
+ cursor = res.nextCursor;
107
+ if (!res.hasNextPage || iter === 8) {
124
108
  cursor = null;
125
109
  }
126
- iter++;
127
- } while (cursor !== null);
128
- return coins;
129
- });
110
+ }
111
+ catch (error) {
112
+ console.log(error);
113
+ cursor = null;
114
+ }
115
+ iter++;
116
+ } while (cursor !== null);
117
+ return coins;
130
118
  },
131
119
  getCoinsGreaterThanAmount(amount, coins) {
132
120
  const coinsWithBalance = [];
@@ -148,25 +136,28 @@ exports.SuiUtils = {
148
136
  throw new Error("Insufficient balance");
149
137
  }
150
138
  },
151
- getOwnedObjectsByPage(owner_1, query_1) {
152
- return __awaiter(this, arguments, void 0, function* (owner, query, paginationArgs = "all") {
153
- let result = [];
154
- let hasNextPage = true;
155
- const queryAll = paginationArgs === "all";
156
- let nextCursor = queryAll ? null : paginationArgs.cursor;
157
- do {
158
- const res = yield config_1.Config.getSuiClient().getOwnedObjects(Object.assign(Object.assign({ owner }, query), { cursor: nextCursor, limit: queryAll ? null : paginationArgs.limit }));
159
- if (res.data) {
160
- result = [...result, ...res.data];
161
- hasNextPage = res.hasNextPage;
162
- nextCursor = res.nextCursor;
163
- }
164
- else {
165
- hasNextPage = false;
166
- }
167
- } while (queryAll && hasNextPage);
168
- return { data: result, nextCursor, hasNextPage };
169
- });
139
+ async getOwnedObjectsByPage(owner, query, paginationArgs = "all") {
140
+ let result = [];
141
+ let hasNextPage = true;
142
+ const queryAll = paginationArgs === "all";
143
+ let nextCursor = queryAll ? null : paginationArgs.cursor;
144
+ do {
145
+ const res = await config_1.Config.getSuiClient().getOwnedObjects({
146
+ owner,
147
+ ...query,
148
+ cursor: nextCursor,
149
+ limit: queryAll ? null : paginationArgs.limit,
150
+ });
151
+ if (res.data) {
152
+ result = [...result, ...res.data];
153
+ hasNextPage = res.hasNextPage;
154
+ nextCursor = res.nextCursor;
155
+ }
156
+ else {
157
+ hasNextPage = false;
158
+ }
159
+ } while (queryAll && hasNextPage);
160
+ return { data: result, nextCursor, hasNextPage };
170
161
  },
171
162
  isValidStructTag(value) {
172
163
  try {
@@ -204,11 +195,11 @@ exports.SuiUtils = {
204
195
  arguments: [balance],
205
196
  })[0];
206
197
  },
207
- transferOrDestroyZeroCoin(tx, coinType, coin, to) {
198
+ collectDust(tx, coinType, coin) {
208
199
  tx.moveCall({
209
- target: `0x6f5e582ede61fe5395b50c4a449ec11479a54d7ff8e0158247adfda60d98970b::utils::${to ? "send_coin" : "transfer_coin_to_sender"}`,
200
+ target: `${_7k_1._7K_PACKAGE_ID}::vault::collect_dust`,
210
201
  typeArguments: [coinType],
211
- arguments: [coin, ...(to ? [tx.pure.address(to)] : [])],
202
+ arguments: [tx.object(_7k_1._7K_VAULT), tx.object(_7k_1._7K_CONFIG), coin],
212
203
  });
213
204
  },
214
205
  };
@@ -1,8 +1,14 @@
1
1
  import { SuiClient, getFullnodeUrl } from "@mysten/sui/client";
2
+ import { SuiPriceServiceConnection, SuiPythClient, } from "@pythnetwork/pyth-sui-js";
3
+ const HERMES_API = "https://hermes.pyth.network";
4
+ const WORMHOLE_STATE_ID = "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c";
5
+ const PYTH_STATE_ID = "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8";
2
6
  let apiKey = "";
3
7
  let suiClient = new SuiClient({
4
8
  url: getFullnodeUrl("mainnet"),
5
9
  });
10
+ let pythClient = new SuiPythClient(suiClient, PYTH_STATE_ID, WORMHOLE_STATE_ID);
11
+ let pythConnection = new SuiPriceServiceConnection(HERMES_API);
6
12
  function setApiKey(key) {
7
13
  apiKey = key;
8
14
  }
@@ -15,10 +21,26 @@ function getSuiClient() {
15
21
  function setSuiClient(client) {
16
22
  suiClient = client;
17
23
  }
24
+ function setPythClient(client) {
25
+ pythClient = client;
26
+ }
27
+ function getPythClient() {
28
+ return pythClient;
29
+ }
30
+ function setPythConnection(connection) {
31
+ pythConnection = connection;
32
+ }
33
+ function getPythConnection() {
34
+ return pythConnection;
35
+ }
18
36
  const Config = {
19
37
  setApiKey,
20
38
  getApiKey,
21
39
  setSuiClient,
22
40
  getSuiClient,
41
+ setPythClient,
42
+ getPythClient,
43
+ setPythConnection,
44
+ getPythConnection,
23
45
  };
24
46
  export { Config };
@@ -1,5 +1,8 @@
1
- export const _7K_PACKAGE_ID = "0x7ea6e27ad7af6f3b8671d59df1aaebd7c03dddab893e52a714227b2f4fe91519";
1
+ export const _7K_PACKAGE_ID = "0xe8f996ea6ff38c557c253d3b93cfe2ebf393816487266786371aa4532a9229f2";
2
+ //legacy V3: "0x7ea6e27ad7af6f3b8671d59df1aaebd7c03dddab893e52a714227b2f4fe91519";
2
3
  //legacy V2: "0xa13447019cd982d6bef91cf7b46ad384a52583b1dfc2bdecf31ef0c4bd787a0f";
3
4
  //legacy V1: "0xd48e7cdc9e92bec69ce3baa75578010458a0c5b2733d661a84971e8cef6806bc";
4
- export const _7K_CONFIG = "0x0f8fc23dbcc9362b72c7a4c5aa53fcefa02ebfbb83a812c8c262ccd2c076d9ee";
5
- export const _7K_VAULT = "0x39a3c55742c0e011b6f65548e73cf589e1ae5e82dbfab449ca57f24c3bcd9514";
5
+ export const _7K_CONFIG = "0x47442a93f7727d188ba7cb71031170d1786af70013cb7ad5115f3fe877ff0c54";
6
+ //legacy v3: "0x0f8fc23dbcc9362b72c7a4c5aa53fcefa02ebfbb83a812c8c262ccd2c076d9ee";
7
+ export const _7K_VAULT = "0x442ad50389ed5cda6f7a6f5a7ae6361a4c05ef1d9fb2e54fbba5a268d690bfe6";
8
+ //legacy v3: "0x39a3c55742c0e011b6f65548e73cf589e1ae5e82dbfab449ca57f24c3bcd9514";
@@ -1,4 +1,3 @@
1
- import BigNumber from "bignumber.js";
2
1
  import { API_ENDPOINTS } from "../../constants/apiEndpoints";
3
2
  export const GLOBAL_CONFIG_ID = "0xffc7f420b481ed7a012b42e125fd7e5716b5673759cf4629e5fcfebce970a72d";
4
3
  export const RATE_SCALE = BigInt("1000000000000");
@@ -7,5 +6,5 @@ export const PACKAGE = "0x0ef0f805710cf53c10f29c4f73e1144a662747e1839689a846e252
7
6
  export const LIMIT_ORDER_MODULE_ID = `${PACKAGE}::limit_order`;
8
7
  export const DCA_ORDER_MODULE_ID = `${PACKAGE}::dca_order`;
9
8
  export const CONFIG_MODULE_ID = `${PACKAGE}::config`;
10
- export const DCA_MAX_RATE = new BigNumber("18446744073709551615");
9
+ export const DCA_MAX_RATE = BigInt("18446744073709551615");
11
10
  export const LO_DCA_API = `${API_ENDPOINTS.LO_DCA}/api`;