@paraswap/dex-lib 3.8.13 → 3.8.15

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 (287) hide show
  1. package/.vscode/launch.json +16 -0
  2. package/.vscode/settings.json +3 -0
  3. package/build/abi/Uncompressor.json +250 -0
  4. package/build/abi/concentrator/arUSD5115.json +1746 -0
  5. package/build/abi/fx-protocol/FxMarket.json +1284 -0
  6. package/build/abi/fx-protocol/weETHOralce.json +676 -0
  7. package/build/abi/integral/factory.json +333 -0
  8. package/build/abi/integral/oracle.json +501 -0
  9. package/build/abi/{inception/inception-ineth-pool.json → integral/pool.json} +522 -543
  10. package/build/abi/integral/relayer.json +1536 -0
  11. package/build/abi/maverick-v2/MaverickV2Router.json +778 -0
  12. package/build/dex/aave-v1/aave-v1.d.ts +1 -2
  13. package/build/dex/aave-v1/aave-v1.js +0 -22
  14. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  15. package/build/dex/bProtocol.d.ts +18 -0
  16. package/build/dex/bProtocol.js +39 -0
  17. package/build/dex/bProtocol.js.map +1 -0
  18. package/build/dex/bancor.d.ts +26 -0
  19. package/build/dex/bancor.js +58 -0
  20. package/build/dex/bancor.js.map +1 -0
  21. package/build/dex/compound.d.ts +18 -0
  22. package/build/dex/compound.js +46 -0
  23. package/build/dex/compound.js.map +1 -0
  24. package/build/dex/concentrator-arusd/concentrator-arusd-event.d.ts +17 -0
  25. package/build/dex/concentrator-arusd/concentrator-arusd-event.js +66 -0
  26. package/build/dex/concentrator-arusd/concentrator-arusd-event.js.map +1 -0
  27. package/build/dex/concentrator-arusd/concentrator-arusd.d.ts +6 -3
  28. package/build/dex/concentrator-arusd/concentrator-arusd.js +45 -41
  29. package/build/dex/concentrator-arusd/concentrator-arusd.js.map +1 -1
  30. package/build/dex/concentrator-arusd/config.d.ts +1 -2
  31. package/build/dex/concentrator-arusd/config.js +2 -6
  32. package/build/dex/concentrator-arusd/config.js.map +1 -1
  33. package/build/dex/concentrator-arusd/types.d.ts +7 -3
  34. package/build/dex/concentrator-arusd/utils.d.ts +4 -0
  35. package/build/dex/concentrator-arusd/utils.js +27 -0
  36. package/build/dex/concentrator-arusd/utils.js.map +1 -0
  37. package/build/dex/curve-v2.d.ts +58 -0
  38. package/build/dex/curve-v2.js +180 -0
  39. package/build/dex/curve-v2.js.map +1 -0
  40. package/build/dex/dodo-v1.d.ts +33 -0
  41. package/build/dex/dodo-v1.js +63 -0
  42. package/build/dex/dodo-v1.js.map +1 -0
  43. package/build/dex/etherfi/etherfi.d.ts +26 -0
  44. package/build/dex/etherfi/etherfi.js +96 -0
  45. package/build/dex/etherfi/etherfi.js.map +1 -0
  46. package/build/dex/fx-protocol-rusd/config.d.ts +1 -2
  47. package/build/dex/fx-protocol-rusd/config.js +3 -6
  48. package/build/dex/fx-protocol-rusd/config.js.map +1 -1
  49. package/build/dex/fx-protocol-rusd/fx-protocol-rusd-event.d.ts +18 -0
  50. package/build/dex/fx-protocol-rusd/fx-protocol-rusd-event.js +71 -0
  51. package/build/dex/fx-protocol-rusd/fx-protocol-rusd-event.js.map +1 -0
  52. package/build/dex/fx-protocol-rusd/fx-protocol-rusd.d.ts +10 -10
  53. package/build/dex/fx-protocol-rusd/fx-protocol-rusd.js +75 -70
  54. package/build/dex/fx-protocol-rusd/fx-protocol-rusd.js.map +1 -1
  55. package/build/dex/fx-protocol-rusd/types.d.ts +6 -3
  56. package/build/dex/fx-protocol-rusd/utils.d.ts +4 -0
  57. package/build/dex/fx-protocol-rusd/utils.js +26 -0
  58. package/build/dex/fx-protocol-rusd/utils.js.map +1 -0
  59. package/build/dex/index.js +4 -0
  60. package/build/dex/index.js.map +1 -1
  61. package/build/dex/{infusion → integral}/config.d.ts +1 -1
  62. package/build/dex/integral/config.js +20 -0
  63. package/build/dex/integral/config.js.map +1 -0
  64. package/build/dex/integral/context.d.ts +40 -0
  65. package/build/dex/integral/context.js +158 -0
  66. package/build/dex/integral/context.js.map +1 -0
  67. package/build/dex/integral/helpers.d.ts +17 -0
  68. package/build/dex/integral/helpers.js +157 -0
  69. package/build/dex/integral/helpers.js.map +1 -0
  70. package/build/dex/integral/integral-factory.d.ts +24 -0
  71. package/build/dex/integral/integral-factory.js +95 -0
  72. package/build/dex/integral/integral-factory.js.map +1 -0
  73. package/build/dex/integral/integral-pool.d.ts +50 -0
  74. package/build/dex/integral/integral-pool.js +149 -0
  75. package/build/dex/integral/integral-pool.js.map +1 -0
  76. package/build/dex/integral/integral-pricing.d.ts +18 -0
  77. package/build/dex/integral/integral-pricing.js +114 -0
  78. package/build/dex/integral/integral-pricing.js.map +1 -0
  79. package/build/dex/integral/integral-relayer.d.ts +42 -0
  80. package/build/dex/integral/integral-relayer.js +192 -0
  81. package/build/dex/integral/integral-relayer.js.map +1 -0
  82. package/build/dex/integral/integral-token.d.ts +27 -0
  83. package/build/dex/integral/integral-token.js +59 -0
  84. package/build/dex/integral/integral-token.js.map +1 -0
  85. package/build/dex/{inception/inception-native.d.ts → integral/integral.d.ts} +19 -21
  86. package/build/dex/integral/integral.js +377 -0
  87. package/build/dex/integral/integral.js.map +1 -0
  88. package/build/dex/integral/types.d.ts +84 -0
  89. package/build/dex/integral/types.js +9 -0
  90. package/build/dex/integral/types.js.map +1 -0
  91. package/build/dex/integral/utils-e2e.d.ts +9 -0
  92. package/build/dex/integral/utils-e2e.js +131 -0
  93. package/build/dex/integral/utils-e2e.js.map +1 -0
  94. package/build/dex/integral/utils.d.ts +17 -0
  95. package/build/dex/integral/utils.js +94 -0
  96. package/build/dex/integral/utils.js.map +1 -0
  97. package/build/dex/lido.d.ts +19 -0
  98. package/build/dex/lido.js +42 -0
  99. package/build/dex/lido.js.map +1 -0
  100. package/build/dex/onebit.d.ts +25 -0
  101. package/build/dex/onebit.js +42 -0
  102. package/build/dex/onebit.js.map +1 -0
  103. package/build/dex/oswap/oswap.js +4 -1
  104. package/build/dex/oswap/oswap.js.map +1 -1
  105. package/build/dex/platypus/platypus.d.ts +1 -2
  106. package/build/dex/platypus/platypus.js +0 -31
  107. package/build/dex/platypus/platypus.js.map +1 -1
  108. package/build/dex/sdai/config.d.ts +11 -0
  109. package/build/dex/sdai/config.js +21 -0
  110. package/build/dex/sdai/config.js.map +1 -0
  111. package/build/dex/sdai/constants.d.ts +2 -0
  112. package/build/dex/sdai/constants.js +6 -0
  113. package/build/dex/sdai/constants.js.map +1 -0
  114. package/build/dex/sdai/scripts/validate-state.d.ts +1 -0
  115. package/build/dex/sdai/scripts/validate-state.js +102 -0
  116. package/build/dex/sdai/scripts/validate-state.js.map +1 -0
  117. package/build/dex/sdai/sdai-pool.d.ts +16 -0
  118. package/build/dex/sdai/sdai-pool.js +85 -0
  119. package/build/dex/sdai/sdai-pool.js.map +1 -0
  120. package/build/dex/sdai/sdai.d.ts +51 -0
  121. package/build/dex/sdai/sdai.js +172 -0
  122. package/build/dex/sdai/sdai.js.map +1 -0
  123. package/build/dex/sdai/types.d.ts +21 -0
  124. package/build/dex/sdai/types.js +11 -0
  125. package/build/dex/sdai/types.js.map +1 -0
  126. package/build/dex/sdai/utils.d.ts +4 -0
  127. package/build/dex/sdai/utils.js +39 -0
  128. package/build/dex/sdai/utils.js.map +1 -0
  129. package/build/dex/smoothy.d.ts +26 -0
  130. package/build/dex/smoothy.js +48 -0
  131. package/build/dex/smoothy.js.map +1 -0
  132. package/build/dex/stable-pool.d.ts +28 -0
  133. package/build/dex/stable-pool.js +62 -0
  134. package/build/dex/stable-pool.js.map +1 -0
  135. package/build/dex/swaap-v1/swaap-v1.d.ts +1 -2
  136. package/build/dex/swaap-v1/swaap-v1.js +0 -10
  137. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  138. package/build/dex/trader-joe-v2.1.d.ts +43 -0
  139. package/build/dex/trader-joe-v2.1.js +79 -0
  140. package/build/dex/trader-joe-v2.1.js.map +1 -0
  141. package/build/executor/Executor01BytecodeBuilder.js +4 -5
  142. package/build/executor/Executor01BytecodeBuilder.js.map +1 -1
  143. package/build/executor/Executor02BytecodeBuilder.js +2 -3
  144. package/build/executor/Executor02BytecodeBuilder.js.map +1 -1
  145. package/build/executor/Executor03BytecodeBuilder.js +24 -14
  146. package/build/executor/Executor03BytecodeBuilder.js.map +1 -1
  147. package/build/executor/compressor/Compressor.d.ts +23 -0
  148. package/build/executor/compressor/Compressor.js +144 -0
  149. package/build/executor/compressor/Compressor.js.map +1 -0
  150. package/build/executor/compressor/compress.d.ts +17 -0
  151. package/build/executor/compressor/compress.js +187 -0
  152. package/build/executor/compressor/compress.js.map +1 -0
  153. package/build/executor/compressor/compress_functions/addressSubstitution.d.ts +6 -0
  154. package/build/executor/compressor/compress_functions/addressSubstitution.js +29 -0
  155. package/build/executor/compressor/compress_functions/addressSubstitution.js.map +1 -0
  156. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.d.ts +10 -0
  157. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js +40 -0
  158. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js.map +1 -0
  159. package/build/executor/compressor/compress_functions/byteSubstitution.d.ts +11 -0
  160. package/build/executor/compressor/compress_functions/byteSubstitution.js +64 -0
  161. package/build/executor/compressor/compress_functions/byteSubstitution.js.map +1 -0
  162. package/build/executor/compressor/compress_functions/ffSubstitution.d.ts +7 -0
  163. package/build/executor/compressor/compress_functions/ffSubstitution.js +54 -0
  164. package/build/executor/compressor/compress_functions/ffSubstitution.js.map +1 -0
  165. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.d.ts +8 -0
  166. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js +67 -0
  167. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js.map +1 -0
  168. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.d.ts +8 -0
  169. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js +61 -0
  170. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js.map +1 -0
  171. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.d.ts +6 -0
  172. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js +37 -0
  173. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js.map +1 -0
  174. package/build/executor/compressor/compress_functions/searchUnusedBytes.d.ts +9 -0
  175. package/build/executor/compressor/compress_functions/searchUnusedBytes.js +33 -0
  176. package/build/executor/compressor/compress_functions/searchUnusedBytes.js.map +1 -0
  177. package/build/executor/compressor/fetchSaved.d.ts +0 -0
  178. package/build/executor/compressor/fetchSaved.js +17 -0
  179. package/build/executor/compressor/fetchSaved.js.map +1 -0
  180. package/build/executor/compressor/utils/computeCostL2.d.ts +2 -0
  181. package/build/executor/compressor/utils/computeCostL2.js +14 -0
  182. package/build/executor/compressor/utils/computeCostL2.js.map +1 -0
  183. package/build/executor/compressor/utils/findLongestDuplicatedString.d.ts +2 -0
  184. package/build/executor/compressor/utils/findLongestDuplicatedString.js +30 -0
  185. package/build/executor/compressor/utils/findLongestDuplicatedString.js.map +1 -0
  186. package/build/executor/compressor/utils/getAllIndexes.d.ts +2 -0
  187. package/build/executor/compressor/utils/getAllIndexes.js +12 -0
  188. package/build/executor/compressor/utils/getAllIndexes.js.map +1 -0
  189. package/build/executor/compressor/utils/getByteForAddress.d.ts +2 -0
  190. package/build/executor/compressor/utils/getByteForAddress.js +14 -0
  191. package/build/executor/compressor/utils/getByteForAddress.js.map +1 -0
  192. package/build/executor/compressor/utils/intTo2Bytes.d.ts +2 -0
  193. package/build/executor/compressor/utils/intTo2Bytes.js +14 -0
  194. package/build/executor/compressor/utils/intTo2Bytes.js.map +1 -0
  195. package/build/executor/compressor/utils/intTo3Bytes.d.ts +2 -0
  196. package/build/executor/compressor/utils/intTo3Bytes.js +18 -0
  197. package/build/executor/compressor/utils/intTo3Bytes.js.map +1 -0
  198. package/build/executor/compressor/utils/intToByte.d.ts +2 -0
  199. package/build/executor/compressor/utils/intToByte.js +10 -0
  200. package/build/executor/compressor/utils/intToByte.js.map +1 -0
  201. package/build/generic-swap-transaction-builder.d.ts +1 -1
  202. package/build/generic-swap-transaction-builder.js +10 -10
  203. package/build/generic-swap-transaction-builder.js.map +1 -1
  204. package/package.json +1 -1
  205. package/src/abi/concentrator/arUSD.json +568 -0
  206. package/src/abi/concentrator/arUSD5115.json +1746 -0
  207. package/src/abi/fx-protocol/FxMarket.json +1284 -0
  208. package/src/abi/fx-protocol/FxUSD.json +1227 -0
  209. package/src/abi/fx-protocol/weETHOralce.json +676 -0
  210. package/src/dex/concentrator-arusd/concentrator-arusd-e2e.test.ts +92 -0
  211. package/src/dex/concentrator-arusd/concentrator-arusd-event.ts +100 -0
  212. package/src/dex/concentrator-arusd/concentrator-arusd-integration.test.ts +104 -0
  213. package/src/dex/concentrator-arusd/concentrator-arusd.ts +269 -0
  214. package/src/dex/concentrator-arusd/concetrator-arusd-events.test.ts +97 -0
  215. package/src/dex/concentrator-arusd/config.ts +13 -0
  216. package/src/dex/concentrator-arusd/types.ts +16 -0
  217. package/src/dex/concentrator-arusd/utils.ts +36 -0
  218. package/src/dex/fx-protocol-rusd/config.ts +14 -0
  219. package/src/dex/fx-protocol-rusd/fx-protocol-e2e.test.ts +96 -0
  220. package/src/dex/fx-protocol-rusd/fx-protocol-events.test.ts +101 -0
  221. package/src/dex/fx-protocol-rusd/fx-protocol-integration.test.ts +104 -0
  222. package/src/dex/fx-protocol-rusd/fx-protocol-rusd-event.ts +112 -0
  223. package/src/dex/fx-protocol-rusd/fx-protocol-rusd.ts +282 -0
  224. package/src/dex/fx-protocol-rusd/types.ts +16 -0
  225. package/src/dex/fx-protocol-rusd/utils.ts +47 -0
  226. package/src/dex/index.ts +4 -0
  227. package/src/dex/wsteth/wsteth-integration.test.ts +0 -1
  228. package/src/executor/Executor01BytecodeBuilder.ts +4 -8
  229. package/src/executor/Executor02BytecodeBuilder.ts +2 -7
  230. package/src/executor/Executor03BytecodeBuilder.ts +34 -19
  231. package/src/generic-swap-transaction-builder.ts +3 -5
  232. package/tests/constants-e2e.ts +10 -0
  233. package/build/abi/inception/inception-ineth.json +0 -609
  234. package/build/abi/inception/inception-ratio-feed.json +0 -93
  235. package/build/abi/inception/inception-vault.json +0 -991
  236. package/build/abi/infusion/InfusionFactory.json +0 -147
  237. package/build/abi/infusion/InfusionPair.json +0 -658
  238. package/build/abi/infusion/InfusionRouter.json +0 -442
  239. package/build/dex/idle-dao/idle-dao-pool.d.ts +0 -56
  240. package/build/dex/idle-dao/idle-dao-pool.js +0 -176
  241. package/build/dex/idle-dao/idle-dao-pool.js.map +0 -1
  242. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +0 -16
  243. package/build/dex/idle-dao/idle-dao-pooling-pool.js +0 -57
  244. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +0 -1
  245. package/build/dex/idle-dao/scripts.d.ts +0 -9
  246. package/build/dex/idle-dao/scripts.js +0 -552
  247. package/build/dex/idle-dao/scripts.js.map +0 -1
  248. package/build/dex/inception/config.d.ts +0 -5
  249. package/build/dex/inception/config.js +0 -112
  250. package/build/dex/inception/config.js.map +0 -1
  251. package/build/dex/inception/inception-event-pool.d.ts +0 -23
  252. package/build/dex/inception/inception-event-pool.js +0 -34
  253. package/build/dex/inception/inception-event-pool.js.map +0 -1
  254. package/build/dex/inception/inception-native.js +0 -131
  255. package/build/dex/inception/inception-native.js.map +0 -1
  256. package/build/dex/inception/inception-pool.d.ts +0 -18
  257. package/build/dex/inception/inception-pool.js +0 -32
  258. package/build/dex/inception/inception-pool.js.map +0 -1
  259. package/build/dex/inception/inception-price-feed.d.ts +0 -19
  260. package/build/dex/inception/inception-price-feed.js +0 -51
  261. package/build/dex/inception/inception-price-feed.js.map +0 -1
  262. package/build/dex/inception/inception.d.ts +0 -44
  263. package/build/dex/inception/inception.js +0 -162
  264. package/build/dex/inception/inception.js.map +0 -1
  265. package/build/dex/inception/tokens.d.ts +0 -9
  266. package/build/dex/inception/tokens.js +0 -28
  267. package/build/dex/inception/tokens.js.map +0 -1
  268. package/build/dex/inception/types.d.ts +0 -22
  269. package/build/dex/inception/types.js +0 -3
  270. package/build/dex/inception/types.js.map +0 -1
  271. package/build/dex/inception/utils.d.ts +0 -7
  272. package/build/dex/inception/utils.js +0 -58
  273. package/build/dex/inception/utils.js.map +0 -1
  274. package/build/dex/infusion/config.js +0 -25
  275. package/build/dex/infusion/config.js.map +0 -1
  276. package/build/dex/infusion/infusion-stable-pool.d.ts +0 -4
  277. package/build/dex/infusion/infusion-stable-pool.js +0 -74
  278. package/build/dex/infusion/infusion-stable-pool.js.map +0 -1
  279. package/build/dex/infusion/infusion.d.ts +0 -54
  280. package/build/dex/infusion/infusion.js +0 -532
  281. package/build/dex/infusion/infusion.js.map +0 -1
  282. package/build/dex/infusion/types.d.ts +0 -47
  283. package/build/dex/infusion/types.js +0 -3
  284. package/build/dex/infusion/types.js.map +0 -1
  285. package/build/dex/infusion/utils/isStablePair.d.ts +0 -2
  286. package/build/dex/infusion/utils/isStablePair.js +0 -18
  287. package/build/dex/infusion/utils/isStablePair.js.map +0 -1
