@paraswap/dex-lib 2.41.4 → 2.42.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 (225) hide show
  1. package/.idea/aws.xml +17 -0
  2. package/.idea/codeStyles/Project.xml +19 -0
  3. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  4. package/.idea/misc.xml +6 -0
  5. package/.idea/modules.xml +8 -0
  6. package/.idea/paraswap-dex-lib.iml +9 -0
  7. package/.idea/vcs.xml +6 -0
  8. package/build/abi/algebra/AlgebraPool.abi.json +727 -0
  9. package/build/abi/curve-v1/StableSwapFRXETH.json +889 -0
  10. package/build/abi/curve-v1/StableSwapWBETH.json +1223 -0
  11. package/build/abi/polygon-migration/PolygonMigration.abi.json +364 -0
  12. package/build/abi/sushiswap-v3/QuoterV2.json +267 -0
  13. package/build/abi/sushiswap-v3/RouterProcessor3.json +289 -0
  14. package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +193 -0
  15. package/build/abi/uniswap-v3/pancakeswap-v3/PancakeswapV3QuoterV2.abi.json +285 -0
  16. package/build/abi/uniswap-v3/pancakeswap-v3/PancakeswapV3Router.abi.json +583 -0
  17. package/build/abi/wBETH.json +1527 -0
  18. package/build/abi/woo-fi/WooFeeManager.abi.json +318 -0
  19. package/build/abi/woo-fi/WooPP.abi.json +548 -0
  20. package/build/abi/woo-fi/Wooracle.abi.json +260 -0
  21. package/build/config.js +2 -2
  22. package/build/dex/aave-v3/tokens/arbitrum.json +50 -0
  23. package/build/dex/aave-v3/tokens/avalanche.json +74 -0
  24. package/build/dex/aave-v3/tokens/fantom.json +62 -0
  25. package/build/dex/aave-v3/tokens/optimism.json +50 -0
  26. package/build/dex/aave-v3/tokens/polygon.json +116 -0
  27. package/build/dex/algebra/algebra-pool.d.ts +46 -0
  28. package/build/dex/algebra/algebra-pool.js +336 -0
  29. package/build/dex/algebra/algebra-pool.js.map +1 -0
  30. package/build/dex/balancer-v2/LinearMath.d.ts +19 -0
  31. package/build/dex/balancer-v2/LinearMath.js +179 -0
  32. package/build/dex/balancer-v2/LinearMath.js.map +1 -0
  33. package/build/dex/balancer-v2/LinearPool.d.ts +47 -0
  34. package/build/dex/balancer-v2/LinearPool.js +324 -0
  35. package/build/dex/balancer-v2/LinearPool.js.map +1 -0
  36. package/build/dex/balancer-v2/PhantomStablePool.d.ts +47 -0
  37. package/build/dex/balancer-v2/PhantomStablePool.js +294 -0
  38. package/build/dex/balancer-v2/PhantomStablePool.js.map +1 -0
  39. package/build/dex/balancer-v2/StableMath.d.ts +9 -0
  40. package/build/dex/balancer-v2/StableMath.js +272 -0
  41. package/build/dex/balancer-v2/StableMath.js.map +1 -0
  42. package/build/dex/balancer-v2/balancer-v2-pool.d.ts +75 -0
  43. package/build/dex/balancer-v2/balancer-v2-pool.js +417 -0
  44. package/build/dex/balancer-v2/balancer-v2-pool.js.map +1 -0
  45. package/build/dex/curve-v1/pools/frxETHpool.d.ts +7 -0
  46. package/build/dex/curve-v1/pools/frxETHpool.js +27 -0
  47. package/build/dex/curve-v1/pools/frxETHpool.js.map +1 -0
  48. package/build/dex/curve-v1/pools/wbETHpool.d.ts +29 -0
  49. package/build/dex/curve-v1/pools/wbETHpool.js +408 -0
  50. package/build/dex/curve-v1/pools/wbETHpool.js.map +1 -0
  51. package/build/dex/index.js +2 -0
  52. package/build/dex/index.js.map +1 -1
  53. package/build/dex/lighter-v1/abi/erc20.json +222 -0
  54. package/build/dex/lighter-v1/abi/factory.json +291 -0
  55. package/build/dex/lighter-v1/abi/order_book.json +594 -0
  56. package/build/dex/lighter-v1/abi/order_book_helper.json +176 -0
  57. package/build/dex/lighter-v1/abi/router.json +488 -0
  58. package/build/dex/{my-test-dex → lighter-v1}/config.d.ts +1 -1
  59. package/build/dex/lighter-v1/config.js +17 -0
  60. package/build/dex/lighter-v1/config.js.map +1 -0
  61. package/build/dex/lighter-v1/constants.d.ts +2 -0
  62. package/build/dex/lighter-v1/constants.js +13 -0
  63. package/build/dex/lighter-v1/constants.js.map +1 -0
  64. package/build/dex/{my-test-dex/my-test-dex-pool.d.ts → lighter-v1/lighter-v1-pool.d.ts} +24 -6
  65. package/build/dex/lighter-v1/lighter-v1-pool.js +310 -0
  66. package/build/dex/lighter-v1/lighter-v1-pool.js.map +1 -0
  67. package/build/dex/{my-test-dex/my-test-dex.d.ts → lighter-v1/lighter-v1.d.ts} +18 -10
  68. package/build/dex/lighter-v1/lighter-v1.js +331 -0
  69. package/build/dex/lighter-v1/lighter-v1.js.map +1 -0
  70. package/build/dex/lighter-v1/types.d.ts +40 -0
  71. package/build/dex/{my-test-dex → lighter-v1}/types.js.map +1 -1
  72. package/build/dex/pancakeswap-v3/types.d.ts +14 -0
  73. package/build/dex/pancakeswap-v3/types.js.map +1 -0
  74. package/build/dex/polygon-migrator/config.d.ts +11 -0
  75. package/build/dex/polygon-migrator/config.js +21 -0
  76. package/build/dex/polygon-migrator/config.js.map +1 -0
  77. package/build/dex/polygon-migrator/constants.d.ts +1 -0
  78. package/build/dex/polygon-migrator/constants.js +5 -0
  79. package/build/dex/polygon-migrator/constants.js.map +1 -0
  80. package/build/dex/polygon-migrator/polygon-migrator.d.ts +48 -0
  81. package/build/dex/polygon-migrator/polygon-migrator.js +109 -0
  82. package/build/dex/polygon-migrator/polygon-migrator.js.map +1 -0
  83. package/build/dex/polygon-migrator/types.d.ts +11 -0
  84. package/build/dex/polygon-migrator/types.js +9 -0
  85. package/build/dex/polygon-migrator/types.js.map +1 -0
  86. package/build/dex/quickswap/camelot-v3.d.ts +6 -0
  87. package/build/dex/quickswap/camelot-v3.js +19 -0
  88. package/build/dex/quickswap/camelot-v3.js.map +1 -0
  89. package/build/dex/quickswap/zyberswap-v3.d.ts +6 -0
  90. package/build/dex/quickswap/zyberswap-v3.js +19 -0
  91. package/build/dex/quickswap/zyberswap-v3.js.map +1 -0
  92. package/build/dex/quickswap-v3.d.ts +21 -0
  93. package/build/dex/quickswap-v3.js +40 -0
  94. package/build/dex/quickswap-v3.js.map +1 -0
  95. package/build/dex/ramses-v2/config.d.ts +4 -0
  96. package/build/dex/ramses-v2/config.js +28 -0
  97. package/build/dex/ramses-v2/config.js.map +1 -0
  98. package/build/dex/ramses-v2/constants.d.ts +28 -0
  99. package/build/dex/ramses-v2/constants.js +35 -0
  100. package/build/dex/ramses-v2/constants.js.map +1 -0
  101. package/build/dex/ramses-v2/contract-math/BitMath.d.ts +4 -0
  102. package/build/dex/ramses-v2/contract-math/BitMath.js +93 -0
  103. package/build/dex/ramses-v2/contract-math/BitMath.js.map +1 -0
  104. package/build/dex/ramses-v2/contract-math/FixedPoint128.d.ts +3 -0
  105. package/build/dex/ramses-v2/contract-math/FixedPoint128.js +8 -0
  106. package/build/dex/ramses-v2/contract-math/FixedPoint128.js.map +1 -0
  107. package/build/dex/ramses-v2/contract-math/FixedPoint96.d.ts +4 -0
  108. package/build/dex/ramses-v2/contract-math/FixedPoint96.js +9 -0
  109. package/build/dex/ramses-v2/contract-math/FixedPoint96.js.map +1 -0
  110. package/build/dex/ramses-v2/contract-math/FullMath.d.ts +4 -0
  111. package/build/dex/ramses-v2/contract-math/FullMath.js +19 -0
  112. package/build/dex/ramses-v2/contract-math/FullMath.js.map +1 -0
  113. package/build/dex/ramses-v2/contract-math/LiquidityMath.d.ts +3 -0
  114. package/build/dex/ramses-v2/contract-math/LiquidityMath.js +22 -0
  115. package/build/dex/ramses-v2/contract-math/LiquidityMath.js.map +1 -0
  116. package/build/dex/ramses-v2/contract-math/Oracle.d.ts +10 -0
  117. package/build/dex/ramses-v2/contract-math/Oracle.js +133 -0
  118. package/build/dex/ramses-v2/contract-math/Oracle.js.map +1 -0
  119. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.d.ts +10 -0
  120. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js +91 -0
  121. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js.map +1 -0
  122. package/build/dex/ramses-v2/contract-math/SwapMath.d.ts +8 -0
  123. package/build/dex/ramses-v2/contract-math/SwapMath.js +70 -0
  124. package/build/dex/ramses-v2/contract-math/SwapMath.js.map +1 -0
  125. package/build/dex/ramses-v2/contract-math/Tick.d.ts +7 -0
  126. package/build/dex/ramses-v2/contract-math/Tick.js +45 -0
  127. package/build/dex/ramses-v2/contract-math/Tick.js.map +1 -0
  128. package/build/dex/ramses-v2/contract-math/TickBitMap.d.ts +8 -0
  129. package/build/dex/ramses-v2/contract-math/TickBitMap.js +87 -0
  130. package/build/dex/ramses-v2/contract-math/TickBitMap.js.map +1 -0
  131. package/build/dex/ramses-v2/contract-math/TickMath.d.ts +8 -0
  132. package/build/dex/ramses-v2/contract-math/TickMath.js +162 -0
  133. package/build/dex/ramses-v2/contract-math/TickMath.js.map +1 -0
  134. package/build/dex/ramses-v2/contract-math/UnsafeMath.d.ts +3 -0
  135. package/build/dex/ramses-v2/contract-math/UnsafeMath.js +10 -0
  136. package/build/dex/ramses-v2/contract-math/UnsafeMath.js.map +1 -0
  137. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.d.ts +18 -0
  138. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js +392 -0
  139. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js.map +1 -0
  140. package/build/dex/ramses-v2/contract-math/utils.d.ts +3 -0
  141. package/build/dex/ramses-v2/contract-math/utils.js +16 -0
  142. package/build/dex/ramses-v2/contract-math/utils.js.map +1 -0
  143. package/build/dex/ramses-v2/ramses-v2-pool.d.ts +42 -0
  144. package/build/dex/ramses-v2/ramses-v2-pool.js +307 -0
  145. package/build/dex/ramses-v2/ramses-v2-pool.js.map +1 -0
  146. package/build/dex/ramses-v2/ramses-v2.d.ts +61 -0
  147. package/build/dex/ramses-v2/ramses-v2.js +690 -0
  148. package/build/dex/ramses-v2/ramses-v2.js.map +1 -0
  149. package/build/dex/ramses-v2/types.d.ts +154 -0
  150. package/build/dex/ramses-v2/types.js +9 -0
  151. package/build/dex/ramses-v2/types.js.map +1 -0
  152. package/build/dex/ramses-v2/utils.d.ts +6 -0
  153. package/build/dex/ramses-v2/utils.js +71 -0
  154. package/build/dex/ramses-v2/utils.js.map +1 -0
  155. package/build/dex/sushiswap-v3/config.d.ts +4 -0
  156. package/build/dex/sushiswap-v3/config.js +132 -0
  157. package/build/dex/sushiswap-v3/config.js.map +1 -0
  158. package/build/dex/sushiswap-v3/constants.d.ts +4 -0
  159. package/build/dex/sushiswap-v3/constants.js +32 -0
  160. package/build/dex/sushiswap-v3/constants.js.map +1 -0
  161. package/build/dex/sushiswap-v3/sushiswap-v3-original.d.ts +56 -0
  162. package/build/dex/sushiswap-v3/sushiswap-v3-original.js +598 -0
  163. package/build/dex/sushiswap-v3/sushiswap-v3-original.js.map +1 -0
  164. package/build/dex/sushiswap-v3/sushiswap-v3-pool.d.ts +1 -0
  165. package/build/dex/sushiswap-v3/sushiswap-v3-pool.js +6 -0
  166. package/build/dex/sushiswap-v3/sushiswap-v3-pool.js.map +1 -0
  167. package/build/dex/sushiswap-v3/sushiswap-v3.d.ts +21 -0
  168. package/build/dex/sushiswap-v3/sushiswap-v3.js +58 -0
  169. package/build/dex/sushiswap-v3/sushiswap-v3.js.map +1 -0
  170. package/build/dex/sushiswap-v3/token.d.ts +6 -0
  171. package/build/dex/sushiswap-v3/token.js +23 -0
  172. package/build/dex/sushiswap-v3/token.js.map +1 -0
  173. package/build/dex/sushiswap-v3/types.d.ts +15 -0
  174. package/build/dex/sushiswap-v3/types.js +18 -0
  175. package/build/dex/sushiswap-v3/types.js.map +1 -0
  176. package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.d.ts +12 -0
  177. package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.js +23 -0
  178. package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.js.map +1 -0
  179. package/build/dex/{hello → woo-fi}/config.d.ts +1 -1
  180. package/build/dex/woo-fi/config.js +141 -0
  181. package/build/dex/woo-fi/config.js.map +1 -0
  182. package/build/dex/woo-fi/constants.d.ts +5 -0
  183. package/build/dex/woo-fi/constants.js +20 -0
  184. package/build/dex/woo-fi/constants.js.map +1 -0
  185. package/build/dex/woo-fi/types.d.ts +48 -0
  186. package/build/dex/woo-fi/types.js +3 -0
  187. package/build/dex/{hello → woo-fi}/types.js.map +1 -1
  188. package/build/dex/woo-fi/woo-fi-decimal-math.d.ts +14 -0
  189. package/build/dex/woo-fi/woo-fi-decimal-math.js +42 -0
  190. package/build/dex/woo-fi/woo-fi-decimal-math.js.map +1 -0
  191. package/build/dex/woo-fi/woo-fi-math.d.ts +31 -0
  192. package/build/dex/woo-fi/woo-fi-math.js +300 -0
  193. package/build/dex/woo-fi/woo-fi-math.js.map +1 -0
  194. package/build/dex/woo-fi/woo-fi.d.ts +65 -0
  195. package/build/dex/woo-fi/woo-fi.js +480 -0
  196. package/build/dex/woo-fi/woo-fi.js.map +1 -0
  197. package/package.json +1 -1
  198. package/src/abi/polygon-migration/PolygonMigration.abi.json +364 -0
  199. package/src/config.ts +2 -2
  200. package/src/dex/index.ts +2 -0
  201. package/src/dex/polygon-migrator/config.ts +25 -0
  202. package/src/dex/polygon-migrator/constants.ts +2 -0
  203. package/src/dex/polygon-migrator/polygon-migrator-e2e.test.ts +102 -0
  204. package/src/dex/polygon-migrator/polygon-migrator-integration.test.ts +140 -0
  205. package/src/dex/polygon-migrator/polygon-migrator.ts +151 -0
  206. package/src/dex/polygon-migrator/types.ts +14 -0
  207. package/tests/constants-e2e.ts +10 -0
  208. package/build/dex/hello/config.js +0 -15
  209. package/build/dex/hello/config.js.map +0 -1
  210. package/build/dex/hello/hello-pool.d.ts +0 -39
  211. package/build/dex/hello/hello-pool.js +0 -64
  212. package/build/dex/hello/hello-pool.js.map +0 -1
  213. package/build/dex/hello/hello.d.ts +0 -37
  214. package/build/dex/hello/hello.js +0 -126
  215. package/build/dex/hello/hello.js.map +0 -1
  216. package/build/dex/hello/types.d.ts +0 -6
  217. package/build/dex/my-test-dex/config.js +0 -15
  218. package/build/dex/my-test-dex/config.js.map +0 -1
  219. package/build/dex/my-test-dex/my-test-dex-pool.js +0 -64
  220. package/build/dex/my-test-dex/my-test-dex-pool.js.map +0 -1
  221. package/build/dex/my-test-dex/my-test-dex.js +0 -126
  222. package/build/dex/my-test-dex/my-test-dex.js.map +0 -1
  223. package/build/dex/my-test-dex/types.d.ts +0 -6
  224. /package/build/dex/{hello → lighter-v1}/types.js +0 -0
  225. /package/build/dex/{my-test-dex → pancakeswap-v3}/types.js +0 -0
