@paraswap/dex-lib 2.42.28 → 2.42.29

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 (130) hide show
  1. package/build/abi/{algebra/AlgebraPool.abi.json → solidly-v3/SolidlyV3Pool.abi.json} +293 -282
  2. package/build/abi/solidly-v3/SolidlyV3StateMulticall.abi.json +375 -0
  3. package/build/config.js +2 -2
  4. package/build/dex/index.js +2 -0
  5. package/build/dex/index.js.map +1 -1
  6. package/build/dex/solidly-v3/config.d.ts +9 -0
  7. package/build/dex/solidly-v3/config.js +58 -0
  8. package/build/dex/solidly-v3/config.js.map +1 -0
  9. package/build/dex/solidly-v3/constants.d.ts +27 -0
  10. package/build/dex/solidly-v3/constants.js +34 -0
  11. package/build/dex/solidly-v3/constants.js.map +1 -0
  12. package/build/dex/solidly-v3/contract-math/BitMath.d.ts +4 -0
  13. package/build/dex/solidly-v3/contract-math/BitMath.js +93 -0
  14. package/build/dex/solidly-v3/contract-math/BitMath.js.map +1 -0
  15. package/build/dex/solidly-v3/contract-math/FixedPoint128.d.ts +3 -0
  16. package/build/dex/solidly-v3/contract-math/FixedPoint128.js +8 -0
  17. package/build/dex/solidly-v3/contract-math/FixedPoint128.js.map +1 -0
  18. package/build/dex/solidly-v3/contract-math/FixedPoint96.d.ts +4 -0
  19. package/build/dex/solidly-v3/contract-math/FixedPoint96.js +9 -0
  20. package/build/dex/solidly-v3/contract-math/FixedPoint96.js.map +1 -0
  21. package/build/dex/solidly-v3/contract-math/FullMath.d.ts +4 -0
  22. package/build/dex/solidly-v3/contract-math/FullMath.js +19 -0
  23. package/build/dex/solidly-v3/contract-math/FullMath.js.map +1 -0
  24. package/build/dex/solidly-v3/contract-math/LiquidityMath.d.ts +3 -0
  25. package/build/dex/solidly-v3/contract-math/LiquidityMath.js +22 -0
  26. package/build/dex/solidly-v3/contract-math/LiquidityMath.js.map +1 -0
  27. package/build/dex/solidly-v3/contract-math/SqrtPriceMath.d.ts +10 -0
  28. package/build/dex/solidly-v3/contract-math/SqrtPriceMath.js +91 -0
  29. package/build/dex/solidly-v3/contract-math/SqrtPriceMath.js.map +1 -0
  30. package/build/dex/solidly-v3/contract-math/SwapMath.d.ts +8 -0
  31. package/build/dex/solidly-v3/contract-math/SwapMath.js +70 -0
  32. package/build/dex/solidly-v3/contract-math/SwapMath.js.map +1 -0
  33. package/build/dex/solidly-v3/contract-math/Tick.d.ts +7 -0
  34. package/build/dex/solidly-v3/contract-math/Tick.js +36 -0
  35. package/build/dex/solidly-v3/contract-math/Tick.js.map +1 -0
  36. package/build/dex/solidly-v3/contract-math/TickBitMap.d.ts +7 -0
  37. package/build/dex/solidly-v3/contract-math/TickBitMap.js +84 -0
  38. package/build/dex/solidly-v3/contract-math/TickBitMap.js.map +1 -0
  39. package/build/dex/solidly-v3/contract-math/TickMath.d.ts +8 -0
  40. package/build/dex/solidly-v3/contract-math/TickMath.js +162 -0
  41. package/build/dex/solidly-v3/contract-math/TickMath.js.map +1 -0
  42. package/build/dex/solidly-v3/contract-math/UnsafeMath.d.ts +3 -0
  43. package/build/dex/solidly-v3/contract-math/UnsafeMath.js +10 -0
  44. package/build/dex/solidly-v3/contract-math/UnsafeMath.js.map +1 -0
  45. package/build/dex/solidly-v3/contract-math/uniswap-v3-math.d.ts +31 -0
  46. package/build/dex/solidly-v3/contract-math/uniswap-v3-math.js +363 -0
  47. package/build/dex/solidly-v3/contract-math/uniswap-v3-math.js.map +1 -0
  48. package/build/dex/solidly-v3/contract-math/utils.d.ts +7 -0
  49. package/build/dex/solidly-v3/contract-math/utils.js +39 -0
  50. package/build/dex/solidly-v3/contract-math/utils.js.map +1 -0
  51. package/build/dex/solidly-v3/solidly-v3-factory.d.ts +26 -0
  52. package/build/dex/solidly-v3/solidly-v3-factory.js +44 -0
  53. package/build/dex/solidly-v3/solidly-v3-factory.js.map +1 -0
  54. package/build/dex/{algebra/algebra-pool.d.ts → solidly-v3/solidly-v3-pool.d.ts} +14 -16
  55. package/build/dex/{algebra/algebra-pool.js → solidly-v3/solidly-v3-pool.js} +127 -165
  56. package/build/dex/solidly-v3/solidly-v3-pool.js.map +1 -0
  57. package/build/dex/solidly-v3/solidly-v3.d.ts +67 -0
  58. package/build/dex/solidly-v3/solidly-v3.js +590 -0
  59. package/build/dex/solidly-v3/solidly-v3.js.map +1 -0
  60. package/build/dex/solidly-v3/types.d.ts +132 -0
  61. package/build/dex/solidly-v3/types.js +9 -0
  62. package/build/dex/solidly-v3/types.js.map +1 -0
  63. package/build/dex/solidly-v3/utils.d.ts +6 -0
  64. package/build/dex/solidly-v3/utils.js +53 -0
  65. package/build/dex/solidly-v3/utils.js.map +1 -0
  66. package/build/dex/trader-joe-v2-1-2/config.d.ts +4 -0
  67. package/build/dex/trader-joe-v2-1-2/config.js +15 -0
  68. package/build/dex/trader-joe-v2-1-2/config.js.map +1 -0
  69. package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.d.ts +39 -0
  70. package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js +64 -0
  71. package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js.map +1 -0
  72. package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.d.ts +37 -0
  73. package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js +126 -0
  74. package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js.map +1 -0
  75. package/build/dex/trader-joe-v2-1-2/types.d.ts +6 -0
  76. package/build/dex/trader-joe-v2-1-2/types.js +3 -0
  77. package/build/dex/trader-joe-v2-1-2/types.js.map +1 -0
  78. package/build/dex/trader-joe-v2_1/config.d.ts +4 -0
  79. package/build/dex/trader-joe-v2_1/config.js +48 -0
  80. package/build/dex/trader-joe-v2_1/config.js.map +1 -0
  81. package/build/dex/trader-joe-v2_1/constants.d.ts +15 -0
  82. package/build/dex/trader-joe-v2_1/constants.js +17 -0
  83. package/build/dex/trader-joe-v2_1/constants.js.map +1 -0
  84. package/build/dex/trader-joe-v2_1/trader-joe-v2.1.d.ts +0 -0
  85. package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js +183 -0
  86. package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js.map +1 -0
  87. package/build/dex/trader-joe-v2_1/types.d.ts +39 -0
  88. package/build/dex/trader-joe-v2_1/types.js +3 -0
  89. package/build/dex/trader-joe-v2_1/types.js.map +1 -0
  90. package/build/dex/wombat/wombat-pool-poller.d.ts +22 -0
  91. package/build/dex/wombat/wombat-pool-poller.js +164 -0
  92. package/build/dex/wombat/wombat-pool-poller.js.map +1 -0
  93. package/package.json +1 -1
  94. package/src/abi/solidly-v3/SolidlyV3Pool.abi.json +738 -0
  95. package/src/abi/solidly-v3/SolidlyV3StateMulticall.abi.json +375 -0
  96. package/src/config.ts +2 -2
  97. package/src/dex/index.ts +2 -0
  98. package/src/dex/solidly-v3/config.ts +64 -0
  99. package/src/dex/solidly-v3/constants.ts +42 -0
  100. package/src/dex/solidly-v3/contract-math/BitMath.ts +90 -0
  101. package/src/dex/solidly-v3/contract-math/FixedPoint128.ts +3 -0
  102. package/src/dex/solidly-v3/contract-math/FixedPoint96.ts +4 -0
  103. package/src/dex/solidly-v3/contract-math/FullMath.ts +30 -0
  104. package/src/dex/solidly-v3/contract-math/LiquidityMath.ts +17 -0
  105. package/src/dex/solidly-v3/contract-math/SqrtPriceMath.ts +226 -0
  106. package/src/dex/solidly-v3/contract-math/SwapMath.ts +139 -0
  107. package/src/dex/solidly-v3/contract-math/Tick.ts +66 -0
  108. package/src/dex/solidly-v3/contract-math/TickBitMap.ts +123 -0
  109. package/src/dex/solidly-v3/contract-math/TickMath.ts +211 -0
  110. package/src/dex/solidly-v3/contract-math/UnsafeMath.ts +5 -0
  111. package/src/dex/solidly-v3/contract-math/uniswap-v3-math.ts +570 -0
  112. package/src/dex/solidly-v3/contract-math/utils.ts +50 -0
  113. package/src/dex/solidly-v3/solidly-v3-e2e.test.ts +124 -0
  114. package/src/dex/solidly-v3/solidly-v3-events.test.ts +144 -0
  115. package/src/dex/solidly-v3/solidly-v3-factory.ts +73 -0
  116. package/src/dex/solidly-v3/solidly-v3-integration.test.ts +358 -0
  117. package/src/dex/solidly-v3/solidly-v3-pool.ts +494 -0
  118. package/src/dex/solidly-v3/solidly-v3.ts +988 -0
  119. package/src/dex/solidly-v3/types.ts +158 -0
  120. package/src/dex/solidly-v3/utils.ts +71 -0
  121. package/src/dex/uniswap-v3/uniswap-v3-events.test.ts +3 -0
  122. package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
  123. package/build/dex/algebra/algebra-pool.js.map +0 -1
  124. package/build/dex/quickswap/camelot-v3.d.ts +0 -6
  125. package/build/dex/quickswap/camelot-v3.js +0 -19
  126. package/build/dex/quickswap/camelot-v3.js.map +0 -1
  127. package/build/dex/quickswap/zyberswap-v3.d.ts +0 -6
  128. package/build/dex/quickswap/zyberswap-v3.js +0 -19
  129. package/build/dex/quickswap/zyberswap-v3.js.map +0 -1
  130. package/build/dex/uniswap-v2/rebase-tokens.json +0 -7
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._reduceTicks = exports._reduceTickBitmap = exports._gt = exports._lt = exports._mulmod = void 0;
4
+ const utils_1 = require("../../../utils");
5
+ function _mulmod(x, y, m) {
6
+ return m === 0n ? 0n : (x * y) % m;
7
+ }
8
+ exports._mulmod = _mulmod;
9
+ function _lt(x, y) {
10
+ return x < y ? 1n : 0n;
11
+ }
12
+ exports._lt = _lt;
13
+ function _gt(x, y) {
14
+ return x > y ? 1n : 0n;
15
+ }
16
+ exports._gt = _gt;
17
+ function _reduceTickBitmap(tickBitmap, tickBitmapToReduce) {
18
+ return tickBitmapToReduce.reduce((acc, curr) => {
19
+ const { index, value } = curr;
20
+ acc[index] = (0, utils_1.bigIntify)(value);
21
+ return acc;
22
+ }, tickBitmap);
23
+ }
24
+ exports._reduceTickBitmap = _reduceTickBitmap;
25
+ function _reduceTicks(ticks, ticksToReduce) {
26
+ return ticksToReduce.reduce((acc, curr) => {
27
+ const { index, value } = curr;
28
+ if (value.initialized) {
29
+ acc[index] = {
30
+ liquidityGross: (0, utils_1.bigIntify)(value.liquidityGross),
31
+ liquidityNet: (0, utils_1.bigIntify)(value.liquidityNet),
32
+ initialized: value.initialized,
33
+ };
34
+ }
35
+ return acc;
36
+ }, ticks);
37
+ }
38
+ exports._reduceTicks = _reduceTicks;
39
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/dex/solidly-v3/contract-math/utils.ts"],"names":[],"mappings":";;;AAMA,0CAA2C;AAE3C,SAAgB,OAAO,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS;IACrD,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC;AAFD,0BAEC;AAED,SAAgB,GAAG,CAAC,CAAS,EAAE,CAAS;IACtC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACzB,CAAC;AAFD,kBAEC;AAED,SAAgB,GAAG,CAAC,CAAS,EAAE,CAAS;IACtC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACzB,CAAC;AAFD,kBAEC;AAED,SAAgB,iBAAiB,CAC/B,UAA0C,EAC1C,kBAAqD;IAErD,OAAO,kBAAkB,CAAC,MAAM,CAC9B,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QACZ,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAC9B,GAAG,CAAC,KAAK,CAAC,GAAG,IAAA,iBAAS,EAAC,KAAK,CAAC,CAAC;QAC9B,OAAO,GAAG,CAAC;IACb,CAAC,EACD,UAAU,CACX,CAAC;AACJ,CAAC;AAZD,8CAYC;AAED,SAAgB,YAAY,CAC1B,KAAuC,EACvC,aAA8C;IAE9C,OAAO,aAAa,CAAC,MAAM,CAA2B,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QAClE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAC9B,IAAI,KAAK,CAAC,WAAW,EAAE;YACrB,GAAG,CAAC,KAAK,CAAC,GAAG;gBACX,cAAc,EAAE,IAAA,iBAAS,EAAC,KAAK,CAAC,cAAc,CAAC;gBAC/C,YAAY,EAAE,IAAA,iBAAS,EAAC,KAAK,CAAC,YAAY,CAAC;gBAC3C,WAAW,EAAE,KAAK,CAAC,WAAW;aAC/B,CAAC;SACH;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,KAAK,CAAC,CAAC;AACZ,CAAC;AAfD,oCAeC"}
@@ -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, tickSpacing, }: {
9
+ token0: string;
10
+ token1: string;
11
+ tickSpacing: bigint;
12
+ }) => Promise<void>;
13
+ export declare class SolidlyV3Factory 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.SolidlyV3Factory = 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 SolidlyV3Factory 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 tickSpacing = BigInt(event.args.tickSpacing);
40
+ await this.onPoolCreated({ token0, token1, tickSpacing });
41
+ }
42
+ }
43
+ exports.SolidlyV3Factory = SolidlyV3Factory;
44
+ //# sourceMappingURL=solidly-v3-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solidly-v3-factory.js","sourceRoot":"","sources":["../../../src/dex/solidly-v3/solidly-v3-factory.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA+C;AAE/C,+GAAwE;AAExE,+EAA0E;AAe1E;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,mDAAqC;IASzE,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,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAEnD,MAAM,IAAI,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;IAC5D,CAAC;CACF;AAjDD,4CAiDC"}
@@ -1,46 +1,44 @@
1
+ import { Contract } from 'web3-eth-contract';
1
2
  import { Interface } from '@ethersproject/abi';
