@paraswap/dex-lib 3.8.23 → 3.8.24

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 (243) hide show
  1. package/build/abi/{integral/pool.json → inception/inception-ineth-pool.json} +558 -537
  2. package/build/abi/inception/inception-ineth.json +609 -0
  3. package/build/abi/inception/inception-ratio-feed.json +93 -0
  4. package/build/abi/inception/inception-vault.json +991 -0
  5. package/build/abi/infusion/InfusionFactory.json +147 -0
  6. package/build/abi/infusion/InfusionPair.json +658 -0
  7. package/build/abi/infusion/InfusionRouter.json +442 -0
  8. package/build/dex/aave-v1/aave-v1.d.ts +2 -1
  9. package/build/dex/aave-v1/aave-v1.js +22 -0
  10. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  11. package/build/dex/idle-dao/idle-dao-pool.d.ts +56 -0
  12. package/build/dex/idle-dao/idle-dao-pool.js +176 -0
  13. package/build/dex/idle-dao/idle-dao-pool.js.map +1 -0
  14. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +16 -0
  15. package/build/dex/idle-dao/idle-dao-pooling-pool.js +57 -0
  16. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +1 -0
  17. package/build/dex/idle-dao/scripts.d.ts +9 -0
  18. package/build/dex/idle-dao/scripts.js +552 -0
  19. package/build/dex/idle-dao/scripts.js.map +1 -0
  20. package/build/dex/inception/config.d.ts +5 -0
  21. package/build/dex/inception/config.js +112 -0
  22. package/build/dex/inception/config.js.map +1 -0
  23. package/build/dex/inception/inception-event-pool.d.ts +23 -0
  24. package/build/dex/inception/inception-event-pool.js +34 -0
  25. package/build/dex/inception/inception-event-pool.js.map +1 -0
  26. package/build/dex/{integral/integral.d.ts → inception/inception-native.d.ts} +21 -19
  27. package/build/dex/inception/inception-native.js +131 -0
  28. package/build/dex/inception/inception-native.js.map +1 -0
  29. package/build/dex/inception/inception-pool.d.ts +18 -0
  30. package/build/dex/inception/inception-pool.js +32 -0
  31. package/build/dex/inception/inception-pool.js.map +1 -0
  32. package/build/dex/inception/inception-price-feed.d.ts +19 -0
  33. package/build/dex/inception/inception-price-feed.js +51 -0
  34. package/build/dex/inception/inception-price-feed.js.map +1 -0
  35. package/build/dex/inception/inception.d.ts +44 -0
  36. package/build/dex/inception/inception.js +162 -0
  37. package/build/dex/inception/inception.js.map +1 -0
  38. package/build/dex/inception/tokens.d.ts +9 -0
  39. package/build/dex/inception/tokens.js +28 -0
  40. package/build/dex/inception/tokens.js.map +1 -0
  41. package/build/dex/inception/types.d.ts +22 -0
  42. package/build/dex/inception/types.js +3 -0
  43. package/build/dex/inception/types.js.map +1 -0
  44. package/build/dex/inception/utils.d.ts +7 -0
  45. package/build/dex/inception/utils.js +58 -0
  46. package/build/dex/inception/utils.js.map +1 -0
  47. package/build/dex/index.js +2 -0
  48. package/build/dex/index.js.map +1 -1
  49. package/build/dex/infusion/config.d.ts +3 -0
  50. package/build/dex/infusion/config.js +20 -0
  51. package/build/dex/infusion/config.js.map +1 -0
  52. package/build/dex/infusion/infusion-stable-pool.d.ts +4 -0
  53. package/build/dex/infusion/infusion-stable-pool.js +74 -0
  54. package/build/dex/infusion/infusion-stable-pool.js.map +1 -0
  55. package/build/dex/infusion/infusion.d.ts +51 -0
  56. package/build/dex/infusion/infusion.js +457 -0
  57. package/build/dex/infusion/infusion.js.map +1 -0
  58. package/build/dex/infusion/types.d.ts +45 -0
  59. package/build/dex/infusion/types.js +3 -0
  60. package/build/dex/infusion/types.js.map +1 -0
  61. package/build/dex/infusion/utils/isStablePair.d.ts +2 -0
  62. package/build/dex/infusion/utils/isStablePair.js +18 -0
  63. package/build/dex/infusion/utils/isStablePair.js.map +1 -0
  64. package/build/dex/lite-psm/lite-psm.js +2 -5
  65. package/build/dex/lite-psm/lite-psm.js.map +1 -1
  66. package/build/dex/maker-psm/maker-psm.js +2 -6
  67. package/build/dex/maker-psm/maker-psm.js.map +1 -1
  68. package/build/dex/oswap/oswap.d.ts +2 -2
  69. package/build/dex/oswap/oswap.js +43 -36
  70. package/build/dex/oswap/oswap.js.map +1 -1
  71. package/build/dex/platypus/platypus.d.ts +2 -1
  72. package/build/dex/platypus/platypus.js +31 -0
  73. package/build/dex/platypus/platypus.js.map +1 -1
  74. package/build/dex/swaap-v1/swaap-v1.d.ts +2 -1
  75. package/build/dex/swaap-v1/swaap-v1.js +10 -0
  76. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  77. package/package.json +1 -1
  78. package/src/abi/infusion/InfusionFactory.json +147 -0
  79. package/src/abi/infusion/InfusionPair.json +658 -0
  80. package/src/abi/infusion/InfusionRouter.json +442 -0
  81. package/src/dex/index.ts +2 -0
  82. package/src/dex/infusion/config.ts +21 -0
  83. package/src/dex/infusion/infusion-e2e.test.ts +110 -0
  84. package/src/dex/infusion/infusion-integration.test.ts +232 -0
  85. package/src/dex/infusion/infusion-stable-pool.ts +91 -0
  86. package/src/dex/infusion/infusion.ts +652 -0
  87. package/src/dex/infusion/types.ts +60 -0
  88. package/src/dex/infusion/utils/isStablePair.ts +18 -0
  89. package/src/dex/lite-psm/lite-psm.ts +2 -5
  90. package/src/dex/maker-psm/maker-psm.ts +2 -6
  91. package/tests/constants-e2e.ts +1 -1
  92. package/.vscode/launch.json +0 -16
  93. package/.vscode/settings.json +0 -3
  94. package/build/abi/Uncompressor.json +0 -250
  95. package/build/abi/integral/factory.json +0 -333
  96. package/build/abi/integral/oracle.json +0 -501
  97. package/build/abi/integral/relayer.json +0 -1536
  98. package/build/dex/bProtocol.d.ts +0 -18
  99. package/build/dex/bProtocol.js +0 -39
  100. package/build/dex/bProtocol.js.map +0 -1
  101. package/build/dex/bancor.d.ts +0 -26
  102. package/build/dex/bancor.js +0 -58
  103. package/build/dex/bancor.js.map +0 -1
  104. package/build/dex/compound.d.ts +0 -18
  105. package/build/dex/compound.js +0 -46
  106. package/build/dex/compound.js.map +0 -1
  107. package/build/dex/curve-v2.d.ts +0 -58
  108. package/build/dex/curve-v2.js +0 -180
  109. package/build/dex/curve-v2.js.map +0 -1
  110. package/build/dex/dodo-v1.d.ts +0 -33
  111. package/build/dex/dodo-v1.js +0 -63
  112. package/build/dex/dodo-v1.js.map +0 -1
  113. package/build/dex/etherfi/etherfi.d.ts +0 -26
  114. package/build/dex/etherfi/etherfi.js +0 -96
  115. package/build/dex/etherfi/etherfi.js.map +0 -1
  116. package/build/dex/integral/config.d.ts +0 -4
  117. package/build/dex/integral/config.js +0 -20
  118. package/build/dex/integral/config.js.map +0 -1
  119. package/build/dex/integral/context.d.ts +0 -40
  120. package/build/dex/integral/context.js +0 -158
  121. package/build/dex/integral/context.js.map +0 -1
  122. package/build/dex/integral/helpers.d.ts +0 -17
  123. package/build/dex/integral/helpers.js +0 -157
  124. package/build/dex/integral/helpers.js.map +0 -1
  125. package/build/dex/integral/integral-factory.d.ts +0 -24
  126. package/build/dex/integral/integral-factory.js +0 -95
  127. package/build/dex/integral/integral-factory.js.map +0 -1
  128. package/build/dex/integral/integral-pool.d.ts +0 -50
  129. package/build/dex/integral/integral-pool.js +0 -149
  130. package/build/dex/integral/integral-pool.js.map +0 -1
  131. package/build/dex/integral/integral-pricing.d.ts +0 -18
  132. package/build/dex/integral/integral-pricing.js +0 -114
  133. package/build/dex/integral/integral-pricing.js.map +0 -1
  134. package/build/dex/integral/integral-relayer.d.ts +0 -42
  135. package/build/dex/integral/integral-relayer.js +0 -192
  136. package/build/dex/integral/integral-relayer.js.map +0 -1
  137. package/build/dex/integral/integral-token.d.ts +0 -27
  138. package/build/dex/integral/integral-token.js +0 -59
  139. package/build/dex/integral/integral-token.js.map +0 -1
  140. package/build/dex/integral/integral.js +0 -376
  141. package/build/dex/integral/integral.js.map +0 -1
  142. package/build/dex/integral/types.d.ts +0 -85
  143. package/build/dex/integral/types.js +0 -9
  144. package/build/dex/integral/types.js.map +0 -1
  145. package/build/dex/integral/utils-e2e.d.ts +0 -9
  146. package/build/dex/integral/utils-e2e.js +0 -131
  147. package/build/dex/integral/utils-e2e.js.map +0 -1
  148. package/build/dex/integral/utils.d.ts +0 -17
  149. package/build/dex/integral/utils.js +0 -94
  150. package/build/dex/integral/utils.js.map +0 -1
  151. package/build/dex/lido.d.ts +0 -19
  152. package/build/dex/lido.js +0 -42
  153. package/build/dex/lido.js.map +0 -1
  154. package/build/dex/onebit.d.ts +0 -25
  155. package/build/dex/onebit.js +0 -42
  156. package/build/dex/onebit.js.map +0 -1
  157. package/build/dex/sdai/config.d.ts +0 -11
  158. package/build/dex/sdai/config.js +0 -21
  159. package/build/dex/sdai/config.js.map +0 -1
  160. package/build/dex/sdai/constants.d.ts +0 -2
  161. package/build/dex/sdai/constants.js +0 -6
  162. package/build/dex/sdai/constants.js.map +0 -1
  163. package/build/dex/sdai/scripts/validate-state.d.ts +0 -1
  164. package/build/dex/sdai/scripts/validate-state.js +0 -102
  165. package/build/dex/sdai/scripts/validate-state.js.map +0 -1
  166. package/build/dex/sdai/sdai-pool.d.ts +0 -16
  167. package/build/dex/sdai/sdai-pool.js +0 -85
  168. package/build/dex/sdai/sdai-pool.js.map +0 -1
  169. package/build/dex/sdai/sdai.d.ts +0 -51
  170. package/build/dex/sdai/sdai.js +0 -172
  171. package/build/dex/sdai/sdai.js.map +0 -1
  172. package/build/dex/sdai/types.d.ts +0 -21
  173. package/build/dex/sdai/types.js +0 -11
  174. package/build/dex/sdai/types.js.map +0 -1
  175. package/build/dex/sdai/utils.d.ts +0 -4
  176. package/build/dex/sdai/utils.js +0 -39
  177. package/build/dex/sdai/utils.js.map +0 -1
  178. package/build/dex/smoothy.d.ts +0 -26
  179. package/build/dex/smoothy.js +0 -48
  180. package/build/dex/smoothy.js.map +0 -1
  181. package/build/dex/stable-pool.d.ts +0 -28
  182. package/build/dex/stable-pool.js +0 -62
  183. package/build/dex/stable-pool.js.map +0 -1
  184. package/build/dex/trader-joe-v2.1/optimizer.d.ts +0 -2
  185. package/build/dex/trader-joe-v2.1/optimizer.js +0 -44
  186. package/build/dex/trader-joe-v2.1/optimizer.js.map +0 -1
  187. package/build/dex/trader-joe-v2.1.d.ts +0 -43
  188. package/build/dex/trader-joe-v2.1.js +0 -79
  189. package/build/dex/trader-joe-v2.1.js.map +0 -1
  190. package/build/executor/compressor/Compressor.d.ts +0 -23
  191. package/build/executor/compressor/Compressor.js +0 -144
  192. package/build/executor/compressor/Compressor.js.map +0 -1
  193. package/build/executor/compressor/compress.d.ts +0 -17
  194. package/build/executor/compressor/compress.js +0 -187
  195. package/build/executor/compressor/compress.js.map +0 -1
  196. package/build/executor/compressor/compress_functions/addressSubstitution.d.ts +0 -6
  197. package/build/executor/compressor/compress_functions/addressSubstitution.js +0 -29
  198. package/build/executor/compressor/compress_functions/addressSubstitution.js.map +0 -1
  199. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.d.ts +0 -10
  200. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js +0 -40
  201. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js.map +0 -1
  202. package/build/executor/compressor/compress_functions/byteSubstitution.d.ts +0 -11
  203. package/build/executor/compressor/compress_functions/byteSubstitution.js +0 -64
  204. package/build/executor/compressor/compress_functions/byteSubstitution.js.map +0 -1
  205. package/build/executor/compressor/compress_functions/ffSubstitution.d.ts +0 -7
  206. package/build/executor/compressor/compress_functions/ffSubstitution.js +0 -54
  207. package/build/executor/compressor/compress_functions/ffSubstitution.js.map +0 -1
  208. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.d.ts +0 -8
  209. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js +0 -67
  210. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js.map +0 -1
  211. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.d.ts +0 -8
  212. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js +0 -61
  213. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js.map +0 -1
  214. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.d.ts +0 -6
  215. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js +0 -37
  216. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js.map +0 -1
  217. package/build/executor/compressor/compress_functions/searchUnusedBytes.d.ts +0 -9
  218. package/build/executor/compressor/compress_functions/searchUnusedBytes.js +0 -33
  219. package/build/executor/compressor/compress_functions/searchUnusedBytes.js.map +0 -1
  220. package/build/executor/compressor/fetchSaved.d.ts +0 -0
  221. package/build/executor/compressor/fetchSaved.js +0 -17
  222. package/build/executor/compressor/fetchSaved.js.map +0 -1
  223. package/build/executor/compressor/utils/computeCostL2.d.ts +0 -2
  224. package/build/executor/compressor/utils/computeCostL2.js +0 -14
  225. package/build/executor/compressor/utils/computeCostL2.js.map +0 -1
  226. package/build/executor/compressor/utils/findLongestDuplicatedString.d.ts +0 -2
  227. package/build/executor/compressor/utils/findLongestDuplicatedString.js +0 -30
  228. package/build/executor/compressor/utils/findLongestDuplicatedString.js.map +0 -1
  229. package/build/executor/compressor/utils/getAllIndexes.d.ts +0 -2
  230. package/build/executor/compressor/utils/getAllIndexes.js +0 -12
  231. package/build/executor/compressor/utils/getAllIndexes.js.map +0 -1
  232. package/build/executor/compressor/utils/getByteForAddress.d.ts +0 -2
  233. package/build/executor/compressor/utils/getByteForAddress.js +0 -14
  234. package/build/executor/compressor/utils/getByteForAddress.js.map +0 -1
  235. package/build/executor/compressor/utils/intTo2Bytes.d.ts +0 -2
  236. package/build/executor/compressor/utils/intTo2Bytes.js +0 -14
  237. package/build/executor/compressor/utils/intTo2Bytes.js.map +0 -1
  238. package/build/executor/compressor/utils/intTo3Bytes.d.ts +0 -2
  239. package/build/executor/compressor/utils/intTo3Bytes.js +0 -18
  240. package/build/executor/compressor/utils/intTo3Bytes.js.map +0 -1
  241. package/build/executor/compressor/utils/intToByte.d.ts +0 -2
  242. package/build/executor/compressor/utils/intToByte.js +0 -10
  243. package/build/executor/compressor/utils/intToByte.js.map +0 -1
