@paraswap/dex-lib 3.9.7-fluid-dex.2 → 3.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/.vscode/launch.json +53 -0
  2. package/.vscode/settings.json +2 -0
  3. package/.vscode/tasks.json +15 -0
  4. package/build/abi/{integral/pool.json → inception/inception-ineth-pool.json} +558 -537
  5. package/build/abi/inception/inception-ratio-feed.json +329 -0
  6. package/build/abi/inception/inception-vault.json +991 -0
  7. package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +52 -0
  8. package/build/abi/{integral/relayer.json → wombat/pool.json} +474 -721
  9. package/build/config.js +28 -0
  10. package/build/config.js.map +1 -1
  11. package/build/constants.d.ts +2 -1
  12. package/build/constants.js +1 -0
  13. package/build/constants.js.map +1 -1
  14. package/build/dex/aave-v1/aave-v1.d.ts +2 -1
  15. package/build/dex/aave-v1/aave-v1.js +23 -0
  16. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  17. package/build/dex/aave-v2/tokens-avalanche.json +44 -0
  18. package/build/dex/aave-v2/tokens-mainnet.json +188 -0
  19. package/build/dex/aave-v2/tokens-polygon.json +44 -0
  20. package/build/dex/aave-v3/aave-v3.js +1 -1
  21. package/build/dex/aave-v3/aave-v3.js.map +1 -1
  22. package/build/dex/aave-v3/config.js +6 -0
  23. package/build/dex/aave-v3/config.js.map +1 -1
  24. package/build/dex/aave-v3-stata/config.js +3 -3
  25. package/build/dex/aave-v3-stata/config.js.map +1 -1
  26. package/build/dex/algebra/algebra-pool-v1_9_bidirectional_fee.js +1 -1
  27. package/build/dex/algebra/algebra-pool-v1_9_bidirectional_fee.js.map +1 -1
  28. package/build/dex/algebra/config.js +20 -0
  29. package/build/dex/algebra/config.js.map +1 -1
  30. package/build/dex/balancer-v2/balancer-v2.js +1 -1
  31. package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
  32. package/build/dex/balancer-v2/config.js +4 -0
  33. package/build/dex/balancer-v2/config.js.map +1 -1
  34. package/build/dex/curve-v1/config.js +36 -0
  35. package/build/dex/curve-v1/config.js.map +1 -1
  36. package/build/dex/curve-v1/curve-v1.js +1 -1
  37. package/build/dex/curve-v1/curve-v1.js.map +1 -1
  38. package/build/dex/curve-v1-factory/constants.js +1 -0
  39. package/build/dex/curve-v1-factory/constants.js.map +1 -1
  40. package/build/dex/curve-v1-factory/curve-v1-factory.js +1 -1
  41. package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
  42. package/build/dex/curve-v1-stable-ng/config.js +28 -0
  43. package/build/dex/curve-v1-stable-ng/config.js.map +1 -1
  44. package/build/dex/inception/config.d.ts +4 -0
  45. package/build/dex/inception/config.js +109 -0
  46. package/build/dex/inception/config.js.map +1 -0
  47. package/build/dex/inception/inception-event-pool.d.ts +16 -0
  48. package/build/dex/inception/inception-event-pool.js +49 -0
  49. package/build/dex/inception/inception-event-pool.js.map +1 -0
  50. package/build/dex/inception/inception.d.ts +43 -0
  51. package/build/dex/inception/inception.js +180 -0
  52. package/build/dex/inception/inception.js.map +1 -0
  53. package/build/dex/inception/tokens.d.ts +9 -0
  54. package/build/dex/inception/tokens.js +28 -0
  55. package/build/dex/inception/tokens.js.map +1 -0
  56. package/build/dex/inception/types.d.ts +22 -0
  57. package/build/dex/{fluid-dex → inception}/types.js.map +1 -1
  58. package/build/dex/inception/utils.d.ts +7 -0
  59. package/build/dex/inception/utils.js +58 -0
  60. package/build/dex/inception/utils.js.map +1 -0
  61. package/build/dex/index.js +0 -2
  62. package/build/dex/index.js.map +1 -1
  63. package/build/dex/jarvis.d.ts +2 -1
  64. package/build/dex/jarvis.js +58 -0
  65. package/build/dex/jarvis.js.map +1 -1
  66. package/build/dex/maker-psm/scripts/gem.abi.json +136 -0
  67. package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
  68. package/build/dex/maker-psm/scripts/validate-state.js +185 -0
  69. package/build/dex/maker-psm/scripts/validate-state.js.map +1 -0
  70. package/build/dex/maker-psm/scripts/vat.abi.json +243 -0
  71. package/build/dex/platypus/platypus.d.ts +2 -1
  72. package/build/dex/platypus/platypus.js +45 -0
  73. package/build/dex/platypus/platypus.js.map +1 -1
  74. package/build/dex/solidly-v3/scripts/check-event-pool-event.d.ts +1 -0
  75. package/build/dex/solidly-v3/scripts/check-event-pool-event.js +53 -0
  76. package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +1 -0
  77. package/build/dex/stable-pool.js +1 -8
  78. package/build/dex/stable-pool.js.map +1 -1
  79. package/build/dex/swaap-v1/swaap-v1.d.ts +2 -1
  80. package/build/dex/swaap-v1/swaap-v1.js +14 -0
  81. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  82. package/build/dex/uniswap-v2/config.js +14 -0
  83. package/build/dex/uniswap-v2/config.js.map +1 -1
  84. package/build/dex/uniswap-v2/nomiswap-v2.js +10 -0
  85. package/build/dex/uniswap-v2/nomiswap-v2.js.map +1 -1
  86. package/build/dex/uniswap-v2/uniswap-v2.js +1 -1
  87. package/build/dex/uniswap-v2/uniswap-v2.js.map +1 -1
  88. package/build/dex/uniswap-v3/config.js +14 -0
  89. package/build/dex/uniswap-v3/config.js.map +1 -1
  90. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +17 -0
  91. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +64 -0
  92. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +1 -0
  93. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +17 -0
  94. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +79 -0
  95. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +1 -0
  96. package/build/dex/uniswap-v3/uniswap-v3-pricing.d.ts +4 -0
  97. package/build/dex/uniswap-v3/uniswap-v3-pricing.js +43 -0
  98. package/build/dex/uniswap-v3/uniswap-v3-pricing.js.map +1 -0
  99. package/build/dex/uniswap-v3/uniswap-v3-worker.d.ts +1 -0
  100. package/build/dex/uniswap-v3/uniswap-v3-worker.js +10 -0
  101. package/build/dex/uniswap-v3/uniswap-v3-worker.js.map +1 -0
  102. package/build/dex/uniswap-v3/uniswap-v3.js +1 -0
  103. package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
  104. package/build/dex/weth/config.js +5 -0
  105. package/build/dex/weth/config.js.map +1 -1
  106. package/build/dex/wusdm/config.js +8 -0
  107. package/build/dex/wusdm/config.js.map +1 -1
  108. package/build/dex/wusdm/wusdm.d.ts +1 -0
  109. package/build/dex/wusdm/wusdm.js +9 -4
  110. package/build/dex/wusdm/wusdm.js.map +1 -1
  111. package/build/dex/zerox/index.d.ts +4 -26
  112. package/build/dex/zerox/index.js +50 -42
  113. package/build/dex/zerox/index.js.map +1 -1
  114. package/build/dex/zerox/types.d.ts +29 -0
  115. package/build/dex/zerox/types.js +8 -1
  116. package/build/dex/zerox/types.js.map +1 -1
  117. package/build/executor/WETHBytecodeBuilder.js +1 -0
  118. package/build/executor/WETHBytecodeBuilder.js.map +1 -1
  119. package/package.json +1 -1
  120. package/src/config.ts +29 -1
  121. package/src/constants.ts +1 -0
  122. package/src/dex/aave-v3/aave-v3-e2e.test.ts +69 -0
  123. package/src/dex/aave-v3/aave-v3.ts +1 -1
  124. package/src/dex/aave-v3/config.ts +7 -0
  125. package/src/dex/aave-v3-stata/config.ts +4 -4
  126. package/src/dex/algebra/algebra-e2e.test.ts +22 -0
  127. package/src/dex/algebra/algebra-pool-v1_9_bidirectional_fee.ts +1 -1
  128. package/src/dex/algebra/config.ts +21 -0
  129. package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +22 -250
  130. package/src/dex/balancer-v2/balancer-v2.ts +1 -1
  131. package/src/dex/balancer-v2/config.ts +4 -0
  132. package/src/dex/curve-v1/config.ts +36 -0
  133. package/src/dex/curve-v1/curve-v1-e2e.test.ts +69 -0
  134. package/src/dex/curve-v1/curve-v1.ts +1 -1
  135. package/src/dex/curve-v1-factory/constants.ts +1 -0
  136. package/src/dex/curve-v1-factory/curve-v1-factory.ts +2 -1
  137. package/src/dex/curve-v1-stable-ng/config.ts +28 -0
  138. package/src/dex/curve-v1-stable-ng/curve-v1-stable-ng-e2e.test.ts +20 -0
  139. package/src/dex/index.ts +0 -2
  140. package/src/dex/uniswap-v2/config.ts +16 -0
  141. package/src/dex/uniswap-v2/nomiswap-v2.ts +11 -0
  142. package/src/dex/uniswap-v2/uniswap-v2-e2e-gnosis.test.ts +283 -0
  143. package/src/dex/uniswap-v2/uniswap-v2.ts +1 -1
  144. package/src/dex/uniswap-v3/config.ts +14 -0
  145. package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +24 -0
  146. package/src/dex/uniswap-v3/uniswap-v3.ts +1 -0
  147. package/src/dex/weth/config.ts +5 -0
  148. package/src/dex/wusdm/config.ts +8 -0
  149. package/src/dex/wusdm/wusdm-e2e.test.ts +38 -0
  150. package/src/dex/wusdm/wusdm.ts +11 -4
  151. package/src/executor/WETHBytecodeBuilder.ts +3 -2
  152. package/tests/constants-e2e.ts +77 -2
  153. package/.idea/aws.xml +0 -17
  154. package/.idea/codeStyles/Project.xml +0 -19
  155. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  156. package/.idea/misc.xml +0 -6
  157. package/.idea/modules.xml +0 -8
  158. package/.idea/paraswap-dex-lib.iml +0 -9
  159. package/.idea/prettier.xml +0 -7
  160. package/.idea/vcs.xml +0 -6
  161. package/build/abi/fluid-dex/dexFactory.abi.json +0 -506
  162. package/build/abi/fluid-dex/fluid-dex.abi.json +0 -922
  163. package/build/abi/fluid-dex/liquidityUserModule.abi.json +0 -145
  164. package/build/abi/fluid-dex/resolver.abi.json +0 -999
  165. package/build/abi/integral/factory.json +0 -333
  166. package/build/abi/integral/oracle.json +0 -501
  167. package/build/dex/fluid-dex/config.d.ts +0 -4
  168. package/build/dex/fluid-dex/config.js +0 -20
  169. package/build/dex/fluid-dex/config.js.map +0 -1
  170. package/build/dex/fluid-dex/fluid-dex-generate-pool.d.ts +0 -49
  171. package/build/dex/fluid-dex/fluid-dex-generate-pool.js +0 -104
  172. package/build/dex/fluid-dex/fluid-dex-generate-pool.js.map +0 -1
  173. package/build/dex/fluid-dex/fluid-dex-pool.d.ts +0 -47
  174. package/build/dex/fluid-dex/fluid-dex-pool.js +0 -119
  175. package/build/dex/fluid-dex/fluid-dex-pool.js.map +0 -1
  176. package/build/dex/fluid-dex/fluid-dex.d.ts +0 -127
  177. package/build/dex/fluid-dex/fluid-dex.js +0 -502
  178. package/build/dex/fluid-dex/fluid-dex.js.map +0 -1
  179. package/build/dex/fluid-dex/types.d.ts +0 -52
  180. package/build/dex/integral/config.d.ts +0 -4
  181. package/build/dex/integral/config.js +0 -20
  182. package/build/dex/integral/config.js.map +0 -1
  183. package/build/dex/integral/context.d.ts +0 -40
  184. package/build/dex/integral/context.js +0 -158
  185. package/build/dex/integral/context.js.map +0 -1
  186. package/build/dex/integral/integral-factory.d.ts +0 -24
  187. package/build/dex/integral/integral-factory.js +0 -95
  188. package/build/dex/integral/integral-factory.js.map +0 -1
  189. package/build/dex/integral/integral-pool.d.ts +0 -50
  190. package/build/dex/integral/integral-pool.js +0 -149
  191. package/build/dex/integral/integral-pool.js.map +0 -1
  192. package/build/dex/integral/integral-pricing.d.ts +0 -18
  193. package/build/dex/integral/integral-pricing.js +0 -114
  194. package/build/dex/integral/integral-pricing.js.map +0 -1
  195. package/build/dex/integral/integral-relayer.d.ts +0 -42
  196. package/build/dex/integral/integral-relayer.js +0 -192
  197. package/build/dex/integral/integral-relayer.js.map +0 -1
  198. package/build/dex/integral/integral-token.d.ts +0 -27
  199. package/build/dex/integral/integral-token.js +0 -59
  200. package/build/dex/integral/integral-token.js.map +0 -1
  201. package/build/dex/integral/integral.d.ts +0 -41
  202. package/build/dex/integral/integral.js +0 -376
  203. package/build/dex/integral/integral.js.map +0 -1
  204. package/build/dex/integral/types.d.ts +0 -85
  205. package/build/dex/integral/types.js +0 -9
  206. package/build/dex/integral/types.js.map +0 -1
  207. package/build/dex/integral/utils-e2e.d.ts +0 -9
  208. package/build/dex/integral/utils-e2e.js +0 -131
  209. package/build/dex/integral/utils-e2e.js.map +0 -1
  210. package/build/dex/integral/utils.d.ts +0 -17
  211. package/build/dex/integral/utils.js +0 -94
  212. package/build/dex/integral/utils.js.map +0 -1
  213. package/build/dex/trader-joe-v2.1/optimizer.d.ts +0 -2
  214. package/build/dex/trader-joe-v2.1/optimizer.js +0 -47
  215. package/build/dex/trader-joe-v2.1/optimizer.js.map +0 -1
  216. package/src/abi/fluid-dex/dexFactory.abi.json +0 -506
  217. package/src/abi/fluid-dex/fluid-dex.abi.json +0 -922
  218. package/src/abi/fluid-dex/liquidityUserModule.abi.json +0 -145
  219. package/src/abi/fluid-dex/resolver.abi.json +0 -999
  220. package/src/dex/fluid-dex/config.ts +0 -20
  221. package/src/dex/fluid-dex/fluid-dex-e2e.test.ts +0 -154
  222. package/src/dex/fluid-dex/fluid-dex-events.test.ts +0 -294
  223. package/src/dex/fluid-dex/fluid-dex-generate-pool.ts +0 -143
  224. package/src/dex/fluid-dex/fluid-dex-integration.test.ts +0 -304
  225. package/src/dex/fluid-dex/fluid-dex-pool.ts +0 -178
  226. package/src/dex/fluid-dex/fluid-dex.ts +0 -780
  227. package/src/dex/fluid-dex/types.ts +0 -62
  228. package/tests/constants-e2e.d.ts +0 -22
  229. package/tests/constants-e2e.js +0 -1942
  230. package/tests/constants-e2e.js.map +0 -1
  231. package/tests/smart-tokens.d.ts +0 -36
  232. package/tests/smart-tokens.js +0 -64
  233. package/tests/smart-tokens.js.map +0 -1
  234. /package/build/dex/{fluid-dex → inception}/types.js +0 -0
