@paraswap/dex-lib 4.7.18-before-multi-route.0 → 4.7.19

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 (170) hide show
  1. package/build/abi/PendleRouterStatic.json +19 -0
  2. package/build/abi/apex-defi/ApexDefiFactory.abi.json +1749 -0
  3. package/build/abi/apex-defi/ApexDefiRouter.abi.json +1120 -0
  4. package/build/abi/apex-defi/ApexDefiToken.abi.json +229 -0
  5. package/build/abi/apex-defi/ApexDefiWrapper.abi.json +92 -0
  6. package/build/abi/apex-defi/ApexDefiWrapperFactory.abi.json +1107 -0
  7. package/build/abi/pangolin-v3/PangolinV3StateMulticall.abi.json +796 -0
  8. package/build/abi/pendle/pendle-deployer.abi.json +520 -0
  9. package/build/abi/pendle/pendle-oracle.abi.json +413 -0
  10. package/build/abi/pharaoh-v3/PharaohV3Factory.abi.json +101 -0
  11. package/build/abi/ring-v2/few-wrapped-token.json +587 -0
  12. package/build/abi/ring-v2/ring-v2-factory.json +125 -0
  13. package/build/abi/ring-v2/ring-v2-pool.json +461 -0
  14. package/build/abi/ring-v2/ring-v2-router.json +332 -0
  15. package/build/abi/stabull/stabull-curve.json +738 -0
  16. package/build/abi/stabull/stabull-router.json +76 -0
  17. package/build/abi/uniswap-v4/hooks/SpotDynamicFeeManager.json +26 -0
  18. package/build/abi/uniswap-v4/hooks/SpotHook.json +54 -0
  19. package/build/abi/uniswap-v4/hooks/SpotPolicyManager.json +45 -0
  20. package/build/abi/uniswap-v4/hooks/cabalcoin-hook.abi.json +682 -0
  21. package/build/abi/uniswap-v4/hooks/fee-hook.abi.json +1335 -0
  22. package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying-factory.d.ts +29 -0
  23. package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying-factory.js +153 -0
  24. package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying-factory.js.map +1 -0
  25. package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying.d.ts +40 -0
  26. package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying.js +323 -0
  27. package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying.js.map +1 -0
  28. package/build/dex/aave-pt-to-underlying/config.d.ts +3 -0
  29. package/build/dex/aave-pt-to-underlying/config.js +24 -0
  30. package/build/dex/aave-pt-to-underlying/config.js.map +1 -0
  31. package/build/dex/aave-pt-to-underlying/constants.d.ts +2 -0
  32. package/build/dex/aave-pt-to-underlying/constants.js +6 -0
  33. package/build/dex/aave-pt-to-underlying/constants.js.map +1 -0
  34. package/build/dex/aave-pt-to-underlying/types.d.ts +24 -0
  35. package/build/dex/aave-pt-to-underlying/types.js +3 -0
  36. package/build/dex/aave-pt-to-underlying/types.js.map +1 -0
  37. package/build/dex/aave-pt-to-usdc/aave-pt-to-usdc.d.ts +39 -0
  38. package/build/dex/aave-pt-to-usdc/aave-pt-to-usdc.js +244 -0
  39. package/build/dex/aave-pt-to-usdc/aave-pt-to-usdc.js.map +1 -0
  40. package/build/dex/aave-pt-to-usdc/config.d.ts +3 -0
  41. package/build/dex/aave-pt-to-usdc/config.js +47 -0
  42. package/build/dex/aave-pt-to-usdc/config.js.map +1 -0
  43. package/build/dex/aave-pt-to-usdc/constants.d.ts +2 -0
  44. package/build/dex/aave-pt-to-usdc/constants.js +6 -0
  45. package/build/dex/aave-pt-to-usdc/constants.js.map +1 -0
  46. package/build/dex/aave-pt-to-usdc/types.d.ts +22 -0
  47. package/build/dex/aave-pt-to-usdc/types.js +3 -0
  48. package/build/dex/aave-pt-to-usdc/types.js.map +1 -0
  49. package/build/dex/apex-defi/apex-defi-factory.d.ts +26 -0
  50. package/build/dex/apex-defi/apex-defi-factory.js +53 -0
  51. package/build/dex/apex-defi/apex-defi-factory.js.map +1 -0
  52. package/build/dex/apex-defi/apex-defi-pool.d.ts +55 -0
  53. package/build/dex/apex-defi/apex-defi-pool.js +247 -0
  54. package/build/dex/apex-defi/apex-defi-pool.js.map +1 -0
  55. package/build/dex/apex-defi/apex-defi-wrapper-factory.d.ts +57 -0
  56. package/build/dex/apex-defi/apex-defi-wrapper-factory.js +250 -0
  57. package/build/dex/apex-defi/apex-defi-wrapper-factory.js.map +1 -0
  58. package/build/dex/apex-defi/apex-defi.d.ts +97 -0
  59. package/build/dex/apex-defi/apex-defi.js +1021 -0
  60. package/build/dex/apex-defi/apex-defi.js.map +1 -0
  61. package/build/dex/apex-defi/config.d.ts +4 -0
  62. package/build/dex/apex-defi/config.js +138 -0
  63. package/build/dex/apex-defi/config.js.map +1 -0
  64. package/build/dex/apex-defi/types.d.ts +32 -0
  65. package/build/dex/apex-defi/types.js +3 -0
  66. package/build/dex/apex-defi/types.js.map +1 -0
  67. package/build/dex/apex-defi/utils.d.ts +46 -0
  68. package/build/dex/apex-defi/utils.js +133 -0
  69. package/build/dex/apex-defi/utils.js.map +1 -0
  70. package/build/dex/idle-dao/idle-dao.d.ts +0 -1
  71. package/build/dex/idle-dao/idle-dao.js +11 -23
  72. package/build/dex/idle-dao/idle-dao.js.map +1 -1
  73. package/build/dex/maker-psm/maker-psm.d.ts +41 -4
  74. package/build/dex/maker-psm/maker-psm.js +143 -40
  75. package/build/dex/maker-psm/maker-psm.js.map +1 -1
  76. package/build/dex/miro-migrator/miro-migrator-state.d.ts +27 -0
  77. package/build/dex/miro-migrator/miro-migrator-state.js +89 -0
  78. package/build/dex/miro-migrator/miro-migrator-state.js.map +1 -0
  79. package/build/dex/simple-exchange.js +1 -7
  80. package/build/dex/simple-exchange.js.map +1 -1
  81. package/build/dex/stabull/config.d.ts +3 -0
  82. package/build/dex/stabull/config.js +177 -0
  83. package/build/dex/stabull/config.js.map +1 -0
  84. package/build/dex/stabull/stabull-pool.d.ts +46 -0
  85. package/build/dex/stabull/stabull-pool.js +113 -0
  86. package/build/dex/stabull/stabull-pool.js.map +1 -0
  87. package/build/dex/stabull/stabull.d.ts +55 -0
  88. package/build/dex/stabull/stabull.js +286 -0
  89. package/build/dex/stabull/stabull.js.map +1 -0
  90. package/build/dex/stabull/types.d.ts +21 -0
  91. package/build/dex/stabull/types.js +3 -0
  92. package/build/dex/stabull/types.js.map +1 -0
  93. package/build/dex/uniswap-v2/constants.js +2 -0
  94. package/build/dex/uniswap-v2/constants.js.map +1 -1
  95. package/build/dex/uniswap-v3/forks/pangolin-v3/utils.d.ts +4 -0
  96. package/build/dex/uniswap-v3/forks/pangolin-v3/utils.js +56 -0
  97. package/build/dex/uniswap-v3/forks/pangolin-v3/utils.js.map +1 -0
  98. package/build/dex/uniswap-v4/config.js +2 -0
  99. package/build/dex/uniswap-v4/config.js.map +1 -1
  100. package/build/dex/uniswap-v4/contract-math/uniswap-v4-pool-math.d.ts +2 -1
  101. package/build/dex/uniswap-v4/contract-math/uniswap-v4-pool-math.js +28 -9
  102. package/build/dex/uniswap-v4/contract-math/uniswap-v4-pool-math.js.map +1 -1
  103. package/build/dex/uniswap-v4/hooks/arena/arena-hook.js +4 -4
  104. package/build/dex/uniswap-v4/hooks/arena/arena-hook.js.map +1 -1
  105. package/build/dex/uniswap-v4/hooks/arena.d.ts +6 -0
  106. package/build/dex/uniswap-v4/hooks/arena.js +10 -0
  107. package/build/dex/uniswap-v4/hooks/arena.js.map +1 -0
  108. package/build/dex/uniswap-v4/hooks/base-fee/base-fee-hook.d.ts +0 -0
  109. package/build/dex/uniswap-v4/hooks/base-fee/base-fee-hook.js +2 -0
  110. package/build/dex/uniswap-v4/hooks/base-fee/base-fee-hook.js.map +1 -0
  111. package/build/dex/uniswap-v4/hooks/cabalcoin-hook/cabalcoin-hook-pool.d.ts +7 -0
  112. package/build/dex/uniswap-v4/hooks/cabalcoin-hook/cabalcoin-hook-pool.js +28 -0
  113. package/build/dex/uniswap-v4/hooks/cabalcoin-hook/cabalcoin-hook-pool.js.map +1 -0
  114. package/build/dex/uniswap-v4/hooks/cabalcoin-hook/types.d.ts +0 -0
  115. package/build/dex/uniswap-v4/hooks/cabalcoin-hook/types.js +2 -0
  116. package/build/dex/uniswap-v4/hooks/cabalcoin-hook/types.js.map +1 -0
  117. package/build/dex/uniswap-v4/hooks/fee-hook/fee-hook-pool.d.ts +7 -0
  118. package/build/dex/uniswap-v4/hooks/fee-hook/fee-hook-pool.js +28 -0
  119. package/build/dex/uniswap-v4/hooks/fee-hook/fee-hook-pool.js.map +1 -0
  120. package/build/dex/uniswap-v4/hooks/fee-hook/types.d.ts +0 -0
  121. package/build/dex/uniswap-v4/hooks/fee-hook/types.js +2 -0
  122. package/build/dex/uniswap-v4/hooks/fee-hook/types.js.map +1 -0
  123. package/build/dex/uniswap-v4/hooks/index.d.ts +1 -0
  124. package/build/dex/uniswap-v4/hooks/index.js +18 -0
  125. package/build/dex/uniswap-v4/hooks/index.js.map +1 -0
  126. package/build/dex/uniswap-v4/hooks/spot.d.ts +15 -0
  127. package/build/dex/uniswap-v4/hooks/spot.js +109 -0
  128. package/build/dex/uniswap-v4/hooks/spot.js.map +1 -0
  129. package/build/dex/uniswap-v4/hooks/template.d.ts +150 -0
  130. package/build/dex/uniswap-v4/hooks/template.js +104 -0
  131. package/build/dex/uniswap-v4/hooks/template.js.map +1 -0
  132. package/build/dex/uniswap-v4/hooks/types.d.ts +4 -0
  133. package/build/dex/uniswap-v4/subgraph.d.ts +4 -4
  134. package/build/dex/uniswap-v4/subgraph.js +24 -21
  135. package/build/dex/uniswap-v4/subgraph.js.map +1 -1
  136. package/build/dex/uniswap-v4/types.d.ts +2 -0
  137. package/build/dex/uniswap-v4/uniswap-v4-pool-manager.d.ts +7 -1
  138. package/build/dex/uniswap-v4/uniswap-v4-pool-manager.js +54 -9
  139. package/build/dex/uniswap-v4/uniswap-v4-pool-manager.js.map +1 -1
  140. package/build/dex/uniswap-v4/uniswap-v4-pool.d.ts +3 -1
  141. package/build/dex/uniswap-v4/uniswap-v4-pool.js +3 -1
  142. package/build/dex/uniswap-v4/uniswap-v4-pool.js.map +1 -1
  143. package/build/dex/uniswap-v4/uniswap-v4.d.ts +3 -1
  144. package/build/dex/uniswap-v4/uniswap-v4.js +15 -5
  145. package/build/dex/uniswap-v4/uniswap-v4.js.map +1 -1
  146. package/build/dex/uniswap-v4/utils.d.ts +2 -1
  147. package/build/dex/uniswap-v4/utils.js +11 -0
  148. package/build/dex/uniswap-v4/utils.js.map +1 -1
  149. package/build/dex/usdc-transmuter/usdc-transmuter-pool.d.ts +26 -0
  150. package/build/dex/usdc-transmuter/usdc-transmuter-pool.js +75 -0
  151. package/build/dex/usdc-transmuter/usdc-transmuter-pool.js.map +1 -0
  152. package/build/dex/usual/usual-usdc-usdc.d.ts +17 -0
  153. package/build/dex/usual/usual-usdc-usdc.js +59 -0
  154. package/build/dex/usual/usual-usdc-usdc.js.map +1 -0
  155. package/build/dex/yo/config.d.ts +3 -0
  156. package/build/dex/yo/config.js +21 -0
  157. package/build/dex/yo/config.js.map +1 -0
  158. package/build/dex/yo/types.d.ts +13 -0
  159. package/build/dex/yo/types.js +3 -0
  160. package/build/dex/yo/types.js.map +1 -0
  161. package/build/dex/yo/yo-pool.d.ts +13 -0
  162. package/build/dex/yo/yo-pool.js +26 -0
  163. package/build/dex/yo/yo-pool.js.map +1 -0
  164. package/build/dex/yo/yo.d.ts +39 -0
  165. package/build/dex/yo/yo.js +248 -0
  166. package/build/dex/yo/yo.js.map +1 -0
  167. package/build/implementations/api-paraswap-sdk.d.ts +25 -0
  168. package/build/implementations/api-paraswap-sdk.js +102 -0
  169. package/build/implementations/api-paraswap-sdk.js.map +1 -0
  170. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/stabull/config.ts"],"names":[],"mappings":";;;AAEA,+CAA0C;AAE7B,QAAA,aAAa,GAA4B;IACpD,OAAO,EAAE;QACP,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,MAAM,EAAE,4CAA4C;YACpD,aAAa,EAAE,4CAA4C;YAC3D,KAAK,EAAE;gBACL,4CAA4C,EAAE;oBAC5C,MAAM,EAAE;wBACN;4BACE,OAAO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;yBACb,EAAE,MAAM;wBACT;4BACE,OAAO,EAAE,4CAA4C;4BACrD,QAAQ,EAAE,CAAC;yBACZ,EAAE,OAAO;qBACX;iBACF;gBACD,4CAA4C,EAAE;oBAC5C,MAAM,EAAE;wBACN;4BACE,OAAO,EAAE,4CAA4C;4BACrD,QAAQ,EAAE,CAAC;yBACZ,EAAE,OAAO;wBACV;4BACE,OAAO,EAAE,4CAA4C;4BACrD,QAAQ,EAAE,CAAC;yBACZ,EAAE,OAAO;qBACX;iBACF;aACF;SACF;KACF;CACF,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { DeepReadonly } from 'ts-essentials';