2
3
  import { DeepReadonly } from 'ts-essentials';
3
- import { Address, BlockHeader, Log, Logger } from '../../types';
4
+ import { Log, Logger, BlockHeader, Address } from '../../types';
4
5
  import { InitializeStateOptions, StatefulEventSubscriber } from '../../stateful-event-subscriber';
5
6
  import { IDexHelper } from '../../dex-helper/idex-helper';
6
- import { PoolState } from './types';
7
- import { Contract } from 'web3-eth-contract';
8
- import { DecodedStateMultiCallResultWithRelativeBitmaps } from './types';
9
- export declare class AlgebraEventPool extends StatefulEventSubscriber<PoolState> {
7
+ import { PoolState, DecodeStateMultiCallFunc } from './types';
8
+ export declare class SolidlyV3EventPool extends StatefulEventSubscriber<PoolState> {
10
9
  readonly dexHelper: IDexHelper;
11
10
  readonly stateMultiContract: Contract;
11
+ readonly decodeStateMultiCallResultWithRelativeBitmaps: DecodeStateMultiCallFunc | undefined;
12
12
  readonly erc20Interface: Interface;
13
13
  protected readonly factoryAddress: Address;
14
+ readonly tickSpacing: bigint;
14
15
  readonly poolInitCodeHash: string;
15
- readonly poolDeployer: string;
16
16
  handlers: {
17
- [event: string]: (event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>, blockHeader: BlockHeader) => DeepReadonly<PoolState> | null;
17
+ [event: string]: (event: any, pool: PoolState, log: Log, blockHeader: Readonly<BlockHeader>) => PoolState;
18
18
  };
19
19
  logDecoder: (log: Log) => any;
20
- addressesSubscribed: string[];
21
- private _poolAddress?;
22
20
  readonly token0: Address;
23
21
  readonly token1: Address;
22
+ _poolAddress?: Address;
23
+ private _stateRequestCallData?;
24
24
  readonly poolIface: Interface;
25
25
  initFailed: boolean;
26
26
  initRetryAttemptCount: number;
27
- constructor(dexHelper: IDexHelper, parentName: string, stateMultiContract: Contract, erc20Interface: Interface, factoryAddress: Address, token0: Address, token1: Address, logger: Logger, mapKey: string | undefined, poolInitCodeHash: string, poolDeployer: string);
27
+ readonly tickSpacingAsString: string;
28
+ constructor(dexHelper: IDexHelper, parentName: string, stateMultiContract: Contract, decodeStateMultiCallResultWithRelativeBitmaps: DecodeStateMultiCallFunc | undefined, erc20Interface: Interface, factoryAddress: Address, tickSpacing: bigint, token0: Address, token1: Address, logger: Logger, mapKey: string | undefined, poolInitCodeHash: string);
28
29
  get poolAddress(): Address;
29
30
  set poolAddress(address: Address);
30
31
  initialize(blockNumber: number, options?: InitializeStateOptions<PoolState>): Promise<void>;
31
32
  protected processBlockLogs(state: DeepReadonly<PoolState>, logs: Readonly<Log>[], blockHeader: Readonly<BlockHeader>): Promise<DeepReadonly<PoolState> | null>;
32
33
  protected processLog(state: DeepReadonly<PoolState>, log: Readonly<Log>, blockHeader: Readonly<BlockHeader>): DeepReadonly<PoolState> | null;
34
+ private _getStateRequestCallData;
33
35
  getBitmapRangeToRequest(): bigint;
34
- private _fetchPoolStateSingleStep;
35
- private _fetchPoolStateMultiStep;
36
- _fetchInitStateMultiStrategies(blockNumber: number): Promise<[bigint, bigint, DecodedStateMultiCallResultWithRelativeBitmaps]>;
37
36
  generateState(blockNumber: number): Promise<Readonly<PoolState>>;
38
37
  handleSwapEvent(event: any, pool: PoolState, log: Log, blockHeader: BlockHeader): PoolState;
39
- handleMintEvent(event: any, pool: PoolState, log: Log, blockHeader: BlockHeader): PoolState;
40
38
  handleBurnEvent(event: any, pool: PoolState, log: Log, blockHeader: BlockHeader): PoolState;
41
- handleNewFee(event: any, pool: PoolState, log: Log, blockHeader: BlockHeader): PoolState;
39
+ handleMintEvent(event: any, pool: PoolState, log: Log, blockHeader: BlockHeader): PoolState;
42
40
  handleCollectEvent(event: any, pool: PoolState, log: Log, blockHeader: BlockHeader): PoolState;
43
41
  handleFlashEvent(event: any, pool: PoolState, log: Log, blockHeader: BlockHeader): PoolState;
44
- handleCommunityFee(event: any, pool: PoolState, log: Log, blockHeader: BlockHeader): PoolState;
42
+ handleSetFeeEvent(event: any, pool: PoolState, log: Log, blockHeader: BlockHeader): PoolState;
45
43
  private _computePoolAddress;
46
44
  }
@@ -3,50 +3,57 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AlgebraEventPool = void 0;
6
+ exports.SolidlyV3EventPool = void 0;
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
8
  const abi_1 = require("@ethersproject/abi");
9
+ const ethers_1 = require("ethers");
9
10
  const ts_essentials_1 = require("ts-essentials");
10
- const utils_1 = require("../../utils");
11
11
  const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
12
- const ethers_1 = require("ethers");
13
- const AlgebraPool_abi_json_1 = __importDefault(require("../../abi/algebra/AlgebraPool.abi.json"));
14
- const constants_1 = require("../uniswap-v3/constants");
12
+ const SolidlyV3Pool_abi_json_1 = __importDefault(require("../../abi/solidly-v3/SolidlyV3Pool.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");
15
17
  const decoders_1 = require("../../lib/decoders");
16
18
  const utils_2 = require("./utils");
17
- const AlgebraMath_1 = require("./lib/AlgebraMath");
18
- const TickBitMap_1 = require("../uniswap-v3/contract-math/TickBitMap");
19
- const utils_3 = require("../uniswap-v3/contract-math/utils");
20
- const Constants_1 = require("./lib/Constants");
21
- const constants_2 = require("../../constants");
22
- class AlgebraEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
23
- constructor(dexHelper, parentName, stateMultiContract, erc20Interface, factoryAddress, token0, token1, logger, mapKey = '', poolInitCodeHash, poolDeployer) {
24
- super(parentName, `${token0}_${token1}`, dexHelper, logger, true, mapKey);
19
+ const utils_3 = require("./contract-math/utils");
20
+ const FEES_TO_TICK_SPACING = {
21
+ 500: 10n,
22
+ };
23
+ class SolidlyV3EventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
24
+ constructor(dexHelper, parentName, stateMultiContract, decodeStateMultiCallResultWithRelativeBitmaps, erc20Interface, factoryAddress, tickSpacing, token0, token1, logger, mapKey = '', poolInitCodeHash) {
25
+ super(parentName, `${token0}_${token1}_${tickSpacing}`, dexHelper, logger, true, mapKey);
25
26
  this.dexHelper = dexHelper;
26
27
  this.stateMultiContract = stateMultiContract;
28
+ this.decodeStateMultiCallResultWithRelativeBitmaps = decodeStateMultiCallResultWithRelativeBitmaps;
27
29
  this.erc20Interface = erc20Interface;
28
30
  this.factoryAddress = factoryAddress;
31
+ this.tickSpacing = tickSpacing;
29
32
  this.poolInitCodeHash = poolInitCodeHash;
30
- this.poolDeployer = poolDeployer;
31
33
  this.handlers = {};
32
- this.poolIface = new abi_1.Interface(AlgebraPool_abi_json_1.default);
34
+ this.poolIface = new abi_1.Interface(SolidlyV3Pool_abi_json_1.default);
33
35
  this.initFailed = false;
34
36
  this.initRetryAttemptCount = 0;
37
+ // this.feeCodeAsString = feeCode.toString();
38
+ this.tickSpacingAsString = tickSpacing.toString();
35
39
  this.token0 = token0.toLowerCase();
36
40
  this.token1 = token1.toLowerCase();
37
41
  this.logDecoder = (log) => this.poolIface.parseLog(log);
38
42
  this.addressesSubscribed = new Array(1);
39
- this.handlers['Fee'] = this.handleNewFee.bind(this);
43
+ // Add handlers
40
44
  this.handlers['Swap'] = this.handleSwapEvent.bind(this);
41
- this.handlers['Mint'] = this.handleMintEvent.bind(this);
42
45
  this.handlers['Burn'] = this.handleBurnEvent.bind(this);
43
- this.handlers['Flash'] = this.handleFlashEvent.bind(this);
46
+ this.handlers['Mint'] = this.handleMintEvent.bind(this);
47
+ // Wen need them to keep balance of the pool up to date
44
48
  this.handlers['Collect'] = this.handleCollectEvent.bind(this);
45
- this.handlers['CommunityFee'] = this.handleCommunityFee.bind(this);
49
+ // Almost the same as Collect, but for pool owners
50
+ this.handlers['CollectProtocol'] = this.handleCollectEvent.bind(this);
51
+ this.handlers['Flash'] = this.handleFlashEvent.bind(this);
52
+ this.handlers['SetFee'] = this.handleSetFeeEvent.bind(this);
46
53
  }
47
54
  get poolAddress() {
48
55
  if (this._poolAddress === undefined) {
49
- this._poolAddress = this._computePoolAddress(this.token0, this.token1);
56
+ this._poolAddress = this._computePoolAddress(this.token0, this.token1, this.tickSpacing);
50
57
  }
51
58
  return this._poolAddress;
52
59
  }
@@ -66,14 +73,19 @@ class AlgebraEventPool extends stateful_event_subscriber_1.StatefulEventSubscrib
66
73
  processLog(state, log, blockHeader) {
67
74
  try {
68
75
  const event = this.logDecoder(log);
76
+ const uniswapV3EventLoggingSampleRate = this.dexHelper.config.data.uniswapV3EventLoggingSampleRate;
77
+ if (!this.dexHelper.config.isSlave &&
78
+ uniswapV3EventLoggingSampleRate &&
79
+ (0, utils_1.isSampled)(uniswapV3EventLoggingSampleRate)) {
80
+ this.logger.info(`event=${event.name} - block=${blockHeader.number}. Log sampled at rate ${uniswapV3EventLoggingSampleRate * 100}%`);
81
+ }
69
82
  if (event.name in this.handlers) {
70
83
  // Because we have observations in array which is mutable by nature, there is a
71
84
  // ts compile error: https://stackoverflow.com/questions/53412934/disable-allowing-assigning-readonly-types-to-non-readonly-types
72
85
  // And there is no good workaround, so turn off the type checker for this line
73
86
  const _state = lodash_1.default.cloneDeep(state);
74
87
  try {
75
- const newState = this.handlers[event.name](event, _state, log, blockHeader);
76
- return newState;
88
+ return this.handlers[event.name](event, _state, log, blockHeader);
77
89
  }
78
90
  catch (e) {
79
91
  if (e instanceof Error &&
@@ -84,7 +96,7 @@ class AlgebraEventPool extends stateful_event_subscriber_1.StatefulEventSubscrib
84
96
  this.logger.error(`${this.parentName}: Pool ${this.poolAddress}, ` +
85
97
  `network=${this.dexHelper.config.data.network}: Unexpected ` +
86
98
  `error while handling event on blockNumber=${blockHeader.number}, ` +
87
- `blockHash=${blockHeader.hash} and parentHash=${blockHeader.parentHash} for QuickSwapV3, ${JSON.stringify(event)}`, e);
99
+ `blockHash=${blockHeader.hash} and parentHash=${blockHeader.parentHash} for UniswapV3, ${JSON.stringify(event)}`, e);
88
100
  }
89
101
  _state.isValid = false;
90
102
  return _state;
@@ -96,135 +108,87 @@ class AlgebraEventPool extends stateful_event_subscriber_1.StatefulEventSubscrib
96
108
  }
97
109
  return null; // ignore unrecognized event
98
110
  }
111
+ _getStateRequestCallData() {
112
+ if (!this._stateRequestCallData) {
113
+ const callData = [
114
+ {
115
+ target: this.token0,
116
+ callData: this.erc20Interface.encodeFunctionData('balanceOf', [
117
+ this.poolAddress,
118
+ ]),
119
+ decodeFunction: decoders_1.uint256ToBigInt,
120
+ },
121
+ {
122
+ target: this.token1,
123
+ callData: this.erc20Interface.encodeFunctionData('balanceOf', [
124
+ this.poolAddress,
125
+ ]),
126
+ decodeFunction: decoders_1.uint256ToBigInt,
127
+ },
128
+ {
129
+ target: this.stateMultiContract.options.address,
130
+ callData: this.stateMultiContract.methods
131
+ .getFullStateWithRelativeBitmaps(this.factoryAddress, this.token0, this.token1, this.tickSpacing, this.getBitmapRangeToRequest(), this.getBitmapRangeToRequest())
132
+ .encodeABI(),
133
+ decodeFunction: this.decodeStateMultiCallResultWithRelativeBitmaps !== undefined
134
+ ? this.decodeStateMultiCallResultWithRelativeBitmaps
135
+ : utils_2.decodeStateMultiCallResultWithRelativeBitmaps,
136
+ },
137
+ ];
138
+ this._stateRequestCallData = callData;
139
+ }
140
+ return this._stateRequestCallData;
141
+ }
99
142
  getBitmapRangeToRequest() {
100
143
  return constants_1.TICK_BITMAP_TO_USE + constants_1.TICK_BITMAP_BUFFER;
101
144
  }
102
- async _fetchPoolStateSingleStep(blockNumber) {
103
- const callData = [
104
- {
105
- target: this.token0,
106
- callData: this.erc20Interface.encodeFunctionData('balanceOf', [
107
- this.poolAddress,
108
- ]),
109
- decodeFunction: decoders_1.uint256ToBigInt,
110
- },
111
- {
112
- target: this.token1,
113
- callData: this.erc20Interface.encodeFunctionData('balanceOf', [
114
- this.poolAddress,
115
- ]),
116
- decodeFunction: decoders_1.uint256ToBigInt,
117
- },
118
- {
119
- target: this.stateMultiContract.options.address,
120
- callData: this.stateMultiContract.methods
121
- .getFullStateWithRelativeBitmaps(this.factoryAddress, this.token0, this.token1, this.getBitmapRangeToRequest(), this.getBitmapRangeToRequest())
122
- .encodeABI(),
123
- decodeFunction: utils_2.decodeStateMultiCallResultWithRelativeBitmaps,
124
- },
125
- ];
145
+ async generateState(blockNumber) {
146
+ const callData = this._getStateRequestCallData();
126
147
  const [resBalance0, resBalance1, resState] = await this.dexHelper.multiWrapper.tryAggregate(false, callData, blockNumber, this.dexHelper.multiWrapper.defaultBatchSize, false);
148
+ // Quite ugly solution, but this is the one that fits to current flow.
149
+ // I think UniswapV3 callbacks subscriptions are complexified for no reason.
150
+ // Need to be revisited later
127
151
  (0, ts_essentials_1.assert)(resState.success, 'Pool does not exist');
128
152
  const [balance0, balance1, _state] = [
129
153
  resBalance0.returnData,
130
154
  resBalance1.returnData,
131
155
  resState.returnData,
132
156
  ];
133
- return [balance0, balance1, _state];
134
- }
135
- async _fetchPoolStateMultiStep(blockNumber) {
136
- const balancesAndGlobalStateCalldata = [
137
- {
138
- target: this.token0,
139
- callData: this.erc20Interface.encodeFunctionData('balanceOf', [
140
- this.poolAddress,
141
- ]),
142
- decodeFunction: decoders_1.uint256ToBigInt,
143
- },
144
- {
145
- target: this.token1,
146
- callData: this.erc20Interface.encodeFunctionData('balanceOf', [
147
- this.poolAddress,
148
- ]),
149
- decodeFunction: decoders_1.uint256ToBigInt,
150
- },
151
- {
152
- target: this.stateMultiContract.options.address,
153
- callData: this.stateMultiContract.methods
154
- .getFullStateWithoutTicks(this.factoryAddress, this.token0, this.token1, 0, 0)
155
- .encodeABI(),
156
- decodeFunction: utils_2.decodeStateMultiCallResultWithRelativeBitmaps,
157
- },
158
- ];
159
- const [resBalance0, resBalance1, stateWithoutTicksAndTickBitmap] = await this.dexHelper.multiWrapper.tryAggregate(false, balancesAndGlobalStateCalldata, blockNumber, this.dexHelper.multiWrapper.defaultBatchSize, false);
160
- (0, ts_essentials_1.assert)(stateWithoutTicksAndTickBitmap.success, 'Pool does not exist');
161
- const [balance0, balance1, _stateWithoutTicksAndTickBitmap] = [
162
- resBalance0.returnData,
163
- resBalance1.returnData,
164
- stateWithoutTicksAndTickBitmap.returnData,
165
- ];
166
- const { globalState: { tick }, } = _stateWithoutTicksAndTickBitmap;
167
- const currentBitmapIndex = (0, utils_1.int16)((BigInt(tick) / Constants_1.Constants.TICK_SPACING) >> 8n);
168
- const buffer = this.getBitmapRangeToRequest();
169
- const startBitMapIndex = currentBitmapIndex - buffer;
170
- const endBitMapIndex = currentBitmapIndex + buffer;
171
- const allBitMapIndices = Array.from({ length: 2 * Number(buffer) + 1 }, () => startBitMapIndex + endBitMapIndex);
172
- const ticksAndBitMaps = await Promise.all(allBitMapIndices.map(relativeTick => {
173
- return this.stateMultiContract.methods
174
- .getAdditionalBitmapWithTicks(this.factoryAddress, this.token0, this.token1, relativeTick, relativeTick)
175
- .call();
176
- }));
177
- const _state = {
178
- ..._stateWithoutTicksAndTickBitmap,
179
- tickBitmap: ticksAndBitMaps.flatMap(v => v[0]),
180
- ticks: ticksAndBitMaps.flatMap(v => v[1]),
181
- };
182
- return [balance0, balance1, _state];
183
- }
184
- async _fetchInitStateMultiStrategies(blockNumber) {
185
- try {
186
- return await this._fetchPoolStateSingleStep(blockNumber);
187
- }
188
- catch (e) {
189
- if (e instanceof Error && e.message.includes('Pool does not exist'))
190
- throw e;
191
- if (this.dexHelper.config.data.network != constants_2.Network.ZKEVM)
192
- throw e;
193
- return this._fetchPoolStateMultiStep(blockNumber);
194
- }
195
- }
196
- async generateState(blockNumber) {
197
- const [balance0, balance1, _state] = await this._fetchInitStateMultiStrategies(blockNumber);
198
157
  const tickBitmap = {};
199
158
  const ticks = {};
200
159
  (0, utils_3._reduceTickBitmap)(tickBitmap, _state.tickBitmap);
201
160
  (0, utils_3._reduceTicks)(ticks, _state.ticks);
202
- const globalState = {
203
- communityFeeToken0: (0, utils_1.bigIntify)(_state.globalState.communityFeeToken0),
204
- communityFeeToken1: (0, utils_1.bigIntify)(_state.globalState.communityFeeToken1),
205
- fee: (0, utils_1.bigIntify)(_state.globalState.fee),
206
- price: (0, utils_1.bigIntify)(_state.globalState.price),
207
- tick: (0, utils_1.bigIntify)(_state.globalState.tick),
208
- };
209
- const currentTick = globalState.tick;
210
- const startTickBitmap = TickBitMap_1.TickBitMap.position(BigInt(currentTick) / Constants_1.Constants.TICK_SPACING)[0];
161
+ const currentTick = (0, utils_1.bigIntify)(_state.slot0.tick);
162
+ const tickSpacing = (0, utils_1.bigIntify)(_state.tickSpacing);
163
+ const fee = (0, utils_1.bigIntify)(_state.slot0.fee);
164
+ const startTickBitmap = TickBitMap_1.TickBitMap.position(currentTick / tickSpacing)[0];
165
+ const requestedRange = this.getBitmapRangeToRequest();
211
166
  return {
212
167
  pool: _state.pool,
213
168
  blockTimestamp: (0, utils_1.bigIntify)(_state.blockTimestamp),
214
- globalState,
169
+ slot0: {
170
+ sqrtPriceX96: (0, utils_1.bigIntify)(_state.slot0.sqrtPriceX96),
171
+ tick: currentTick,
172
+ fee: (0, utils_1.bigIntify)(_state.slot0.fee),
173
+ },
215
174
  liquidity: (0, utils_1.bigIntify)(_state.liquidity),
216
- tickSpacing: Constants_1.Constants.TICK_SPACING,
217
- maxLiquidityPerTick: Constants_1.Constants.MAX_LIQUIDITY_PER_TICK,
175
+ tickSpacing,
176
+ maxLiquidityPerTick: (0, utils_1.bigIntify)(_state.maxLiquidityPerTick),
218
177
  tickBitmap,
219
178
  ticks,
220
- startTickBitmap,
221
179
  isValid: true,
180
+ startTickBitmap,
181
+ lowestKnownTick: (BigInt.asIntN(24, startTickBitmap - requestedRange) << 8n) *
182
+ tickSpacing,
183
+ highestKnownTick: ((BigInt.asIntN(24, startTickBitmap + requestedRange) << 8n) +
184
+ BigInt.asIntN(24, 255n)) *
185
+ tickSpacing,
222
186
  balance0,
223
187
  balance1,
224
188
  };
225
189
  }
226
190
  handleSwapEvent(event, pool, log, blockHeader) {
227
- const newSqrtPriceX96 = (0, utils_1.bigIntify)(event.args.price);
191
+ const newSqrtPriceX96 = (0, utils_1.bigIntify)(event.args.sqrtPriceX96);
228
192
  const amount0 = (0, utils_1.bigIntify)(event.args.amount0);
229
193
  const amount1 = (0, utils_1.bigIntify)(event.args.amount1);
230
194
  const newTick = (0, utils_1.bigIntify)(event.args.tick);
@@ -238,7 +202,7 @@ class AlgebraEventPool extends stateful_event_subscriber_1.StatefulEventSubscrib
238
202
  }
239
203
  else {
240
204
  const zeroForOne = amount0 > 0n;
241
- const [, , , , , communityFee] = AlgebraMath_1.AlgebraMath._calculateSwapAndLock(pool, zeroForOne, newSqrtPriceX96, newTick, newLiquidity);
205
+ uniswap_v3_math_1.uniswapV3Math.swapFromEvent(pool, newSqrtPriceX96, newTick, newLiquidity, zeroForOne);
242
206
  if (zeroForOne) {
243
207
  if (amount1 < 0n) {
244
208
  pool.balance1 -= BigInt.asUintN(256, -amount1);
@@ -261,45 +225,43 @@ class AlgebraEventPool extends stateful_event_subscriber_1.StatefulEventSubscrib
261
225
  }
262
226
  pool.balance1 += BigInt.asUintN(256, amount1);
263
227
  }
264
- if (communityFee > 0n) {
265
- // _payCommunityFee
266
- if (zeroForOne) {
267
- pool.balance0 -= communityFee;
268
- }
269
- else {
270
- pool.balance1 -= communityFee;
271
- }
272
- }
273
228
  return pool;
274
229
  }
275
230
  }
231
+ handleBurnEvent(event, pool, log, blockHeader) {
232
+ const amount = (0, utils_1.bigIntify)(event.args.amount);
233
+ const tickLower = (0, utils_1.bigIntify)(event.args.tickLower);
234
+ const tickUpper = (0, utils_1.bigIntify)(event.args.tickUpper);
235
+ pool.blockTimestamp = (0, utils_1.bigIntify)(blockHeader.timestamp);
236
+ uniswap_v3_math_1.uniswapV3Math._modifyPosition(pool, {
237
+ tickLower,
238
+ tickUpper,
239
+ liquidityDelta: -BigInt.asIntN(128, BigInt.asIntN(256, amount)),
240
+ });
241
+ // From this transaction I conclude that there is no balance change from
242
+ // Burn event: https://dashboard.tenderly.co/tx/mainnet/0xfccf5341147ac3ad0e66452273d12dfc3219e81f8fb369a6cdecfb24b9b9d078/logs
243
+ // And it aligns with UniswapV3 doc:
244
+ // https://github.com/Uniswap/v3-core/blob/05c10bf6d547d6121622ac51c457f93775e1df09/contracts/interfaces/pool/IUniswapV3PoolActions.sol#L59
245
+ // It just updates positions and tokensOwed which may be requested calling collect
246
+ // So, we don't need to update pool.balances0 and pool.balances1 here
247
+ return pool;
248
+ }
276
249
  handleMintEvent(event, pool, log, blockHeader) {
277
- const bottomTick = (0, utils_1.bigIntify)(event.args.bottomTick);
278
- const topTick = (0, utils_1.bigIntify)(event.args.topTick);
279
- const liquidityActual = (0, utils_1.bigIntify)(event.args.liquidityAmount);
250
+ const amount = (0, utils_1.bigIntify)(event.args.amount);
251
+ const tickLower = (0, utils_1.bigIntify)(event.args.tickLower);
252
+ const tickUpper = (0, utils_1.bigIntify)(event.args.tickUpper);
280
253
  const amount0 = (0, utils_1.bigIntify)(event.args.amount0);
281
254
  const amount1 = (0, utils_1.bigIntify)(event.args.amount1);
282
255
  pool.blockTimestamp = (0, utils_1.bigIntify)(blockHeader.timestamp);
283
- AlgebraMath_1.AlgebraMath._updatePositionTicksAndFees(pool, bottomTick, topTick, liquidityActual);
256
+ uniswap_v3_math_1.uniswapV3Math._modifyPosition(pool, {
257
+ tickLower,
258
+ tickUpper,
259
+ liquidityDelta: amount,
260
+ });
284
261
  pool.balance0 += amount0;
285
262
  pool.balance1 += amount1;
286
263
  return pool;
287
264
  }
288
- handleBurnEvent(event, pool, log, blockHeader) {
289
- const bottomTick = (0, utils_1.bigIntify)(event.args.bottomTick);
290
- const topTick = (0, utils_1.bigIntify)(event.args.topTick);
291
- const amount = (0, utils_1.bigIntify)(event.args.liquidityAmount);
292
- pool.blockTimestamp = (0, utils_1.bigIntify)(blockHeader.timestamp);
293
- AlgebraMath_1.AlgebraMath._updatePositionTicksAndFees(pool, bottomTick, topTick, -BigInt.asIntN(128, BigInt.asIntN(256, amount)));
294
- // no balance change
295
- return pool;
296
- }
297
- handleNewFee(event, pool, log, blockHeader) {
298
- const fee = (0, utils_1.bigIntify)(event.args.fee);
299
- pool.globalState.fee = fee;
300
- pool.blockTimestamp = (0, utils_1.bigIntify)(blockHeader.timestamp);
301
- return pool;
302
- }
303
265
  handleCollectEvent(event, pool, log, blockHeader) {
304
266
  const amount0 = (0, utils_1.bigIntify)(event.args.amount0);
305
267
  const amount1 = (0, utils_1.bigIntify)(event.args.amount1);
@@ -316,21 +278,21 @@ class AlgebraEventPool extends stateful_event_subscriber_1.StatefulEventSubscrib
316
278
  pool.blockTimestamp = (0, utils_1.bigIntify)(blockHeader.timestamp);
317
279
  return pool;
318
280
  }
319
- handleCommunityFee(event, pool, log, blockHeader) {
320
- const communityFeeToken0 = (0, utils_1.bigIntify)(event.ags.communityFee0New);
321
- const communityFeeToken1 = (0, utils_1.bigIntify)(event.ags.communityFee1New);
322
- pool.globalState.communityFeeToken0 = communityFeeToken0;
323
- pool.globalState.communityFeeToken1 = communityFeeToken1;
281
+ handleSetFeeEvent(event, pool, log, blockHeader) {
282
+ const feeNew = (0, utils_1.bigIntify)(event.args.feeNew);
283
+ pool.slot0.fee = feeNew;
324
284
  pool.blockTimestamp = (0, utils_1.bigIntify)(blockHeader.timestamp);
325
285
  return pool;
326
286
  }
327
- _computePoolAddress(token0, token1) {
287
+ _computePoolAddress(token0, token1, tickSpacing) {
328
288
  // https://github.com/Uniswap/v3-periphery/blob/main/contracts/libraries/PoolAddress.sol
329
289
  if (token0 > token1)
330
290
  [token0, token1] = [token1, token0];
331
- const encodedKey = ethers_1.ethers.utils.keccak256(ethers_1.ethers.utils.defaultAbiCoder.encode(['address', 'address'], [token0, token1]));
332
- return ethers_1.ethers.utils.getCreate2Address(this.poolDeployer, encodedKey, this.poolInitCodeHash);
291
+ const encodedKey = ethers_1.ethers.utils.keccak256(ethers_1.ethers.utils.defaultAbiCoder.encode(['address', 'address', 'int24'],
292
+ // [token0, token1, BigInt.asUintN(24, fee)],
293
+ [token0, token1, BigInt.asUintN(24, tickSpacing)]));
294
+ return ethers_1.ethers.utils.getCreate2Address(this.factoryAddress, encodedKey, this.poolInitCodeHash);
333
295
  }
334
296
  }
335
- exports.AlgebraEventPool = AlgebraEventPool;
336
- //# sourceMappingURL=algebra-pool.js.map
297
+ exports.SolidlyV3EventPool = SolidlyV3EventPool;
298
+ //# sourceMappingURL=solidly-v3-pool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solidly-v3-pool.js","sourceRoot":"","sources":["../../../src/dex/solidly-v3/solidly-v3-pool.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAEvB,4CAA+C;AAC/C,mCAAgC;AAChC,iDAAqD;AAErD,+EAGyC;AAOzC,yGAA2E;AAC3E,uCAAuE;AACvE,qEAAgE;AAEhE,2CAIqB;AACrB,2DAAwD;AACxD,iDAAqD;AACrD,mCAAwE;AACxE,iDAAwE;AAExE,MAAM,oBAAoB,GAA2B;IACnD,GAAG,EAAE,GAAG;CACT,CAAC;AAEF,MAAa,kBAAmB,SAAQ,mDAAkC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