@@ -1,96 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.EtherFi = void 0;
7
- const abi_1 = require("@ethersproject/abi");
8
- const constants_1 = require("../../constants");
9
- const simple_exchange_1 = require("../simple-exchange");
10
- const eETHPool_json_1 = __importDefault(require("../../abi/etherfi/eETHPool.json"));
11
- const weETH_json_1 = __importDefault(require("../../abi/etherfi/weETH.json"));
12
- const utils_1 = require("../../utils");
13
- const ts_essentials_1 = require("ts-essentials");
14
- const types_1 = require("../weth/types");
15
- var EtherFiFunctions;
16
- (function (EtherFiFunctions) {
17
- EtherFiFunctions["deposit"] = "deposit";
18
- EtherFiFunctions["wrap"] = "wrap";
19
- EtherFiFunctions["unwrap"] = "unwrap";
20
- })(EtherFiFunctions || (EtherFiFunctions = {}));
21
- const EtherFiConfig = {
22
- 1: {
23
- eETH: '0x35fa164735182de50811e8e2e824cfb9b6118ac2',
24
- eETHPool: '0x308861a430be4cce5502d0a12724771fc6daf216',
25
- weETH: '0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee',
26
- },
27
- };
28
- class EtherFi extends simple_exchange_1.SimpleExchange {
29
- constructor(dexHelper) {
30
- super(dexHelper, 'etherfi');
31
- this.needWrapNative = false;
32
- this.is_eETH = (token) => token.toLowerCase() === this.eETH;
33
- this.is_weETH = (token) => token.toLowerCase() === this.weETH;
34
- this.eETHPoolInterface = new abi_1.Interface(eETHPool_json_1.default);
35
- this.weETHInterface = new abi_1.Interface(weETH_json_1.default);
36
- this.eETH = EtherFiConfig[this.network].eETH.toLowerCase();
37
- this.eETHPool = EtherFiConfig[this.network].eETHPool.toLowerCase();
38
- this.weETH = EtherFiConfig[this.network].weETH.toLowerCase();
39
- }
40
- async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
41
- const [Interface, swapCallee, swapFunction, swapFunctionParams] = (() => {
42
- if (this.is_weETH(destToken)) {
43
- (0, ts_essentials_1.assert)(this.is_eETH(srcToken), 'srcToken should be eETH');
44
- return [
45
- this.weETHInterface,
46
- this.weETH,
47
- EtherFiFunctions.wrap,
48
- [srcAmount],
49
- ];
50
- }
51
- if (this.is_weETH(srcToken)) {
52
- (0, ts_essentials_1.assert)(this.is_eETH(destToken), 'destToken should be eETH');
53
- return [
54
- this.weETHInterface,
55
- this.weETH,
56
- EtherFiFunctions.unwrap,
57
- [srcAmount],
58
- ];
59
- }
60
- if (this.is_eETH(destToken)) {
61
- (0, ts_essentials_1.assert)(this.isWETH(srcToken) || (0, utils_1.isETHAddress)(srcToken), 'srcToken should be (w)eth');
62
- return [
63
- this.eETHPoolInterface,
64
- this.eETHPool,
65
- EtherFiFunctions.deposit,
66
- [],
67
- ];
68
- }
69
- throw new Error('LOGIC ERROR');
70
- })();
71
- const swapData = Interface.encodeFunctionData(swapFunction, swapFunctionParams);
72
- // if src token is WETH, we need to withdraw from weth and pass eth value on call. For other cases, we need to approve and perform call
73
- const isSrcTokenWeth = this.isWETH(srcToken);
74
- return this.buildSimpleParamWithoutWETHConversion(isSrcTokenWeth ? constants_1.ETHER_ADDRESS : srcToken, srcAmount, destToken, destAmount, swapData, swapCallee, swapCallee, '0', isSrcTokenWeth
75
- ? {
76
- callees: [this.dexHelper.config.data.wrappedNativeTokenAddress],
77
- calldata: [
78
- this.erc20Interface.encodeFunctionData(types_1.WethFunctions.withdraw, [
79
- srcAmount,
80
- ]),
81
- ],
82
- values: ['0'],
83
- }
84
- : undefined);
85
- }
86
- getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
87
- return {
88
- targetExchange: constants_1.NULL_ADDRESS,
89
- payload: '0x',
90
- networkFee: '0',
91
- };
92
- }
93
- }
94
- exports.EtherFi = EtherFi;
95
- EtherFi.dexKeys = ['etherfi'];
96
- //# sourceMappingURL=etherfi.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"etherfi.js","sourceRoot":"","sources":["../../../src/dex/etherfi/etherfi.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAC7D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AAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAE7C,OAAO,IAAI,CAAC,qCAAqC,CAC/C,cAAc,CAAC,CAAC,CAAC,yBAAa,CAAC,CAAC,CAAC,QAAQ,EACzC,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,UAAU,EACV,UAAU,EACV,GAAG,EACH,cAAc;YACZ,CAAC,CAAC;gBACE,OAAO,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC;gBAC/D,QAAQ,EAAE;oBACR,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,qBAAa,CAAC,QAAQ,EAAE;wBAC7D,SAAS;qBACV,CAAC;iBACH;gBACD,MAAM,EAAE,CAAC,GAAG,CAAC;aACd;YACH,CAAC,CAAC,SAAS,CACd,CAAC;IACJ,CAAC;IAED,eAAe,CACb,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAiB,EACjB,IAAc;QAEd,OAAO;YACL,cAAc,EAAE,wBAAY;YAC5B,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;;AA1HH,0BA2HC;AAvHQ,eAAO,GAAG,CAAC,SAAS,CAAC,CAAC"}
@@ -1,4 +0,0 @@
1
- import { DexParams } from './types';
2
- import { DexConfigMap, AdapterMappings } from '../../types';
3
- export declare const IntegralConfig: DexConfigMap<DexParams>;
4
- export declare const Adapters: Record<number, AdapterMappings>;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Adapters = exports.IntegralConfig = void 0;
4
- const constants_1 = require("../../constants");
5
- exports.IntegralConfig = {
6
- Integral: {
7
- [constants_1.Network.MAINNET]: {
8
- factoryAddress: '0xC480b33eE5229DE3FbDFAD1D2DCD3F3BAD0C56c6',
9
- relayerAddress: '0xd17b3c9784510E33cD5B87b490E79253BcD81e2E',
10
- subgraphURL: 'ANd5QJuYtyfngmXvBMu9kZAv935vhcqp4xAGBkmCADN3',
11
- },
12
- [constants_1.Network.ARBITRUM]: {
13
- factoryAddress: '0x717EF162cf831db83c51134734A15D1EBe9E516a',
14
- relayerAddress: '0x3c6951FDB433b5b8442e7aa126D50fBFB54b5f42',
15
- subgraphURL: 'HXeVedRK7VgogXwbK5Sc4mjyLkhBAS5akskRvbSYnkHU',
16
- },
17
- },
18
- };
19
- exports.Adapters = {};
20
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/integral/config.ts"],"names":[],"mappings":";;;AAEA,+CAA0C;AAE7B,QAAA,cAAc,GAA4B;IACrD,QAAQ,EAAE;QACR,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,cAAc,EAAE,4CAA4C;YAC5D,cAAc,EAAE,4CAA4C;YAC5D,WAAW,EAAE,8CAA8C;SAC5D;QACD,CAAC,mBAAO,CAAC,QAAQ,CAAC,EAAE;YAClB,cAAc,EAAE,4CAA4C;YAC5D,cAAc,EAAE,4CAA4C;YAC5D,WAAW,EAAE,8CAA8C;SAC5D;KACF;CACF,CAAC;AAEW,QAAA,QAAQ,GAAoC,EAAE,CAAC"}
@@ -1,40 +0,0 @@
1
- import { Address } from '@paraswap/core';
2
- import { IntegralFactory } from './integral-factory';
3
- import { IntegralRelayer } from './integral-relayer';
4
- import { Network } from '../../constants';
5
- import { IDexHelper } from '../../dex-helper';
6
- import { Logger } from 'log4js';
7
- import { Interface } from '@ethersproject/abi';
8
- import { IntegralPool, PoolInitProps, RelayerPoolState } from './types';
9
- import { IntegralToken } from './integral-token';
10
- export declare class IntegralContext {
11
- readonly network: Network;
12
- readonly dexKey: string;
13
- readonly dexHelper: IDexHelper;
14
- readonly erc20Interface: Interface;
15
- readonly factoryAddress: Address;
16
- readonly relayerAddress: Address;
17
- static instances: {
18
- [network: number]: IntegralContext;
19
- };
20
- pools: {
21
- [poolId: string]: IntegralPool;
22
- };
23
- tokens: {
24
- [tokenAddress: Address]: IntegralToken;
25
- };
26
- factory: IntegralFactory;
27
- relayer: IntegralRelayer;
28
- logger: Logger;
29
- private constructor();
30
- addPools(pools: PoolInitProps, blockNumber: number, initPhase?: boolean): Promise<void>;
31
- getPoolAddresses(): string[];
32
- private removeDisabledPoolInitProps;
33
- static initialize(network: Network, dexKey: string, dexHelper: IDexHelper, erc20Interface: Interface, factoryAddress: Address, relayerAddress: Address): IntegralContext;
34
- static getInstance(network: Network): IntegralContext;
35
- onRelayerPoolEnabledSet(poolAddress: Address, state: RelayerPoolState, blockNumber: number): Promise<void>;
36
- onRebalanceSellOrderExecuted(blockNumber: number, orderId: bigint): void;
37
- onPoolCreatedAddPool(token0: Address, token1: Address, poolAddress: Address, blockNumber: number): Promise<void>;
38
- onPoolSwapForRelayer(blockNumber: number, poolAddress: Address, recipient: Address, amount0Out: bigint, amount1Out: bigint): Promise<void>;
39
- onTransferUpdateBalance(token: Address, from: Address, to: Address, amount: bigint, blockNumber: number): Promise<void>;
40
- }
@@ -1,158 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.IntegralContext = void 0;
7
- const integral_pool_1 = require("./integral-pool");
8
- const integral_pricing_1 = require("./integral-pricing");
9
- const integral_factory_1 = require("./integral-factory");
10
- const integral_relayer_1 = require("./integral-relayer");
11
- const integral_token_1 = require("./integral-token");
12
- const utils_1 = require("./utils");
13
- const lodash_1 = __importDefault(require("lodash"));
14
- class IntegralContext {
15
- constructor(network, dexKey, dexHelper, erc20Interface, factoryAddress, relayerAddress) {
16
- this.network = network;
17
- this.dexKey = dexKey;
18
- this.dexHelper = dexHelper;
19
- this.erc20Interface = erc20Interface;
20
- this.factoryAddress = factoryAddress;
21
- this.relayerAddress = relayerAddress;
22
- this.pools = {};
23
- this.tokens = {};
24
- this.logger = dexHelper.getLogger(dexKey);
25
- this.factory = new integral_factory_1.IntegralFactory(dexHelper, dexKey, this.factoryAddress, this.onPoolCreatedAddPool, this.logger);
26
- this.relayer = new integral_relayer_1.IntegralRelayer(dexHelper, dexKey, this.erc20Interface, this.relayerAddress, {}, this.onRelayerPoolEnabledSet, this.logger);
27
- }
28
- async addPools(pools, blockNumber, initPhase = false) {
29
- this.relayer.addPools(pools);
30
- if (initPhase) {
31
- await this.relayer.initialize(blockNumber);
32
- }
33
- const _relayerState = this.relayer.getState(blockNumber);
34
- const relayerState = _relayerState
35
- ? _relayerState
36
- : await this.relayer.generateState(blockNumber);
37
- if (!_relayerState) {
38
- this.relayer.setState(relayerState, blockNumber);
39
- }
40
- const poolInitProps = this.removeDisabledPoolInitProps(relayerState, pools);
41
- const bases = Object.entries(poolInitProps).map(([poolAddress, p]) => {
42
- const poolId = (0, utils_1.getPoolIdentifier)(this.dexKey, p.token0, p.token1);
43
- const base = (this.pools[poolId] && this.pools[poolId].base) ||
44
- new integral_pool_1.IntegralEventPool(this.dexKey, this.network, this.dexHelper, poolAddress, p.token0, p.token1, this.logger);
45
- this.pools[poolId] = { base, enabled: true };
46
- return base;
47
- });
48
- await Promise.all(bases.map(base => !base.isInitialized && base.initialize(blockNumber)));
49
- const pricings = await Promise.all(bases.map(async (base) => {
50
- const _poolState = base.getState(blockNumber);
51
- const poolState = _poolState
52
- ? _poolState
53
- : await base.generateState(blockNumber);
54
- const poolId = (0, utils_1.getPoolIdentifier)(this.dexKey, base.token0, base.token1);
55
- const pricing = (this.pools[poolId] && this.pools[poolId].pricing) ||
56
- new integral_pricing_1.IntegralPricing(this.dexHelper, poolId, this.erc20Interface, poolState.uniswapPool, base.token0, base.token1, poolState.uniswapPoolFee, this.logger, this.network);
57
- this.pools[poolId].pricing = pricing;
58
- return pricing;
59
- }));
60
- await Promise.all(pricings.map(pricing => !pricing.isInitialized && pricing.initialize(blockNumber)));
61
- const initIntegralToken = (token) => new integral_token_1.IntegralToken(this.network, this.dexHelper, this.dexKey, this.erc20Interface, token, this.relayerAddress, this.onTransferUpdateBalance, this.logger);
62
- bases.map(base => {
63
- this.tokens[base.token0] =
64
- this.tokens[base.token0] || initIntegralToken(base.token0);
65
- this.tokens[base.token1] =
66
- this.tokens[base.token1] || initIntegralToken(base.token1);
67
- });
68
- await Promise.all(Object.values(this.tokens).map(token => !token.isInitialized && token.initialize(blockNumber)));
69
- }
70
- getPoolAddresses() {
71
- return Object.values(this.pools)
72
- .filter((pool) => !!pool.base && pool.enabled)
73
- .map(({ base }) => base.poolAddress);
74
- }
75
- removeDisabledPoolInitProps(state, props) {
76
- Object.entries(state.pools).forEach(([poolAddress, poolState]) => !poolState.isEnabled && delete props[poolAddress]);
77
- return props;
78
- }
79
- static initialize(network, dexKey, dexHelper, erc20Interface, factoryAddress, relayerAddress) {
80
- if (!this.instances[network]) {
81
- this.instances[network] = new IntegralContext(network, dexKey, dexHelper, erc20Interface, factoryAddress, relayerAddress);
82
- }
83
- return this.instances[network];
84
- }
85
- static getInstance(network) {
86
- if (!this.instances[network]) {
87
- throw new Error('IntegralContext instance not initialized');
88
- }
89
- return this.instances[network];
90
- }
91
- async onRelayerPoolEnabledSet(poolAddress, state, blockNumber) {
92
- const poolEntry = (0, utils_1.getPoolBackReferencedFrom)(this, poolAddress);
93
- if (state.isEnabled && (!poolEntry || !poolEntry[1].enabled)) {
94
- const _factoryState = this.factory.getStaleState();
95
- const factoryState = _factoryState
96
- ? _factoryState
97
- : await this.factory.generateState(blockNumber);
98
- const { token0, token1 } = factoryState.pools[poolAddress];
99
- await this.addPools({ [poolAddress]: { token0, token1 } }, blockNumber);
100
- }
101
- else if (!state.isEnabled && poolEntry && poolEntry[1].enabled) {
102
- this.pools[poolEntry[0]].enabled = false;
103
- }
104
- }
105
- onRebalanceSellOrderExecuted(blockNumber, orderId) {
106
- this.relayer.executeOrder(orderId, blockNumber);
107
- }
108
- async onPoolCreatedAddPool(token0, token1, poolAddress, blockNumber) {
109
- await this.addPools({ [poolAddress]: { token0, token1 } }, blockNumber);
110
- }
111
- async onPoolSwapForRelayer(blockNumber, poolAddress, recipient, amount0Out, amount1Out) {
112
- if (recipient.toLowerCase() === this.relayerAddress.toLowerCase()) {
113
- const pools = this.relayer.getPools();
114
- if (pools[poolAddress.toLowerCase()]) {
115
- const token0 = pools[poolAddress.toLowerCase()].token0;
116
- const token1 = pools[poolAddress.toLowerCase()].token1;
117
- let _state = this.relayer.getStaleState();
118
- if (!_state) {
119
- _state = await this.relayer.generateState(blockNumber);
120
- this.relayer.setState(_state, blockNumber);
121
- return;
122
- }
123
- else {
124
- blockNumber = this.relayer.getStateBlockNumber();
125
- }
126
- const state = lodash_1.default.cloneDeep(_state);
127
- if (amount1Out > 0n) {
128
- state.tokens[token1].balance += amount1Out;
129
- }
130
- else {
131
- state.tokens[token0].balance += amount0Out;
132
- }
133
- this.relayer.setState(state, blockNumber);
134
- }
135
- else {
136
- this.logger.error('Integral Relayer: Pool address not found for', poolAddress);
137
- }
138
- }
139
- }
140
- async onTransferUpdateBalance(token, from, to, amount, blockNumber) {
141
- let _state = this.relayer.getStaleState();
142
- if (!_state) {
143
- this.logger.error('Integral Token: Relayer stale state not found');
144
- return;
145
- }
146
- const state = lodash_1.default.cloneDeep(_state);
147
- if (this.relayer.relayerAddress.toLowerCase() === from) {
148
- state.tokens[token].balance -= amount;
149
- }
150
- else if (this.relayer.relayerAddress.toLowerCase() === to) {
151
- state.tokens[token].balance += amount;
152
- }
153
- this.relayer.setState(state, blockNumber);
154
- }
155
- }
156
- exports.IntegralContext = IntegralContext;
157
- IntegralContext.instances = {};
158
- //# sourceMappingURL=context.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/dex/integral/context.ts"],"names":[],"mappings":";;;;;;AACA,mDAAoD;AACpD,yDAAqD;AACrD,yDAAqD;AACrD,yDAAqD;AAYrD,qDAAiD;AACjD,mCAAuE;AACvE,oDAAuB;AAEvB,MA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,yBAAS,GAA2C,EAAE,CAAC"}
@@ -1,17 +0,0 @@
1
- import { Address } from '../../types';
2
- import { PoolState as UniswapPoolState } from '../uniswap-v3/types';
3
- import { IntegralContext } from './context';
4
- import { PoolStates, RelayerPoolState } from './types';
5
- export declare function sortTokens(srcAddress: Address, destAddress: Address): string[];
6
- export declare function getDecimalsConverter(decimals0: number, decimals1: number, inverted: boolean): bigint;
7
- export declare function getPrice(states: PoolStates, inverted: boolean): bigint;
8
- export declare function getSpotPrice(pricing: UniswapPoolState, decimalsConverter: bigint): bigint;
9
- export declare function getAveragePrice(relayer: RelayerPoolState, pricing: UniswapPoolState, decimalsConverter: bigint): bigint;
10
- export declare function getTickCumulatives(poolState: UniswapPoolState, secondsAgos: bigint[]): bigint[];
11
- export declare function isInverted(tokenIn: Address, tokenOut: Address): boolean;
12
- export declare function getPoolIdentifier(dexKey: string, srcAddress: Address, destAddress: Address): string;
13
- export declare function onPoolSwapForRelayer(blockNumber: number, poolAddress: Address, recipient: Address, amount0Out: bigint, amount1Out: bigint, _context?: IntegralContext): Promise<void>;
14
- export declare function onRelayerPoolEnabledSet(poolAddress: Address, state: RelayerPoolState, blockNumber: number): Promise<void>;
15
- export declare function onRebalanceSellOrderExecuted(blockNumber: number, orderId: bigint): void;
16
- export declare function onPoolCreatedAddPool(token0: Address, token1: Address, poolAddress: Address, blockNumber: number): Promise<void>;
17
- export declare function onTransferUpdateBalance(token: Address, from: Address, to: Address, amount: bigint, blockNumber: number, _context?: IntegralContext): Promise<void>;
@@ -1,157 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.onTransferUpdateBalance = exports.onPoolCreatedAddPool = exports.onRebalanceSellOrderExecuted = exports.onRelayerPoolEnabledSet = exports.onPoolSwapForRelayer = exports.getPoolIdentifier = exports.isInverted = exports.getTickCumulatives = exports.getAveragePrice = exports.getSpotPrice = exports.getPrice = exports.getDecimalsConverter = exports.sortTokens = void 0;
7
- const lodash_1 = __importDefault(require("lodash"));
8
- const utils_1 = require("../../utils");
9
- const FullMath_1 = require("../uniswap-v3/contract-math/FullMath");
10
- const Oracle_1 = require("../uniswap-v3/contract-math/Oracle");
11
- const TickMath_1 = require("../uniswap-v3/contract-math/TickMath");
12
- const context_1 = require("./context");
13
- function sortTokens(srcAddress, destAddress) {
14
- return [srcAddress, destAddress].sort((a, b) => (a < b ? -1 : 1));
15
- }
16
- exports.sortTokens = sortTokens;
17
- function getDecimalsConverter(decimals0, decimals1, inverted) {
18
- return (10n **
19
- (18n + BigInt(inverted ? decimals1 - decimals0 : decimals0 - decimals1)));
20
- }
21
- exports.getDecimalsConverter = getDecimalsConverter;
22
- function getPrice(states, inverted) {
23
- const { base, pricing, relayer } = states;
24
- const decimalsConverter = getDecimalsConverter(base.decimals0, base.decimals1, false);
25
- const spotPrice = getSpotPrice(pricing, decimalsConverter);
26
- const averagePrice = getAveragePrice(relayer, pricing, decimalsConverter);
27
- if (inverted) {
28
- return 10n ** 36n / (spotPrice > averagePrice ? spotPrice : averagePrice);
29
- }
30
- else {
31
- return spotPrice < averagePrice ? spotPrice : averagePrice;
32
- }
33
- }
34
- exports.getPrice = getPrice;
35
- function getSpotPrice(pricing, decimalsConverter) {
36
- const sqrtPriceX96 = pricing.slot0.sqrtPriceX96;
37
- const priceX128 = FullMath_1.FullMath.mulDiv(sqrtPriceX96, sqrtPriceX96, 2n ** 64n);
38
- return FullMath_1.FullMath.mulDiv(priceX128, decimalsConverter, 2n ** 128n);
39
- }
40
- exports.getSpotPrice = getSpotPrice;
41
- function getAveragePrice(relayer, pricing, decimalsConverter) {
42
- (0, utils_1._require)(relayer.twapInterval > 0, 'Twap Interval not set');
43
- const secondsAgo = BigInt(relayer.twapInterval);
44
- const secondsAgos = [secondsAgo, 0n];
45
- const tickCumulatives = getTickCumulatives(pricing, secondsAgos);
46
- const delta = tickCumulatives[1] - tickCumulatives[0];
47
- let arithmeticMeanTick = delta / secondsAgo;
48
- if (delta < 0 && delta % secondsAgo != 0n) {
49
- --arithmeticMeanTick;
50
- }
51
- const sqrtRatioX96 = TickMath_1.TickMath.getSqrtRatioAtTick(arithmeticMeanTick);
52
- const ratioX128 = FullMath_1.FullMath.mulDiv(sqrtRatioX96, sqrtRatioX96, 2n ** 64n);
53
- return FullMath_1.FullMath.mulDiv(ratioX128, decimalsConverter, 2n ** 128n);
54
- }
55
- exports.getAveragePrice = getAveragePrice;
56
- function getTickCumulatives(poolState, secondsAgos) {
57
- const { tickCumulatives } = secondsAgos.reduce((memo, secondsAgo, i) => {
58
- [memo.tickCumulatives[i], memo.secondsPerLiquidityCumulativeX128s[i]] =
59
- Oracle_1.Oracle.observeSingle(poolState, BigInt.asUintN(32, poolState.blockTimestamp), secondsAgo, poolState.slot0.tick, poolState.slot0.observationIndex, poolState.liquidity, poolState.slot0.observationCardinality);
60
- return memo;
61
- }, {
62
- tickCumulatives: Array(secondsAgos.length),
63
- secondsPerLiquidityCumulativeX128s: Array(secondsAgos.length),
64
- });
65
- return tickCumulatives;
66
- }
67
- exports.getTickCumulatives = getTickCumulatives;
68
- function isInverted(tokenIn, tokenOut) {
69
- const [, token1] = tokenIn.toLowerCase() < tokenOut.toLowerCase()
70
- ? [tokenIn, tokenOut]
71
- : [tokenOut, tokenIn];
72
- return tokenIn === token1;
73
- }
74
- exports.isInverted = isInverted;
75
- function getPoolIdentifier(dexKey, srcAddress, destAddress) {
76
- const tokenAddresses = sortTokens(srcAddress.toLowerCase(), destAddress.toLowerCase()).join('_');
77
- return `${dexKey}_${tokenAddresses}`;
78
- }
79
- exports.getPoolIdentifier = getPoolIdentifier;
80
- async function onPoolSwapForRelayer(blockNumber, poolAddress, recipient, amount0Out, amount1Out, _context) {
81
- const context = _context || context_1.IntegralContext.getInstance();
82
- if (recipient.toLowerCase() === context.relayerAddress.toLowerCase()) {
83
- const pools = context.relayer.getPools();
84
- if (pools[poolAddress.toLowerCase()]) {
85
- const token0 = pools[poolAddress.toLowerCase()].token0;
86
- const token1 = pools[poolAddress.toLowerCase()].token1;
87
- let _state = context.relayer.getStaleState();
88
- if (!_state) {
89
- _state = await context.relayer.generateState(blockNumber);
90
- context.relayer.setState(_state, blockNumber);
91
- return;
92
- }
93
- else {
94
- blockNumber = context.relayer.getStateBlockNumber();
95
- }
96
- const state = lodash_1.default.cloneDeep(_state);
97
- if (amount1Out > 0n) {
98
- state.tokens[token1].balance += amount1Out;
99
- }
100
- else {
101
- state.tokens[token0].balance += amount0Out;
102
- }
103
- context.relayer.setState(state, blockNumber);
104
- }
105
- else {
106
- context.logger.error('Integral Relayer: Pool address not found for', poolAddress);
107
- }
108
- }
109
- }
110
- exports.onPoolSwapForRelayer = onPoolSwapForRelayer;
111
- function getPoolBackReferencedFrom(context, poolAddress) {
112
- return Object.entries(context.pools).find(([, pool]) => pool.base?.poolAddress === poolAddress);
113
- }
114
- async function onRelayerPoolEnabledSet(poolAddress, state, blockNumber) {
115
- const context = context_1.IntegralContext.getInstance();
116
- const poolEntry = getPoolBackReferencedFrom(context, poolAddress);
117
- if (state.isEnabled && (!poolEntry || !poolEntry[1].enabled)) {
118
- const _factoryState = context.factory.getStaleState();
119
- const factoryState = _factoryState
120
- ? _factoryState
121
- : await context.factory.generateState(blockNumber);
122
- const { token0, token1 } = factoryState.pools[poolAddress];
123
- await context.addPools({ [poolAddress]: { token0, token1 } }, blockNumber);
124
- }
125
- else if (!state.isEnabled && poolEntry && poolEntry[1].enabled) {
126
- context.pools[poolEntry[0]].enabled = false;
127
- }
128
- }
129
- exports.onRelayerPoolEnabledSet = onRelayerPoolEnabledSet;
130
- function onRebalanceSellOrderExecuted(blockNumber, orderId) {
131
- const context = context_1.IntegralContext.getInstance();
132
- context.relayer.executeOrder(orderId, blockNumber);
133
- }
134
- exports.onRebalanceSellOrderExecuted = onRebalanceSellOrderExecuted;
135
- async function onPoolCreatedAddPool(token0, token1, poolAddress, blockNumber) {
136
- const context = context_1.IntegralContext.getInstance();
137
- await context.addPools({ [poolAddress]: { token0, token1 } }, blockNumber);
138
- }
139
- exports.onPoolCreatedAddPool = onPoolCreatedAddPool;
140
- async function onTransferUpdateBalance(token, from, to, amount, blockNumber, _context) {
141
- const context = _context || context_1.IntegralContext.getInstance();
142
- let _state = context.relayer.getStaleState();
143
- if (!_state) {
144
- context.logger.error('Integral Token: Relayer stale state not found');
145
- return;
146
- }
147
- const state = lodash_1.default.cloneDeep(_state);
148
- if (context.relayer.relayerAddress.toLowerCase() === from) {
149
- state.tokens[token].balance -= amount;
150
- }
151
- else if (context.relayer.relayerAddress.toLowerCase() === to) {
152
- state.tokens[token].balance += amount;
153
- }
154
- context.relayer.setState(state, blockNumber);
155
- }
156
- exports.onTransferUpdateBalance = onTransferUpdateBalance;
157
- //# sourceMappingURL=helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/dex/integral/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAEvB,uCAAuC;AACvC,mEAAgE;AAChE,+DAA4D;AAC5D,mEAAgE;AAEhE,uCAA4C;AAG5C,SAAgB,UAAU,CAAC,UAAmB,EAAE,WAAoB;IAClE,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC;AAFD,gCAEC;AAED,SAAgB,oBAAoB,CAClC,SAAiB,EACjB,SAAiB,EACjB,QAAiB;IAEjB,OAAO,CACL,GAAG;QACH,CAAC,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC,CACzE,CAAC;AACJ,CAAC;AATD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,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC;AAC7E,CAAC;AARD,oDAQC;AAEM,KAAK,UAAU,uBAAuB,CAC3C,KAAc,EACd,IAAa,EACb,EAAW,EACX,MAAc,EACd,WAAmB,EACnB,QAA0B;IAE1B,MAAM,OAAO,GAAG,QAAQ,IAAI,yBAAe,CAAC,WAAW,EAAE,CAAC;IAC1D,IAAI,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;IAC7C,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;QACtE,OAAO;KACR;IACD,MAAM,KAAK,GAAiB,gBAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAChD,IAAI,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,WAAW,EAAE,KAAK,IAAI,EAAE;QACzD,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC;KACvC;SAAM,IAAI,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,WAAW,EAAE,KAAK,EAAE,EAAE;QAC9D,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC;KACvC;IACD,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;AAC/C,CAAC;AArBD,0DAqBC"}
@@ -1,24 +0,0 @@
1
- import { Interface } from '@ethersproject/abi';
2
- import { LogDescription } from 'ethers/lib/utils';
3
- import { IDexHelper } from '../../dex-helper';
4
- import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
5
- import { Address, BlockHeader, Log, Logger } from '../../types';
6
- import { FactoryState } from './types';
7
- export declare type OnPoolCreatedCallback = (token0: Address, token1: Address, poolAddress: Address, blockNumber: number) => Promise<void>;
8
- export declare class IntegralFactory extends StatefulEventSubscriber<FactoryState> {
9
- readonly dexHelper: IDexHelper;
10
- protected readonly factoryAddress: Address;
11
- protected readonly onPoolCreated: OnPoolCreatedCallback;
12
- handlers: {
13
- [event: string]: (event: any, state: FactoryState, blockHeader: Readonly<BlockHeader>) => Promise<FactoryState>;
14
- };
15
- logDecoder: (log: Log) => any;
16
- readonly factoryIface: Interface;
17
- constructor(dexHelper: IDexHelper, parentName: string, factoryAddress: Address, onPoolCreated: OnPoolCreatedCallback, logger: Logger, mapKey?: string);
18
- protected getPoolIdentifierData(): {
19
- factory: string;
20
- };
21
- generateState(blockNumber?: number | 'latest'): Promise<FactoryState>;
22
- protected processLog(state: FactoryState, log: Readonly<Log>, blockHeader: Readonly<BlockHeader>): Promise<FactoryState>;
23
- handlePairCreated(event: LogDescription, state: FactoryState, blockHeader: Readonly<BlockHeader>): Promise<FactoryState>;
24
- }