2
+ import { Log, Logger } from '../../types';
3
+ import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
4
+ import { IDexHelper } from '../../dex-helper/idex-helper';
5
+ import { PoolState } from './types';
6
+ export declare class StabullEventPool extends StatefulEventSubscriber<PoolState> {
7
+ readonly parentName: string;
8
+ protected network: number;
9
+ protected dexHelper: IDexHelper;
10
+ readonly poolAddress: string;
11
+ protected addressesSubscribed_: string[];
12
+ handlers: {
13
+ [event: string]: (event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>) => DeepReadonly<PoolState> | null;
14
+ };
15
+ logDecoder: (log: Log) => any;
16
+ constructor(parentName: string, network: number, dexHelper: IDexHelper, poolAddress: string, addressesSubscribed_: string[], logger: Logger);
17
+ /**
18
+ * The function is called every time any of the subscribed
19
+ * addresses release log. The function accepts the current
20
+ * state, updates the state according to the log, and returns
21
+ * the updated state.
22
+ * @param state - Current state of event subscriber
23
+ * @param log - Log released by one of the subscribed addresses
24
+ * @returns Updates state of the event subscriber after the log
25
+ */
26
+ protected processLog(state: DeepReadonly<PoolState>, log: Readonly<Log>): DeepReadonly<PoolState> | null;
27
+ /**
28
+ * The function generates state using on-chain calls. This
29
+ * function is called to regenerate state if the event based
30
+ * system fails to fetch events and the local state is no
31
+ * more correct.
32
+ * @param blockNumber - Blocknumber for which the state should
33
+ * should be generated
34
+ * @returns state of the event subscriber at blocknumber
35
+ */
36
+ generateState(blockNumber: number): Promise<DeepReadonly<PoolState>>;
37
+ /**
38
+ * Handles a transfer event and updates the pool state accordingly.
39
+ *
40
+ * @param event - The transfer event object containing details about the transfer.
41
+ * @param state - The current state of the pool.
42
+ * @param log - The log object containing additional information about the event.
43
+ * @returns The updated pool state if the transfer involves the pool, otherwise null.
44
+ */
45
+ handleTransfer(event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>): DeepReadonly<PoolState> | null;
46
+ }
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StabullEventPool = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
6
+ const utils_2 = require("../../lib/tokens/utils");
7
+ const decoders_1 = require("../../lib/decoders");
8
+ class StabullEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
9
+ parentName;
10
+ network;
11
+ dexHelper;
12
+ poolAddress;
13
+ addressesSubscribed_;
14
+ handlers = {};
15
+ logDecoder;
16
+ constructor(parentName, network, dexHelper, poolAddress, addressesSubscribed_, logger) {
17
+ super(parentName, poolAddress.toLowerCase(), dexHelper, logger);
18
+ this.parentName = parentName;
19
+ this.network = network;
20
+ this.dexHelper = dexHelper;
21
+ this.poolAddress = poolAddress;
22
+ this.addressesSubscribed_ = addressesSubscribed_;
23
+ this.logDecoder = (log) => utils_2.erc20Iface.parseLog(log);
24
+ this.addressesSubscribed = addressesSubscribed_;
25
+ this.poolAddress = poolAddress.toLowerCase();
26
+ }
27
+ /**
28
+ * The function is called every time any of the subscribed
29
+ * addresses release log. The function accepts the current
30
+ * state, updates the state according to the log, and returns
31
+ * the updated state.
32
+ * @param state - Current state of event subscriber
33
+ * @param log - Log released by one of the subscribed addresses
34
+ * @returns Updates state of the event subscriber after the log
35
+ */
36
+ processLog(state, log) {
37
+ try {
38
+ const event = this.logDecoder(log);
39
+ if (event.name in this.handlers) {
40
+ return this.handlers[event.name](event, state, log);
41
+ }
42
+ }
43
+ catch (e) {
44
+ (0, utils_1.catchParseLogError)(e, this.logger);
45
+ }
46
+ return null;
47
+ }
48
+ /**
49
+ * The function generates state using on-chain calls. This
50
+ * function is called to regenerate state if the event based
51
+ * system fails to fetch events and the local state is no
52
+ * more correct.
53
+ * @param blockNumber - Blocknumber for which the state should
54
+ * should be generated
55
+ * @returns state of the event subscriber at blocknumber
56
+ */
57
+ async generateState(blockNumber) {
58
+ let calldata = [
59
+ {
60
+ target: this.addressesSubscribed[0],
61
+ callData: utils_2.erc20Iface.encodeFunctionData('balanceOf', [
62
+ this.poolAddress,
63
+ ]),
64
+ decodeFunction: decoders_1.uint256ToBigInt,
65
+ },
66
+ {
67
+ target: this.addressesSubscribed[1],
68
+ callData: utils_2.erc20Iface.encodeFunctionData('balanceOf', [
69
+ this.poolAddress,
70
+ ]),
71
+ decodeFunction: decoders_1.uint256ToBigInt,
72
+ },
73
+ ];
74
+ const data = await this.dexHelper.multiWrapper.tryAggregate(true, calldata, blockNumber);
75
+ return {
76
+ reserves0: data[0].success ? data[0].returnData : 0n,
77
+ reserves1: data[1].success ? data[1].returnData : 0n,
78
+ };
79
+ }
80
+ /**
81
+ * Handles a transfer event and updates the pool state accordingly.
82
+ *
83
+ * @param event - The transfer event object containing details about the transfer.
84
+ * @param state - The current state of the pool.
85
+ * @param log - The log object containing additional information about the event.
86
+ * @returns The updated pool state if the transfer involves the pool, otherwise null.
87
+ */
88
+ handleTransfer(event, state, log) {
89
+ const from = event.args.from.toLowerCase();
90
+ const to = event.args.to.toLowerCase();
91
+ // Check if pool is involved in the transfer
92
+ if (from !== this.poolAddress && to !== this.poolAddress) {
93
+ return null;
94
+ }
95
+ // Determine which token this is
96
+ const eventTokenAddress = log.address.toLowerCase();
97
+ const isToken0 = eventTokenAddress === this.addressesSubscribed[0].toLowerCase();
98
+ const value = event.args.value.toBigInt();
99
+ const reserveKey = isToken0 ? 'reserves0' : 'reserves1';
100
+ const currentReserve = state[reserveKey];
101
+ // Pool is sending tokens (decrease) or receiving tokens (increase)
102
+ const isFromPool = from === this.poolAddress;
103
+ const newReserve = isFromPool
104
+ ? currentReserve - value
105
+ : currentReserve + value;
106
+ return {
107
+ ...state,
108
+ [reserveKey]: newReserve,
109
+ };
110
+ }
111
+ }
112
+ exports.StabullEventPool = StabullEventPool;
113
+ //# sourceMappingURL=stabull-pool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stabull-pool.js","sourceRoot":"","sources":["../../../src/dex/stabull/stabull-pool.ts"],"names":[],"mappings":";;;AAEA,uCAAiD;AACjD,+EAA0E;AAG1E,kDAAoD;AACpD,iDAAqD;AAErD,MAAa,gBAAiB,SAAQ,mDAAkC;IAY3D;IACC;IACA;IACD;IACC;IAfZ,QAAQ,GAMJ,EAAE,CAAC;IAEP,UAAU,CAAoB;IAE9B,YACW,UAAkB,EACjB,OAAe,EACf,SAAqB,EACtB,WAAmB,EAClB,oBAA8B,EACxC,MAAc;QAEd,KAAK,CAAC,UAAU,EAAE,WAAW,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAPvD,eAAU,GAAV,UAAU,CAAQ;QACjB,YAAO,GAAP,OAAO,CAAQ;QACf,cAAS,GAAT,SAAS,CAAY;QACtB,gBAAW,GAAX,WAAW,CAAQ;QAClB,yBAAoB,GAApB,oBAAoB,CAAU;QAKxC,IAAI,CAAC,UAAU,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC,kBAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACzD,IAAI,CAAC,mBAAmB,GAAG,oBAAoB,CAAC;QAChD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;IAC/C,CAAC;IAED;;;;;;;;OAQG;IACO,UAAU,CAClB,KAA8B,EAC9B,GAAkB;QAElB,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC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;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,cAAc,CACZ,KAAU,EACV,KAA8B,EAC9B,GAAkB;QAElB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QAC3C,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC;QAEvC,4CAA4C;QAC5C,IAAI,IAAI,KAAK,IAAI,CAAC,WAAW,IAAI,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC;YACzD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,gCAAgC;QAChC,MAAM,iBAAiB,GAAG,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QACpD,MAAM,QAAQ,GACZ,iBAAiB,KAAK,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAElE,MAAM,KAAK,GAAW,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAClD,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC;QACxD,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;QAEzC,mEAAmE;QACnE,MAAM,UAAU,GAAG,IAAI,KAAK,IAAI,CAAC,WAAW,CAAC;QAC7C,MAAM,UAAU,GAAG,UAAU;YAC3B,CAAC,CAAC,cAAc,GAAG,KAAK;YACxB,CAAC,CAAC,cAAc,GAAG,KAAK,CAAC;QAE3B,OAAO;YACL,GAAG,KAAK;YACR,CAAC,UAAU,CAAC,EAAE,UAAU;SACzB,CAAC;IACJ,CAAC;CACF;AAnID,4CAmIC"}
@@ -0,0 +1,55 @@
1
+ import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, PoolLiquidity, Logger, DexExchangeParam } from '../../types';
2
+ import { SwapSide, Network } from '../../constants';
3
+ import { IDex } from '../../dex/idex';
4
+ import { IDexHelper } from '../../dex-helper/idex-helper';
5
+ import { StabullData } from './types';
6
+ import { SimpleExchange } from '../simple-exchange';
7
+ import { ethers } from 'ethers';
8
+ export declare class Stabull extends SimpleExchange implements IDex<StabullData> {
9
+ readonly network: Network;
10
+ readonly dexKey: string;
11
+ readonly dexHelper: IDexHelper;
12
+ protected poolIface: ethers.utils.Interface;
13
+ protected routerIface: ethers.utils.Interface;
14
+ protected routerAddress: string;
15
+ protected quoteCurrency: string;
16
+ private pools;
17
+ private poolsConfig;
18
+ readonly hasConstantPriceLargeAmounts = false;
19
+ readonly needWrapNative = true;
20
+ readonly isFeeOnTransferSupported = false;
21
+ static dexKeysWithNetwork: {
22
+ key: string;
23
+ networks: Network[];
24
+ }[];
25
+ logger: Logger;
26
+ constructor(network: Network, dexKey: string, dexHelper: IDexHelper, poolIface?: ethers.utils.Interface, routerIface?: ethers.utils.Interface, routerAddress?: string, quoteCurrency?: string);
27
+ getAdapters(side: SwapSide): {
28
+ name: string;
29
+ index: number;
30
+ }[] | null;
31
+ getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
32
+ getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<StabullData>>;
33
+ getCalldataGasCost(poolPrices: PoolPrices<StabullData>): number | number[];
34
+ getAdapterParam: (srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: StabullData, side: SwapSide) => AdapterExchangeParam;
35
+ updatePoolState(): Promise<void>;
36
+ getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
37
+ /**
38
+ * Retrieves the decentralized exchange (DEX) parameters for a swap operation.
39
+ *
40
+ * @param srcToken - The address of the source token.
41
+ * @param destToken - The address of the destination token.
42
+ * @param srcAmount - The amount of the source token to swap.
43
+ * @param destAmount - The desired amount of the destination token.
44
+ * @param recipient - The address of the recipient.
45
+ * @param data - Additional data required for the swap.
46
+ * @param side - The side of the swap (SELL or BUY).
47
+ * @param options - Options for global tokens.
48
+ * @param executorAddress - The address of the executor.
49
+ * @returns A promise that resolves to the DEX exchange parameters.
50
+ */
51
+ getDexParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, recipient: string, data: StabullData, side: SwapSide, options: {
52
+ isGlobalSrcToken: boolean;
53
+ isGlobalDestToken: boolean;
54
+ }, executorAddress: string): Promise<DexExchangeParam>;
55
+ }
@@ -0,0 +1,286 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.Stabull = void 0;
40
+ const constants_1 = require("../../constants");
41
+ const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
42
+ const utils_1 = require("../../utils");
43
+ const stabull_pool_1 = require("./stabull-pool");
44
+ const simple_exchange_1 = require("../simple-exchange");
45
+ const config_1 = require("./config");
46
+ const stabull_curve_json_1 = __importDefault(require("../../abi/stabull/stabull-curve.json"));
47
+ const stabull_router_json_1 = __importDefault(require("../../abi/stabull/stabull-router.json"));
48
+ const ethers_1 = require("ethers");
49
+ const decoders_1 = require("../../lib/decoders");
50
+ const bigint_constants_1 = require("../../bigint-constants");
51
+ class Stabull extends simple_exchange_1.SimpleExchange {
52
+ network;
53
+ dexKey;
54
+ dexHelper;
55
+ poolIface;
56
+ routerIface;
57
+ routerAddress;
58
+ quoteCurrency;
59
+ pools = {};
60
+ poolsConfig;
61
+ hasConstantPriceLargeAmounts = false;
62
+ needWrapNative = true;
63
+ isFeeOnTransferSupported = false;
64
+ static dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.StabullConfig);
65
+ logger;
66
+ constructor(network, dexKey, dexHelper, poolIface = new ethers_1.ethers.utils.Interface(stabull_curve_json_1.default), routerIface = new ethers_1.ethers.utils.Interface(stabull_router_json_1.default), routerAddress = config_1.StabullConfig.Stabull[network].router, quoteCurrency = config_1.StabullConfig.Stabull[network].quoteCurrency) {
67
+ super(dexHelper, dexKey);
68
+ this.network = network;
69
+ this.dexKey = dexKey;
70
+ this.dexHelper = dexHelper;
71
+ this.poolIface = poolIface;
72
+ this.routerIface = routerIface;
73
+ this.routerAddress = routerAddress;
74
+ this.quoteCurrency = quoteCurrency;
75
+ this.logger = dexHelper.getLogger(dexKey);
76
+ this.poolsConfig = config_1.StabullConfig.Stabull[network].pools;
77
+ //Iterate over pools and Initialize event pools
78
+ Object.keys(this.poolsConfig).forEach(poolAddress => {
79
+ const pool = this.poolsConfig[poolAddress];
80
+ const tokenAddresses = pool.tokens.map(t => t.address);
81
+ // Initialize event pools
82
+ this.pools[poolAddress] = new stabull_pool_1.StabullEventPool(dexKey, network, dexHelper, poolAddress, tokenAddresses, this.logger);
83
+ });
84
+ }
85
+ // Legacy: was only used for V5
86
+ // Returns the list of contract adapters (name and index)
87
+ // for a buy/sell. Return null if there are no adapters.
88
+ getAdapters(side) {
89
+ return null;
90
+ }
91
+ // Returns list of pool identifiers that can be used
92
+ // for a given swap. poolIdentifiers must be unique
93
+ // across DEXes. It is recommended to use
94
+ // ${dexKey}_${poolAddress} as a poolIdentifier
95
+ async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
96
+ const pool = Object.entries(this.poolsConfig).find(([, pool]) => {
97
+ const tokenAddresses = pool.tokens.map(t => t.address.toLowerCase());
98
+ return (tokenAddresses.includes(srcToken.address.toLowerCase()) &&
99
+ tokenAddresses.includes(destToken.address.toLowerCase()));
100
+ })?.[0];
101
+ return pool ? [`${this.dexKey}_${pool}`.toLowerCase()] : [];
102
+ }
103
+ // Returns pool prices for amounts.
104
+ // If limitPools is defined only pools in limitPools
105
+ // should be used. If limitPools is undefined then
106
+ // any pools can be used.
107
+ async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
108
+ const poolIdentifiers = await this.getPoolIdentifiers(srcToken, destToken, side, blockNumber);
109
+ if (poolIdentifiers.length === 0)
110
+ return null;
111
+ const poolIdentifier = poolIdentifiers[0];
112
+ const poolAddress = poolIdentifier.split('_')[1];
113
+ if (!poolAddress) {
114
+ this.logger.debug(`Invalid pool identifier: ${poolIdentifier}`);
115
+ return null;
116
+ }
117
+ const isSell = side === constants_1.SwapSide.SELL;
118
+ const methodName = isSell ? 'viewOriginSwap' : 'viewTargetSwap';
119
+ try {
120
+ const unitAmount = bigint_constants_1.BI_POWS[isSell ? srcToken.decimals : destToken.decimals];
121
+ const queryAmounts = [unitAmount, ...amounts];
122
+ const callData = queryAmounts.map(amount => ({
123
+ target: poolAddress,
124
+ callData: this.poolIface.encodeFunctionData(methodName, [
125
+ srcToken.address,
126
+ destToken.address,
127
+ amount.toString(),
128
+ ]),
129
+ decodeFunction: decoders_1.uint256ToBigInt,
130
+ }));
131
+ const quotes = await this.dexHelper.multiWrapper.tryAggregate(false, callData, blockNumber, this.dexHelper.multiWrapper.defaultBatchSize, false);
132
+ const unit = quotes[0].success ? quotes[0].returnData : 0n;
133
+ const prices = quotes.slice(1).map(q => (q.success ? q.returnData : 0n));
134
+ return [
135
+ {
136
+ unit,
137
+ prices,
138
+ data: { poolAddress },
139
+ exchange: this.dexKey,
140
+ gasCost: 150000,
141
+ poolAddresses: [poolAddress],
142
+ poolIdentifiers: [poolIdentifier],
143
+ },
144
+ ];
145
+ }
146
+ catch (e) {
147
+ this.logger.error('Failed to get prices', e);
148
+ return null;
149
+ }
150
+ }
151
+ // Returns estimated gas cost of calldata for this DEX in multiSwap
152
+ getCalldataGasCost(poolPrices) {
153
+ return (CALLDATA_GAS_COST.DEX_OVERHEAD +
154
+ CALLDATA_GAS_COST.FUNCTION_SELECTOR +
155
+ CALLDATA_GAS_COST.ADDRESS * 2 +
156
+ CALLDATA_GAS_COST.AMOUNT * 2 +
157
+ CALLDATA_GAS_COST.TIMESTAMP);
158
+ }
159
+ // Encode params required by the exchange adapter
160
+ // V5: Used for multiSwap, buy & megaSwap
161
+ // V6: Not used, can be left blank
162
+ // Hint: abiCoder.encodeParameter() could be useful
163
+ // Update this method to use the correct AbiCoder syntax
164
+ getAdapterParam = (srcToken, destToken, srcAmount, destAmount, data, side) => {
165
+ return {
166
+ targetExchange: config_1.StabullConfig.Stabull[this.network].router,
167
+ payload: '0x',
168
+ networkFee: '0',
169
+ };
170
+ };
171
+ // This is called once before getTopPoolsForToken is
172
+ // called for multiple tokens. This can be helpful to
173
+ // update common state required for calculating
174
+ // getTopPoolsForToken. It is optional for a DEX
175
+ // to implement this
176
+ async updatePoolState() {
177
+ const blockNumber = await this.dexHelper.web3Provider.eth.getBlockNumber();
178
+ await Promise.all(Object.values(this.pools).map(async (poolInstance) => {
179
+ const state = await poolInstance.generateState(blockNumber);
180
+ poolInstance.setState(state, blockNumber);
181
+ }));
182
+ }
183
+ // Returns list of top pools based on liquidity. Max
184
+ // limit number pools should be returned.
185
+ async getTopPoolsForToken(tokenAddress, limit) {
186
+ const lowerToken = tokenAddress.toLowerCase();
187
+ const poolsWithToken = [];
188
+ for (const [poolAddress, pool] of Object.entries(this.pools)) {
189
+ const tokenIndex = pool.addressesSubscribed.findIndex(t => t.toLowerCase() === lowerToken);
190
+ if (tokenIndex === -1)
191
+ continue;
192
+ poolsWithToken.push({
193
+ pool,
194
+ tokenIndex,
195
+ connectorIndex: 1 - tokenIndex,
196
+ poolConfig: this.poolsConfig[poolAddress],
197
+ });
198
+ }
199
+ if (poolsWithToken.length === 0)
200
+ return [];
201
+ const tokenToAmount = new Map();
202
+ for (const { pool, tokenIndex, connectorIndex } of poolsWithToken) {
203
+ const state = pool.getStaleState();
204
+ if (!state)
205
+ continue;
206
+ const token = pool.addressesSubscribed[tokenIndex];
207
+ const connector = pool.addressesSubscribed[connectorIndex];
208
+ tokenToAmount.set(token, state[tokenIndex === 0 ? 'reserves0' : 'reserves1'] ?? 0n);
209
+ tokenToAmount.set(connector, state[connectorIndex === 0 ? 'reserves0' : 'reserves1'] ?? 0n);
210
+ }
211
+ const tokenAmountsArray = Array.from(tokenToAmount.entries());
212
+ const usdAmounts = await this.dexHelper.getUsdTokenAmounts(tokenAmountsArray);
213
+ const usdMap = new Map(tokenAmountsArray.map((t, i) => [t[0], usdAmounts[i]]));
214
+ const relevantPools = poolsWithToken.map(({ pool, tokenIndex, connectorIndex, poolConfig }) => {
215
+ const token = pool.addressesSubscribed[tokenIndex];
216
+ const connector = pool.addressesSubscribed[connectorIndex];
217
+ return {
218
+ exchange: this.dexKey,
219
+ address: pool.poolAddress,
220
+ connectorTokens: [
221
+ {
222
+ address: connector,
223
+ decimals: poolConfig.tokens[connectorIndex]?.decimals ?? 18,
224
+ liquidityUSD: usdMap.get(connector) ?? 0,
225
+ },
226
+ ],
227
+ liquidityUSD: usdMap.get(token) ?? 0,
228
+ };
229
+ });
230
+ relevantPools.sort((a, b) => b.liquidityUSD - a.liquidityUSD);
231
+ return relevantPools.slice(0, limit);
232
+ }
233
+ /**
234
+ * Retrieves the decentralized exchange (DEX) parameters for a swap operation.
235
+ *
236
+ * @param srcToken - The address of the source token.
237
+ * @param destToken - The address of the destination token.
238
+ * @param srcAmount - The amount of the source token to swap.
239
+ * @param destAmount - The desired amount of the destination token.
240
+ * @param recipient - The address of the recipient.
241
+ * @param data - Additional data required for the swap.
242
+ * @param side - The side of the swap (SELL or BUY).
243
+ * @param options - Options for global tokens.
244
+ * @param executorAddress - The address of the executor.
245
+ * @returns A promise that resolves to the DEX exchange parameters.
246
+ */
247
+ async getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side, options, executorAddress) {
248
+ // For SELL operations, always use the router for swaps
249
+ if (side === constants_1.SwapSide.SELL) {
250
+ const swapData = this.routerIface.encodeFunctionData('originSwap', [
251
+ this.quoteCurrency, // quoteCurrency
252
+ srcToken, // origin
253
+ destToken, // target
254
+ srcAmount, // originAmount
255
+ '1', // minTargetAmount - set to minimum to ensure execution
256
+ (0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)(), // deadline
257
+ ]);
258
+ return {
259
+ needWrapNative: this.needWrapNative,
260
+ dexFuncHasRecipient: false,
261
+ exchangeData: swapData,
262
+ targetExchange: this.routerAddress,
263
+ spender: this.routerAddress,
264
+ returnAmountPos: 0,
265
+ };
266
+ }
267
+ // Direct swap case for BUY operations (one token must be quote currency)
268
+ const swapData = this.poolIface.encodeFunctionData('targetSwap', [
269
+ srcToken, // origin
270
+ destToken, // target
271
+ ethers_1.ethers.constants.MaxUint256.toString(), // maxOriginAmount
272
+ destAmount, // targetAmount
273
+ (0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)(), // deadline
274
+ ]);
275
+ return {
276
+ needWrapNative: this.needWrapNative,
277
+ dexFuncHasRecipient: false,
278
+ exchangeData: swapData,
279
+ targetExchange: data.poolAddress,
280
+ spender: data.poolAddress,
281
+ returnAmountPos: 0,
282
+ };
283
+ }
284
+ }
285
+ exports.Stabull = Stabull;
286
+ //# sourceMappingURL=stabull.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stabull.js","sourceRoot":"","sources":["../../../src/dex/stabull/stabull.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,+CAAoD;AACpD,2EAA6D;AAC7D,uCAAoD;AAGpD,iDAAkD;AAElD,wDAG4B;AAC5B,qCAAyC;AACzC,8FAA4D;AAC5D,gGAA8D;AAC9D,mCAAgC;AAChC,iDAAqD;AACrD,6DAAiD;AAEjD,MAAa,OAAQ,SAAQ,gCAAc;IAe9B;IACA;IACA;IACC;IACA;IACA;IACA;IApBJ,KAAK,GAAqC,EAAE,CAAC;IAC7C,WAAW,CAAc;IAExB,4BAA4B,GAAG,KAAK,CAAC;IACrC,cAAc,GAAG,IAAI,CAAC;IAEtB,wBAAwB,GAAG,KAAK,CAAC;IAEnC,MAAM,CAAC,kBAAkB,GAC9B,IAAA,6BAAqB,EAAC,sBAAa,CAAC,CAAC;IAEvC,MAAM,CAAS;IAEf,YACW,OAAgB,EAChB,MAAc,EACd,SAAqB,EACpB,YAAY,IAAI,eAAM,CAAC,KAAK,CAAC,SAAS,CAAC,4BAAQ,CAAC,EAChD,cAAc,IAAI,eAAM,CAAC,KAAK,CAAC,SAAS,CAAC,6BAAS,CAAC,EACnD,gBAAgB,sBAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EACrD,gBAAgB,sBAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,aAAa;QAEtE,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QARhB,YAAO,GAAP,OAAO,CAAS;QAChB,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS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AAE,WAAW;SACrD,CAAC,CAAC;QAEH,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,mBAAmB,EAAE,KAAK;YAC1B,YAAY,EAAE,QAAQ;YACtB,cAAc,EAAE,IAAI,CAAC,WAAW;YAChC,OAAO,EAAE,IAAI,CAAC,WAAW;YACzB,eAAe,EAAE,CAAC;SACnB,CAAC;IACJ,CAAC;;AAjVH,0BAkVC"}
@@ -0,0 +1,21 @@
1
+ export type PoolState = {
2
+ reserves0: bigint;
3
+ reserves1: bigint;
4
+ };
5
+ export type StabullData = {
6
+ poolAddress: string;
7
+ };
8
+ export type TokenConfig = {
9
+ address: string;
10
+ decimals: number;
11
+ };
12
+ export type PoolsConfig = {
13
+ [poolAddress: string]: {
14
+ tokens: TokenConfig[];
15
+ };
16
+ };
17
+ export type DexParams = {
18
+ router: string;
19
+ quoteCurrency: string;
20
+ pools: PoolsConfig;
21
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/stabull/types.ts"],"names":[],"mappings":""}
@@ -40,5 +40,7 @@ exports.UniswapV2Alias = {
40
40
  [constants_1.Network.ARBITRUM]: 'uniswapv2',
41
41
  [constants_1.Network.OPTIMISM]: 'uniswapv2',
42
42
  [constants_1.Network.BASE]: 'uniswapv2',
43
+ [constants_1.Network.GNOSIS]: 'uniswapv2',
44
+ [constants_1.Network.UNICHAIN]: 'uniswapv2',
43
45
  };
44
46
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/dex/uniswap-v2/constants.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAC1C,qCAA2C;AAC3C,iCAAoC;AACpC,qCAAwC;AACxC,iCAAoC;AAEpC,wFAAwF;AACxF,4EAA4E;AAC5E,4BA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CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACb,CAAC,EACD,EAAE,CACH,CAAC;AAES,QAAA,uBAAuB,GAAG,qBAAqB,CAAC;IAC3D,GAAG,wBAAe;IAClB,GAAG,iBAAU;IACb,GAAG,qBAAY;IACf,GAAG,iBAAU;CACd,CAAC,CAAC;AAEU,QAAA,cAAc,GAAkC;IAC3D,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE,WAAW;IAC9B,CAAC,mBAAO,CAAC,GAAG,CAAC,EAAE,WAAW;IAC1B,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE,WAAW;IAC9B,CAAC,mBAAO,CAAC,SAAS,CAAC,EAAE,WAAW;IAChC,CAAC,mBAAO,CAAC,QAAQ,CAAC,EAAE,WAAW;IAC/B,CAAC,mBAAO,CAAC,QAAQ,CAAC,EAAE,WAAW;IAC/B,CAAC,mBAAO,CAAC,IAAI,CAAC,EAAE,WAAW;IAC3B,CAAC,mBAAO,CAAC,MAAM,CAAC,EAAE,WAAW;IAC7B,CAAC,mBAAO,CAAC,QAAQ,CAAC,EAAE,WAAW;CAChC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { MultiResult } from '../../../../lib/multi-wrapper';
2
+ import { BytesLike } from 'ethers';
3
+ import { DecodedStateMultiCallResultWithRelativeBitmaps } from '../../types';
4
+ export declare function decodeStateMultiCallResultWithRelativeBitmaps(result: MultiResult<BytesLike> | BytesLike): DecodedStateMultiCallResultWithRelativeBitmaps;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decodeStateMultiCallResultWithRelativeBitmaps = decodeStateMultiCallResultWithRelativeBitmaps;
4
+ const ethers_1 = require("ethers");
5
+ const decoders_1 = require("../../../../lib/decoders");
6
+ const ts_essentials_1 = require("ts-essentials");
7
+ function decodeStateMultiCallResultWithRelativeBitmaps(result) {
8
+ const [isSuccess, toDecode] = (0, decoders_1.extractSuccessAndValue)(result);
9
+ (0, ts_essentials_1.assert)(isSuccess && toDecode !== '0x', `decodeStateMultiCallResultWithRelativeBitmaps failed to get decodable result: ${result}`);
10
+ const decoded = ethers_1.ethers.utils.defaultAbiCoder.decode([
11
+ // I don't want to pass here any interface, so I just use it in ethers format
12
+ `
13
+ tuple(
14
+ address pool,
15
+ uint256 blockTimestamp,
16
+ tuple(
17
+ uint160 sqrtPriceX96,
18
+ int24 tick,
19
+ uint16 observationIndex,
20
+ uint16 observationCardinality,
21
+ uint16 observationCardinalityNext,
22
+ uint8 feeProtocol,
23
+ bool unlocked
24
+ ) slot0,
25
+ uint128 liquidity,
26
+ int24 tickSpacing,
27
+ uint128 maxLiquidityPerTick,
28
+ tuple(
29
+ uint32 blockTimestamp,
30
+ int56 tickCumulative,
31
+ uint160 secondsPerLiquidityCumulativeX128,
32
+ bool initialized
33
+ ) observation,
34
+ tuple(
35
+ int16 index,
36
+ uint256 value
37
+ )[] tickBitmap,
38
+ tuple(
39
+ int24 index,
40
+ tuple(
41
+ uint128 liquidityGross,
42
+ int128 liquidityNet,
43
+ int56 tickCumulativeOutside,
44
+ uint160 secondsPerLiquidityOutsideX128,
45
+ uint32 secondsOutside,
46
+ bool initialized
47
+ ) value
48
+ )[] ticks
49
+ )
50
+ `,
51
+ ], toDecode)[0];
52
+ // This conversion is not precise, because when we decode, we have more values
53
+ // But I typed only the ones that are used later
54
+ return decoded;
55
+ }
56
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../src/dex/uniswap-v3/forks/pangolin-v3/utils.ts"],"names":[],"mappings":";;AAMA,sGA2DC;AAhED,mCAA2C;AAE3C,uDAAkE;AAClE,iDAAuC;AAEvC,SAAgB,6CAA6C,CAC3D,MAA0C;IAE1C,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,IAAA,iCAAsB,EAAC,MAAM,CAAC,CAAC;IAE7D,IAAA,sBAAM,EACJ,SAAS,IAAI,QAAQ,KAAK,IAAI,EAC9B,iFAAiF,MAAM,EAAE,CAC1F,CAAC;IAEF,MAAM,OAAO,GAAG,eAAM,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,CACjD;QACE,6EAA6E;QAC7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsCD;KACA,EACD,QAAQ,CACT,CAAC,CAAC,CAAC,CAAC;IAEL,8EAA8E;IAC9E,gDAAgD;IAChD,OAAO,OAAyD,CAAC;AACnE,CAAC"}