@paraswap/dex-lib 3.8.13 → 3.8.14

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 (174) 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/maverick-v2/MaverickV2Router.json +778 -0
  5. package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +52 -0
  6. package/build/abi/{fx-protocol/FxUSD.json → wombat/pool.json} +604 -542
  7. package/build/dex/aave-v1/aave-v1.js +1 -0
  8. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  9. package/build/dex/aave-v2/tokens-avalanche.json +44 -0
  10. package/build/dex/aave-v2/tokens-mainnet.json +188 -0
  11. package/build/dex/aave-v2/tokens-polygon.json +44 -0
  12. package/build/dex/bProtocol.d.ts +18 -0
  13. package/build/dex/bProtocol.js +39 -0
  14. package/build/dex/bProtocol.js.map +1 -0
  15. package/build/dex/bancor.d.ts +26 -0
  16. package/build/dex/bancor.js +58 -0
  17. package/build/dex/bancor.js.map +1 -0
  18. package/build/dex/compound.d.ts +18 -0
  19. package/build/dex/compound.js +46 -0
  20. package/build/dex/compound.js.map +1 -0
  21. package/build/dex/curve-v2.d.ts +58 -0
  22. package/build/dex/curve-v2.js +180 -0
  23. package/build/dex/curve-v2.js.map +1 -0
  24. package/build/dex/dodo-v1.d.ts +33 -0
  25. package/build/dex/dodo-v1.js +63 -0
  26. package/build/dex/dodo-v1.js.map +1 -0
  27. package/build/dex/lido.d.ts +19 -0
  28. package/build/dex/lido.js +42 -0
  29. package/build/dex/lido.js.map +1 -0
  30. package/build/dex/maker-psm/scripts/gem.abi.json +136 -0
  31. package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
  32. package/build/dex/maker-psm/scripts/validate-state.js +185 -0
  33. package/build/dex/maker-psm/scripts/validate-state.js.map +1 -0
  34. package/build/dex/maker-psm/scripts/vat.abi.json +243 -0
  35. package/build/dex/onebit.d.ts +25 -0
  36. package/build/dex/onebit.js +42 -0
  37. package/build/dex/onebit.js.map +1 -0
  38. package/build/dex/platypus/platypus.js +17 -3
  39. package/build/dex/platypus/platypus.js.map +1 -1
  40. package/build/dex/smoothy.d.ts +26 -0
  41. package/build/dex/smoothy.js +48 -0
  42. package/build/dex/smoothy.js.map +1 -0
  43. package/build/dex/solidly-v3/scripts/check-event-pool-event.d.ts +1 -0
  44. package/build/dex/solidly-v3/scripts/check-event-pool-event.js +53 -0
  45. package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +1 -0
  46. package/build/dex/stable-pool.d.ts +28 -0
  47. package/build/dex/stable-pool.js +55 -0
  48. package/build/dex/stable-pool.js.map +1 -0
  49. package/build/dex/swaap-v1/swaap-v1.js +4 -0
  50. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  51. package/build/dex/trader-joe-v2.1/base.d.ts +18 -0
  52. package/build/dex/trader-joe-v2.1/base.js +99 -0
  53. package/build/dex/trader-joe-v2.1/base.js.map +1 -0
  54. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.d.ts +7 -0
  55. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js +20 -0
  56. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js.map +1 -0
  57. package/build/dex/trader-joe-v2.1/trader-joe-v2.2.d.ts +7 -0
  58. package/build/dex/trader-joe-v2.1/trader-joe-v2.2.js +20 -0
  59. package/build/dex/trader-joe-v2.1/trader-joe-v2.2.js.map +1 -0
  60. package/build/dex/trader-joe-v2.1.d.ts +43 -0
  61. package/build/dex/trader-joe-v2.1.js +79 -0
  62. package/build/dex/trader-joe-v2.1.js.map +1 -0
  63. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +17 -0
  64. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +64 -0
  65. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +1 -0
  66. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +17 -0
  67. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +79 -0
  68. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +1 -0
  69. package/build/executor/Executor01BytecodeBuilder.js +4 -5
  70. package/build/executor/Executor01BytecodeBuilder.js.map +1 -1
  71. package/build/executor/Executor02BytecodeBuilder.js +2 -3
  72. package/build/executor/Executor02BytecodeBuilder.js.map +1 -1
  73. package/build/executor/Executor03BytecodeBuilder.js +24 -14
  74. package/build/executor/Executor03BytecodeBuilder.js.map +1 -1
  75. package/build/generic-swap-transaction-builder.d.ts +1 -1
  76. package/build/generic-swap-transaction-builder.js +10 -10
  77. package/build/generic-swap-transaction-builder.js.map +1 -1
  78. package/config.ts +1946 -0
  79. package/package.json +1 -1
  80. package/src/dex/dexs.txt +58 -0
  81. package/src/executor/Executor01BytecodeBuilder.ts +4 -8
  82. package/src/executor/Executor02BytecodeBuilder.ts +2 -7
  83. package/src/executor/Executor03BytecodeBuilder.ts +34 -19
  84. package/src/generic-swap-transaction-builder.ts +3 -5
  85. package/build/abi/concentrator/arUSD.json +0 -568
  86. package/build/abi/inception/inception-ineth-pool.json +0 -1062
  87. package/build/abi/inception/inception-ineth.json +0 -609
  88. package/build/abi/inception/inception-ratio-feed.json +0 -93
  89. package/build/abi/inception/inception-vault.json +0 -991
  90. package/build/abi/infusion/InfusionFactory.json +0 -147
  91. package/build/abi/infusion/InfusionPair.json +0 -658
  92. package/build/abi/infusion/InfusionRouter.json +0 -442
  93. package/build/abi/oswap/oswap.abi.json +0 -452
  94. package/build/dex/concentrator-arusd/concentrator-arusd.d.ts +0 -38
  95. package/build/dex/concentrator-arusd/concentrator-arusd.js +0 -184
  96. package/build/dex/concentrator-arusd/concentrator-arusd.js.map +0 -1
  97. package/build/dex/concentrator-arusd/config.d.ts +0 -4
  98. package/build/dex/concentrator-arusd/config.js +0 -18
  99. package/build/dex/concentrator-arusd/config.js.map +0 -1
  100. package/build/dex/concentrator-arusd/types.d.ts +0 -10
  101. package/build/dex/concentrator-arusd/types.js +0 -3
  102. package/build/dex/concentrator-arusd/types.js.map +0 -1
  103. package/build/dex/fx-protocol-rusd/config.d.ts +0 -4
  104. package/build/dex/fx-protocol-rusd/config.js +0 -18
  105. package/build/dex/fx-protocol-rusd/config.js.map +0 -1
  106. package/build/dex/fx-protocol-rusd/fx-protocol-rusd.d.ts +0 -39
  107. package/build/dex/fx-protocol-rusd/fx-protocol-rusd.js +0 -196
  108. package/build/dex/fx-protocol-rusd/fx-protocol-rusd.js.map +0 -1
  109. package/build/dex/fx-protocol-rusd/types.d.ts +0 -10
  110. package/build/dex/fx-protocol-rusd/types.js +0 -3
  111. package/build/dex/fx-protocol-rusd/types.js.map +0 -1
  112. package/build/dex/idle-dao/idle-dao-pool.d.ts +0 -56
  113. package/build/dex/idle-dao/idle-dao-pool.js +0 -176
  114. package/build/dex/idle-dao/idle-dao-pool.js.map +0 -1
  115. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +0 -16
  116. package/build/dex/idle-dao/idle-dao-pooling-pool.js +0 -57
  117. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +0 -1
  118. package/build/dex/idle-dao/scripts.d.ts +0 -9
  119. package/build/dex/idle-dao/scripts.js +0 -552
  120. package/build/dex/idle-dao/scripts.js.map +0 -1
  121. package/build/dex/inception/config.d.ts +0 -5
  122. package/build/dex/inception/config.js +0 -112
  123. package/build/dex/inception/config.js.map +0 -1
  124. package/build/dex/inception/inception-event-pool.d.ts +0 -23
  125. package/build/dex/inception/inception-event-pool.js +0 -34
  126. package/build/dex/inception/inception-event-pool.js.map +0 -1
  127. package/build/dex/inception/inception-native.d.ts +0 -43
  128. package/build/dex/inception/inception-native.js +0 -131
  129. package/build/dex/inception/inception-native.js.map +0 -1
  130. package/build/dex/inception/inception-pool.d.ts +0 -18
  131. package/build/dex/inception/inception-pool.js +0 -32
  132. package/build/dex/inception/inception-pool.js.map +0 -1
  133. package/build/dex/inception/inception-price-feed.d.ts +0 -19
  134. package/build/dex/inception/inception-price-feed.js +0 -51
  135. package/build/dex/inception/inception-price-feed.js.map +0 -1
  136. package/build/dex/inception/inception.d.ts +0 -44
  137. package/build/dex/inception/inception.js +0 -162
  138. package/build/dex/inception/inception.js.map +0 -1
  139. package/build/dex/inception/tokens.d.ts +0 -9
  140. package/build/dex/inception/tokens.js +0 -28
  141. package/build/dex/inception/tokens.js.map +0 -1
  142. package/build/dex/inception/types.d.ts +0 -22
  143. package/build/dex/inception/types.js +0 -3
  144. package/build/dex/inception/types.js.map +0 -1
  145. package/build/dex/inception/utils.d.ts +0 -7
  146. package/build/dex/inception/utils.js +0 -58
  147. package/build/dex/inception/utils.js.map +0 -1
  148. package/build/dex/infusion/config.d.ts +0 -4
  149. package/build/dex/infusion/config.js +0 -25
  150. package/build/dex/infusion/config.js.map +0 -1
  151. package/build/dex/infusion/infusion-stable-pool.d.ts +0 -4
  152. package/build/dex/infusion/infusion-stable-pool.js +0 -74
  153. package/build/dex/infusion/infusion-stable-pool.js.map +0 -1
  154. package/build/dex/infusion/infusion.d.ts +0 -54
  155. package/build/dex/infusion/infusion.js +0 -532
  156. package/build/dex/infusion/infusion.js.map +0 -1
  157. package/build/dex/infusion/types.d.ts +0 -47
  158. package/build/dex/infusion/types.js +0 -3
  159. package/build/dex/infusion/types.js.map +0 -1
  160. package/build/dex/infusion/utils/isStablePair.d.ts +0 -2
  161. package/build/dex/infusion/utils/isStablePair.js +0 -18
  162. package/build/dex/infusion/utils/isStablePair.js.map +0 -1
  163. package/build/dex/oswap/config.d.ts +0 -5
  164. package/build/dex/oswap/config.js +0 -31
  165. package/build/dex/oswap/config.js.map +0 -1
  166. package/build/dex/oswap/oswap-pool.d.ts +0 -51
  167. package/build/dex/oswap/oswap-pool.js +0 -150
  168. package/build/dex/oswap/oswap-pool.js.map +0 -1
  169. package/build/dex/oswap/oswap.d.ts +0 -46
  170. package/build/dex/oswap/oswap.js +0 -263
  171. package/build/dex/oswap/oswap.js.map +0 -1
  172. package/build/dex/oswap/types.d.ts +0 -20
  173. package/build/dex/oswap/types.js +0 -3
  174. package/build/dex/oswap/types.js.map +0 -1
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Adapters = exports.ConcentratorArusdConfig = void 0;
4
- const constants_1 = require("../../constants");
5
- exports.ConcentratorArusdConfig = {
6
- ConcentratorArusd: {
7
- [constants_1.Network.MAINNET]: {
8
- rUSDAddress: '0x65D72AA8DA931F047169112fcf34f52DbaAE7D18',
9
- arUSDAddress: '0x07D1718fF05a8C53C8F05aDAEd57C0d672945f9a',
10
- weETHAddress: '0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee',
11
- },
12
- },
13
- };
14
- exports.Adapters = {
15
- // This is an example to copy
16
- [constants_1.Network.MAINNET]: { [constants_1.SwapSide.SELL]: [{ name: 'Adapter02', index: 0 }] },
17
- };
18
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/concentrator-arusd/config.ts"],"names":[],"mappings":";;;AAEA,+CAAoD;AAEvC,QAAA,uBAAuB,GAA4B;IAC9D,iBAAiB,EAAE;QACjB,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,WAAW,EAAE,4CAA4C;YACzD,YAAY,EAAE,4CAA4C;YAC1D,YAAY,EAAE,4CAA4C;SAC3D;KACF;CACF,CAAC;AAEW,QAAA,QAAQ,GAAoC;IACvD,6BAA6B;IAC7B,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,oBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE;CAC1E,CAAC"}
@@ -1,10 +0,0 @@
1
- import { Address } from '../../types';
2
- export declare type PoolState = {
3
- nav: bigint;
4
- };
5
- export declare type ConcentratorArusdData = {};
6
- export declare type DexParams = {
7
- arUSDAddress: Address;
8
- rUSDAddress: Address;
9
- weETHAddress: Address;
10
- };
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/concentrator-arusd/types.ts"],"names":[],"mappings":""}
@@ -1,4 +0,0 @@
1
- import { DexParams } from './types';
2
- import { DexConfigMap, AdapterMappings } from '../../types';
3
- export declare const FxProtocolConfig: DexConfigMap<DexParams>;
4
- export declare const Adapters: Record<number, AdapterMappings>;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Adapters = exports.FxProtocolConfig = void 0;
4
- const constants_1 = require("../../constants");
5
- exports.FxProtocolConfig = {
6
- FxProtocolRusd: {
7
- [constants_1.Network.MAINNET]: {
8
- rUSDAddress: '0x65D72AA8DA931F047169112fcf34f52DbaAE7D18',
9
- weETHAddress: '0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee',
10
- ezETHAddress: '0xbf5495Efe5DB9ce00f80364C8B423567e58d2110',
11
- },
12
- },
13
- };
14
- exports.Adapters = {
15
- // This is an example to copy
16
- [constants_1.Network.MAINNET]: { [constants_1.SwapSide.SELL]: [{ name: 'Adapter02', index: 0 }] },
17
- };
18
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/fx-protocol-rusd/config.ts"],"names":[],"mappings":";;;AAEA,+CAAoD;AAEvC,QAAA,gBAAgB,GAA4B;IACvD,cAAc,EAAE;QACd,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,WAAW,EAAE,4CAA4C;YACzD,YAAY,EAAE,4CAA4C;YAC1D,YAAY,EAAE,4CAA4C;SAC3D;KACF;CACF,CAAC;AAEW,QAAA,QAAQ,GAAoC;IACvD,6BAA6B;IAC7B,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,oBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE;CAC1E,CAAC"}
@@ -1,39 +0,0 @@
1
- import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, PoolLiquidity, Logger, NumberAsString, DexExchangeParam } from '../../types';
2
- import { SwapSide, Network } from '../../constants';
3
- import { IDex } from '../idex';
4
- import { IDexHelper } from '../../dex-helper/idex-helper';
5
- import { DexParams, FxProtocolData } from './types';
6
- import { SimpleExchange } from '../simple-exchange';
7
- import { Interface } from '@ethersproject/abi';
8
- export declare class FxProtocolRusd extends SimpleExchange implements IDex<FxProtocolData> {
9
- readonly network: Network;
10
- readonly dexKey: string;
11
- readonly dexHelper: IDexHelper;
12
- protected adapters: import("../../types").AdapterMappings;
13
- static readonly fxUSDIface: Interface;
14
- protected config: DexParams;
15
- readonly hasConstantPriceLargeAmounts = true;
16
- readonly needWrapNative = false;
17
- readonly isFeeOnTransferSupported = false;
18
- static dexKeysWithNetwork: {
19
- key: string;
20
- networks: Network[];
21
- }[];
22
- logger: Logger;
23
- private state;
24
- constructor(network: Network, dexKey: string, dexHelper: IDexHelper, adapters?: import("../../types").AdapterMappings);
25
- is_weETH(token: string): boolean;
26
- is_rUSD(token: string): boolean;
27
- is_ezETH(token: string): boolean;
28
- is_rUSD_swap_token(srcToken: string, destToken: string): boolean;
29
- getAdapters(side: SwapSide): {
30
- name: string;
31
- index: number;
32
- }[] | null;
33
- getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
34
- getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<FxProtocolData>>;
35
- getCalldataGasCost(poolPrices: PoolPrices<FxProtocolData>): number | number[];
36
- getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: FxProtocolData, side: SwapSide): AdapterExchangeParam;
37
- getDexParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: FxProtocolData, side: SwapSide): Promise<DexExchangeParam>;
38
- getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
39
- }
@@ -1,196 +0,0 @@
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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.FxProtocolRusd = void 0;
30
- const ts_essentials_1 = require("ts-essentials");
31
- const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
32
- const utils_1 = require("../../utils");
33
- const simple_exchange_1 = require("../simple-exchange");
34
- const config_1 = require("./config");
35
- const abi_1 = require("@ethersproject/abi");
36
- const FxUSD_json_1 = __importDefault(require("../../abi/fx-protocol/FxUSD.json"));
37
- const decoders_1 = require("../../lib/decoders");
38
- const utils_2 = require("../../executor/utils");
39
- class FxProtocolRusd extends simple_exchange_1.SimpleExchange {
40
- constructor(network, dexKey, dexHelper, adapters = config_1.Adapters[network] || {}) {
41
- super(dexHelper, dexKey);
42
- this.network = network;
43
- this.dexKey = dexKey;
44
- this.dexHelper = dexHelper;
45
- this.adapters = adapters;
46
- this.hasConstantPriceLargeAmounts = true;
47
- this.needWrapNative = false;
48
- this.isFeeOnTransferSupported = false;
49
- this.state = {
50
- blockNumber: 0,
51
- nav: 0n,
52
- };
53
- const config = config_1.FxProtocolConfig[dexKey][network];
54
- this.config = {
55
- rUSDAddress: config.rUSDAddress.toLowerCase(),
56
- weETHAddress: config.weETHAddress.toLowerCase(),
57
- ezETHAddress: config.ezETHAddress.toLowerCase(),
58
- };
59
- this.logger = dexHelper.getLogger(dexKey);
60
- }
61
- is_weETH(token) {
62
- return token.toLowerCase() === this.config.weETHAddress;
63
- }
64
- is_rUSD(token) {
65
- return token.toLowerCase() === this.config.rUSDAddress;
66
- }
67
- is_ezETH(token) {
68
- return token.toLowerCase() === this.config.ezETHAddress;
69
- }
70
- is_rUSD_swap_token(srcToken, destToken) {
71
- if (this.is_weETH(srcToken) && this.is_rUSD(destToken)) {
72
- return true;
73
- }
74
- if (this.is_rUSD(srcToken) && this.is_weETH(destToken)) {
75
- return true;
76
- }
77
- if (this.is_rUSD(srcToken) && this.is_ezETH(destToken)) {
78
- return true;
79
- }
80
- return false;
81
- }
82
- getAdapters(side) {
83
- return null;
84
- }
85
- // Returns list of pool identifiers that can be used
86
- // for a given swap. poolIdentifiers must be unique
87
- // across DEXes. It is recommended to use
88
- // ${dexKey}_${poolAddress} as a poolIdentifier
89
- async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
90
- if (!this.is_rUSD_swap_token(srcToken.address, destToken.address)) {
91
- return [];
92
- }
93
- return [this.dexKey];
94
- }
95
- // // Returns pool prices for amounts.
96
- // // If limitPools is defined only pools in limitPools
97
- // // should be used. If limitPools is undefined then
98
- // // any pools can be used.
99
- async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
100
- const isRUSDSwapToken = this.is_rUSD_swap_token(srcToken.address, destToken.address);
101
- if (!isRUSDSwapToken) {
102
- return null;
103
- }
104
- const readerCallData = [
105
- {
106
- target: this.config.rUSDAddress,
107
- callData: FxProtocolRusd.fxUSDIface.encodeFunctionData('nav'),
108
- decodeFunction: decoders_1.uint256ToBigInt,
109
- },
110
- ];
111
- // const readerResult = (
112
- // await this.dexHelper.multiContract.methods
113
- // .aggregate(readerCallData)
114
- // .call({}, blockNumber)
115
- // ).returnData;
116
- // const results = await this.dexHelper.multiWrapper.tryAggregate<bigint>(
117
- // true,
118
- // readerCallData,
119
- // blockNumber,
120
- // );
121
- // const _price = results[0].returnData;
122
- return [
123
- {
124
- unit: 1000000000000000000n,
125
- prices: amounts,
126
- data: {},
127
- poolAddresses: [this.config.rUSDAddress],
128
- exchange: this.dexKey,
129
- gasCost: 70000,
130
- },
131
- ];
132
- }
133
- // Returns estimated gas cost of calldata for this DEX in multiSwap
134
- getCalldataGasCost(poolPrices) {
135
- return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
136
- }
137
- getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
138
- const payload = '0x';
139
- return {
140
- targetExchange: this.config.rUSDAddress,
141
- payload,
142
- networkFee: '0',
143
- };
144
- }
145
- async getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side) {
146
- const is_rUSD_src = this.is_rUSD(srcToken);
147
- const is_weETH_src = this.is_weETH(srcToken);
148
- const is_rUSD_dest = this.is_rUSD(destToken);
149
- const is_weETH_dest = this.is_weETH(destToken);
150
- const is_eETH_dest = this.is_ezETH(destToken);
151
- if (is_weETH_src && is_rUSD_dest) {
152
- (0, ts_essentials_1.assert)(this.is_weETH(srcToken), 'srcToken should be weETH');
153
- const exchangeData = FxProtocolRusd.fxUSDIface.encodeFunctionData('mint', [this.config.weETHAddress, srcAmount, recipient, '0']);
154
- return {
155
- needWrapNative: false,
156
- dexFuncHasRecipient: true,
157
- exchangeData,
158
- targetExchange: this.config.rUSDAddress,
159
- returnAmountPos: (0, utils_2.extractReturnAmountPosition)(FxProtocolRusd.fxUSDIface, 'mint', '_amountOut'),
160
- };
161
- }
162
- if (is_rUSD_src && (is_weETH_dest || is_eETH_dest)) {
163
- (0, ts_essentials_1.assert)(this.is_rUSD(srcToken), 'srcToken should be rUSD');
164
- const exchangeData = FxProtocolRusd.fxUSDIface.encodeFunctionData('redeem', [destToken, srcAmount, recipient, '0']);
165
- return {
166
- needWrapNative: false,
167
- dexFuncHasRecipient: true,
168
- exchangeData,
169
- targetExchange: this.config.rUSDAddress,
170
- returnAmountPos: (0, utils_2.extractReturnAmountPosition)(FxProtocolRusd.fxUSDIface, 'redeem', '_amountOut'),
171
- };
172
- }
173
- throw new Error('LOGIC ERROR');
174
- }
175
- // Returns list of top pools based on liquidity. Max
176
- // limit number pools should be returned.
177
- async getTopPoolsForToken(tokenAddress, limit) {
178
- return [
179
- {
180
- exchange: this.dexKey,
181
- address: this.config.rUSDAddress,
182
- connectorTokens: [
183
- {
184
- decimals: 18,
185
- address: this.config.rUSDAddress,
186
- },
187
- ],
188
- liquidityUSD: 1000000000, // Just returning a big number so this DEX will be preferred
189
- },
190
- ];
191
- }
192
- }
193
- exports.FxProtocolRusd = FxProtocolRusd;
194
- FxProtocolRusd.fxUSDIface = new abi_1.Interface(FxUSD_json_1.default);
195
- FxProtocolRusd.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.FxProtocolConfig);
196
- //# sourceMappingURL=fx-protocol-rusd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fx-protocol-rusd.js","sourceRoot":"","sources":["../../../src/dex/fx-protocol-rusd/fx-protocol-rusd.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAoD;AAcpD,2EAA6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,CAAC;IAED,oDAAoD;IACpD,yCAAyC;IACzC,KAAK,CAAC,mBAAmB,CACvB,YAAqB,EACrB,KAAa;QAEb,OAAO;YACL;gBACE,QAAQ,EAAE,IAAI,CAAC,MAAM;gBACrB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;gBAChC,eAAe,EAAE;oBACf;wBACE,QAAQ,EAAE,EAAE;wBACZ,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;qBACjC;iBACF;gBACD,YAAY,EAAE,UAAU,EAAE,4DAA4D;aACvF;SACF,CAAC;IACJ,CAAC;;AAzOH,wCA0OC;AAtOiB,yBAAU,GAAG,IAAI,eAAS,CAAC,oBAAS,CAAC,CAAC;AAUxC,iCAAkB,GAC9B,IAAA,6BAAqB,EAAC,yBAAgB,CAAC,CAAC"}
@@ -1,10 +0,0 @@
1
- import { Address } from '../../types';
2
- export declare type PoolState = {
3
- nav: bigint;
4
- };
5
- export declare type FxProtocolData = {};
6
- export declare type DexParams = {
7
- rUSDAddress: Address;
8
- weETHAddress: Address;
9
- ezETHAddress: Address;
10
- };
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/fx-protocol-rusd/types.ts"],"names":[],"mappings":""}
@@ -1,56 +0,0 @@
1
- import BigNumber from 'bignumber.js';
2
- import { Contract } from 'web3-eth-contract';
3
- import { Interface } from '@ethersproject/abi';
4
- import { DeepReadonly } from 'ts-essentials';
5
- import { Log, Logger } from '../../types';
6
- import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
7
- import { IDexHelper } from '../../dex-helper/idex-helper';
8
- import { PoolState, IdleToken } from './types';
9
- import { IdleDao } from './idle-dao';
10
- declare type BlocksTransfers = Record<number, {
11
- underlyingAmount: BigNumber;
12
- idleAmount: BigNumber;
13
- processed: boolean;
14
- }>;
15
- export declare class IdleDaoEventPool extends StatefulEventSubscriber<PoolState> {
16
- readonly parentName: string;
17
- protected network: number;
18
- protected dexHelper: IDexHelper;
19
- protected logger: Logger;
20
- protected idleToken: IdleToken;
21
- protected IdleDao: IdleDao;
22
- handlers: {
23
- [event: string]: (event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>) => Promise<DeepReadonly<PoolState> | null>;
24
- };
25
- logDecoder: (log: Log) => any;
26
- cdoContract: Contract;
27
- poolInterface: Interface;
28
- addressesSubscribed: string[];
29
- blocksTransfers: BlocksTransfers;
30
- constructor(parentName: string, network: number, dexHelper: IDexHelper, logger: Logger, idleToken: IdleToken, IdleDao: IdleDao);
31
- /**
32
- * The function is called every time any of the subscribed
33
- * addresses release log. The function accepts the current
34
- * state, updates the state according to the log, and returns
35
- * the updated state.
36
- * @param state - Current state of event subscriber
37
- * @param log - Log released by one of the subscribed addresses
38
- * @returns Updates state of the event subscriber after the log
39
- */
40
- protected processLog(state: DeepReadonly<PoolState>, log: Readonly<Log>): Promise<DeepReadonly<PoolState> | null>;
41
- /**
42
- * The function generates state using on-chain calls. This
43
- * function is called to regenerate state if the event based
44
- * system fails to fetch events and the local state is no
45
- * more correct.
46
- * @param blockNumber - Blocknumber for which the state should
47
- * should be generated
48
- * @returns state of the event subscriber at blocknumber
49
- */
50
- generateState(blockNumber: number): Promise<DeepReadonly<PoolState>>;
51
- setBlockState(blockNumber: number, state: PoolState): void;
52
- handleCoinTransfer(event: any, state: PoolState, log: Log): Promise<DeepReadonly<PoolState> | null>;
53
- processBlockTransfer(blockNumber: number, state: PoolState): PoolState;
54
- handleCoinTransfer_old(event: any, state: PoolState, log: Log): Promise<DeepReadonly<PoolState> | null>;
55
- }
56
- export {};
@@ -1,176 +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.IdleDaoEventPool = void 0;
7
- const bignumber_js_1 = __importDefault(require("bignumber.js"));
8
- const abi_1 = require("@ethersproject/abi");
9
- const utils_1 = require("../../utils");
10
- const erc20_json_1 = __importDefault(require("../../abi/erc20.json"));
11
- const idle_cdo_json_1 = __importDefault(require("../../abi/idle-dao/idle-cdo.json"));
12
- const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
13
- const idle_dao_pooling_pool_1 = require("./idle-dao-pooling-pool");
14
- const tokens_1 = require("./tokens");
15
- class IdleDaoEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
16
- constructor(parentName, network, dexHelper, logger, idleToken, IdleDao) {
17
- // TODO: Add pool name
18
- super(parentName, idleToken.idleSymbol, dexHelper, logger);
19
- this.parentName = parentName;
20
- this.network = network;
21
- this.dexHelper = dexHelper;
22
- this.logger = logger;
23
- this.idleToken = idleToken;
24
- this.IdleDao = IdleDao;
25
- this.handlers = {};
26
- this.blocksTransfers = {};
27
- this.poolInterface = new abi_1.Interface(erc20_json_1.default);
28
- // TODO: make logDecoder decode logs that
29
- this.logDecoder = (log) => this.poolInterface.parseLog(log);
30
- this.addressesSubscribed = [idleToken.address.toLowerCase()];
31
- const cdoTokens = (0, tokens_1.getTokensByCdoAddress)(this.idleToken.cdoAddress);
32
- if (cdoTokens) {
33
- cdoTokens.forEach((idleToken) => {
34
- if (!this.addressesSubscribed.includes(idleToken.idleAddress.toLowerCase())) {
35
- this.addressesSubscribed.push(idleToken.idleAddress.toLowerCase());
36
- }
37
- });
38
- }
39
- // this.logger.debug('addressesSubscribed', this.idleToken.idleAddress, this.addressesSubscribed)
40
- // Add handlers
41
- this.handlers['Transfer'] = this.handleCoinTransfer.bind(this);
42
- this.idleToken = idleToken;
43
- this.cdoContract = new dexHelper.web3Provider.eth.Contract(idle_cdo_json_1.default, this.idleToken.cdoAddress);
44
- }
45
- /**
46
- * The function is called every time any of the subscribed
47
- * addresses release log. The function accepts the current
48
- * state, updates the state according to the log, and returns
49
- * the updated state.
50
- * @param state - Current state of event subscriber
51
- * @param log - Log released by one of the subscribed addresses
52
- * @returns Updates state of the event subscriber after the log
53
- */
54
- async processLog(state, log) {
55
- try {
56
- const event = this.logDecoder(log);
57
- if (event.name in this.handlers) {
58
- const result = await this.handlers[event.name](event, state, log);
59
- return result;
60
- }
61
- }
62
- catch (e) {
63
- (0, utils_1.catchParseLogError)(e, this.logger);
64
- }
65
- return null;
66
- }
67
- /**
68
- * The function generates state using on-chain calls. This
69
- * function is called to regenerate state if the event based
70
- * system fails to fetch events and the local state is no
71
- * more correct.
72
- * @param blockNumber - Blocknumber for which the state should
73
- * should be generated
74
- * @returns state of the event subscriber at blocknumber
75
- */
76
- async generateState(blockNumber) {
77
- const tranchePrice = await this.cdoContract.methods['virtualPrice'](this.idleToken.idleAddress).call({}, blockNumber);
78
- return {
79
- tokenPrice: BigInt(tranchePrice),
80
- };
81
- }
82
- setBlockState(blockNumber, state) {
83
- this.logger.debug('setBlockState', blockNumber, this.idleToken.idleAddress, state);
84
- return this._setState(state, blockNumber);
85
- }
86
- async handleCoinTransfer(event, state, log) {
87
- const idleTokens = (0, tokens_1.getTokensByCdoAddress)(this.idleToken.cdoAddress);
88
- if (!idleTokens)
89
- return null;
90
- const pollingPool = new idle_dao_pooling_pool_1.IdleDaoPollingPool(this.parentName, this.parentName, this.dexHelper, idleTokens, this.logger);
91
- const blockNumber = log.blockNumber;
92
- let poolsState = null;
93
- if (log.address.toLowerCase() === this.idleToken.address.toLowerCase()) {
94
- if (event.args.dst.toLowerCase() ===
95
- this.idleToken.cdoAddress.toLowerCase() ||
96
- event.args.src.toLowerCase() === this.idleToken.cdoAddress.toLowerCase()) {
97
- poolsState = await pollingPool.getAggregatedBlockData(blockNumber);
98
- }
99
- }
100
- else if (this.addressesSubscribed.includes(log.address.toLowerCase())) {
101
- poolsState = await pollingPool.getAggregatedBlockData(blockNumber);
102
- }
103
- // Update pools with the new state
104
- if (poolsState) {
105
- Object.keys(poolsState.value).forEach((idleAddress) => {
106
- const poolState = poolsState?.value?.[idleAddress];
107
- if (poolState) {
108
- this.IdleDao.setEventPoolStateBlock(idleAddress, poolsState.blockNumber, poolState);
109
- // Overwrite state
110
- if (idleAddress === this.idleToken.idleAddress) {
111
- state = poolState;
112
- }
113
- }
114
- });
115
- }
116
- return state;
117
- }
118
- processBlockTransfer(blockNumber, state) {
119
- if (!this.blocksTransfers[blockNumber] ||
120
- this.blocksTransfers[blockNumber].processed)
121
- return state;
122
- const idleAmount = this.blocksTransfers[blockNumber].idleAmount.div(1e18);
123
- const underlyingAmount = this.blocksTransfers[blockNumber].underlyingAmount.div(`1e${this.idleToken.decimals}`);
124
- if (idleAmount.gt(0) && underlyingAmount.gt(0)) {
125
- const tokenPrice = BigInt(bignumber_js_1.default.maximum(idleAmount, underlyingAmount)
126
- .div(bignumber_js_1.default.minimum(idleAmount, underlyingAmount))
127
- .times(`1e${this.idleToken.decimals}`)
128
- .toFixed(0));
129
- this.logger.debug('tokenPrice', blockNumber, this.idleToken.idleSymbol, this.idleToken.decimals, idleAmount.toString(), underlyingAmount.toString(), tokenPrice.toString());
130
- this.blocksTransfers[blockNumber].processed = true;
131
- return {
132
- tokenPrice,
133
- };
134
- }
135
- return state;
136
- }
137
- async handleCoinTransfer_old(event, state, log) {
138
- // Handle underlying token transfer
139
- if (log.address.toLowerCase() === this.idleToken.address.toLowerCase()) {
140
- if (event.args.dst.toLowerCase() ===
141
- this.idleToken.cdoAddress.toLowerCase() ||
142
- event.args.src.toLowerCase() === this.idleToken.cdoAddress.toLowerCase()) {
143
- if (!this.blocksTransfers[log.blockNumber]) {
144
- this.blocksTransfers[log.blockNumber] = {
145
- processed: false,
146
- idleAmount: (0, bignumber_js_1.default)(0),
147
- underlyingAmount: (0, bignumber_js_1.default)(0),
148
- };
149
- }
150
- this.logger.debug('UnderlyingAmount', log.blockNumber, 'event', event, 'log', log, (0, bignumber_js_1.default)(BigInt(event.args.wad).toString()).toFixed());
151
- this.blocksTransfers[log.blockNumber].underlyingAmount = (0, bignumber_js_1.default)(BigInt(event.args.wad).toString());
152
- }
153
- }
154
- // Handle idle token transfer
155
- else if (log.address.toLowerCase() === this.idleToken.idleAddress.toLowerCase()) {
156
- this.logger.debug('IdleToken Transfer', log.blockNumber, 'event', event, 'log', log);
157
- if (event.args.src.toLowerCase() ===
158
- '0x0000000000000000000000000000000000000000' ||
159
- event.args.dst.toLowerCase() ===
160
- '0x0000000000000000000000000000000000000000') {
161
- if (!this.blocksTransfers[log.blockNumber]) {
162
- this.blocksTransfers[log.blockNumber] = {
163
- processed: false,
164
- idleAmount: (0, bignumber_js_1.default)(0),
165
- underlyingAmount: (0, bignumber_js_1.default)(0),
166
- };
167
- }
168
- this.logger.debug('IdleAmount', log.blockNumber, 'event', event, 'log', log, (0, bignumber_js_1.default)(BigInt(event.args.wad).toString()).toFixed());
169
- this.blocksTransfers[log.blockNumber].idleAmount = (0, bignumber_js_1.default)(BigInt(event.args.wad).toString());
170
- }
171
- }
172
- return this.processBlockTransfer(log.blockNumber, state);
173
- }
174
- }
175
- exports.IdleDaoEventPool = IdleDaoEventPool;
176
- //# sourceMappingURL=idle-dao-pool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"idle-dao-pool.js","sourceRoot":"","sources":["../../../src/dex/idle-dao/idle-dao-pool.ts"],"names":[],"mappings":";;;;;;AACA,gEAAqC;AAErC,4CAA+C;AAG/C,uCAAiD;AACjD,sEAA6C;AAC7C,qFAAuD;AACvD,+EAA0E;AAG1E,mEAA6D;AAC7D,qCAAiD;AAajD,MAAa,gBAAiB,SAAQ,mDAAkC;IAgBtE,YACW,UAAkB,EACjB,OAAe,EACf,SAAqB,EACrB,MAAc,EACd,SAAoB,EACpB,OAAgB;QAE1B,sBAAsB;QACtB,KAAK,CAAC,UAAU,EAAE,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QARlD,eAAU,GAAV,UAAU,CAAQ;QACjB,YAAO,GAAP,OAAO,CAAQ;QACf,cAAS,GAAT,SAAS,C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MultiCallParams } from '../../lib/multi-wrapper';
4
- import { StatefulRpcPoller } from '../../lib/stateful-rpc-poller/stateful-rpc-poller';
5
- import { Logger } from '../../types';
6
- import { ObjWithUpdateInfo } from '../../lib/stateful-rpc-poller/types';
7
- declare type MulticallResultOutputs = bigint;
8
- export declare class IdleDaoPollingPool extends StatefulRpcPoller<PoolsState, MulticallResultOutputs> {
9
- protected idleTokens: IdleToken[];
10
- protected logger: Logger;
11
- constructor(dexKey: string, poolIdentifier: string, dexHelper: IDexHelper, idleTokens: IdleToken[], logger: Logger);
12
- getAggregatedBlockData(blockNumber: number): Promise<ObjWithUpdateInfo<PoolsState> | null>;
13
- protected _getFetchStateMultiCalls(): MultiCallParams<MulticallResultOutputs>[];
14
- protected _parseStateFromMultiResults(multiOutputs: MulticallResultOutputs[]): PoolsState;
15
- }
16
- export {};