@paraswap/dex-lib 2.42.4 → 2.42.5

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 (203) hide show
  1. package/build/abi/kyberswap-elastic/IAntiSnipAttackPositionManager.json +1276 -0
  2. package/build/abi/kyberswap-elastic/IFactory.json +550 -0
  3. package/build/abi/kyberswap-elastic/IPool.json +1042 -0
  4. package/build/abi/kyberswap-elastic/IQuoterV2.json +226 -0
  5. package/build/abi/kyberswap-elastic/IRouter.json +239 -0
  6. package/build/abi/kyberswap-elastic/TicksFeesReader.json +142 -0
  7. package/build/abi/wombat/asset.json +769 -0
  8. package/build/abi/wombat/bmw.json +1247 -0
  9. package/build/abi/wombat/pool.json +1364 -0
  10. package/build/dex/baseswap-v3/baseswap-v3-factory.d.ts +26 -0
  11. package/build/dex/baseswap-v3/baseswap-v3-factory.js +44 -0
  12. package/build/dex/baseswap-v3/baseswap-v3-factory.js.map +1 -0
  13. package/build/dex/baseswap-v3/baseswap-v3-pool.d.ts +46 -0
  14. package/build/dex/baseswap-v3/baseswap-v3-pool.js +312 -0
  15. package/build/dex/baseswap-v3/baseswap-v3-pool.js.map +1 -0
  16. package/build/dex/baseswap-v3/baseswap-v3.d.ts +71 -0
  17. package/build/dex/baseswap-v3/baseswap-v3.js +752 -0
  18. package/build/dex/baseswap-v3/baseswap-v3.js.map +1 -0
  19. package/build/dex/baseswap-v3/config.d.ts +9 -0
  20. package/build/dex/baseswap-v3/config.js +48 -0
  21. package/build/dex/baseswap-v3/config.js.map +1 -0
  22. package/build/dex/baseswap-v3/constants.d.ts +28 -0
  23. package/build/dex/baseswap-v3/constants.js +35 -0
  24. package/build/dex/baseswap-v3/constants.js.map +1 -0
  25. package/build/dex/baseswap-v3/contract-math/BitMath.d.ts +4 -0
  26. package/build/dex/baseswap-v3/contract-math/BitMath.js +93 -0
  27. package/build/dex/baseswap-v3/contract-math/BitMath.js.map +1 -0
  28. package/build/dex/baseswap-v3/contract-math/FixedPoint128.d.ts +3 -0
  29. package/build/dex/baseswap-v3/contract-math/FixedPoint128.js +8 -0
  30. package/build/dex/baseswap-v3/contract-math/FixedPoint128.js.map +1 -0
  31. package/build/dex/baseswap-v3/contract-math/FixedPoint96.d.ts +4 -0
  32. package/build/dex/baseswap-v3/contract-math/FixedPoint96.js +9 -0
  33. package/build/dex/baseswap-v3/contract-math/FixedPoint96.js.map +1 -0
  34. package/build/dex/baseswap-v3/contract-math/FullMath.d.ts +4 -0
  35. package/build/dex/baseswap-v3/contract-math/FullMath.js +19 -0
  36. package/build/dex/baseswap-v3/contract-math/FullMath.js.map +1 -0
  37. package/build/dex/baseswap-v3/contract-math/LiquidityMath.d.ts +3 -0
  38. package/build/dex/baseswap-v3/contract-math/LiquidityMath.js +22 -0
  39. package/build/dex/baseswap-v3/contract-math/LiquidityMath.js.map +1 -0
  40. package/build/dex/baseswap-v3/contract-math/Oracle.d.ts +10 -0
  41. package/build/dex/baseswap-v3/contract-math/Oracle.js +133 -0
  42. package/build/dex/baseswap-v3/contract-math/Oracle.js.map +1 -0
  43. package/build/dex/baseswap-v3/contract-math/SqrtPriceMath.d.ts +10 -0
  44. package/build/dex/baseswap-v3/contract-math/SqrtPriceMath.js +91 -0
  45. package/build/dex/baseswap-v3/contract-math/SqrtPriceMath.js.map +1 -0
  46. package/build/dex/baseswap-v3/contract-math/SwapMath.d.ts +8 -0
  47. package/build/dex/baseswap-v3/contract-math/SwapMath.js +70 -0
  48. package/build/dex/baseswap-v3/contract-math/SwapMath.js.map +1 -0
  49. package/build/dex/baseswap-v3/contract-math/Tick.d.ts +7 -0
  50. package/build/dex/baseswap-v3/contract-math/Tick.js +45 -0
  51. package/build/dex/baseswap-v3/contract-math/Tick.js.map +1 -0
  52. package/build/dex/baseswap-v3/contract-math/TickBitMap.d.ts +7 -0
  53. package/build/dex/baseswap-v3/contract-math/TickBitMap.js +84 -0
  54. package/build/dex/baseswap-v3/contract-math/TickBitMap.js.map +1 -0
  55. package/build/dex/baseswap-v3/contract-math/TickMath.d.ts +8 -0
  56. package/build/dex/baseswap-v3/contract-math/TickMath.js +162 -0
  57. package/build/dex/baseswap-v3/contract-math/TickMath.js.map +1 -0
  58. package/build/dex/baseswap-v3/contract-math/UnsafeMath.d.ts +3 -0
  59. package/build/dex/baseswap-v3/contract-math/UnsafeMath.js +10 -0
  60. package/build/dex/baseswap-v3/contract-math/UnsafeMath.js.map +1 -0
  61. package/build/dex/baseswap-v3/contract-math/uniswap-v3-math.d.ts +37 -0
  62. package/build/dex/baseswap-v3/contract-math/uniswap-v3-math.js +393 -0
  63. package/build/dex/baseswap-v3/contract-math/uniswap-v3-math.js.map +1 -0
  64. package/build/dex/baseswap-v3/contract-math/utils.d.ts +7 -0
  65. package/build/dex/baseswap-v3/contract-math/utils.js +42 -0
  66. package/build/dex/baseswap-v3/contract-math/utils.js.map +1 -0
  67. package/build/dex/baseswap-v3/types.d.ts +164 -0
  68. package/build/dex/baseswap-v3/types.js +9 -0
  69. package/build/dex/baseswap-v3/types.js.map +1 -0
  70. package/build/dex/baseswap-v3/utils.d.ts +6 -0
  71. package/build/dex/baseswap-v3/utils.js +65 -0
  72. package/build/dex/baseswap-v3/utils.js.map +1 -0
  73. package/build/dex/hello/config.d.ts +4 -0
  74. package/build/dex/hello/config.js +15 -0
  75. package/build/dex/hello/config.js.map +1 -0
  76. package/build/dex/hello/hello-pool.d.ts +39 -0
  77. package/build/dex/hello/hello-pool.js +64 -0
  78. package/build/dex/hello/hello-pool.js.map +1 -0
  79. package/build/dex/hello/hello.d.ts +37 -0
  80. package/build/dex/hello/hello.js +126 -0
  81. package/build/dex/hello/hello.js.map +1 -0
  82. package/build/dex/hello/types.d.ts +6 -0
  83. package/build/dex/hello/types.js +3 -0
  84. package/build/dex/hello/types.js.map +1 -0
  85. package/build/dex/kyberswap-elastic/config.d.ts +4 -0
  86. package/build/dex/kyberswap-elastic/config.js +80 -0
  87. package/build/dex/kyberswap-elastic/config.js.map +1 -0
  88. package/build/dex/kyberswap-elastic/constants.d.ts +17 -0
  89. package/build/dex/kyberswap-elastic/constants.js +42 -0
  90. package/build/dex/kyberswap-elastic/constants.js.map +1 -0
  91. package/build/dex/kyberswap-elastic/contract-math/FixedPoint96.d.ts +4 -0
  92. package/build/dex/kyberswap-elastic/contract-math/FixedPoint96.js +9 -0
  93. package/build/dex/kyberswap-elastic/contract-math/FixedPoint96.js.map +1 -0
  94. package/build/dex/kyberswap-elastic/contract-math/FullMath.d.ts +5 -0
  95. package/build/dex/kyberswap-elastic/contract-math/FullMath.js +22 -0
  96. package/build/dex/kyberswap-elastic/contract-math/FullMath.js.map +1 -0
  97. package/build/dex/kyberswap-elastic/contract-math/LiqDeltaMath.d.ts +3 -0
  98. package/build/dex/kyberswap-elastic/contract-math/LiqDeltaMath.js +12 -0
  99. package/build/dex/kyberswap-elastic/contract-math/LiqDeltaMath.js.map +1 -0
  100. package/build/dex/kyberswap-elastic/contract-math/LiquidityMath.d.ts +3 -0
  101. package/build/dex/kyberswap-elastic/contract-math/LiquidityMath.js +22 -0
  102. package/build/dex/kyberswap-elastic/contract-math/LiquidityMath.js.map +1 -0
  103. package/build/dex/kyberswap-elastic/contract-math/QtyDeltaMath.d.ts +5 -0
  104. package/build/dex/kyberswap-elastic/contract-math/QtyDeltaMath.js +25 -0
  105. package/build/dex/kyberswap-elastic/contract-math/QtyDeltaMath.js.map +1 -0
  106. package/build/dex/kyberswap-elastic/contract-math/QuadMath.d.ts +4 -0
  107. package/build/dex/kyberswap-elastic/contract-math/QuadMath.js +27 -0
  108. package/build/dex/kyberswap-elastic/contract-math/QuadMath.js.map +1 -0
  109. package/build/dex/kyberswap-elastic/contract-math/ReinvestmentMath.d.ts +3 -0
  110. package/build/dex/kyberswap-elastic/contract-math/ReinvestmentMath.js +14 -0
  111. package/build/dex/kyberswap-elastic/contract-math/ReinvestmentMath.js.map +1 -0
  112. package/build/dex/kyberswap-elastic/contract-math/SafeCast.d.ts +8 -0
  113. package/build/dex/kyberswap-elastic/contract-math/SafeCast.js +30 -0
  114. package/build/dex/kyberswap-elastic/contract-math/SafeCast.js.map +1 -0
  115. package/build/dex/kyberswap-elastic/contract-math/SqrtPriceMath.d.ts +10 -0
  116. package/build/dex/kyberswap-elastic/contract-math/SqrtPriceMath.js +91 -0
  117. package/build/dex/kyberswap-elastic/contract-math/SqrtPriceMath.js.map +1 -0
  118. package/build/dex/kyberswap-elastic/contract-math/SwapMath.d.ts +13 -0
  119. package/build/dex/kyberswap-elastic/contract-math/SwapMath.js +188 -0
  120. package/build/dex/kyberswap-elastic/contract-math/SwapMath.js.map +1 -0
  121. package/build/dex/kyberswap-elastic/contract-math/TickLinkedList.d.ts +6 -0
  122. package/build/dex/kyberswap-elastic/contract-math/TickLinkedList.js +41 -0
  123. package/build/dex/kyberswap-elastic/contract-math/TickLinkedList.js.map +1 -0
  124. package/build/dex/kyberswap-elastic/contract-math/TickMath.d.ts +9 -0
  125. package/build/dex/kyberswap-elastic/contract-math/TickMath.js +165 -0
  126. package/build/dex/kyberswap-elastic/contract-math/TickMath.js.map +1 -0
  127. package/build/dex/kyberswap-elastic/contract-math/UnsafeMath.d.ts +3 -0
  128. package/build/dex/kyberswap-elastic/contract-math/UnsafeMath.js +10 -0
  129. package/build/dex/kyberswap-elastic/contract-math/UnsafeMath.js.map +1 -0
  130. package/build/dex/kyberswap-elastic/contract-math/kyberswap-elastic-math.d.ts +28 -0
  131. package/build/dex/kyberswap-elastic/contract-math/kyberswap-elastic-math.js +502 -0
  132. package/build/dex/kyberswap-elastic/contract-math/kyberswap-elastic-math.js.map +1 -0
  133. package/build/dex/kyberswap-elastic/contract-math/utils.d.ts +3 -0
  134. package/build/dex/kyberswap-elastic/contract-math/utils.js +16 -0
  135. package/build/dex/kyberswap-elastic/contract-math/utils.js.map +1 -0
  136. package/build/dex/kyberswap-elastic/errors.d.ts +2 -0
  137. package/build/dex/kyberswap-elastic/errors.js +6 -0
  138. package/build/dex/kyberswap-elastic/errors.js.map +1 -0
  139. package/build/dex/kyberswap-elastic/kyberswap-elastic-pool.d.ts +80 -0
  140. package/build/dex/kyberswap-elastic/kyberswap-elastic-pool.js +458 -0
  141. package/build/dex/kyberswap-elastic/kyberswap-elastic-pool.js.map +1 -0
  142. package/build/dex/kyberswap-elastic/kyberswap-elastic.d.ts +53 -0
  143. package/build/dex/kyberswap-elastic/kyberswap-elastic.js +610 -0
  144. package/build/dex/kyberswap-elastic/kyberswap-elastic.js.map +1 -0
  145. package/build/dex/kyberswap-elastic/types.d.ts +134 -0
  146. package/build/dex/kyberswap-elastic/types.js +9 -0
  147. package/build/dex/kyberswap-elastic/types.js.map +1 -0
  148. package/build/dex/kyberswap-elastic/utils/decoders.d.ts +9 -0
  149. package/build/dex/kyberswap-elastic/utils/decoders.js +78 -0
  150. package/build/dex/kyberswap-elastic/utils/decoders.js.map +1 -0
  151. package/build/dex/morphex/config.d.ts +11 -0
  152. package/build/dex/morphex/config.js +43 -0
  153. package/build/dex/morphex/config.js.map +1 -0
  154. package/build/dex/morphex/morphex.d.ts +25 -0
  155. package/build/dex/morphex/morphex.js +19 -0
  156. package/build/dex/morphex/morphex.js.map +1 -0
  157. package/build/dex/my-test-dex/config.d.ts +4 -0
  158. package/build/dex/my-test-dex/config.js +15 -0
  159. package/build/dex/my-test-dex/config.js.map +1 -0
  160. package/build/dex/my-test-dex/my-test-dex-pool.d.ts +39 -0
  161. package/build/dex/my-test-dex/my-test-dex-pool.js +64 -0
  162. package/build/dex/my-test-dex/my-test-dex-pool.js.map +1 -0
  163. package/build/dex/my-test-dex/my-test-dex.d.ts +37 -0
  164. package/build/dex/my-test-dex/my-test-dex.js +126 -0
  165. package/build/dex/my-test-dex/my-test-dex.js.map +1 -0
  166. package/build/dex/my-test-dex/types.d.ts +6 -0
  167. package/build/dex/my-test-dex/types.js +3 -0
  168. package/build/dex/my-test-dex/types.js.map +1 -0
  169. package/build/dex/solidly/forks-override/fvm.d.ts +20 -0
  170. package/build/dex/solidly/forks-override/fvm.js +42 -0
  171. package/build/dex/solidly/forks-override/fvm.js.map +1 -0
  172. package/build/dex/uniswap-v3/config.js +14 -0
  173. package/build/dex/uniswap-v3/config.js.map +1 -1
  174. package/build/dex/uniswap-v3/uniswap-v3.js +1 -0
  175. package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
  176. package/build/dex/wombat/config.d.ts +5 -0
  177. package/build/dex/wombat/config.js +36 -0
  178. package/build/dex/wombat/config.js.map +1 -0
  179. package/build/dex/wombat/types.d.ts +33 -0
  180. package/build/dex/wombat/types.js +3 -0
  181. package/build/dex/wombat/types.js.map +1 -0
  182. package/build/dex/wombat/utils.d.ts +9 -0
  183. package/build/dex/wombat/utils.js +66 -0
  184. package/build/dex/wombat/utils.js.map +1 -0
  185. package/build/dex/wombat/wombat-bmw.d.ts +40 -0
  186. package/build/dex/wombat/wombat-bmw.js +145 -0
  187. package/build/dex/wombat/wombat-bmw.js.map +1 -0
  188. package/build/dex/wombat/wombat-pool.d.ts +22 -0
  189. package/build/dex/wombat/wombat-pool.js +161 -0
  190. package/build/dex/wombat/wombat-pool.js.map +1 -0
  191. package/build/dex/wombat/wombat-quoter.d.ts +16 -0
  192. package/build/dex/wombat/wombat-quoter.js +176 -0
  193. package/build/dex/wombat/wombat-quoter.js.map +1 -0
  194. package/build/dex/wombat/wombat.d.ts +55 -0
  195. package/build/dex/wombat/wombat.js +292 -0
  196. package/build/dex/wombat/wombat.js.map +1 -0
  197. package/package.json +1 -1
  198. package/src/dex/uniswap-v3/config.ts +14 -0
  199. package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +24 -0
  200. package/src/dex/uniswap-v3/uniswap-v3-integration.test.ts +331 -0
  201. package/src/dex/uniswap-v3/uniswap-v3.ts +1 -0
  202. package/.vscode/launch.json +0 -16
  203. package/build/test.js +0 -26