@@ -1,162 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.Inception = void 0;
30
- const abi_1 = require("@ethersproject/abi");
31
- const inception_vault_json_1 = __importDefault(require("../../abi/inception/inception-vault.json"));
32
- const inception_ineth_pool_json_1 = __importDefault(require("../../abi/inception/inception-ineth-pool.json"));
33
- const constants_1 = require("../../constants");
34
- const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
35
- const utils_1 = require("../../utils");
36
- const simple_exchange_1 = require("../simple-exchange");
37
- const config_1 = require("./config");
38
- const tokens_1 = require("./tokens");
39
- const utils_2 = require("./utils");
40
- const inception_event_pool_1 = require("./inception-event-pool");
41
- const DECIMALS = BigInt(1e18);
42
- class Inception extends simple_exchange_1.SimpleExchange {
43
- constructor(network, dexKey, dexHelper, config = config_1.InceptionConfig[dexKey][network], adapters = config_1.Adapters[network] || {}) {
44
- super(dexHelper, dexKey);
45
- this.network = network;
46
- this.dexKey = dexKey;
47
- this.dexHelper = dexHelper;
48
- this.config = config;
49
- this.adapters = adapters;
50
- this.hasConstantPriceLargeAmounts = false;
51
- this.needWrapNative = false;
52
- this.isFeeOnTransferSupported = false;
53
- this.logger = dexHelper.getLogger(dexKey);
54
- this.vaultInterface = new abi_1.Interface(inception_vault_json_1.default);
55
- this.poolInterface = new abi_1.Interface(inception_ineth_pool_json_1.default);
56
- this.eventPool = new inception_event_pool_1.InceptionEventPool(dexKey, network, dexHelper, this.logger, {
57
- ratioFeedAddress: config_1.InceptionPricePoolConfig[dexKey][network].ratioFeed,
58
- initState: {},
59
- }, this.poolInterface);
60
- }
61
- async initializePricing(blockNumber) {
62
- const poolState = await (0, utils_2.getOnChainState)(this.dexHelper.multiContract, this.vaultInterface, this.network, blockNumber);
63
- await this.eventPool.initialize(blockNumber, {
64
- state: poolState,
65
- });
66
- await this.initializeTokens();
67
- }
68
- async initializeTokens() {
69
- let tokenList = await (0, utils_2.getTokenList)(this.network);
70
- (0, tokens_1.setTokensOnNetwork)(this.network, tokenList);
71
- }
72
- getAdapters(side) {
73
- return null;
74
- }
75
- async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
76
- return [
77
- this.dexKey +
78
- '-' +
79
- [srcToken.address.toLowerCase(), destToken.address.toLowerCase()]
80
- .sort((a, b) => (a > b ? 1 : -1))
81
- .join('_'),
82
- ];
83
- }
84
- async getPoolState(pool, blockNumber) {
85
- const eventState = pool.getState(blockNumber);
86
- if (eventState)
87
- return eventState;
88
- const onChainState = await pool.generateState(blockNumber);
89
- pool.setState(onChainState, blockNumber);
90
- return onChainState;
91
- }
92
- async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
93
- const src = (0, tokens_1.getTokenFromAddress)(this.network, srcToken.address);
94
- const dest = (0, tokens_1.getTokenFromAddress)(this.network, destToken.address);
95
- if (src !== dest) {
96
- return null;
97
- }
98
- const poolState = await this.getPoolState(this.eventPool, blockNumber);
99
- if (!poolState)
100
- return null;
101
- return [
102
- {
103
- prices: amounts.map(amount => {
104
- const ratio = poolState[src.symbol.toLowerCase()].ratio;
105
- return (ratio * amount) / DECIMALS;
106
- }),
107
- unit: DECIMALS,
108
- gasCost: 120000,
109
- exchange: this.dexKey,
110
- data: {
111
- exchange: dest.vault,
112
- },
113
- poolAddresses: [src.token.toLowerCase()],
114
- },
115
- ];
116
- }
117
- getCalldataGasCost(poolPrices) {
118
- return CALLDATA_GAS_COST.DEX_OVERHEAD + CALLDATA_GAS_COST.LENGTH_SMALL;
119
- }
120
- getAdapterParam() {
121
- return {
122
- targetExchange: constants_1.NULL_ADDRESS,
123
- payload: '0x',
124
- networkFee: '0',
125
- };
126
- }
127
- getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side) {
128
- const dexParams = (0, tokens_1.getTokenFromAddress)(this.network, srcToken);
129
- const isNative = dexParams.baseTokenSlug === 'ETH';
130
- let swapData;
131
- let dexFuncHasRecipient;
132
- if (isNative) {
133
- swapData = this.poolInterface.encodeFunctionData('stake()', []);
134
- dexFuncHasRecipient = false;
135
- }
136
- else {
137
- swapData = this.vaultInterface.encodeFunctionData('deposit', [
138
- srcAmount,
139
- recipient,
140
- ]);
141
- dexFuncHasRecipient = true;
142
- }
143
- return {
144
- needWrapNative: false,
145
- dexFuncHasRecipient,
146
- exchangeData: swapData,
147
- targetExchange: dexParams.vault,
148
- swappedAmountNotPresentInExchangeData: true,
149
- returnAmountPos: undefined,
150
- };
151
- }
152
- async updatePoolState() { }
153
- async getTopPoolsForToken(tokenAddress, limit) {
154
- await this.initializeTokens();
155
- // TODO: Implement
156
- return [];
157
- }
158
- releaseResources() { }
159
- }
160
- exports.Inception = Inception;
161
- Inception.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.InceptionConfig);
162
- //# sourceMappingURL=inception.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"inception.js","sourceRoot":"","sources":["../../../src/dex/inception/inception.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA6D;AAa7D,oGAAqE;AACrE,8GAA+E;AAC/E,+CAAwD;AACxD,2EAA6D;AAC7D,uCAA2D;AAI3D,wDAAoD;AACpD,qCAA+E;AAC/E,qCAA2E;AAC3E,mCAAwD;AACxD,iEAA4D;AAE5D,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;AAE9B,MAAa,SACX,SAAQ,gCAAc;IAiBtB,YACW,OAAgB,EAChB,MAAc,EACd,SAAqB,EACpB,SAAS,wBAAe,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EACzC,WAAW,iBAAQ,CAAC,OAAO,CAAC,IAAI,EAAE;QAE5C,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QANhB,YAAO,GAAP,OAAO,CAAS;QAChB,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAY;QAC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,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,SAAS,EAAE;gBAC3D,SAAS;gBACT,SAAS;aACV,CAAC,CAAC;YACH,mBAAmB,GAAG,IAAI,CAAC;SAC5B;QAED,OAAO;YACL,cAAc,EAAE,KAAK;YACrB,mBAAmB;YACnB,YAAY,EAAE,QAAQ;YACtB,cAAc,EAAE,SAAS,CAAC,KAAK;YAC/B,qCAAqC,EAAE,IAAI;YAC3C,eAAe,EAAE,SAAS;SAC3B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,eAAe,KAAmB,CAAC;IAEzC,KAAK,CAAC,mBAAmB,CACvB,YAAqB,EACrB,KAAa;QAEb,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC9B,kBAAkB;QAClB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,gBAAgB,KAAuB,CAAC;;AA3L1C,8BA4LC;AAjLe,4BAAkB,GAC9B,IAAA,6BAAqB,EAAC,wBAAe,CAAC,CAAC"}
@@ -1,9 +0,0 @@
1
- import { Network } from '../../constants';
2
- import { DexParams } from './types';
3
- export declare const Tokens: {
4
- [network: number]: {
5
- [symbol: string]: DexParams;
6
- };
7
- };
8
- export declare function setTokensOnNetwork(network: Network, tokens: DexParams[]): void;
9
- export declare function getTokenFromAddress(network: Network, address: string): DexParams;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTokenFromAddress = exports.setTokensOnNetwork = exports.Tokens = void 0;
4
- exports.Tokens = {};
5
- const TokensByAddress = {};
6
- function setTokensOnNetwork(network, tokens) {
7
- if (exports.Tokens[network] === undefined) {
8
- exports.Tokens[network] = {};
9
- }
10
- if (TokensByAddress[network] === undefined) {
11
- TokensByAddress[network] = {};
12
- }
13
- for (let token of tokens) {
14
- token.vault = token.vault.toLowerCase();
15
- token.token = token.token.toLowerCase();
16
- token.baseToken = token.baseToken.toLowerCase();
17
- exports.Tokens[network][token.symbol] = token;
18
- TokensByAddress[network][token.vault] = token;
19
- TokensByAddress[network][token.token] = token;
20
- TokensByAddress[network][token.baseToken] = token;
21
- }
22
- }
23
- exports.setTokensOnNetwork = setTokensOnNetwork;
24
- function getTokenFromAddress(network, address) {
25
- return TokensByAddress[network]?.[address.toLowerCase()];
26
- }
27
- exports.getTokenFromAddress = getTokenFromAddress;
28
- //# sourceMappingURL=tokens.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/dex/inception/tokens.ts"],"names":[],"mappings":";;;AAGa,QAAA,MAAM,GACjB,EAAE,CAAC;AAEL,MAAM,eAAe,GAEjB,EAAE,CAAC;AAEP,SAAgB,kBAAkB,CAAC,OAAgB,EAAE,MAAmB;IACtE,IAAI,cAAM,CAAC,OAAO,CAAC,KAAK,SAAS,EAAE;QACjC,cAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;KACtB;IAED,IAAI,eAAe,CAAC,OAAO,CAAC,KAAK,SAAS,EAAE;QAC1C,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;KAC/B;IAED,KAAK,IAAI,KAAK,IAAI,MAAM,EAAE;QACxB,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QACxC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QACxC,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;QAEhD,cAAM,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;QACtC,eAAe,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;QAC9C,eAAe,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;QAC9C,eAAe,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC;KACnD;AACH,CAAC;AAnBD,gDAmBC;AAED,SAAgB,mBAAmB,CACjC,OAAgB,EAChB,OAAe;IAEf,OAAO,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;AAC3D,CAAC;AALD,kDAKC"}
@@ -1,22 +0,0 @@
1
- export declare type PoolState = {
2
- [symbol: string]: {
3
- ratio: bigint;
4
- };
5
- };
6
- export declare type PoolConfig = {
7
- ratioFeedAddress: string;
8
- initState: PoolState;
9
- };
10
- export declare type InceptionDexData = {
11
- exchange: string;
12
- };
13
- export declare type DexParams = {
14
- symbol: string;
15
- vault: string;
16
- token: string;
17
- baseToken: string;
18
- baseTokenSlug: string;
19
- };
20
- export declare type PricePoolParams = {
21
- ratioFeed: string;
22
- };
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/inception/types.ts"],"names":[],"mappings":""}
@@ -1,7 +0,0 @@
1
- import { Contract } from 'web3-eth-contract';
2
- import { DexParams, PoolState } from './types';
3
- import { Interface } from '@ethersproject/abi';
4
- import { Network } from '../../constants';
5
- export declare function getOnChainRatio(multiContract: Contract, poolInterface: Interface, network: Network, p: DexParams, blockNumber: number | 'latest'): Promise<bigint>;
6
- export declare function getOnChainState(multiContract: Contract, poolInterface: Interface, network: Network, blockNumber: number | 'latest'): Promise<PoolState>;
7
- export declare const getTokenList: (network: Network) => Promise<DexParams[]>;
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTokenList = exports.getOnChainState = exports.getOnChainRatio = void 0;
4
- const abi_1 = require("@ethersproject/abi");
5
- const config_1 = require("./config");
6
- const coder = new abi_1.AbiCoder();
7
- async function getOnChainRatio(multiContract, poolInterface, network, p, blockNumber) {
8
- let addr;
9
- if (p.baseTokenSlug === 'ETH') {
10
- addr = p.token;
11
- }
12
- else {
13
- addr = p.vault;
14
- }
15
- const data = await multiContract.methods
16
- .aggregate([
17
- {
18
- target: addr,
19
- callData: poolInterface.encodeFunctionData('ratio', []),
20
- },
21
- ])
22
- .call({}, blockNumber);
23
- const decodedData = coder.decode(['uint256'], data.returnData[0]);
24
- const ratio = BigInt(decodedData[0].toString());
25
- return ratio;
26
- }
27
- exports.getOnChainRatio = getOnChainRatio;
28
- async function getOnChainState(multiContract, poolInterface, network, blockNumber) {
29
- let tokenList = await (0, exports.getTokenList)(network);
30
- const state = {};
31
- for (const p of tokenList) {
32
- let addr;
33
- if (p.baseTokenSlug === 'ETH') {
34
- addr = p.token;
35
- }
36
- else {
37
- addr = p.vault;
38
- }
39
- const data = await multiContract.methods
40
- .aggregate([
41
- {
42
- target: addr,
43
- callData: poolInterface.encodeFunctionData('ratio', []),
44
- },
45
- ])
46
- .call({}, blockNumber);
47
- const decodedData = coder.decode(['uint256'], data.returnData[0]);
48
- const ratio = BigInt(decodedData[0].toString());
49
- state[p.symbol.toLowerCase()] = { ratio };
50
- }
51
- return state;
52
- }
53
- exports.getOnChainState = getOnChainState;
54
- const getTokenList = async (network) => {
55
- return config_1.InceptionConfig['InceptionLRT'][network];
56
- };
57
- exports.getTokenList = getTokenList;
58
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/dex/inception/utils.ts"],"names":[],"mappings":";;;AAEA,4CAAyD;AACzD,qCAA2C;AAG3C,MAAM,KAAK,GAAG,IAAI,cAAQ,EAAE,CAAC;AAEtB,KAAK,UAAU,eAAe,CACnC,aAAuB,EACvB,aAAwB,EACxB,OAAgB,EAChB,CAAY,EACZ,WAA8B;IAE9B,IAAI,IAAI,CAAC;IACT,IAAI,CAAC,CAAC,aAAa,KAAK,KAAK,EAAE;QAC7B,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC;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C,SAAS,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAClE,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QAChD,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC;KAC3C;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AA/BD,0CA+BC;AAEM,MAAM,YAAY,GAAG,KAAK,EAAE,OAAgB,EAAwB,EAAE;IAC3E,OAAO,wBAAe,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC;AAClD,CAAC,CAAC;AAFW,QAAA,YAAY,gBAEvB"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Adapters = exports.InfusionConfig = void 0;
4
- const constants_1 = require("../../constants");
5
- exports.InfusionConfig = {
6
- Infusion: {
7
- [constants_1.Network.BASE]: {
8
- subgraphURL: 'https://api.goldsky.com/api/public/project_clvn0ei0x2qro0130fpihh83o/subgraphs/infusion-subgraph/1.0.0/gn',
9
- factoryAddress: '0x2D9A3a2bd6400eE28d770c7254cA840c82faf23f',
10
- router: '0x1E891C9F96DcA29Da8B97bE3403D16135EBe8028',
11
- initCode: '0xc1ac28b1c4ebe53c0cff67bab5878c4eb68759bb1e9f73977cd266b247d149f0',
12
- // updatable fees on the factory without event
13
- stableFee: 2,
14
- volatileFee: 2,
15
- poolGasCost: 180 * 1000,
16
- feeCode: 2,
17
- },
18
- },
19
- };
20
- exports.Adapters = {
21
- [constants_1.Network.BASE]: {
22
- [constants_1.SwapSide.SELL]: [{ name: 'BaseAdapter01', index: 6 }], // velodrome
23
- },
24
- };
25
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/infusion/config.ts"],"names":[],"mappings":";;;AAEA,+CAAoD;AAEvC,QAAA,cAAc,GAA4B;IACrD,QAAQ,EAAE;QACR,CAAC,mBAAO,CAAC,IAAI,CAAC,EAAE;YACd,WAAW,EACT,2GAA2G;YAC7G,cAAc,EAAE,4CAA4C;YAC5D,MAAM,EAAE,4CAA4C;YACpD,QAAQ,EACN,oEAAoE;YACtE,8CAA8C;YAC9C,SAAS,EAAE,CAAC;YACZ,WAAW,EAAE,CAAC;YACd,WAAW,EAAE,GAAG,GAAG,IAAI;YACvB,OAAO,EAAE,CAAC;SACX;KACF;CACF,CAAC;AAEW,QAAA,QAAQ,GAAoC;IACvD,CAAC,mBAAO,CAAC,IAAI,CAAC,EAAE;QACd,CAAC,oBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,YAAY;KACrE;CACF,CAAC"}
@@ -1,4 +0,0 @@
1
- import { InfusionPoolOrderedParams } from './types';
2
- export declare class InfusionStablePool {
3
- static getSellPrice(priceParams: InfusionPoolOrderedParams, srcAmount: bigint, feeFactor: number): Promise<bigint>;
4
- }
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InfusionStablePool = void 0;
4
- const bigint_constants_1 = require("../../bigint-constants");
5
- const uniswap_v2_1 = require("../uniswap-v2/uniswap-v2");
6
- const e18 = bigint_constants_1.BI_POWS[18];
7
- function _k(x, y, decimals0, decimals1) {
8
- const _x = (x * e18) / decimals0;
9
- const _y = (y * e18) / decimals1;
10
- const _a = (_x * _y) / e18;
11
- const _b = (_x * _x) / e18 + (_y * _y) / e18;
12
- // x3y+y3x >= k
13
- return (_a * _b) / e18;
14
- }
15
- function _f(x0, y) {
16
- return ((x0 * ((((y * y) / e18) * y) / e18)) / e18 +
17
- (((((x0 * x0) / e18) * x0) / e18) * y) / e18);
18
- }
19
- function _d(x0, y) {
20
- return (3n * x0 * ((y * y) / e18)) / e18 + (((x0 * x0) / e18) * x0) / e18;
21
- }
22
- function _getY(x0, xy, y) {
23
- for (let i = 0; i < 255; i++) {
24
- const yPrev = y;
25
- const k = _f(x0, y);
26
- if (k < xy) {
27
- const dy = ((xy - k) * e18) / _d(x0, y);
28
- y = y + dy;
29
- }
30
- else {
31
- const dy = ((k - xy) * e18) / _d(x0, y);
32
- y = y - dy;
33
- }
34
- if (_closeTo(y, yPrev, 1n)) {
35
- break;
36
- }
37
- }
38
- return y;
39
- }
40
- function _closeTo(a, b, target) {
41
- if (a > b) {
42
- if (a - b <= target) {
43
- return true;
44
- }
45
- }
46
- else {
47
- if (b - a <= target) {
48
- return true;
49
- }
50
- }
51
- return false;
52
- }
53
- class InfusionStablePool {
54
- static async getSellPrice(priceParams, srcAmount, feeFactor) {
55
- const { reservesIn, reservesOut, decimalsIn, decimalsOut, fee } = priceParams;
56
- // FIXME: some dexes use uint112 others use uint256
57
- if (BigInt(reservesIn) + srcAmount > uniswap_v2_1.RESERVE_LIMIT) {
58
- return 0n;
59
- }
60
- const amountIn = srcAmount - (srcAmount * BigInt(fee)) / BigInt(feeFactor);
61
- const reservesInN = BigInt(reservesIn);
62
- const reservesOutN = BigInt(reservesOut);
63
- const decimalsInN = 10n ** BigInt(decimalsIn);
64
- const decimalsOutN = 10n ** BigInt(decimalsOut);
65
- const xy = _k(reservesInN, reservesOutN, decimalsInN, decimalsOutN);
66
- const reserveA = (reservesInN * e18) / decimalsInN;
67
- const reserveB = (reservesOutN * e18) / decimalsOutN;
68
- const amountInNorm = (amountIn * e18) / decimalsInN;
69
- const y = reserveB - _getY(amountInNorm + reserveA, xy, reserveB);
70
- return (y * decimalsOutN) / e18;
71
- }
72
- }
73
- exports.InfusionStablePool = InfusionStablePool;
74
- //# sourceMappingURL=infusion-stable-pool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"infusion-stable-pool.js","sourceRoot":"","sources":["../../../src/dex/infusion/infusion-stable-pool.ts"],"names":[],"mappings":";;;AAAA,6DAAiD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I,MAAM,CAAC,UAAU,CAAC,GAAG,SAAS,GAAG,0BAAa,EAAE;YAClD,OAAO,EAAE,CAAC;SACX;QAED,MAAM,QAAQ,GAAG,SAAS,GAAG,CAAC,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;QAE3E,MAAM,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QACvC,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QACzC,MAAM,WAAW,GAAG,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC;QAC9C,MAAM,YAAY,GAAG,GAAG,IAAI,MAAM,CAAC,WAAW,CAAC,CAAC;QAEhD,MAAM,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;QACpE,MAAM,QAAQ,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC,GAAG,WAAW,CAAC;QACnD,MAAM,QAAQ,GAAG,CAAC,YAAY,GAAG,GAAG,CAAC,GAAG,YAAY,CAAC;QACrD,MAAM,YAAY,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,GAAG,WAAW,CAAC;QACpD,MAAM,CAAC,GAAG,QAAQ,GAAG,KAAK,CAAC,YAAY,GAAG,QAAQ,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;QAClE,OAAO,CAAC,CAAC,GAAG,YAAY,CAAC,GAAG,GAAG,CAAC;IAClC,CAAC;CACF;AA5BD,gDA4BC"}
@@ -1,54 +0,0 @@
1
- import { UniswapV2 } from '../uniswap-v2/uniswap-v2';
2
- import { Network } from '../../constants';
3
- import { AdapterExchangeParam, Address, DexExchangeParam, ExchangePrices, PoolLiquidity, SimpleExchangeParam, Token, TransferFeeParams } from '../../types';
4
- import { IDexHelper } from '../../dex-helper';
5
- import { UniswapData, UniswapV2Data } from '../uniswap-v2/types';
6
- import { NumberAsString, SwapSide } from '@paraswap/core';
7
- import { PoolState, InfusionData, InfusionPair, InfusionPoolOrderedParams } from './types';
8
- export declare enum InfusionRouterFunctions {
9
- sellExactEth = "swapExactETHForTokens",
10
- sellExactToken = "swapExactTokensForETH",
11
- swapExactIn = "swapExactTokensForTokens"
12
- }
13
- export interface SmardexData extends Omit<UniswapV2Data, 'feeFactor'> {
14
- deadline: number;
15
- receiver: Address;
16
- }
17
- export declare class Infusion extends UniswapV2 {
18
- protected network: Network;
19
- protected dexHelper: IDexHelper;
20
- pairs: {
21
- [key: string]: InfusionPair;
22
- };
23
- stableFee?: number;
24
- volatileFee?: number;
25
- readonly isFeeOnTransferSupported: boolean;
26
- readonly SRC_TOKEN_DEX_TRANSFERS = 1;
27
- readonly DEST_TOKEN_DEX_TRANSFERS = 1;
28
- static dexKeysWithNetwork: {
29
- key: string;
30
- networks: Network[];
31
- }[];
32
- constructor(network: Network, dexKey: string, dexHelper: IDexHelper, isDynamicFees?: boolean, factoryAddress?: Address, subgraphURL?: string, initCode?: string, feeCode?: number, poolGasCost?: number, routerAddress?: Address);
33
- findInfusionPair(from: Token, to: Token, stable: boolean): Promise<InfusionPair | null>;
34
- batchCatchUpPairs(pairs: [Token, Token][], blockNumber: number): Promise<void>;
35
- getManyPoolReserves(pairs: InfusionPair[], blockNumber: number): Promise<PoolState[]>;
36
- getSellPrice(priceParams: InfusionPoolOrderedParams, srcAmount: bigint): Promise<bigint>;
37
- getBuyPrice(priceParams: InfusionPoolOrderedParams, srcAmount: bigint): Promise<bigint>;
38
- getPricesVolume(_from: Token, _to: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[], transferFees?: TransferFeeParams): Promise<ExchangePrices<UniswapV2Data> | null>;
39
- getTopPoolsForToken(tokenAddress: Address, count: number): Promise<PoolLiquidity[]>;
40
- getInfusionPairOrderedParams(from: Token, to: Token, blockNumber: number, stable: boolean, tokenDexTransferFee: number): Promise<InfusionPoolOrderedParams | null>;
41
- getPoolIdentifiers(_from: Token, _to: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
42
- poolPostfix(stable: boolean): "S" | "V";
43
- getSimpleParam(src: Address, dest: Address, srcAmount: NumberAsString, destAmount: NumberAsString, data: UniswapData, side: SwapSide): Promise<SimpleExchangeParam>;
44
- getAdapterParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, toAmount: NumberAsString, // required for buy case
45
- data: InfusionData, side: SwapSide): AdapterExchangeParam;
46
- getDexParam(src: Address, dest: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: InfusionData, side: SwapSide): DexExchangeParam;
47
- protected getFeesMultiCallData(pair: InfusionPair): {
48
- callEntry: {
49
- target: string;
50
- callData: string;
51
- };
52
- callDecoder: (values: any[]) => number;
53
- };
54
- }