@@ -0,0 +1,331 @@
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.LighterV1 = void 0;
30
+ const constants_1 = require("../../constants");
31
+ const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
32
+ const utils_1 = require("../../utils");
33
+ const simple_exchange_1 = require("../simple-exchange");
34
+ const config_1 = require("./config");
35
+ const lighter_v1_pool_1 = require("./lighter-v1-pool");
36
+ const utils_2 = require("ethers/lib/utils");
37
+ const order_book_helper_json_1 = __importDefault(require("./abi/order_book_helper.json"));
38
+ const factory_json_1 = __importDefault(require("./abi/factory.json"));
39
+ const router_json_1 = __importDefault(require("./abi/router.json"));
40
+ const erc20_json_1 = __importDefault(require("./abi/erc20.json"));
41
+ const ethers_1 = require("ethers");
42
+ class LighterV1 extends simple_exchange_1.SimpleExchange {
43
+ constructor(network, dexKey, dexHelper, config = config_1.LighterV1Config[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
+ // protected eventPools: LighterV1EventPool;
51
+ this.hasConstantPriceLargeAmounts = false;
52
+ // TODO: set true here if protocols works only with wrapped asset
53
+ this.needWrapNative = true;
54
+ this.isFeeOnTransferSupported = false;
55
+ this.factoryIface = new utils_2.Interface(factory_json_1.default);
56
+ this.routerIface = new utils_2.Interface(router_json_1.default);
57
+ this.orderBookHelperIface = new utils_2.Interface(order_book_helper_json_1.default);
58
+ this.allSupportedOrderBooks = new Map();
59
+ this.orderBooks = new Map();
60
+ this.logger = dexHelper.getLogger(dexKey);
61
+ }
62
+ // Initialize pricing is called once in the start of
63
+ // pricing service. It is intended to setup the integration
64
+ // for pricing requests. It is optional for a DEX to
65
+ // implement this function
66
+ async initializePricing(blockNumber) {
67
+ await this.updatePoolState(blockNumber);
68
+ }
69
+ // Returns the list of contract adapters (name and index)
70
+ // for a buy/sell. Return null if there are no adapters.
71
+ getAdapters(side) {
72
+ return this.adapters[side] ? this.adapters[side] : null;
73
+ }
74
+ // Returns list of pool identifiers that can be used
75
+ // for a given swap. poolIdentifiers must be unique
76
+ // across DEXes. It is recommended to use
77
+ // ${dexKey}_${poolAddress} as a poolIdentifier
78
+ async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
79
+ if (side == constants_1.SwapSide.BUY) {
80
+ return [];
81
+ }
82
+ const _srcToken = this.dexHelper.config.wrapETH(srcToken);
83
+ const _destToken = this.dexHelper.config.wrapETH(destToken);
84
+ const keyForAsk = `${_srcToken.address}-${_destToken.address}`;
85
+ const keyForBid = `${_destToken.address}-${_srcToken.address}`;
86
+ const orderBookForAsk = this.allSupportedOrderBooks.get(keyForAsk);
87
+ if (orderBookForAsk) {
88
+ return [`${this.dexKey}_${keyForAsk}`];
89
+ }
90
+ const orderBookForBid = this.allSupportedOrderBooks.get(keyForBid);
91
+ if (orderBookForBid) {
92
+ return [`${this.dexKey}_${keyForBid}}`];
93
+ }
94
+ return [];
95
+ }
96
+ // Returns pool prices for amounts.
97
+ // If limitPools is defined only pools in limitPools
98
+ // should be used. If limitPools is undefined then
99
+ // any pools can be used.
100
+ async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
101
+ const poolIdentifier = await this.getPoolIdentifiers(srcToken, destToken, side, blockNumber);
102
+ if (poolIdentifier.length == 0) {
103
+ return null;
104
+ }
105
+ // LighterV1_0x82aF49447D8a07e3bd95BD0d56f35241523fBab1_0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8
106
+ // omit LighterV1 from this string, split
107
+ const key = poolIdentifier[0].split('_')[1];
108
+ const orderBookType = this.allSupportedOrderBooks.get(key);
109
+ if (!orderBookType) {
110
+ return null;
111
+ }
112
+ const pool = this.orderBooks.get(orderBookType.orderBookId);
113
+ if (!pool) {
114
+ return null;
115
+ }
116
+ let state = pool.getState(blockNumber);
117
+ if (!state) {
118
+ state = await pool.generateState(blockNumber);
119
+ }
120
+ const orderBookData = state.orderBook;
121
+ const limitOrders = orderBookType.isAsk
122
+ ? orderBookData.sortedBids
123
+ : orderBookData.sortedAsks;
124
+ const outAmounts = await this.getOutAmount(amounts, orderBookType.isAsk, limitOrders, state.sizeTick);
125
+ return [
126
+ {
127
+ prices: outAmounts,
128
+ unit: (0, utils_1.bigIntify)(0),
129
+ data: { exchange: this.dexKey },
130
+ poolIdentifier: poolIdentifier[0],
131
+ exchange: this.dexKey,
132
+ gasCost: CALLDATA_GAS_COST.DEX_NO_PAYLOAD,
133
+ poolAddresses: [pool.orderBookAddress],
134
+ },
135
+ ];
136
+ }
137
+ async getOutAmount(amountIns, isAsk, limitOrders, sizeTick) {
138
+ return amountIns.map(amountIn => {
139
+ // This is important, reviewer should check this
140
+ // there is a size tick in the order book and we need to round the amountIn
141
+ if (isAsk) {
142
+ amountIn -= amountIn % BigInt(sizeTick);
143
+ }
144
+ let remainingAmountIn = amountIn;
145
+ let runningAmountOut = BigInt(0);
146
+ let partialAmountOut = BigInt(0);
147
+ let orderAmountIn = BigInt(0);
148
+ let orderAmountOut = BigInt(0);
149
+ for (let i = 0; i < limitOrders.length && remainingAmountIn > BigInt(0); i++) {
150
+ if (isAsk != limitOrders[i].isAsk) {
151
+ orderAmountIn = limitOrders[i].amount0;
152
+ orderAmountOut = limitOrders[i].amount1;
153
+ if (remainingAmountIn >= orderAmountIn) {
154
+ runningAmountOut += orderAmountOut;
155
+ remainingAmountIn -= orderAmountIn;
156
+ }
157
+ else {
158
+ partialAmountOut =
159
+ (remainingAmountIn * orderAmountOut) / orderAmountIn;
160
+ if (!isAsk) {
161
+ partialAmountOut -= partialAmountOut % BigInt(sizeTick);
162
+ }
163
+ runningAmountOut += partialAmountOut;
164
+ remainingAmountIn -=
165
+ (partialAmountOut * orderAmountIn) / orderAmountOut;
166
+ break;
167
+ }
168
+ }
169
+ }
170
+ return runningAmountOut;
171
+ });
172
+ }
173
+ // Returns estimated gas cost of calldata for this DEX in multiSwap
174
+ getCalldataGasCost(poolPrices) {
175
+ // TODO: update if there is any payload in getAdapterParam
176
+ return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
177
+ }
178
+ // Encode params required by the exchange adapter
179
+ // Used for multiSwap, buy & megaSwap
180
+ // Hint: abiCoder.encodeParameter() could be useful
181
+ getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
182
+ const { exchange } = data;
183
+ // Encode here the payload for adapter
184
+ const payload = '';
185
+ return {
186
+ targetExchange: exchange,
187
+ payload,
188
+ networkFee: '0',
189
+ };
190
+ }
191
+ // Encode call data used by simpleSwap like routers
192
+ // Used for simpleSwap & simpleBuy
193
+ // Hint: this.buildSimpleParamWithoutWETHConversion
194
+ // could be useful
195
+ async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
196
+ if (side == constants_1.SwapSide.BUY) {
197
+ throw new Error('Buy not supported');
198
+ }
199
+ const poolIdentifier = await this.getPoolIdentifiers({ address: srcToken, decimals: 0 }, { address: destToken, decimals: 0 }, constants_1.SwapSide.SELL, 0);
200
+ if (poolIdentifier.length == 0) {
201
+ throw new Error('Pool identifier not found');
202
+ }
203
+ const key = poolIdentifier[0].split('_')[1];
204
+ const orderBookType = this.allSupportedOrderBooks.get(key);
205
+ if (!orderBookType) {
206
+ throw new Error('Order book type not found');
207
+ }
208
+ // Encode here the transaction arguments
209
+ const helper = new ethers_1.ethers.Contract(this.config.orderBookHelper, this.orderBookHelperIface);
210
+ const payload = helper.interface.encodeFunctionData('swapExactInput', [
211
+ orderBookType.orderBookId,
212
+ orderBookType.isAsk,
213
+ srcAmount,
214
+ destAmount,
215
+ ]);
216
+ return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, payload, helper.address);
217
+ }
218
+ async getQuoteFromHelper(blockNumber, orderBookId, amountIn, isAsk) {
219
+ const helper = new ethers_1.ethers.Contract(this.config.orderBookHelper, this.orderBookHelperIface);
220
+ const data = await this.dexHelper.provider.call({
221
+ to: helper.address,
222
+ data: helper.interface.encodeFunctionData('quoteExactInput', [
223
+ orderBookId,
224
+ isAsk,
225
+ amountIn,
226
+ ]),
227
+ }, blockNumber);
228
+ const [amountInResult, amountOut] = helper.interface.decodeFunctionResult('quoteExactInput', data);
229
+ return amountOut;
230
+ }
231
+ // This is called once before getTopPoolsForToken is
232
+ // called for multiple tokens. This can be helpful to
233
+ // update common state required for calculating
234
+ // getTopPoolsForToken. It is optional for a DEX
235
+ // to implement this
236
+ async updatePoolState(blockNumber) {
237
+ const helper = new ethers_1.ethers.Contract(this.config.orderBookHelper, this.orderBookHelperIface);
238
+ const block = blockNumber
239
+ ? blockNumber
240
+ : await this.dexHelper.provider.getBlockNumber();
241
+ const data = await this.dexHelper.provider.call({
242
+ to: helper.address,
243
+ data: helper.interface.encodeFunctionData('getAllOrderBooks', []),
244
+ }, block);
245
+ const [orderBookIds, orderBookAddresses, token0s, token1s, sizeTicks, _] = helper.interface.decodeFunctionResult('getAllOrderBooks', data);
246
+ for (let i = 0; i < orderBookIds.length; i++) {
247
+ // Generate keys for both sides of each order book
248
+ const keyForAsk = `${token0s[i]}-${token1s[i]}`;
249
+ const keyForBid = `${token1s[i]}-${token0s[i]}`;
250
+ if (!this.allSupportedOrderBooks.has(keyForAsk)) {
251
+ // Construct the OrderBookType objects
252
+ const orderBookForAsk = { orderBookId: orderBookIds[i], isAsk: true };
253
+ const orderBookForBid = { orderBookId: orderBookIds[i], isAsk: false };
254
+ // Add the order books to the map
255
+ this.allSupportedOrderBooks.set(keyForAsk, orderBookForAsk);
256
+ this.allSupportedOrderBooks.set(keyForBid, orderBookForBid);
257
+ }
258
+ let pool;
259
+ if (!this.orderBooks.has(orderBookIds[i])) {
260
+ const token0 = new ethers_1.ethers.Contract(token0s[i], erc20_json_1.default, this.dexHelper.provider);
261
+ const token1 = new ethers_1.ethers.Contract(token1s[i], erc20_json_1.default, this.dexHelper.provider);
262
+ // get token symbol
263
+ const token0Symbol = await token0.symbol();
264
+ const token1Symbol = await token1.symbol();
265
+ // get token decimals
266
+ const token0Decimals = await token0.decimals();
267
+ const token1Decimals = await token1.decimals();
268
+ const baseToken = {
269
+ address: token0s[i],
270
+ decimals: token0Decimals,
271
+ symbol: token0Symbol,
272
+ };
273
+ const quoteToken = {
274
+ address: token1s[i],
275
+ decimals: token1Decimals,
276
+ symbol: token1Symbol,
277
+ };
278
+ // create pool
279
+ pool = new lighter_v1_pool_1.LighterV1EventPool(this.dexKey, this.network, this.dexHelper, this.logger, this.config.factory, this.config.router, orderBookIds[i], orderBookAddresses[i], baseToken, quoteToken, sizeTicks[i]);
280
+ this.orderBooks.set(orderBookIds[i], pool);
281
+ }
282
+ pool = this.orderBooks.get(orderBookIds[i]);
283
+ const state = await pool.generateState(block);
284
+ pool.setState(state, block);
285
+ }
286
+ }
287
+ // Returns list of top pools based on liquidity. Max
288
+ // limit number pools should be returned.
289
+ async getTopPoolsForToken(tokenAddress, limit) {
290
+ const pools = [];
291
+ // find the pools that have the token in allSupportedOrderBooks keys
292
+ for (const [key, orderBookType] of this.allSupportedOrderBooks) {
293
+ if (pools.length >= limit) {
294
+ break;
295
+ }
296
+ const [token0, token1] = key.split('-');
297
+ // if one of these tokens is given token
298
+ if (token0 == tokenAddress) {
299
+ const pool = this.orderBooks.get(orderBookType.orderBookId);
300
+ if (!pool) {
301
+ continue;
302
+ }
303
+ const state = pool.getState(pool.getStateBlockNumber());
304
+ if (!state) {
305
+ continue;
306
+ }
307
+ const liq = await pool.calculateLiquidity();
308
+ // find the connector token,
309
+ // if token0 is the given token, then token1 is the connector token
310
+ const connectorToken = tokenAddress == state.baseToken.address
311
+ ? state.quoteToken
312
+ : state.baseToken;
313
+ pools.push({
314
+ exchange: this.dexKey,
315
+ address: this.config.orderBookHelper,
316
+ connectorTokens: [connectorToken],
317
+ liquidityUSD: liq,
318
+ });
319
+ }
320
+ }
321
+ return pools;
322
+ }
323
+ // This is optional function in case if your implementation has acquired any resources
324
+ // you need to release for graceful shutdown. For example, it may be any interval timer
325
+ releaseResources() {
326
+ // TODO: complete me!
327
+ }
328
+ }
329
+ exports.LighterV1 = LighterV1;
330
+ LighterV1.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.LighterV1Config);
331
+ //# sourceMappingURL=lighter-v1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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
+ import { Address, Token } from '../../types';
2
+ export declare type PoolState = {
3
+ pool: Address;
4
+ baseToken: Token;
5
+ quoteToken: Token;
6
+ orderBook: OrderBook;
7
+ sizeTick: bigint;
8
+ };
9
+ export declare type OrderBook = {
10
+ sortedAsks: LimitOrder[];
11
+ sortedBids: LimitOrder[];
12
+ };
13
+ export declare type LighterV1Data = {
14
+ exchange: Address;
15
+ };
16
+ export declare type DexParams = {
17
+ factory: Address;
18
+ router: Address;
19
+ orderBookHelper: Address;
20
+ };
21
+ export declare type OrderBookDetails = {
22
+ orderBookId: number;
23
+ orderBookAddress: string;
24
+ token0Address: string;
25
+ token1Address: string;
26
+ sizeTick: number;
27
+ priceTick: number;
28
+ };
29
+ export declare type LimitOrder = {
30
+ id: number;
31
+ amount0: bigint;
32
+ amount1: bigint;
33
+ isAsk: boolean;
34
+ price: number;
35
+ };
36
+ export declare type OrderBookType = {
37
+ orderBookId: number;
38
+ isAsk: boolean;
39
+ };
40
+ export declare type AllOrderBooks = Map<string, OrderBookType>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/my-test-dex/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/lighter-v1/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import { Address } from '../../types';
2
+ export declare type DexParams = {
3
+ router: Address;
4
+ quoter: Address;
5
+ factory: Address;
6
+ stateMulticall: Address;
7
+ uniswapMulticall: Address;
8
+ supportedFees: bigint[];
9
+ feeProtocols: bigint[];
10
+ chunksCount: number;
11
+ deployer?: Address;
12
+ subgraphURL: string;
13
+ initHash: string;
14
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/pancakeswap-v3/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { DexParams } from './types';
2
+ import { DexConfigMap } from '../../types';
3
+ export declare const PolygonMigratorConfig: DexConfigMap<DexParams>;
4
+ export declare const Adapters: {
5
+ [chainId: number]: {
6
+ [side: string]: {
7
+ name: string;
8
+ index: number;
9
+ }[];
10
+ };
11
+ };
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Adapters = exports.PolygonMigratorConfig = void 0;
4
+ const constants_1 = require("../../constants");
5
+ const core_1 = require("@paraswap/core");
6
+ exports.PolygonMigratorConfig = {
7
+ PolygonMigrator: {
8
+ [constants_1.Network.MAINNET]: {
9
+ migratorAddress: '0x29e7df7b6a1b2b07b731457f499e1696c60e2c4e',
10
+ polTokenAddress: '0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6',
11
+ maticTokenAddress: '0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0'
12
+ },
13
+ },
14
+ };
15
+ exports.Adapters = {
16
+ [constants_1.Network.MAINNET]: {
17
+ [core_1.SwapSide.SELL]: [{ name: 'Adapter04', index: 4 }],
18
+ [core_1.SwapSide.BUY]: [{ name: 'BuyAdapter', index: 11 }],
19
+ },
20
+ };
21
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/polygon-migrator/config.ts"],"names":[],"mappings":";;;AAEA,+CAA0C;AAC1C,yCAA0C;AAE7B,QAAA,qBAAqB,GAA4B;IAC5D,eAAe,EAAE;QACf,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,eAAe,EAAE,4CAA4C;YAC7D,eAAe,EAAE,4CAA4C;YAC7D,iBAAiB,EAAE,4CAA4C;SAChE;KACF;CACF,CAAC;AAEW,QAAA,QAAQ,GAIjB;IACF,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;QACjB,CAAC,eAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAClD,CAAC,eAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;KACpD;CACF,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const POLYGON_MIGRATION_GAS_COST = 90000;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.POLYGON_MIGRATION_GAS_COST = void 0;
4
+ exports.POLYGON_MIGRATION_GAS_COST = 90000;
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/dex/polygon-migrator/constants.ts"],"names":[],"mappings":";;;AACa,QAAA,0BAA0B,GAAE,KAAM,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { SimpleExchange } from '../simple-exchange';
2
+ import { IDex } from '../idex';
3
+ import { DexParams, PolygonMigrationData } from './types';
4
+ import { Network, SwapSide } from '../../constants';
5
+ import { AdapterExchangeParam, Address, ExchangePrices, Logger, PoolLiquidity, PoolPrices, SimpleExchangeParam, Token } from '../../types';
6
+ import { IDexHelper } from '../../dex-helper';
7
+ import { Interface } from 'ethers/lib/utils';
8
+ export declare class PolygonMigrator extends SimpleExchange implements IDex<PolygonMigrationData, DexParams> {
9
+ protected network: Network;
10
+ protected dexHelper: IDexHelper;
11
+ readonly migratorAddress: string;
12
+ readonly polTokenAddress: string;
13
+ readonly maticTokenAddress: string;
14
+ protected unitPrice: bigint;
15
+ protected adapters: {
16
+ [side: string]: {
17
+ name: string;
18
+ index: number;
19
+ }[];
20
+ };
21
+ protected migratorInterface: Interface;
22
+ readonly hasConstantPriceLargeAmounts = true;
23
+ readonly isFeeOnTransferSupported = false;
24
+ static dexKeysWithNetwork: {
25
+ key: string;
26
+ networks: Network[];
27
+ }[];
28
+ logger: Logger;
29
+ constructor(network: Network, dexKey: string, dexHelper: IDexHelper, migratorAddress?: string, polTokenAddress?: string, maticTokenAddress?: string, unitPrice?: bigint, adapters?: {
30
+ [side: string]: {
31
+ name: string;
32
+ index: number;
33
+ }[];
34
+ }, migratorInterface?: Interface);
35
+ getAdapters(side: SwapSide): {
36
+ name: string;
37
+ index: number;
38
+ }[] | null;
39
+ isMatic(tokenAddress: Address): boolean;
40
+ isPol(tokenAddress: Address): boolean;
41
+ isAppropriatePair(srcToken: Token, destToken: Token): boolean;
42
+ getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
43
+ getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<PolygonMigrationData>>;
44
+ getCalldataGasCost(poolPrices: PoolPrices<PolygonMigrationData>): number | number[];
45
+ getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: PolygonMigrationData, side: SwapSide): AdapterExchangeParam;
46
+ getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: PolygonMigrationData, side: SwapSide): Promise<SimpleExchangeParam>;
47
+ getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
48
+ }
@@ -0,0 +1,109 @@
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.PolygonMigrator = void 0;
30
+ const simple_exchange_1 = require("../simple-exchange");
31
+ const types_1 = require("./types");
32
+ const utils_1 = require("../../utils");
33
+ const config_1 = require("./config");
34
+ const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
35
+ const bigint_constants_1 = require("../../bigint-constants");
36
+ const constants_1 = require("./constants");
37
+ const PolygonMigration_abi_json_1 = __importDefault(require("../../abi/polygon-migration/PolygonMigration.abi.json"));
38
+ const utils_2 = require("ethers/lib/utils");
39
+ class PolygonMigrator extends simple_exchange_1.SimpleExchange {
40
+ constructor(network, dexKey, dexHelper, migratorAddress = config_1.PolygonMigratorConfig[dexKey][network].migratorAddress, polTokenAddress = config_1.PolygonMigratorConfig[dexKey][network].polTokenAddress, maticTokenAddress = config_1.PolygonMigratorConfig[dexKey][network].maticTokenAddress, unitPrice = bigint_constants_1.BI_POWS[18], adapters = config_1.Adapters[network] || {}, migratorInterface = new utils_2.Interface(PolygonMigration_abi_json_1.default)) {
41
+ super(dexHelper, dexKey);
42
+ this.network = network;
43
+ this.dexHelper = dexHelper;
44
+ this.migratorAddress = migratorAddress;
45
+ this.polTokenAddress = polTokenAddress;
46
+ this.maticTokenAddress = maticTokenAddress;
47
+ this.unitPrice = unitPrice;
48
+ this.adapters = adapters;
49
+ this.migratorInterface = migratorInterface;
50
+ this.hasConstantPriceLargeAmounts = true;
51
+ this.isFeeOnTransferSupported = false;
52
+ this.logger = dexHelper.getLogger(dexKey);
53
+ }
54
+ getAdapters(side) {
55
+ return this.adapters[side] || null;
56
+ }
57
+ isMatic(tokenAddress) {
58
+ return this.maticTokenAddress.toLowerCase() === tokenAddress.toLowerCase();
59
+ }
60
+ isPol(tokenAddress) {
61
+ return this.polTokenAddress.toLowerCase() === tokenAddress.toLowerCase();
62
+ }
63
+ isAppropriatePair(srcToken, destToken) {
64
+ return (this.isMatic(srcToken.address) && this.isPol(destToken.address))
65
+ || (this.isMatic(destToken.address) && this.isPol(srcToken.address));
66
+ }
67
+ async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
68
+ if (this.isAppropriatePair(srcToken, destToken)) {
69
+ return [`${this.dexKey}_${srcToken.address}_${destToken.address}`];
70
+ }
71
+ return [];
72
+ }
73
+ async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
74
+ if (!this.isAppropriatePair(srcToken, destToken)) {
75
+ return null;
76
+ }
77
+ return [
78
+ {
79
+ prices: amounts,
80
+ unit: this.unitPrice,
81
+ gasCost: constants_1.POLYGON_MIGRATION_GAS_COST,
82
+ exchange: this.dexKey,
83
+ poolAddresses: [this.migratorAddress],
84
+ data: null,
85
+ },
86
+ ];
87
+ }
88
+ // Returns estimated gas cost of calldata for this DEX in multiSwap
89
+ getCalldataGasCost(poolPrices) {
90
+ return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
91
+ }
92
+ getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
93
+ return {
94
+ targetExchange: this.migratorAddress,
95
+ payload: '0x',
96
+ networkFee: '0',
97
+ };
98
+ }
99
+ async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
100
+ const swapData = this.migratorInterface.encodeFunctionData(this.isMatic(srcToken) ? types_1.PolygonMigratorFunctions.migrate : types_1.PolygonMigratorFunctions.unmigrate, [srcAmount]);
101
+ return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, this.migratorAddress);
102
+ }
103
+ async getTopPoolsForToken(tokenAddress, limit) {
104
+ return [];
105
+ }
106
+ }
107
+ exports.PolygonMigrator = PolygonMigrator;
108
+ PolygonMigrator.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.PolygonMigratorConfig);
109
+ //# sourceMappingURL=polygon-migrator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polygon-migrator.js","sourceRoot":"","sources":["../../../src/dex/polygon-migrator/polygon-migrator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAoD;AAEpD,mCAAoF;AAEpF,uCAAoD;AACpD,qCAA2D;AAY3D,2EAA6D;AAC7D,6DAAiD;AACjD,2CAAyD;AACzD,sHAAwF;AACxF,4CAA6C;AAE7C,MAAa,eAAgB,SAAQ,gCAAc;IASjD,YACY,OAAgB,EAC1B,MAAc,EACJ,SAAqB,EACtB,kBAA0B,8BAAqB,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,eAAe,EAChF,kBAA0B,8BAAqB,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,eAAe,EAChF,oBAA4B,8BAAqB,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,iBAAiB,EACnF,YAAY,0BAAO,CAAC,EAAE,CAAC,EACvB,WAAW,iBAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAClC,oBAAoB,IAAI,iBAAS,CAAC,mCAAmB,CAAC;QAEhE,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAVf,YAAO,GAAP,OAAO,CAAS;QAEhB,cAAS,GAAT,SAAS,CAAY;QACtB,oBAAe,GAAf,eAAe,CAAiE;QAChF,oBAAe,GAAf,eAAe,CAAiE;QAChF,sBAAiB,GAAjB,iBAAiB,CAAmE;QACnF,cAAS,GAAT,SAAS,CAAc;QACvB,aAAQ,GAAR,QAAQ,CAA0B;QAClC,sBAAiB,GAAjB,iBAAiB,CAAqC;QAjBzD,iCAA4B,GAAG,IAAI,CAAC;QACpC,6BAAwB,GAAG,KAAK,CAAC;QAmBxC,IAAI,CAAC,MAAM,GAAG,SAA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,EAAE,OAAO;gBACf,IAAI,EAAE,IAAI,CAAC,SAAS;gBACpB,OAAO,EAAE,sCAA0B;gBACnC,QAAQ,EAAE,IAAI,CAAC,MAAM;gBACrB,aAAa,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC;gBACrC,IAAI,EAAE,IAAI;aACX;SACF,CAAC;IACJ,CAAC;IAED,mEAAmE;IACnE,kBAAkB,CAAC,UAA4C;QAC7D,OAAO,iBAAiB,CAAC,cAAc,CAAC;IAC1C,CAAC;IAED,eAAe,CACb,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAA0B,EAC1B,IAAc;QAEd,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,eAAe;YACpC,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAA0B,EAC1B,IAAc;QAEd,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,kBAAkB,CACxD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,gCAAwB,CAAC,OAAO,CAAC,CAAC,CAAC,gCAAwB,CAAC,SAAS,EAC9F,CAAE,SAAS,CAAE,CACd,CAAC;QAEF,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,IAAI,CAAC,eAAe,CACrB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,mBAAmB,CACvB,YAAqB,EACrB,KAAa;QAEb,OAAO,EAAE,CAAC;IACZ,CAAC;;AA9HH,0CA+HC;AA3He,kCAAkB,GAC9B,IAAA,6BAAqB,EAAC,8BAAqB,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { Address } from '../../types';
2
+ export declare type PolygonMigrationData = null;
3
+ export declare type DexParams = {
4
+ migratorAddress: Address;
5
+ polTokenAddress: Address;
6
+ maticTokenAddress: Address;
7
+ };
8
+ export declare enum PolygonMigratorFunctions {
9
+ migrate = "migrate",
10
+ unmigrate = "unmigrate"
11
+ }