@@ -1,47 +0,0 @@
1
- import { Interface } from '@ethersproject/abi';
2
- import { DeepReadonly } from 'ts-essentials';
3
- import { Log, Logger } from '../../types';
4
- import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
5
- import { IDexHelper } from '../../dex-helper/idex-helper';
6
- import { CommonAddresses, FluidDexPoolState } from './types';
7
- import { Address } from '../../types';
8
- export declare class FluidDexEventPool extends StatefulEventSubscriber<FluidDexPoolState> {
9
- readonly parentName: string;
10
- readonly pool: Address;
11
- readonly commonAddresses: CommonAddresses;
12
- protected network: number;
13
- readonly dexHelper: IDexHelper;
14
- handlers: {
15
- [event: string]: (event: any, state: DeepReadonly<FluidDexPoolState>, log: Readonly<Log>) => Promise<DeepReadonly<FluidDexPoolState> | null>;
16
- };
17
- logDecoder: (log: Log) => any;
18
- addressesSubscribed: Address[];
19
- protected liquidityIface: Interface;
20
- constructor(parentName: string, pool: Address, commonAddresses: CommonAddresses, network: number, dexHelper: IDexHelper, logger: Logger);
21
- /**
22
- * Handle a trade rate change on the pool.
23
- */
24
- handleOperate(event: any, state: DeepReadonly<FluidDexPoolState>, log: Readonly<Log>): Promise<DeepReadonly<FluidDexPoolState> | null>;
25
- /**
26
- * The function is called every time any of the subscribed
27
- * addresses release log. The function accepts the current
28
- * state, updates the state according to the log, and returns
29
- * the updated state.
30
- * @param state - Current state of event subscriber
31
- * @param log - Log released by one of the subscribed addresses
32
- * @returns Updates state of the event subscriber after the log
33
- */
34
- processLog(state: DeepReadonly<FluidDexPoolState>, log: Readonly<Log>): Promise<DeepReadonly<FluidDexPoolState> | null>;
35
- getStateOrGenerate(blockNumber: number, readonly?: boolean): Promise<FluidDexPoolState>;
36
- /**
37
- * The function generates state using on-chain calls. This
38
- * function is called to regenerate state if the event based
39
- * system fails to fetch events and the local state is no
40
- * more correct.
41
- * @param blockNumber - Blocknumber for which the state should
42
- * should be generated
43
- * @returns state of the event subscriber at blocknumber
44
- */
45
- generateState(blockNumber: number): Promise<DeepReadonly<FluidDexPoolState>>;
46
- private convertToFluidDexPoolState;
47
- }
@@ -1,119 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.FluidDexEventPool = void 0;
7
- const abi_1 = require("@ethersproject/abi");
8
- const utils_1 = require("../../utils");
9
- const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
10
- const resolver_abi_json_1 = __importDefault(require("../../abi/fluid-dex/resolver.abi.json"));
11
- const liquidityUserModule_abi_json_1 = __importDefault(require("../../abi/fluid-dex/liquidityUserModule.abi.json"));
12
- const ethers_1 = require("ethers");
13
- class FluidDexEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
14
- constructor(parentName, pool, commonAddresses, network, dexHelper, logger) {
15
- super(parentName, 'FluidDex_' + pool, dexHelper, logger);
16
- this.parentName = parentName;
17
- this.pool = pool;
18
- this.commonAddresses = commonAddresses;
19
- this.network = network;
20
- this.dexHelper = dexHelper;
21
- this.handlers = {};
22
- this.liquidityIface = new abi_1.Interface(liquidityUserModule_abi_json_1.default);
23
- this.logDecoder = (log) => this.liquidityIface.parseLog(log);
24
- this.addressesSubscribed = [commonAddresses.liquidityProxy];
25
- // Add handlers
26
- this.handlers['LogOperate'] = this.handleOperate.bind(this);
27
- }
28
- /**
29
- * Handle a trade rate change on the pool.
30
- */
31
- async handleOperate(event, state, log) {
32
- if (!(event.args.user in [this.pool])) {
33
- return null;
34
- }
35
- const resolverContract = new ethers_1.Contract(this.commonAddresses.resolver, resolver_abi_json_1.default, this.dexHelper.provider);
36
- const rawResult = await resolverContract.callStatic.getPoolReservesAdjusted(this.pool, {
37
- blockTag: this.dexHelper.provider,
38
- });
39
- const generatedState = this.convertToFluidDexPoolState(rawResult);
40
- this.setState(generatedState, await this.dexHelper.provider.getBlockNumber());
41
- return generatedState;
42
- }
43
- /**
44
- * The function is called every time any of the subscribed
45
- * addresses release log. The function accepts the current
46
- * state, updates the state according to the log, and returns
47
- * the updated state.
48
- * @param state - Current state of event subscriber
49
- * @param log - Log released by one of the subscribed addresses
50
- * @returns Updates state of the event subscriber after the log
51
- */
52
- async processLog(state, log) {
53
- try {
54
- const event = this.logDecoder(log);
55
- if (event.name in this.handlers) {
56
- return await this.handlers[event.name](event, state, log);
57
- }
58
- }
59
- catch (e) {
60
- (0, utils_1.catchParseLogError)(e, this.logger);
61
- }
62
- return null;
63
- }
64
- async getStateOrGenerate(blockNumber, readonly = false) {
65
- let state = this.getState(blockNumber);
66
- if (!state) {
67
- state = await this.generateState(blockNumber);
68
- if (!readonly)
69
- this.setState(state, blockNumber);
70
- }
71
- return state;
72
- }
73
- /**
74
- * The function generates state using on-chain calls. This
75
- * function is called to regenerate state if the event based
76
- * system fails to fetch events and the local state is no
77
- * more correct.
78
- * @param blockNumber - Blocknumber for which the state should
79
- * should be generated
80
- * @returns state of the event subscriber at blocknumber
81
- */
82
- async generateState(blockNumber) {
83
- const resolverContract = new ethers_1.Contract(this.commonAddresses.resolver, resolver_abi_json_1.default, this.dexHelper.provider);
84
- const rawResult = await resolverContract.callStatic.getPoolReservesAdjusted(this.pool, {
85
- blockTag: blockNumber,
86
- });
87
- const convertedResult = this.convertToFluidDexPoolState(rawResult);
88
- return convertedResult;
89
- }
90
- convertToFluidDexPoolState(input) {
91
- // Ignore the first three addresses
92
- const [, , , feeHex, collateralReservesHex, debtReservesHex] = input;
93
- // Convert fee from hex to number
94
- const fee = Number(feeHex.toString());
95
- // Convert collateral reserves
96
- const collateralReserves = {
97
- token0RealReserves: BigInt(collateralReservesHex[0].toString()),
98
- token1RealReserves: BigInt(collateralReservesHex[1].toString()),
99
- token0ImaginaryReserves: BigInt(collateralReservesHex[2].toString()),
100
- token1ImaginaryReserves: BigInt(collateralReservesHex[3].toString()),
101
- };
102
- // Convert debt reserves
103
- const debtReserves = {
104
- token0Debt: BigInt(debtReservesHex[0].toString()),
105
- token1Debt: BigInt(debtReservesHex[1].toString()),
106
- token0RealReserves: BigInt(debtReservesHex[2].toString()),
107
- token1RealReserves: BigInt(debtReservesHex[3].toString()),
108
- token0ImaginaryReserves: BigInt(debtReservesHex[4].toString()),
109
- token1ImaginaryReserves: BigInt(debtReservesHex[5].toString()),
110
- };
111
- return {
112
- collateralReserves,
113
- debtReserves,
114
- fee,
115
- };
116
- }
117
- }
118
- exports.FluidDexEventPool = FluidDexEventPool;
119
- //# sourceMappingURL=fluid-dex-pool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fluid-dex-pool.js","sourceRoot":"","sources":["../../../src/dex/fluid-dex/fluid-dex-pool.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA+C;AAG/C,uCAAiD;AACjD,+EAA0E;AAE1E,8FAAgE;AAChE,oHAA4E;AAQ5E,mCAAkC;AAElC,MAAa,iBAAkB,SAAQ,mDAA0C;IAc/E,YACW,UAAkB,EAClB,IAAa,EACb,eAAgC,EAC/B,OAAe,EAChB,SAAqB,EAC9B,MAAc;QAEd,KAAK,CAAC,UAAU,EAAE,WAAW,GAAG,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAPhD,eAAU,GAAV,UAAU,CAAQ;QAClB,SAAI,GAAJ,IAAI,CAAS;QACb,oBAAe,GAAf,eAAe,CAAiB;QAC/B,YAAO,GAAP,OAAO,CAAQ;QAChB,cAAS,GAAT,SAAS,CAAY;QAlBhC,aAAQ,GAMJ,EAAE,CAAC;QAKG,mBAAc,GAAG,IAAI,eAAS,CAAC,sCAAY,CAAC,CAAC;QAYrD,IAAI,CAAC,UAAU,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAClE,IAAI,CAAC,mBAAmB,GAAG,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;QAE5D,eAAe;QACf,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa,CACjB,KAAU,EACV,KAAsC,EACtC,GAAkB;QAElB,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,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,MAAM,YAAY,GAAiB;YACjC,UAAU,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;YACjD,UAAU,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;YACjD,kBAAkB,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;YACzD,kBAAkB,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;YACzD,uBAAuB,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC9D,uBAAuB,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;SAC/D,CAAC;QAEF,OAAO;YACL,kBAAkB;YAClB,YAAY;YACZ,GAAG;SACJ,CAAC;IACJ,CAAC;CACF;AAhKD,8CAgKC"}
@@ -1,127 +0,0 @@
1
- import { BytesLike } from 'ethers/lib/utils';
2
- import { Interface } from '@ethersproject/abi';
3
- import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, PoolLiquidity, DexExchangeParam, Logger } from '../../types';
4
- import { SwapSide, Network } from '../../constants';
5
- import { Context, IDex } from '../../dex/idex';
6
- import { IDexHelper } from '../../dex-helper/idex-helper';
7
- import { FluidDexData, FluidDexPool, Pool } from './types';
8
- import { SimpleExchange } from '../simple-exchange';
9
- import { FluidDexEventPool } from './fluid-dex-pool';
10
- import { FluidDexCommonAddresses } from './fluid-dex-generate-pool';
11
- import { MultiResult } from '../../lib/multi-wrapper';
12
- export declare class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
13
- readonly network: Network;
14
- readonly dexKey: string;
15
- readonly dexHelper: IDexHelper;
16
- eventPools: {
17
- [id: string]: FluidDexEventPool;
18
- };
19
- readonly hasConstantPriceLargeAmounts = false;
20
- readonly needWrapNative = false;
21
- readonly isFeeOnTransferSupported = false;
22
- static dexKeysWithNetwork: {
23
- key: string;
24
- networks: Network[];
25
- }[];
26
- logger: Logger;
27
- pools: FluidDexPool[];
28
- readonly fluidCommonAddresses: FluidDexCommonAddresses;
29
- readonly fluidDexPoolIface: Interface;
30
- FEE_100_PERCENT: bigint;
31
- constructor(network: Network, dexKey: string, dexHelper: IDexHelper);
32
- private fetchFluidDexPools;
33
- initializePricing(blockNumber: number): Promise<void>;
34
- getAdapters(side: SwapSide): null;
35
- decodePools: (result: MultiResult<BytesLike> | BytesLike) => Pool[];
36
- getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
37
- getPoolByTokenPair(srcToken: Address, destToken: Address): Promise<FluidDexPool | null>;
38
- getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<FluidDexData>>;
39
- getCalldataGasCost(poolPrices: PoolPrices<FluidDexData>): number | number[];
40
- getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: FluidDexData, side: SwapSide): AdapterExchangeParam;
41
- updatePoolState(): Promise<void>;
42
- getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
43
- getDexParam(srcToken: Address, destToken: Address, srcAmount: string, destAmount: string, recipient: Address, data: FluidDexData, side: SwapSide, context: Context, executorAddress: Address): Promise<DexExchangeParam>;
44
- /**
45
- * Calculates the output amount for a given input amount in a swap operation.
46
- * @param swap0To1 - Direction of the swap. True if swapping token0 for token1, false otherwise.
47
- * @param amountIn - The amount of input token to be swapped (as a BigInt).
48
- * @param colReserves - The reserves of the collateral pool.
49
- * @param debtReserves - The reserves of the debt pool.
50
- * @param inDecimals - The number of decimals for the input token.
51
- * @param outDecimals - The number of decimals for the output token.
52
- * @returns The calculated output amount (as a BigInt).
53
- */
54
- private swapIn;
55
- /**
56
- * Calculates the output amount for a given input amount in a swap operation.
57
- * @param swap0To1 - Direction of the swap. True if swapping token0 for token1, false otherwise.
58
- * @param amountToSwap - The amount of input token to be swapped.
59
- * @param colReserves - The reserves of the collateral pool.
60
- * @param debtReserves - The reserves of the debt pool.
61
- * @returns The calculated output amount.
62
- */
63
- private swapInAdjusted;
64
- /**
65
- * Given an input amount of asset and pair reserves, returns the maximum output amount of the other asset.
66
- * @param amountIn - The amount of input asset.
67
- * @param iReserveIn - Imaginary token reserve with input amount.
68
- * @param iReserveOut - Imaginary token reserve of output amount.
69
- * @returns The maximum output amount of the other asset.
70
- */
71
- private getAmountOut;
72
- /**
73
- * Given an output amount of asset and pair reserves, returns the input amount of the other asset
74
- * @param amountOut - Desired output amount of the asset.
75
- * @param iReserveIn - Imaginary token reserve of input amount.
76
- * @param iReserveOut - Imaginary token reserve of output amount.
77
- * @returns The input amount of the other asset.
78
- */
79
- private getAmountIn;
80
- /**
81
- * Calculates how much of a swap should go through the collateral pool for output amount.
82
- * @param t - Total amount out.
83
- * @param x - Imaginary reserves of token in of collateral.
84
- * @param y - Imaginary reserves of token out of collateral.
85
- * @param x2 - Imaginary reserves of token in of debt.
86
- * @param y2 - Imaginary reserves of token out of debt.
87
- * @returns How much swap should go through collateral pool. Remaining will go from debt.
88
- * @note If a < 0 then entire trade route through debt pool and debt pool arbitrage with col pool.
89
- * @note If a > t then entire trade route through col pool and col pool arbitrage with debt pool.
90
- * @note If a > 0 & a < t then swap will route through both pools.
91
- */
92
- private swapRoutingOut;
93
- /**
94
- * Calculates how much of a swap should go through the collateral pool.
95
- * @param t - Total amount in.
96
- * @param x - Imaginary reserves of token out of collateral.
97
- * @param y - Imaginary reserves of token in of collateral.
98
- * @param x2 - Imaginary reserves of token out of debt.
99
- * @param y2 - Imaginary reserves of token in of debt.
100
- * @returns How much swap should go through collateral pool. Remaining will go from debt.
101
- * @note If a < 0 then entire trade route through debt pool and debt pool arbitrage with col pool.
102
- * @note If a > t then entire trade route through col pool and col pool arbitrage with debt pool.
103
- * @note If a > 0 & a < t then swap will route through both pools.
104
- */
105
- private swapRoutingIn;
106
- /**
107
- * Calculates the input amount for a given output amount in a swap operation.
108
- * @param {boolean} swap0to1 - Direction of the swap. True if swapping token0 for token1, false otherwise.
109
- * @param {bigint} amountOut - The amount of output token to be swapped.
110
- * @param {Reserves} colReserves - The reserves of the collateral pool.
111
- * @param {Reserves} debtReserves - The reserves of the debt pool.
112
- * @param {number} inDecimals - The number of decimals for the input token.
113
- * @param {number} outDecimals - The number of decimals for the output token.
114
- * @param {number} fee - The fee for the swap. 1e4 = 1%
115
- * @returns {bigint} amountIn - The calculated input amount required for the swap.
116
- */
117
- private swapOut;
118
- /**
119
- * Calculates the input amount for a given output amount in a swap operation.
120
- * @param {boolean} swap0to1 - Direction of the swap. True if swapping token0 for token1, false otherwise.
121
- * @param {bigint} amountOut - The amount of output token to be swapped.
122
- * @param {CollateralReserves} colReserves - The reserves of the collateral pool.
123
- * @param {DebtReserves} debtReserves - The reserves of the debt pool.
124
- * @returns {bigint} The calculated input amount required for the swap.
125
- */
126
- private swapOutAdjusted;
127
- }