@@ -0,0 +1,26 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { DeepReadonly } from 'ts-essentials';
3
+ import { IDexHelper } from '../../dex-helper/idex-helper';
4
+ import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
5
+ import { Address, Log, Logger } from '../../types';
6
+ import { LogDescription } from 'ethers/lib/utils';
7
+ import { FactoryState } from './types';
8
+ export declare type OnPoolCreatedCallback = ({ token0, token1, fee, }: {
9
+ token0: string;
10
+ token1: string;
11
+ fee: bigint;
12
+ }) => Promise<void>;
13
+ export declare class BaseswapV3Factory extends StatefulEventSubscriber<FactoryState> {
14
+ readonly dexHelper: IDexHelper;
15
+ protected readonly factoryAddress: Address;
16
+ protected readonly onPoolCreated: OnPoolCreatedCallback;
17
+ handlers: {
18
+ [event: string]: (event: any) => Promise<void>;
19
+ };
20
+ logDecoder: (log: Log) => any;
21
+ readonly factoryIface: Interface;
22
+ constructor(dexHelper: IDexHelper, parentName: string, factoryAddress: Address, logger: Logger, onPoolCreated: OnPoolCreatedCallback, mapKey?: string);
23
+ generateState(): FactoryState;
24
+ protected processLog(_: DeepReadonly<FactoryState>, log: Readonly<Log>): Promise<FactoryState>;
25
+ handleNewPool(event: LogDescription): Promise<void>;
26
+ }
@@ -0,0 +1,44 @@
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.BaseswapV3Factory = void 0;
7
+ const abi_1 = require("@ethersproject/abi");
8
+ const UniswapV3Factory_abi_json_1 = __importDefault(require("../../abi/uniswap-v3/UniswapV3Factory.abi.json"));
9
+ const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
10
+ /*
11
+ * "Stateless" event subscriber in order to capture "PoolCreated" event on new pools created.
12
+ * State is present, but it's a placeholder to actually make the events reach handlers (if there's no previous state - `processBlockLogs` is not called)
13
+ */
14
+ class BaseswapV3Factory extends stateful_event_subscriber_1.StatefulEventSubscriber {
15
+ constructor(dexHelper, parentName, factoryAddress, logger, onPoolCreated, mapKey = '') {
16
+ super(parentName, `${parentName} Factory`, dexHelper, logger, true, mapKey);
17
+ this.dexHelper = dexHelper;
18
+ this.factoryAddress = factoryAddress;
19
+ this.onPoolCreated = onPoolCreated;
20
+ this.handlers = {};
21
+ this.factoryIface = new abi_1.Interface(UniswapV3Factory_abi_json_1.default);
22
+ this.addressesSubscribed = [factoryAddress];
23
+ this.logDecoder = (log) => this.factoryIface.parseLog(log);
24
+ this.handlers['PoolCreated'] = this.handleNewPool.bind(this);
25
+ }
26
+ generateState() {
27
+ return {};
28
+ }
29
+ async processLog(_, log) {
30
+ const event = this.logDecoder(log);
31
+ if (event.name in this.handlers) {
32
+ await this.handlers[event.name](event);
33
+ }
34
+ return {};
35
+ }
36
+ async handleNewPool(event) {
37
+ const token0 = event.args.token0.toLowerCase();
38
+ const token1 = event.args.token1.toLowerCase();
39
+ const fee = event.args.fee;
40
+ await this.onPoolCreated({ token0, token1, fee });
41
+ }
42
+ }
43
+ exports.BaseswapV3Factory = BaseswapV3Factory;
44
+ //# sourceMappingURL=baseswap-v3-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseswap-v3-factory.js","sourceRoot":"","sources":["../../../src/dex/baseswap-v3/baseswap-v3-factory.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA+C;AAE/C,+GAAwE;AAExE,+EAA0E;AAe1E;;;GAGG;AACH,MAAa,iBAAkB,SAAQ,mDAAqC;IAS1E,YACW,SAAqB,EAC9B,UAAkB,EACC,cAAuB,EAC1C,MAAc,EACK,aAAoC,EACvD,SAAiB,EAAE;QAEnB,KAAK,CAAC,UAAU,EAAE,GAAG,UAAU,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAPnE,cAAS,GAAT,SAAS,CAAY;QAEX,mBAAc,GAAd,cAAc,CAAS;QAEvB,kBAAa,GAAb,aAAa,CAAuB;QAbzD,aAAQ,GAEJ,EAAE,CAAC;QAIS,iBAAY,GAAG,IAAI,eAAS,CAAC,mCAAU,CAAC,CAAC;QAYvD,IAAI,CAAC,mBAAmB,GAAG,CAAC,cAAc,CAAC,CAAC;QAE5C,IAAI,CAAC,UAAU,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAEhE,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/D,CAAC;IAED,aAAa;QACX,OAAO,EAAE,CAAC;IACZ,CAAC;IAES,KAAK,CAAC,UAAU,CACxB,CAA6B,EAC7B,GAAkB;QAElB,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACnC,IAAI,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE;YAC/B,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;SACxC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,KAAqB;QACvC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QAC/C,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QAC/C,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;QAE3B,MAAM,IAAI,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IACpD,CAAC;CACF;AAjDD,8CAiDC"}
@@ -0,0 +1,46 @@
1
+ import { Contract } from 'web3-eth-contract';
2
+ import { Interface } from '@ethersproject/abi';
3
+ import { DeepReadonly } from 'ts-essentials';
4
+ import { Log, Logger, BlockHeader, Address } from '../../types';
5
+ import { InitializeStateOptions, StatefulEventSubscriber } from '../../stateful-event-subscriber';
6
+ import { IDexHelper } from '../../dex-helper/idex-helper';
7
+ import { PoolState, DecodedStateMultiCallResultWithRelativeBitmaps, DecodeStateMultiCallFunc } from './types';
8
+ import { MultiCallParams } from '../../lib/multi-wrapper';
9
+ export declare class BaseswapV3EventPool extends StatefulEventSubscriber<PoolState> {
10
+ readonly dexHelper: IDexHelper;
11
+ readonly stateMultiContract: Contract;
12
+ readonly decodeStateMultiCallResultWithRelativeBitmaps: DecodeStateMultiCallFunc | undefined;
13
+ readonly erc20Interface: Interface;
14
+ protected readonly factoryAddress: Address;
15
+ feeCode: bigint;
16
+ readonly poolInitCodeHash: string;
17
+ handlers: {
18
+ [event: string]: (event: any, pool: PoolState, log: Log, blockHeader: Readonly<BlockHeader>) => PoolState;
19
+ };
20
+ logDecoder: (log: Log) => any;
21
+ readonly token0: Address;
22
+ readonly token1: Address;
23
+ private _poolAddress?;
24
+ protected _stateRequestCallData?: MultiCallParams<bigint | DecodedStateMultiCallResultWithRelativeBitmaps>[];
25
+ readonly poolIface: Interface;
26
+ initFailed: boolean;
27
+ initRetryAttemptCount: number;
28
+ feeCodeAsString: string;
29
+ constructor(dexHelper: IDexHelper, parentName: string, stateMultiContract: Contract, decodeStateMultiCallResultWithRelativeBitmaps: DecodeStateMultiCallFunc | undefined, erc20Interface: Interface, factoryAddress: Address, feeCode: bigint, token0: Address, token1: Address, logger: Logger, mapKey: string | undefined, poolInitCodeHash: string);
30
+ get poolAddress(): Address;
31
+ set poolAddress(address: Address);
32
+ initialize(blockNumber: number, options?: InitializeStateOptions<PoolState>): Promise<void>;
33
+ protected processBlockLogs(state: DeepReadonly<PoolState>, logs: Readonly<Log>[], blockHeader: Readonly<BlockHeader>): Promise<DeepReadonly<PoolState> | null>;
34
+ protected processLog(state: DeepReadonly<PoolState>, log: Readonly<Log>, blockHeader: Readonly<BlockHeader>): DeepReadonly<PoolState> | null;
35
+ protected _getStateRequestCallData(): MultiCallParams<bigint | DecodedStateMultiCallResultWithRelativeBitmaps>[];
36
+ getBitmapRangeToRequest(): bigint;
37
+ generateState(blockNumber: number): Promise<Readonly<PoolState>>;
38
+ handleSwapEvent(event: any, pool: PoolState, log: Log, blockHeader: BlockHeader): PoolState;
39
+ handleBurnEvent(event: any, pool: PoolState, log: Log, blockHeader: BlockHeader): PoolState;
40
+ handleMintEvent(event: any, pool: PoolState, log: Log, blockHeader: BlockHeader): PoolState;
41
+ handleSetFeeProtocolEvent(event: any, pool: PoolState, log: Log, blockHeader: BlockHeader): PoolState;
42
+ handleCollectEvent(event: any, pool: PoolState, log: Log, blockHeader: BlockHeader): PoolState;
43
+ handleFlashEvent(event: any, pool: PoolState, log: Log, blockHeader: BlockHeader): PoolState;
44
+ handleIncreaseObservationCardinalityNextEvent(event: any, pool: PoolState, log: Log, blockHeader: BlockHeader): PoolState;
45
+ private _computePoolAddress;
46
+ }
@@ -0,0 +1,312 @@
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.BaseswapV3EventPool = void 0;
7
+ const lodash_1 = __importDefault(require("lodash"));
8
+ const abi_1 = require("@ethersproject/abi");
9
+ const ethers_1 = require("ethers");
10
+ const ts_essentials_1 = require("ts-essentials");
11
+ const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
12
+ const UniswapV3Pool_abi_json_1 = __importDefault(require("../../abi/uniswap-v3/UniswapV3Pool.abi.json"));
13
+ const utils_1 = require("../../utils");
14
+ const uniswap_v3_math_1 = require("./contract-math/uniswap-v3-math");
15
+ const constants_1 = require("./constants");
16
+ const TickBitMap_1 = require("./contract-math/TickBitMap");
17
+ const decoders_1 = require("../../lib/decoders");
18
+ const utils_2 = require("./utils");
19
+ const utils_3 = require("./contract-math/utils");
20
+ class BaseswapV3EventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
21
+ constructor(dexHelper, parentName, stateMultiContract, decodeStateMultiCallResultWithRelativeBitmaps, erc20Interface, factoryAddress, feeCode, token0, token1, logger, mapKey = '', poolInitCodeHash) {
22
+ super(parentName, `${token0}_${token1}_${feeCode}`, dexHelper, logger, true, mapKey);
23
+ this.dexHelper = dexHelper;
24
+ this.stateMultiContract = stateMultiContract;
25
+ this.decodeStateMultiCallResultWithRelativeBitmaps = decodeStateMultiCallResultWithRelativeBitmaps;
26
+ this.erc20Interface = erc20Interface;
27
+ this.factoryAddress = factoryAddress;
28
+ this.feeCode = feeCode;
29
+ this.poolInitCodeHash = poolInitCodeHash;
30
+ this.handlers = {};
31
+ this.poolIface = new abi_1.Interface(UniswapV3Pool_abi_json_1.default);
32
+ this.initFailed = false;
33
+ this.initRetryAttemptCount = 0;
34
+ this.feeCodeAsString = feeCode.toString();
35
+ this.token0 = token0.toLowerCase();
36
+ this.token1 = token1.toLowerCase();
37
+ this.logDecoder = (log) => this.poolIface.parseLog(log);
38
+ this.addressesSubscribed = new Array(1);
39
+ // Add handlers
40
+ this.handlers['Swap'] = this.handleSwapEvent.bind(this);
41
+ this.handlers['Burn'] = this.handleBurnEvent.bind(this);
42
+ this.handlers['Mint'] = this.handleMintEvent.bind(this);
43
+ this.handlers['SetFeeProtocol'] = this.handleSetFeeProtocolEvent.bind(this);
44
+ this.handlers['IncreaseObservationCardinalityNext'] =
45
+ this.handleIncreaseObservationCardinalityNextEvent.bind(this);
46
+ // Wen need them to keep balance of the pool up to date
47
+ this.handlers['Collect'] = this.handleCollectEvent.bind(this);
48
+ // Almost the same as Collect, but for pool owners
49
+ this.handlers['CollectProtocol'] = this.handleCollectEvent.bind(this);
50
+ this.handlers['Flash'] = this.handleFlashEvent.bind(this);
51
+ }
52
+ get poolAddress() {
53
+ if (this._poolAddress === undefined) {
54
+ this._poolAddress = this._computePoolAddress(this.token0, this.token1, this.feeCode);
55
+ }
56
+ return this._poolAddress;
57
+ }
58
+ set poolAddress(address) {
59
+ this._poolAddress = address.toLowerCase();
60
+ }
61
+ async initialize(blockNumber, options) {
62
+ await super.initialize(blockNumber, options);
63
+ }
64
+ async processBlockLogs(state, logs, blockHeader) {
65
+ const newState = await super.processBlockLogs(state, logs, blockHeader);
66
+ if (newState && !newState.isValid) {
67
+ return await this.generateState(blockHeader.number);
68
+ }
69
+ return newState;
70
+ }
71
+ processLog(state, log, blockHeader) {
72
+ try {
73
+ const event = this.logDecoder(log);
74
+ const uniswapV3EventLoggingSampleRate = this.dexHelper.config.data.uniswapV3EventLoggingSampleRate;
75
+ if (!this.dexHelper.config.isSlave &&
76
+ uniswapV3EventLoggingSampleRate &&
77
+ (0, utils_1.isSampled)(uniswapV3EventLoggingSampleRate)) {
78
+ this.logger.info(`event=${event.name} - block=${blockHeader.number}. Log sampled at rate ${uniswapV3EventLoggingSampleRate * 100}%`);
79
+ }
80
+ if (event.name in this.handlers) {
81
+ // Because we have observations in array which is mutable by nature, there is a
82
+ // ts compile error: https://stackoverflow.com/questions/53412934/disable-allowing-assigning-readonly-types-to-non-readonly-types
83
+ // And there is no good workaround, so turn off the type checker for this line
84
+ const _state = lodash_1.default.cloneDeep(state);
85
+ try {
86
+ return this.handlers[event.name](event, _state, log, blockHeader);
87
+ }
88
+ catch (e) {
89
+ if (e instanceof Error &&
90
+ e.message.endsWith(constants_1.OUT_OF_RANGE_ERROR_POSTFIX)) {
91
+ this.logger.warn(`${this.parentName}: Pool ${this.poolAddress} on ${this.dexHelper.config.data.network} is out of TickBitmap requested range. Re-query the state. ${JSON.stringify(event)}`, e);
92
+ }
93
+ else {
94
+ this.logger.error(`${this.parentName}: Pool ${this.poolAddress}, ` +
95
+ `network=${this.dexHelper.config.data.network}: Unexpected ` +
96
+ `error while handling event on blockNumber=${blockHeader.number}, ` +
97
+ `blockHash=${blockHeader.hash} and parentHash=${blockHeader.parentHash} for UniswapV3, ${JSON.stringify(event)}`, e);
98
+ }
99
+ _state.isValid = false;
100
+ return _state;
101
+ }
102
+ }
103
+ }
104
+ catch (e) {
105
+ (0, utils_1.catchParseLogError)(e, this.logger);
106
+ }
107
+ return null; // ignore unrecognized event
108
+ }
109
+ _getStateRequestCallData() {
110
+ if (!this._stateRequestCallData) {
111
+ const callData = [
112
+ {
113
+ target: this.token0,
114
+ callData: this.erc20Interface.encodeFunctionData('balanceOf', [
115
+ this.poolAddress,
116
+ ]),
117
+ decodeFunction: decoders_1.uint256ToBigInt,
118
+ },
119
+ {
120
+ target: this.token1,
121
+ callData: this.erc20Interface.encodeFunctionData('balanceOf', [
122
+ this.poolAddress,
123
+ ]),
124
+ decodeFunction: decoders_1.uint256ToBigInt,
125
+ },
126
+ {
127
+ target: this.stateMultiContract.options.address,
128
+ callData: this.stateMultiContract.methods
129
+ .getFullStateWithRelativeBitmaps(this.factoryAddress, this.token0, this.token1, this.feeCode, this.getBitmapRangeToRequest(), this.getBitmapRangeToRequest())
130
+ .encodeABI(),
131
+ decodeFunction: this.decodeStateMultiCallResultWithRelativeBitmaps !== undefined
132
+ ? this.decodeStateMultiCallResultWithRelativeBitmaps
133
+ : utils_2.decodeStateMultiCallResultWithRelativeBitmaps,
134
+ },
135
+ ];
136
+ this._stateRequestCallData = callData;
137
+ }
138
+ return this._stateRequestCallData;
139
+ }
140
+ getBitmapRangeToRequest() {
141
+ return constants_1.TICK_BITMAP_TO_USE + constants_1.TICK_BITMAP_BUFFER;
142
+ }
143
+ async generateState(blockNumber) {
144
+ const callData = this._getStateRequestCallData();
145
+ const [resBalance0, resBalance1, resState] = await this.dexHelper.multiWrapper.tryAggregate(false, callData, blockNumber, this.dexHelper.multiWrapper.defaultBatchSize, false);
146
+ // Quite ugly solution, but this is the one that fits to current flow.
147
+ // I think UniswapV3 callbacks subscriptions are complexified for no reason.
148
+ // Need to be revisited later
149
+ (0, ts_essentials_1.assert)(resState.success, 'Pool does not exist');
150
+ const [balance0, balance1, _state] = [
151
+ resBalance0.returnData,
152
+ resBalance1.returnData,
153
+ resState.returnData,
154
+ ];
155
+ const tickBitmap = {};
156
+ const ticks = {};
157
+ (0, utils_3._reduceTickBitmap)(tickBitmap, _state.tickBitmap);
158
+ (0, utils_3._reduceTicks)(ticks, _state.ticks);
159
+ const observations = {
160
+ [_state.slot0.observationIndex]: {
161
+ blockTimestamp: (0, utils_1.bigIntify)(_state.observation.blockTimestamp),
162
+ tickCumulative: (0, utils_1.bigIntify)(_state.observation.tickCumulative),
163
+ secondsPerLiquidityCumulativeX128: (0, utils_1.bigIntify)(_state.observation.secondsPerLiquidityCumulativeX128),
164
+ initialized: _state.observation.initialized,
165
+ },
166
+ };
167
+ const currentTick = (0, utils_1.bigIntify)(_state.slot0.tick);
168
+ const tickSpacing = (0, utils_1.bigIntify)(_state.tickSpacing);
169
+ const startTickBitmap = TickBitMap_1.TickBitMap.position(currentTick / tickSpacing)[0];
170
+ const requestedRange = this.getBitmapRangeToRequest();
171
+ return {
172
+ pool: _state.pool,
173
+ blockTimestamp: (0, utils_1.bigIntify)(_state.blockTimestamp),
174
+ slot0: {
175
+ sqrtPriceX96: (0, utils_1.bigIntify)(_state.slot0.sqrtPriceX96),
176
+ tick: currentTick,
177
+ observationIndex: +_state.slot0.observationIndex,
178
+ observationCardinality: +_state.slot0.observationCardinality,
179
+ observationCardinalityNext: +_state.slot0.observationCardinalityNext,
180
+ feeProtocol: (0, utils_1.bigIntify)(_state.slot0.feeProtocol),
181
+ },
182
+ liquidity: (0, utils_1.bigIntify)(_state.liquidity),
183
+ fee: this.feeCode,
184
+ tickSpacing,
185
+ maxLiquidityPerTick: (0, utils_1.bigIntify)(_state.maxLiquidityPerTick),
186
+ tickBitmap,
187
+ ticks,
188
+ observations,
189
+ isValid: true,
190
+ startTickBitmap,
191
+ lowestKnownTick: (BigInt.asIntN(24, startTickBitmap - requestedRange) << 8n) *
192
+ tickSpacing,
193
+ highestKnownTick: ((BigInt.asIntN(24, startTickBitmap + requestedRange) << 8n) +
194
+ BigInt.asIntN(24, 255n)) *
195
+ tickSpacing,
196
+ balance0,
197
+ balance1,
198
+ };
199
+ }
200
+ handleSwapEvent(event, pool, log, blockHeader) {
201
+ const newSqrtPriceX96 = (0, utils_1.bigIntify)(event.args.sqrtPriceX96);
202
+ const amount0 = (0, utils_1.bigIntify)(event.args.amount0);
203
+ const amount1 = (0, utils_1.bigIntify)(event.args.amount1);
204
+ const newTick = (0, utils_1.bigIntify)(event.args.tick);
205
+ const newLiquidity = (0, utils_1.bigIntify)(event.args.liquidity);
206
+ pool.blockTimestamp = (0, utils_1.bigIntify)(blockHeader.timestamp);
207
+ if (amount0 <= 0n && amount1 <= 0n) {
208
+ this.logger.error(`${this.parentName}: amount0 <= 0n && amount1 <= 0n for ` +
209
+ `${this.poolAddress} and ${blockHeader.number}. Check why it happened`);
210
+ pool.isValid = false;
211
+ return pool;
212
+ }
213
+ else {
214
+ const zeroForOne = amount0 > 0n;
215
+ uniswap_v3_math_1.uniswapV3Math.swapFromEvent(pool, newSqrtPriceX96, newTick, newLiquidity, zeroForOne);
216
+ if (zeroForOne) {
217
+ if (amount1 < 0n) {
218
+ pool.balance1 -= BigInt.asUintN(256, -amount1);
219
+ }
220
+ else {
221
+ this.logger.error(`In swapEvent for pool ${pool.pool} received incorrect values ${zeroForOne} and ${amount1}`);
222
+ pool.isValid = false;
223
+ }
224
+ // This is not correct fully, because pool may get more tokens then it needs, but
225
+ // it is not accounted in internal state, it should be good enough
226
+ pool.balance0 += BigInt.asUintN(256, amount0);
227
+ }
228
+ else {
229
+ if (amount0 < 0n) {
230
+ pool.balance0 -= BigInt.asUintN(256, -amount0);
231
+ }
232
+ else {
233
+ this.logger.error(`In swapEvent for pool ${pool.pool} received incorrect values ${zeroForOne} and ${amount0}`);
234
+ pool.isValid = false;
235
+ }
236
+ pool.balance1 += BigInt.asUintN(256, amount1);
237
+ }
238
+ return pool;
239
+ }
240
+ }
241
+ handleBurnEvent(event, pool, log, blockHeader) {
242
+ const amount = (0, utils_1.bigIntify)(event.args.amount);
243
+ const tickLower = (0, utils_1.bigIntify)(event.args.tickLower);
244
+ const tickUpper = (0, utils_1.bigIntify)(event.args.tickUpper);
245
+ pool.blockTimestamp = (0, utils_1.bigIntify)(blockHeader.timestamp);
246
+ uniswap_v3_math_1.uniswapV3Math._modifyPosition(pool, {
247
+ tickLower,
248
+ tickUpper,
249
+ liquidityDelta: -BigInt.asIntN(128, BigInt.asIntN(256, amount)),
250
+ });
251
+ // From this transaction I conclude that there is no balance change from
252
+ // Burn event: https://dashboard.tenderly.co/tx/mainnet/0xfccf5341147ac3ad0e66452273d12dfc3219e81f8fb369a6cdecfb24b9b9d078/logs
253
+ // And it aligns with UniswapV3 doc:
254
+ // https://github.com/Uniswap/v3-core/blob/05c10bf6d547d6121622ac51c457f93775e1df09/contracts/interfaces/pool/IUniswapV3PoolActions.sol#L59
255
+ // It just updates positions and tokensOwed which may be requested calling collect
256
+ // So, we don't need to update pool.balances0 and pool.balances1 here
257
+ return pool;
258
+ }
259
+ handleMintEvent(event, pool, log, blockHeader) {
260
+ const amount = (0, utils_1.bigIntify)(event.args.amount);
261
+ const tickLower = (0, utils_1.bigIntify)(event.args.tickLower);
262
+ const tickUpper = (0, utils_1.bigIntify)(event.args.tickUpper);
263
+ const amount0 = (0, utils_1.bigIntify)(event.args.amount0);
264
+ const amount1 = (0, utils_1.bigIntify)(event.args.amount1);
265
+ pool.blockTimestamp = (0, utils_1.bigIntify)(blockHeader.timestamp);
266
+ uniswap_v3_math_1.uniswapV3Math._modifyPosition(pool, {
267
+ tickLower,
268
+ tickUpper,
269
+ liquidityDelta: amount,
270
+ });
271
+ pool.balance0 += amount0;
272
+ pool.balance1 += amount1;
273
+ return pool;
274
+ }
275
+ handleSetFeeProtocolEvent(event, pool, log, blockHeader) {
276
+ const feeProtocol0 = (0, utils_1.bigIntify)(event.args.feeProtocol0New);
277
+ const feeProtocol1 = (0, utils_1.bigIntify)(event.args.feeProtocol1New);
278
+ pool.slot0.feeProtocol = feeProtocol0 + (feeProtocol1 << 4n);
279
+ pool.blockTimestamp = (0, utils_1.bigIntify)(blockHeader.timestamp);
280
+ return pool;
281
+ }
282
+ handleCollectEvent(event, pool, log, blockHeader) {
283
+ const amount0 = (0, utils_1.bigIntify)(event.args.amount0);
284
+ const amount1 = (0, utils_1.bigIntify)(event.args.amount1);
285
+ pool.balance0 -= amount0;
286
+ pool.balance1 -= amount1;
287
+ pool.blockTimestamp = (0, utils_1.bigIntify)(blockHeader.timestamp);
288
+ return pool;
289
+ }
290
+ handleFlashEvent(event, pool, log, blockHeader) {
291
+ const paid0 = (0, utils_1.bigIntify)(event.args.paid0);
292
+ const paid1 = (0, utils_1.bigIntify)(event.args.paid1);
293
+ pool.balance0 += paid0;
294
+ pool.balance1 += paid1;
295
+ pool.blockTimestamp = (0, utils_1.bigIntify)(blockHeader.timestamp);
296
+ return pool;
297
+ }
298
+ handleIncreaseObservationCardinalityNextEvent(event, pool, log, blockHeader) {
299
+ pool.slot0.observationCardinalityNext = parseInt(event.args.observationCardinalityNextNew, 10);
300
+ pool.blockTimestamp = (0, utils_1.bigIntify)(blockHeader.timestamp);
301
+ return pool;
302
+ }
303
+ _computePoolAddress(token0, token1, fee) {
304
+ // https://github.com/Uniswap/v3-periphery/blob/main/contracts/libraries/PoolAddress.sol
305
+ if (token0 > token1)
306
+ [token0, token1] = [token1, token0];
307
+ const encodedKey = ethers_1.ethers.utils.keccak256(ethers_1.ethers.utils.defaultAbiCoder.encode(['address', 'address', 'uint24'], [token0, token1, BigInt.asUintN(24, fee)]));
308
+ return ethers_1.ethers.utils.getCreate2Address(this.factoryAddress, encodedKey, this.poolInitCodeHash);
309
+ }
310
+ }
311
+ exports.BaseswapV3EventPool = BaseswapV3EventPool;
312
+ //# sourceMappingURL=baseswap-v3-pool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseswap-v3-pool.js","sourceRoot":"","sources":["../../../src/dex/baseswap-v3/baseswap-v3-pool.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAEvB,4CAA+C;AAC/C,mCAAgC;AAChC,iDAAqD;AAErD,+EAGyC;AAOzC,yGAA2E;AAC3E,uCAAuE;AACvE,qEAAgE;AAEh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C,MAAM,CACjC,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,EAChC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAC1C,CACF,CAAC;QAEF,OAAO,eAAM,CAAC,KAAK,CAAC,iBAAiB,CACnC,IAAI,CAAC,cAAc,EACnB,UAAU,EACV,IAAI,CAAC,gBAAgB,CACtB,CAAC;IACJ,CAAC;CACF;AAxeD,kDAweC"}
@@ -0,0 +1,71 @@
1
+ /// <reference types="node" />
2
+ import { Interface } from '@ethersproject/abi';
3
+ import { AdapterExchangeParam, Address, ExchangePrices, ExchangeTxInfo, Logger, NumberAsString, PoolLiquidity, PoolPrices, PreprocessTransactionOptions, SimpleExchangeParam, Token, TxInfo } from '../../types';
4
+ import { Network, SwapSide } from '../../constants';
5
+ import { IDex } from '../idex';
6
+ import { IDexHelper } from '../../dex-helper/idex-helper';
7
+ import { DexParams, PoolState, UniswapV3Data, UniswapV3Param } from './types';
8
+ import { SimpleExchange } from '../simple-exchange';
9
+ import { BaseswapV3EventPool } from './baseswap-v3-pool';
10
+ import { OptimalSwapExchange } from '@paraswap/core';
11
+ import { OnPoolCreatedCallback } from './baseswap-v3-factory';
12
+ export declare class BaseswapV3 extends SimpleExchange implements IDex<UniswapV3Data, UniswapV3Param> {
13
+ protected network: Network;
14
+ protected dexHelper: IDexHelper;
15
+ protected adapters: import("../../types").AdapterMappings;
16
+ readonly routerIface: Interface;
17
+ readonly quoterIface: Interface;
18
+ protected config: DexParams;
19
+ protected poolsToPreload: {
20
+ token0: string;
21
+ token1: string;
22
+ }[];
23
+ private readonly factory;
24
+ readonly isFeeOnTransferSupported: boolean;
25
+ readonly eventPools: Record<string, BaseswapV3EventPool | null>;
26
+ readonly hasConstantPriceLargeAmounts = false;
27
+ readonly needWrapNative = true;
28
+ readonly directSwapIface: Interface;
29
+ intervalTask?: NodeJS.Timeout;
30
+ static dexKeysWithNetwork: {
31
+ key: string;
32
+ networks: Network[];
33
+ }[];
34
+ logger: Logger;
35
+ private uniswapMulti;
36
+ private stateMultiContract;
37
+ private notExistingPoolSetKey;
38
+ constructor(network: Network, dexKey: string, dexHelper: IDexHelper, adapters?: import("../../types").AdapterMappings, routerIface?: Interface, quoterIface?: Interface, config?: DexParams, poolsToPreload?: {
39
+ token0: string;
40
+ token1: string;
41
+ }[]);
42
+ get supportedFees(): bigint[];
43
+ getAdapters(side: SwapSide): {
44
+ name: string;
45
+ index: number;
46
+ }[] | null;
47
+ getPoolIdentifier(srcAddress: Address, destAddress: Address, fee: bigint): string;
48
+ initializePricing(blockNumber: number): Promise<void>;
49
+ onPoolCreatedDeleteFromNonExistingSet: OnPoolCreatedCallback;
50
+ getPool(srcAddress: Address, destAddress: Address, fee: bigint, blockNumber: number): Promise<BaseswapV3EventPool | null>;
51
+ addMasterPool(poolKey: string, blockNumber: number): Promise<boolean>;
52
+ getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
53
+ getPricingFromRpc(from: Token, to: Token, amounts: bigint[], side: SwapSide, pools: BaseswapV3EventPool[], states: PoolState[]): Promise<ExchangePrices<UniswapV3Data> | null>;
54
+ getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<UniswapV3Data>>;
55
+ getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: UniswapV3Data, side: SwapSide): AdapterExchangeParam;
56
+ getCalldataGasCost(poolPrices: PoolPrices<UniswapV3Data>): number | number[];
57
+ getTokenFromAddress(address: Address): Token;
58
+ preProcessTransaction(optimalSwapExchange: OptimalSwapExchange<UniswapV3Data>, srcToken: Token, _0: Token, _1: SwapSide, options: PreprocessTransactionOptions): Promise<[OptimalSwapExchange<UniswapV3Data>, ExchangeTxInfo]>;
59
+ getDirectParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, expectedAmount: NumberAsString, data: UniswapV3Data, side: SwapSide, permit: string, uuid: string, feePercent: NumberAsString, deadline: NumberAsString, partner: string, beneficiary: string, contractMethod?: string): TxInfo<UniswapV3Param>;
60
+ static getDirectFunctionName(): string[];
61
+ getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: UniswapV3Data, side: SwapSide): Promise<SimpleExchangeParam>;
62
+ getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
63
+ private _getPoolsFromIdentifiers;
64
+ private _getLoweredAddresses;
65
+ private _sortTokens;
66
+ private _toLowerForAllConfigAddresses;
67
+ private _getOutputs;
68
+ private _querySubgraph;
69
+ private _encodePath;
70
+ releaseResources(): void;
71
+ }