@paraswap/dex-lib 3.8.13-arusd-fxusd.2 → 3.8.13-infusion
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.
- package/build/abi/{integral/pool.json → inception/inception-ineth-pool.json} +558 -537
- package/build/abi/inception/inception-ineth.json +609 -0
- package/build/abi/inception/inception-ratio-feed.json +93 -0
- package/build/abi/inception/inception-vault.json +991 -0
- package/build/abi/infusion/InfusionFactory.json +147 -0
- package/build/abi/infusion/InfusionPair.json +658 -0
- package/build/abi/infusion/InfusionRouter.json +442 -0
- package/build/dex/aave-v1/aave-v1.d.ts +2 -1
- package/build/dex/aave-v1/aave-v1.js +22 -0
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/concentrator-arusd/concentrator-arusd.d.ts +1 -4
- package/build/dex/concentrator-arusd/concentrator-arusd.js +34 -30
- package/build/dex/concentrator-arusd/concentrator-arusd.js.map +1 -1
- package/build/dex/concentrator-arusd/config.js +1 -1
- package/build/dex/concentrator-arusd/config.js.map +1 -1
- package/build/dex/concentrator-arusd/types.d.ts +2 -6
- package/build/dex/fx-protocol-rusd/config.d.ts +2 -1
- package/build/dex/fx-protocol-rusd/config.js +6 -3
- package/build/dex/fx-protocol-rusd/config.js.map +1 -1
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd.d.ts +10 -10
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd.js +66 -83
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd.js.map +1 -1
- package/build/dex/fx-protocol-rusd/types.d.ts +2 -5
- package/build/dex/idle-dao/idle-dao-pool.d.ts +56 -0
- package/build/dex/idle-dao/idle-dao-pool.js +176 -0
- package/build/dex/idle-dao/idle-dao-pool.js.map +1 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +16 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.js +57 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +1 -0
- package/build/dex/idle-dao/scripts.d.ts +9 -0
- package/build/dex/idle-dao/scripts.js +552 -0
- package/build/dex/idle-dao/scripts.js.map +1 -0
- package/build/dex/inception/config.d.ts +5 -0
- package/build/dex/inception/config.js +112 -0
- package/build/dex/inception/config.js.map +1 -0
- package/build/dex/inception/inception-event-pool.d.ts +23 -0
- package/build/dex/inception/inception-event-pool.js +34 -0
- package/build/dex/inception/inception-event-pool.js.map +1 -0
- package/build/dex/{integral/integral.d.ts → inception/inception-native.d.ts} +21 -19
- package/build/dex/inception/inception-native.js +131 -0
- package/build/dex/inception/inception-native.js.map +1 -0
- package/build/dex/inception/inception-pool.d.ts +18 -0
- package/build/dex/inception/inception-pool.js +32 -0
- package/build/dex/inception/inception-pool.js.map +1 -0
- package/build/dex/inception/inception-price-feed.d.ts +19 -0
- package/build/dex/inception/inception-price-feed.js +51 -0
- package/build/dex/inception/inception-price-feed.js.map +1 -0
- package/build/dex/inception/inception.d.ts +44 -0
- package/build/dex/inception/inception.js +162 -0
- package/build/dex/inception/inception.js.map +1 -0
- package/build/dex/inception/tokens.d.ts +9 -0
- package/build/dex/inception/tokens.js +28 -0
- package/build/dex/inception/tokens.js.map +1 -0
- package/build/dex/inception/types.d.ts +22 -0
- package/build/dex/inception/types.js +3 -0
- package/build/dex/inception/types.js.map +1 -0
- package/build/dex/inception/utils.d.ts +7 -0
- package/build/dex/inception/utils.js +58 -0
- package/build/dex/inception/utils.js.map +1 -0
- package/build/dex/index.js +2 -4
- package/build/dex/index.js.map +1 -1
- package/build/dex/{integral → infusion}/config.d.ts +1 -1
- package/build/dex/infusion/config.js +25 -0
- package/build/dex/infusion/config.js.map +1 -0
- package/build/dex/infusion/infusion-stable-pool.d.ts +4 -0
- package/build/dex/infusion/infusion-stable-pool.js +74 -0
- package/build/dex/infusion/infusion-stable-pool.js.map +1 -0
- package/build/dex/infusion/infusion.d.ts +54 -0
- package/build/dex/infusion/infusion.js +510 -0
- package/build/dex/infusion/infusion.js.map +1 -0
- package/build/dex/infusion/types.d.ts +47 -0
- package/build/dex/infusion/types.js +3 -0
- package/build/dex/infusion/types.js.map +1 -0
- package/build/dex/infusion/utils/isStablePair.d.ts +2 -0
- package/build/dex/infusion/utils/isStablePair.js +18 -0
- package/build/dex/infusion/utils/isStablePair.js.map +1 -0
- package/build/dex/oswap/oswap.js +1 -4
- package/build/dex/oswap/oswap.js.map +1 -1
- package/build/dex/platypus/platypus.d.ts +2 -1
- package/build/dex/platypus/platypus.js +31 -0
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/swaap-v1/swaap-v1.d.ts +2 -1
- package/build/dex/swaap-v1/swaap-v1.js +10 -0
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/infusion/InfusionFactory.json +147 -0
- package/src/abi/infusion/InfusionPair.json +658 -0
- package/src/abi/infusion/InfusionRouter.json +442 -0
- package/src/dex/index.ts +2 -4
- package/src/dex/infusion/config.ts +27 -0
- package/src/dex/infusion/infusion-e2e.test.ts +110 -0
- package/src/dex/infusion/infusion-integration.test.ts +232 -0
- package/src/dex/infusion/infusion-stable-pool.ts +91 -0
- package/src/dex/infusion/infusion.ts +749 -0
- package/src/dex/infusion/types.ts +60 -0
- package/src/dex/infusion/utils/isStablePair.ts +18 -0
- package/src/dex/wsteth/wsteth-integration.test.ts +1 -0
- package/tests/constants-e2e.ts +1 -11
- package/.vscode/launch.json +0 -16
- package/.vscode/settings.json +0 -3
- package/build/abi/Uncompressor.json +0 -250
- package/build/abi/concentrator/arUSD5115.json +0 -1746
- package/build/abi/fx-protocol/FxMarket.json +0 -1284
- package/build/abi/fx-protocol/weETHOralce.json +0 -676
- package/build/abi/integral/factory.json +0 -333
- package/build/abi/integral/oracle.json +0 -501
- package/build/abi/integral/relayer.json +0 -1536
- package/build/abi/maverick-v2/MaverickV2Router.json +0 -778
- package/build/dex/bProtocol.d.ts +0 -18
- package/build/dex/bProtocol.js +0 -39
- package/build/dex/bProtocol.js.map +0 -1
- package/build/dex/bancor.d.ts +0 -26
- package/build/dex/bancor.js +0 -58
- package/build/dex/bancor.js.map +0 -1
- package/build/dex/compound.d.ts +0 -18
- package/build/dex/compound.js +0 -46
- package/build/dex/compound.js.map +0 -1
- package/build/dex/concentrator-arusd/concentrator-arusd-event.d.ts +0 -16
- package/build/dex/concentrator-arusd/concentrator-arusd-event.js +0 -53
- package/build/dex/concentrator-arusd/concentrator-arusd-event.js.map +0 -1
- package/build/dex/concentrator-arusd/utils.d.ts +0 -4
- package/build/dex/concentrator-arusd/utils.js +0 -27
- package/build/dex/concentrator-arusd/utils.js.map +0 -1
- package/build/dex/curve-v2.d.ts +0 -58
- package/build/dex/curve-v2.js +0 -180
- package/build/dex/curve-v2.js.map +0 -1
- package/build/dex/dodo-v1.d.ts +0 -33
- package/build/dex/dodo-v1.js +0 -63
- package/build/dex/dodo-v1.js.map +0 -1
- package/build/dex/etherfi/etherfi.d.ts +0 -26
- package/build/dex/etherfi/etherfi.js +0 -96
- package/build/dex/etherfi/etherfi.js.map +0 -1
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd-event.d.ts +0 -18
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd-event.js +0 -63
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd-event.js.map +0 -1
- package/build/dex/fx-protocol-rusd/utils.d.ts +0 -4
- package/build/dex/fx-protocol-rusd/utils.js +0 -26
- package/build/dex/fx-protocol-rusd/utils.js.map +0 -1
- package/build/dex/integral/config.js +0 -20
- package/build/dex/integral/config.js.map +0 -1
- package/build/dex/integral/context.d.ts +0 -40
- package/build/dex/integral/context.js +0 -158
- package/build/dex/integral/context.js.map +0 -1
- package/build/dex/integral/helpers.d.ts +0 -17
- package/build/dex/integral/helpers.js +0 -157
- package/build/dex/integral/helpers.js.map +0 -1
- package/build/dex/integral/integral-factory.d.ts +0 -24
- package/build/dex/integral/integral-factory.js +0 -95
- package/build/dex/integral/integral-factory.js.map +0 -1
- package/build/dex/integral/integral-pool.d.ts +0 -50
- package/build/dex/integral/integral-pool.js +0 -149
- package/build/dex/integral/integral-pool.js.map +0 -1
- package/build/dex/integral/integral-pricing.d.ts +0 -18
- package/build/dex/integral/integral-pricing.js +0 -114
- package/build/dex/integral/integral-pricing.js.map +0 -1
- package/build/dex/integral/integral-relayer.d.ts +0 -42
- package/build/dex/integral/integral-relayer.js +0 -192
- package/build/dex/integral/integral-relayer.js.map +0 -1
- package/build/dex/integral/integral-token.d.ts +0 -27
- package/build/dex/integral/integral-token.js +0 -59
- package/build/dex/integral/integral-token.js.map +0 -1
- package/build/dex/integral/integral.js +0 -377
- package/build/dex/integral/integral.js.map +0 -1
- package/build/dex/integral/types.d.ts +0 -84
- package/build/dex/integral/types.js +0 -9
- package/build/dex/integral/types.js.map +0 -1
- package/build/dex/integral/utils-e2e.d.ts +0 -9
- package/build/dex/integral/utils-e2e.js +0 -131
- package/build/dex/integral/utils-e2e.js.map +0 -1
- package/build/dex/integral/utils.d.ts +0 -17
- package/build/dex/integral/utils.js +0 -94
- package/build/dex/integral/utils.js.map +0 -1
- package/build/dex/lido.d.ts +0 -19
- package/build/dex/lido.js +0 -42
- package/build/dex/lido.js.map +0 -1
- package/build/dex/onebit.d.ts +0 -25
- package/build/dex/onebit.js +0 -42
- package/build/dex/onebit.js.map +0 -1
- package/build/dex/sdai/config.d.ts +0 -11
- package/build/dex/sdai/config.js +0 -21
- package/build/dex/sdai/config.js.map +0 -1
- package/build/dex/sdai/constants.d.ts +0 -2
- package/build/dex/sdai/constants.js +0 -6
- package/build/dex/sdai/constants.js.map +0 -1
- package/build/dex/sdai/scripts/validate-state.d.ts +0 -1
- package/build/dex/sdai/scripts/validate-state.js +0 -102
- package/build/dex/sdai/scripts/validate-state.js.map +0 -1
- package/build/dex/sdai/sdai-pool.d.ts +0 -16
- package/build/dex/sdai/sdai-pool.js +0 -85
- package/build/dex/sdai/sdai-pool.js.map +0 -1
- package/build/dex/sdai/sdai.d.ts +0 -51
- package/build/dex/sdai/sdai.js +0 -172
- package/build/dex/sdai/sdai.js.map +0 -1
- package/build/dex/sdai/types.d.ts +0 -21
- package/build/dex/sdai/types.js +0 -11
- package/build/dex/sdai/types.js.map +0 -1
- package/build/dex/sdai/utils.d.ts +0 -4
- package/build/dex/sdai/utils.js +0 -39
- package/build/dex/sdai/utils.js.map +0 -1
- package/build/dex/smoothy.d.ts +0 -26
- package/build/dex/smoothy.js +0 -48
- package/build/dex/smoothy.js.map +0 -1
- package/build/dex/stable-pool.d.ts +0 -28
- package/build/dex/stable-pool.js +0 -62
- package/build/dex/stable-pool.js.map +0 -1
- package/build/dex/trader-joe-v2.1.d.ts +0 -43
- package/build/dex/trader-joe-v2.1.js +0 -79
- package/build/dex/trader-joe-v2.1.js.map +0 -1
- package/build/executor/compressor/Compressor.d.ts +0 -23
- package/build/executor/compressor/Compressor.js +0 -144
- package/build/executor/compressor/Compressor.js.map +0 -1
- package/build/executor/compressor/compress.d.ts +0 -17
- package/build/executor/compressor/compress.js +0 -187
- package/build/executor/compressor/compress.js.map +0 -1
- package/build/executor/compressor/compress_functions/addressSubstitution.d.ts +0 -6
- package/build/executor/compressor/compress_functions/addressSubstitution.js +0 -29
- package/build/executor/compressor/compress_functions/addressSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.d.ts +0 -10
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js +0 -40
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js.map +0 -1
- package/build/executor/compressor/compress_functions/byteSubstitution.d.ts +0 -11
- package/build/executor/compressor/compress_functions/byteSubstitution.js +0 -64
- package/build/executor/compressor/compress_functions/byteSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/ffSubstitution.d.ts +0 -7
- package/build/executor/compressor/compress_functions/ffSubstitution.js +0 -54
- package/build/executor/compressor/compress_functions/ffSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.d.ts +0 -8
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js +0 -67
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js.map +0 -1
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.d.ts +0 -8
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js +0 -61
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js.map +0 -1
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.d.ts +0 -6
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js +0 -37
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/searchUnusedBytes.d.ts +0 -9
- package/build/executor/compressor/compress_functions/searchUnusedBytes.js +0 -33
- package/build/executor/compressor/compress_functions/searchUnusedBytes.js.map +0 -1
- package/build/executor/compressor/fetchSaved.d.ts +0 -0
- package/build/executor/compressor/fetchSaved.js +0 -17
- package/build/executor/compressor/fetchSaved.js.map +0 -1
- package/build/executor/compressor/utils/computeCostL2.d.ts +0 -2
- package/build/executor/compressor/utils/computeCostL2.js +0 -14
- package/build/executor/compressor/utils/computeCostL2.js.map +0 -1
- package/build/executor/compressor/utils/findLongestDuplicatedString.d.ts +0 -2
- package/build/executor/compressor/utils/findLongestDuplicatedString.js +0 -30
- package/build/executor/compressor/utils/findLongestDuplicatedString.js.map +0 -1
- package/build/executor/compressor/utils/getAllIndexes.d.ts +0 -2
- package/build/executor/compressor/utils/getAllIndexes.js +0 -12
- package/build/executor/compressor/utils/getAllIndexes.js.map +0 -1
- package/build/executor/compressor/utils/getByteForAddress.d.ts +0 -2
- package/build/executor/compressor/utils/getByteForAddress.js +0 -14
- package/build/executor/compressor/utils/getByteForAddress.js.map +0 -1
- package/build/executor/compressor/utils/intTo2Bytes.d.ts +0 -2
- package/build/executor/compressor/utils/intTo2Bytes.js +0 -14
- package/build/executor/compressor/utils/intTo2Bytes.js.map +0 -1
- package/build/executor/compressor/utils/intTo3Bytes.d.ts +0 -2
- package/build/executor/compressor/utils/intTo3Bytes.js +0 -18
- package/build/executor/compressor/utils/intTo3Bytes.js.map +0 -1
- package/build/executor/compressor/utils/intToByte.d.ts +0 -2
- package/build/executor/compressor/utils/intToByte.js +0 -10
- package/build/executor/compressor/utils/intToByte.js.map +0 -1
- package/src/abi/concentrator/arUSD.json +0 -568
- package/src/abi/concentrator/arUSD5115.json +0 -1746
- package/src/abi/fx-protocol/FxMarket.json +0 -1284
- package/src/abi/fx-protocol/FxUSD.json +0 -1227
- package/src/abi/fx-protocol/weETHOralce.json +0 -676
- package/src/dex/concentrator-arusd/concentrator-arusd-e2e.test.ts +0 -92
- package/src/dex/concentrator-arusd/concentrator-arusd-event.ts +0 -70
- package/src/dex/concentrator-arusd/concentrator-arusd-integration.test.ts +0 -104
- package/src/dex/concentrator-arusd/concentrator-arusd.ts +0 -255
- package/src/dex/concentrator-arusd/concetrator-arusd-events.test.ts +0 -97
- package/src/dex/concentrator-arusd/config.ts +0 -18
- package/src/dex/concentrator-arusd/types.ts +0 -16
- package/src/dex/concentrator-arusd/utils.ts +0 -36
- package/src/dex/fx-protocol-rusd/config.ts +0 -14
- package/src/dex/fx-protocol-rusd/fx-protocol-e2e.test.ts +0 -96
- package/src/dex/fx-protocol-rusd/fx-protocol-events.test.ts +0 -101
- package/src/dex/fx-protocol-rusd/fx-protocol-integration.test.ts +0 -104
- package/src/dex/fx-protocol-rusd/fx-protocol-rusd-event.ts +0 -80
- package/src/dex/fx-protocol-rusd/fx-protocol-rusd.ts +0 -303
- package/src/dex/fx-protocol-rusd/types.ts +0 -16
- package/src/dex/fx-protocol-rusd/utils.ts +0 -46
|
@@ -27,18 +27,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.ConcentratorArusd = void 0;
|
|
30
|
-
const constants_1 = require("../../constants");
|
|
31
30
|
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
32
31
|
const utils_1 = require("../../utils");
|
|
33
32
|
const simple_exchange_1 = require("../simple-exchange");
|
|
34
33
|
const config_1 = require("./config");
|
|
35
34
|
const abi_1 = require("@ethersproject/abi");
|
|
36
35
|
const arUSD_json_1 = __importDefault(require("../../abi/concentrator/arUSD.json"));
|
|
37
|
-
const arUSD5115_json_1 = __importDefault(require("../../abi/concentrator/arUSD5115.json"));
|
|
38
36
|
const utils_2 = require("../../executor/utils");
|
|
39
|
-
const bigint_constants_1 = require("../../bigint-constants");
|
|
40
|
-
const concentrator_arusd_event_1 = require("./concentrator-arusd-event");
|
|
41
|
-
const utils_3 = require("./utils");
|
|
42
37
|
class ConcentratorArusd extends simple_exchange_1.SimpleExchange {
|
|
43
38
|
constructor(network, dexKey, dexHelper, adapters = config_1.Adapters[network] || {}) {
|
|
44
39
|
super(dexHelper, dexKey);
|
|
@@ -53,17 +48,9 @@ class ConcentratorArusd extends simple_exchange_1.SimpleExchange {
|
|
|
53
48
|
this.config = {
|
|
54
49
|
rUSDAddress: config.rUSDAddress.toLowerCase(),
|
|
55
50
|
arUSDAddress: config.arUSDAddress.toLowerCase(),
|
|
56
|
-
|
|
51
|
+
weETHAddress: config.weETHAddress.toLowerCase(),
|
|
57
52
|
};
|
|
58
|
-
this.arUSD5115Iface = new abi_1.Interface(arUSD5115_json_1.default);
|
|
59
53
|
this.logger = dexHelper.getLogger(dexKey);
|
|
60
|
-
this.concentratorArusdEvent = new concentrator_arusd_event_1.ConcentratorArusdEvent(this.dexKey, dexHelper, this.config.arUSD5115Address, this.arUSD5115Iface, this.logger);
|
|
61
|
-
}
|
|
62
|
-
async initializePricing(blockNumber) {
|
|
63
|
-
const poolState = await (0, utils_3.getOnChainState)(this.dexHelper.multiContract, this.config.arUSD5115Address, this.arUSD5115Iface, blockNumber);
|
|
64
|
-
await this.concentratorArusdEvent.initialize(blockNumber, {
|
|
65
|
-
state: poolState,
|
|
66
|
-
});
|
|
67
54
|
}
|
|
68
55
|
is_arUSD(token) {
|
|
69
56
|
return token.toLowerCase() === this.config.arUSDAddress;
|
|
@@ -71,6 +58,9 @@ class ConcentratorArusd extends simple_exchange_1.SimpleExchange {
|
|
|
71
58
|
is_rUSD(token) {
|
|
72
59
|
return token.toLowerCase() === this.config.rUSDAddress;
|
|
73
60
|
}
|
|
61
|
+
is_weETH(token) {
|
|
62
|
+
return token.toLowerCase() === this.config.weETHAddress;
|
|
63
|
+
}
|
|
74
64
|
is_arUSD_swap_token(srcToken, destToken) {
|
|
75
65
|
if (this.is_rUSD(srcToken) && this.is_arUSD(destToken)) {
|
|
76
66
|
return true;
|
|
@@ -78,6 +68,9 @@ class ConcentratorArusd extends simple_exchange_1.SimpleExchange {
|
|
|
78
68
|
if (this.is_arUSD(srcToken) && this.is_rUSD(destToken)) {
|
|
79
69
|
return true;
|
|
80
70
|
}
|
|
71
|
+
if (this.is_arUSD(srcToken) && this.is_weETH(destToken)) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
81
74
|
return false;
|
|
82
75
|
}
|
|
83
76
|
getAdapters(side) {
|
|
@@ -87,33 +80,33 @@ class ConcentratorArusd extends simple_exchange_1.SimpleExchange {
|
|
|
87
80
|
if (!this.is_arUSD_swap_token(srcToken.address, destToken.address)) {
|
|
88
81
|
return [];
|
|
89
82
|
}
|
|
90
|
-
return [
|
|
83
|
+
return [this.dexKey];
|
|
91
84
|
}
|
|
92
85
|
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
|
|
93
|
-
if (side == constants_1.SwapSide.BUY) {
|
|
94
|
-
// note: BUY is not supported
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
86
|
const isArUSDSwapToken = this.is_arUSD_swap_token(srcToken.address, destToken.address);
|
|
98
87
|
if (!isArUSDSwapToken) {
|
|
99
88
|
return null;
|
|
100
89
|
}
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
90
|
+
// const readerCallData = [
|
|
91
|
+
// {
|
|
92
|
+
// target: this.config.arUSDAddress,
|
|
93
|
+
// callData: ConcentratorArusd.arUSDIface.encodeFunctionData('nav'),
|
|
94
|
+
// decodeFunction: uint256ToBigInt,
|
|
95
|
+
// },
|
|
96
|
+
// ];
|
|
97
|
+
// const results = await this.dexHelper.multiWrapper.tryAggregate<bigint>(
|
|
98
|
+
// true,
|
|
99
|
+
// readerCallData,
|
|
100
|
+
// blockNumber,
|
|
101
|
+
// );
|
|
109
102
|
return [
|
|
110
103
|
{
|
|
111
|
-
unit:
|
|
112
|
-
prices:
|
|
104
|
+
unit: 1000000000000000000n,
|
|
105
|
+
prices: amounts,
|
|
113
106
|
data: {},
|
|
114
107
|
poolAddresses: [this.config.arUSDAddress],
|
|
115
108
|
exchange: this.dexKey,
|
|
116
|
-
gasCost:
|
|
109
|
+
gasCost: 70000,
|
|
117
110
|
},
|
|
118
111
|
];
|
|
119
112
|
}
|
|
@@ -134,6 +127,7 @@ class ConcentratorArusd extends simple_exchange_1.SimpleExchange {
|
|
|
134
127
|
const is_arUSD_src = this.is_arUSD(srcToken);
|
|
135
128
|
const is_rUSD_dest = this.is_rUSD(destToken);
|
|
136
129
|
const is_arUSD_dest = this.is_arUSD(destToken);
|
|
130
|
+
const is_weETH_dest = this.is_weETH(destToken);
|
|
137
131
|
if (is_rUSD_src && is_arUSD_dest) {
|
|
138
132
|
const exchangeData = ConcentratorArusd.arUSDIface.encodeFunctionData('deposit', [srcAmount, recipient]);
|
|
139
133
|
return {
|
|
@@ -154,6 +148,16 @@ class ConcentratorArusd extends simple_exchange_1.SimpleExchange {
|
|
|
154
148
|
returnAmountPos: (0, utils_2.extractReturnAmountPosition)(ConcentratorArusd.arUSDIface, 'redeem', 'assets'),
|
|
155
149
|
};
|
|
156
150
|
}
|
|
151
|
+
if (is_arUSD_src && is_weETH_dest) {
|
|
152
|
+
const exchangeData = ConcentratorArusd.arUSDIface.encodeFunctionData('redeemToBaseToken', [srcAmount, recipient, executorAddress, 0]);
|
|
153
|
+
return {
|
|
154
|
+
needWrapNative: false,
|
|
155
|
+
dexFuncHasRecipient: true,
|
|
156
|
+
exchangeData,
|
|
157
|
+
targetExchange: this.config.arUSDAddress,
|
|
158
|
+
returnAmountPos: (0, utils_2.extractReturnAmountPosition)(ConcentratorArusd.arUSDIface, 'redeemToBaseToken', 'assets'),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
157
161
|
throw new Error('LOGIC ERROR');
|
|
158
162
|
}
|
|
159
163
|
// Returns list of top pools based on liquidity. Max
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"concentrator-arusd.js","sourceRoot":"","sources":["../../../src/dex/concentrator-arusd/concentrator-arusd.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"concentrator-arusd.js","sourceRoot":"","sources":["../../../src/dex/concentrator-arusd/concentrator-arusd.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,2EAA6D;AAC7D,uCAAoD;AAIpD,wDAAoD;AACpD,qCAA6D;AAC7D,4CAA+C;AAC/C,mFAA0D;AAC1D,gDAAmE;AAEnE,MAAa,iBACX,SAAQ,gCAAc;IAiBtB,YACW,OAAgB,EAChB,MAAc,EACd,SAAqB,EACpB,WAAW,iBAAQ,CAAC,OAAO,CAAC,IAAI,EAAE;QAE5C,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QALhB,YAAO,GAAP,OAAO,CAAS;QAChB,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAY;QACpB,aAAQ,GAAR,QAAQ,CAA0B;QAdrC,iCAA4B,GAAG,IAAI,CAAC;QACpC,mBAAc,GAAG,IAAI,CAAC;QAEtB,6BAAwB,GAAG,KAAK,CAAC;QAcxC,MAAM,MAAM,GAAG,gCAAuB,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;QACxD,IAAI,C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AAa,EAAE;YACjC,MAAM,YAAY,GAAG,iBAAiB,CAAC,UAAU,CAAC,kBAAkB,CAClE,mBAAmB,EACnB,CAAC,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC,CAC3C,CAAC;YACF,OAAO;gBACL,cAAc,EAAE,KAAK;gBACrB,mBAAmB,EAAE,IAAI;gBACzB,YAAY;gBACZ,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;gBACxC,eAAe,EAAE,IAAA,mCAA2B,EAC1C,iBAAiB,CAAC,UAAU,EAC5B,mBAAmB,EACnB,QAAQ,CACT;aACF,CAAC;SACH;QACD,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;IACjC,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,YAAY;gBACjC,eAAe,EAAE;oBACf;wBACE,QAAQ,EAAE,EAAE;wBACZ,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;qBAClC;iBACF;gBACD,YAAY,EAAE,UAAU,EAAE,4DAA4D;aACvF;SACF,CAAC;IACJ,CAAC;;AArOH,8CAsOC;AAlOiB,4BAAU,GAAG,IAAI,eAAS,CAAC,oBAAS,CAAC,CAAC;AASxC,oCAAkB,GAC9B,IAAA,6BAAqB,EAAC,gCAAuB,CAAC,CAAC"}
|
|
@@ -7,7 +7,7 @@ exports.ConcentratorArusdConfig = {
|
|
|
7
7
|
[constants_1.Network.MAINNET]: {
|
|
8
8
|
rUSDAddress: '0x65D72AA8DA931F047169112fcf34f52DbaAE7D18',
|
|
9
9
|
arUSDAddress: '0x07D1718fF05a8C53C8F05aDAEd57C0d672945f9a',
|
|
10
|
-
|
|
10
|
+
weETHAddress: '0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee',
|
|
11
11
|
},
|
|
12
12
|
},
|
|
13
13
|
};
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,14 +1,10 @@
|
|
|
1
1
|
import { Address } from '../../types';
|
|
2
|
-
export declare type
|
|
3
|
-
totalSupply: bigint;
|
|
4
|
-
totalAssets: bigint;
|
|
5
|
-
};
|
|
6
|
-
export declare type ConcentratorArusdNavState = {
|
|
2
|
+
export declare type PoolState = {
|
|
7
3
|
nav: bigint;
|
|
8
4
|
};
|
|
9
5
|
export declare type ConcentratorArusdData = {};
|
|
10
6
|
export declare type DexParams = {
|
|
11
7
|
arUSDAddress: Address;
|
|
12
8
|
rUSDAddress: Address;
|
|
13
|
-
|
|
9
|
+
weETHAddress: Address;
|
|
14
10
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { DexParams } from './types';
|
|
2
|
-
import { DexConfigMap } from '../../types';
|
|
2
|
+
import { DexConfigMap, AdapterMappings } from '../../types';
|
|
3
3
|
export declare const FxProtocolConfig: DexConfigMap<DexParams>;
|
|
4
|
+
export declare const Adapters: Record<number, AdapterMappings>;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FxProtocolConfig = void 0;
|
|
3
|
+
exports.Adapters = exports.FxProtocolConfig = void 0;
|
|
4
4
|
const constants_1 = require("../../constants");
|
|
5
5
|
exports.FxProtocolConfig = {
|
|
6
6
|
FxProtocolRusd: {
|
|
7
7
|
[constants_1.Network.MAINNET]: {
|
|
8
8
|
rUSDAddress: '0x65D72AA8DA931F047169112fcf34f52DbaAE7D18',
|
|
9
9
|
weETHAddress: '0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee',
|
|
10
|
-
|
|
11
|
-
weETHOracleAddress: '0xddb6f90ffb4d3257dd666b69178e5b3c5bf41136',
|
|
10
|
+
ezETHAddress: '0xbf5495Efe5DB9ce00f80364C8B423567e58d2110',
|
|
12
11
|
},
|
|
13
12
|
},
|
|
14
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
|
+
};
|
|
15
18
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,15 +1,16 @@
|
|
|
1
|
-
import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, Logger, NumberAsString, DexExchangeParam
|
|
1
|
+
import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, PoolLiquidity, Logger, NumberAsString, DexExchangeParam } from '../../types';
|
|
2
2
|
import { SwapSide, Network } from '../../constants';
|
|
3
3
|
import { IDex } from '../idex';
|
|
4
4
|
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
5
5
|
import { DexParams, FxProtocolData } from './types';
|
|
6
6
|
import { SimpleExchange } from '../simple-exchange';
|
|
7
7
|
import { Interface } from '@ethersproject/abi';
|
|
8
|
-
import { fxProtocolRusdEvent } from './fx-protocol-rusd-event';
|
|
9
8
|
export declare class FxProtocolRusd extends SimpleExchange implements IDex<FxProtocolData> {
|
|
10
9
|
readonly network: Network;
|
|
11
10
|
readonly dexKey: string;
|
|
12
11
|
readonly dexHelper: IDexHelper;
|
|
12
|
+
protected adapters: import("../../types").AdapterMappings;
|
|
13
|
+
static readonly fxUSDIface: Interface;
|
|
13
14
|
protected config: DexParams;
|
|
14
15
|
readonly hasConstantPriceLargeAmounts = true;
|
|
15
16
|
readonly needWrapNative = false;
|
|
@@ -18,18 +19,17 @@ export declare class FxProtocolRusd extends SimpleExchange implements IDex<FxPro
|
|
|
18
19
|
key: string;
|
|
19
20
|
networks: Network[];
|
|
20
21
|
}[];
|
|
21
|
-
fxUSDIface: Interface;
|
|
22
|
-
rUSDMarketIface: Interface;
|
|
23
|
-
weETHOracleIface: Interface;
|
|
24
|
-
fxProtocolRusdPool: fxProtocolRusdEvent;
|
|
25
22
|
logger: Logger;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
getConfig(): DexParams;
|
|
23
|
+
private state;
|
|
24
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper, adapters?: import("../../types").AdapterMappings);
|
|
29
25
|
is_weETH(token: string): boolean;
|
|
30
26
|
is_rUSD(token: string): boolean;
|
|
27
|
+
is_ezETH(token: string): boolean;
|
|
31
28
|
is_rUSD_swap_token(srcToken: string, destToken: string): boolean;
|
|
32
|
-
getAdapters():
|
|
29
|
+
getAdapters(side: SwapSide): {
|
|
30
|
+
name: string;
|
|
31
|
+
index: number;
|
|
32
|
+
}[] | null;
|
|
33
33
|
getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
|
|
34
34
|
getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<FxProtocolData>>;
|
|
35
35
|
getCalldataGasCost(poolPrices: PoolPrices<FxProtocolData>): number | number[];
|
|
@@ -27,113 +27,106 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.FxProtocolRusd = void 0;
|
|
30
|
-
const
|
|
30
|
+
const ts_essentials_1 = require("ts-essentials");
|
|
31
31
|
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
32
32
|
const utils_1 = require("../../utils");
|
|
33
33
|
const simple_exchange_1 = require("../simple-exchange");
|
|
34
34
|
const config_1 = require("./config");
|
|
35
35
|
const abi_1 = require("@ethersproject/abi");
|
|
36
36
|
const FxUSD_json_1 = __importDefault(require("../../abi/fx-protocol/FxUSD.json"));
|
|
37
|
-
const
|
|
38
|
-
const weETHOralce_json_1 = __importDefault(require("../../abi/fx-protocol/weETHOralce.json"));
|
|
37
|
+
const decoders_1 = require("../../lib/decoders");
|
|
39
38
|
const utils_2 = require("../../executor/utils");
|
|
40
|
-
const fx_protocol_rusd_event_1 = require("./fx-protocol-rusd-event");
|
|
41
|
-
const bigint_constants_1 = require("../../bigint-constants");
|
|
42
39
|
class FxProtocolRusd extends simple_exchange_1.SimpleExchange {
|
|
43
|
-
constructor(network, dexKey, dexHelper) {
|
|
40
|
+
constructor(network, dexKey, dexHelper, adapters = config_1.Adapters[network] || {}) {
|
|
44
41
|
super(dexHelper, dexKey);
|
|
45
42
|
this.network = network;
|
|
46
43
|
this.dexKey = dexKey;
|
|
47
44
|
this.dexHelper = dexHelper;
|
|
45
|
+
this.adapters = adapters;
|
|
48
46
|
this.hasConstantPriceLargeAmounts = true;
|
|
49
47
|
this.needWrapNative = false;
|
|
50
48
|
this.isFeeOnTransferSupported = false;
|
|
49
|
+
this.state = {
|
|
50
|
+
blockNumber: 0,
|
|
51
|
+
nav: 0n,
|
|
52
|
+
};
|
|
51
53
|
const config = config_1.FxProtocolConfig[dexKey][network];
|
|
52
|
-
this.fxUSDIface = new abi_1.Interface(FxUSD_json_1.default);
|
|
53
|
-
this.rUSDMarketIface = new abi_1.Interface(FxMarket_json_1.default);
|
|
54
|
-
this.weETHOracleIface = new abi_1.Interface(weETHOralce_json_1.default);
|
|
55
54
|
this.config = {
|
|
56
55
|
rUSDAddress: config.rUSDAddress.toLowerCase(),
|
|
57
56
|
weETHAddress: config.weETHAddress.toLowerCase(),
|
|
58
|
-
|
|
59
|
-
weETHOracleAddress: config.weETHOracleAddress.toLowerCase(),
|
|
57
|
+
ezETHAddress: config.ezETHAddress.toLowerCase(),
|
|
60
58
|
};
|
|
61
59
|
this.logger = dexHelper.getLogger(dexKey);
|
|
62
|
-
this.fxProtocolRusdPool = new fx_protocol_rusd_event_1.fxProtocolRusdEvent(this.dexKey, dexHelper, this.config.rUSDWeETHMarketAddress, this.rUSDMarketIface, this.config.weETHOracleAddress, this.weETHOracleIface, this.logger);
|
|
63
|
-
}
|
|
64
|
-
async initializePricing(blockNumber) {
|
|
65
|
-
const data = await this.dexHelper.multiContract.methods
|
|
66
|
-
.aggregate([
|
|
67
|
-
{
|
|
68
|
-
target: this.config.rUSDWeETHMarketAddress,
|
|
69
|
-
callData: this.rUSDMarketIface.encodeFunctionData('fTokenRedeemFeeRatio', []),
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
target: this.config.weETHOracleAddress,
|
|
73
|
-
callData: this.weETHOracleIface.encodeFunctionData('latestAnswer', []),
|
|
74
|
-
},
|
|
75
|
-
])
|
|
76
|
-
.call({}, blockNumber);
|
|
77
|
-
const redeemFee = BigInt(this.rUSDMarketIface.decodeFunctionResult('fTokenRedeemFeeRatio', data.returnData[0])[0]);
|
|
78
|
-
const weETHPrice = BigInt(this.weETHOracleIface.decodeFunctionResult('latestAnswer', data.returnData[1])[0]);
|
|
79
|
-
await Promise.all([
|
|
80
|
-
this.fxProtocolRusdPool.initialize(blockNumber, {
|
|
81
|
-
state: {
|
|
82
|
-
nav: 1000000000000000000n,
|
|
83
|
-
redeemFee,
|
|
84
|
-
weETHPrice,
|
|
85
|
-
},
|
|
86
|
-
}),
|
|
87
|
-
]);
|
|
88
|
-
}
|
|
89
|
-
getConfig() {
|
|
90
|
-
return this.config;
|
|
91
60
|
}
|
|
92
61
|
is_weETH(token) {
|
|
93
|
-
return token.toLowerCase() === this.config.weETHAddress
|
|
62
|
+
return token.toLowerCase() === this.config.weETHAddress;
|
|
94
63
|
}
|
|
95
64
|
is_rUSD(token) {
|
|
96
|
-
return token.toLowerCase() === this.config.rUSDAddress
|
|
65
|
+
return token.toLowerCase() === this.config.rUSDAddress;
|
|
66
|
+
}
|
|
67
|
+
is_ezETH(token) {
|
|
68
|
+
return token.toLowerCase() === this.config.ezETHAddress;
|
|
97
69
|
}
|
|
98
70
|
is_rUSD_swap_token(srcToken, destToken) {
|
|
99
|
-
|
|
100
|
-
|
|
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;
|
|
101
81
|
}
|
|
102
|
-
|
|
103
|
-
// for a buy/sell. Return null if there are no adapters.
|
|
104
|
-
getAdapters() {
|
|
82
|
+
getAdapters(side) {
|
|
105
83
|
return null;
|
|
106
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
|
|
107
89
|
async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
|
|
108
90
|
if (!this.is_rUSD_swap_token(srcToken.address, destToken.address)) {
|
|
109
91
|
return [];
|
|
110
92
|
}
|
|
111
|
-
return [
|
|
93
|
+
return [this.dexKey];
|
|
112
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.
|
|
113
99
|
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
|
|
114
|
-
if (side == constants_1.SwapSide.BUY) {
|
|
115
|
-
// note: BUY is not supported
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
100
|
const isRUSDSwapToken = this.is_rUSD_swap_token(srcToken.address, destToken.address);
|
|
119
101
|
if (!isRUSDSwapToken) {
|
|
120
102
|
return null;
|
|
121
103
|
}
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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;
|
|
129
122
|
return [
|
|
130
123
|
{
|
|
131
|
-
unit:
|
|
132
|
-
prices:
|
|
124
|
+
unit: 1000000000000000000n,
|
|
125
|
+
prices: amounts,
|
|
133
126
|
data: {},
|
|
134
127
|
poolAddresses: [this.config.rUSDAddress],
|
|
135
128
|
exchange: this.dexKey,
|
|
136
|
-
gasCost:
|
|
129
|
+
gasCost: 70000,
|
|
137
130
|
},
|
|
138
131
|
];
|
|
139
132
|
}
|
|
@@ -141,10 +134,6 @@ class FxProtocolRusd extends simple_exchange_1.SimpleExchange {
|
|
|
141
134
|
getCalldataGasCost(poolPrices) {
|
|
142
135
|
return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
|
|
143
136
|
}
|
|
144
|
-
// Encode params required by the exchange adapter
|
|
145
|
-
// V5: Used for multiSwap, buy & megaSwap
|
|
146
|
-
// V6: Not used, can be left blank
|
|
147
|
-
// Hint: abiCoder.encodeParameter() could be useful
|
|
148
137
|
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
149
138
|
const payload = '0x';
|
|
150
139
|
return {
|
|
@@ -158,34 +147,27 @@ class FxProtocolRusd extends simple_exchange_1.SimpleExchange {
|
|
|
158
147
|
const is_weETH_src = this.is_weETH(srcToken);
|
|
159
148
|
const is_rUSD_dest = this.is_rUSD(destToken);
|
|
160
149
|
const is_weETH_dest = this.is_weETH(destToken);
|
|
150
|
+
const is_eETH_dest = this.is_ezETH(destToken);
|
|
161
151
|
if (is_weETH_src && is_rUSD_dest) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
srcAmount,
|
|
165
|
-
this.dexHelper.config.data.executorsAddresses?.Executor01,
|
|
166
|
-
'0',
|
|
167
|
-
]);
|
|
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']);
|
|
168
154
|
return {
|
|
169
155
|
needWrapNative: false,
|
|
170
|
-
dexFuncHasRecipient:
|
|
156
|
+
dexFuncHasRecipient: true,
|
|
171
157
|
exchangeData,
|
|
172
158
|
targetExchange: this.config.rUSDAddress,
|
|
173
|
-
returnAmountPos: (0, utils_2.extractReturnAmountPosition)(
|
|
159
|
+
returnAmountPos: (0, utils_2.extractReturnAmountPosition)(FxProtocolRusd.fxUSDIface, 'mint', '_amountOut'),
|
|
174
160
|
};
|
|
175
161
|
}
|
|
176
|
-
if (is_rUSD_src && is_weETH_dest) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
srcAmount,
|
|
180
|
-
this.dexHelper.config.data.executorsAddresses?.Executor01,
|
|
181
|
-
'0',
|
|
182
|
-
]);
|
|
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']);
|
|
183
165
|
return {
|
|
184
166
|
needWrapNative: false,
|
|
185
|
-
dexFuncHasRecipient:
|
|
167
|
+
dexFuncHasRecipient: true,
|
|
186
168
|
exchangeData,
|
|
187
169
|
targetExchange: this.config.rUSDAddress,
|
|
188
|
-
returnAmountPos: (0, utils_2.extractReturnAmountPosition)(
|
|
170
|
+
returnAmountPos: (0, utils_2.extractReturnAmountPosition)(FxProtocolRusd.fxUSDIface, 'redeem', '_amountOut'),
|
|
189
171
|
};
|
|
190
172
|
}
|
|
191
173
|
throw new Error('LOGIC ERROR');
|
|
@@ -209,5 +191,6 @@ class FxProtocolRusd extends simple_exchange_1.SimpleExchange {
|
|
|
209
191
|
}
|
|
210
192
|
}
|
|
211
193
|
exports.FxProtocolRusd = FxProtocolRusd;
|
|
194
|
+
FxProtocolRusd.fxUSDIface = new abi_1.Interface(FxUSD_json_1.default);
|
|
212
195
|
FxProtocolRusd.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.FxProtocolConfig);
|
|
213
196
|
//# sourceMappingURL=fx-protocol-rusd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fx-protocol-rusd.js","sourceRoot":"","sources":["../../../src/dex/fx-protocol-rusd/fx-protocol-rusd.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"fx-protocol-rusd.js","sourceRoot":"","sources":["../../../src/dex/fx-protocol-rusd/fx-protocol-rusd.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAoD;AAcpD,2EAA6D;AAC7D,uCAA2D;AAI3D,wDAAoD;AACpD,qCAAsD;AACtD,4CAA+C;AAC/C,kFAAyD;AACzD,iDAAqD;AACrD,gDAAmE;AA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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,13 +1,10 @@
|
|
|
1
1
|
import { Address } from '../../types';
|
|
2
|
-
export declare type
|
|
2
|
+
export declare type PoolState = {
|
|
3
3
|
nav: bigint;
|
|
4
|
-
redeemFee: bigint;
|
|
5
|
-
weETHPrice: bigint;
|
|
6
4
|
};
|
|
7
5
|
export declare type FxProtocolData = {};
|
|
8
6
|
export declare type DexParams = {
|
|
9
7
|
rUSDAddress: Address;
|
|
10
8
|
weETHAddress: Address;
|
|
11
|
-
|
|
12
|
-
weETHOracleAddress: Address;
|
|
9
|
+
ezETHAddress: Address;
|
|
13
10
|
};
|
|
@@ -0,0 +1,56 @@
|
|
|
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 {};
|