@paraswap/dex-lib 3.8.14 → 3.8.15
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/.vscode/launch.json +6 -43
- package/.vscode/settings.json +2 -1
- package/build/abi/Uncompressor.json +250 -0
- package/build/abi/concentrator/arUSD.json +568 -0
- package/build/abi/concentrator/arUSD5115.json +1746 -0
- package/build/abi/fx-protocol/FxMarket.json +1284 -0
- package/build/abi/{wombat/pool.json → fx-protocol/FxUSD.json} +541 -603
- package/build/abi/fx-protocol/weETHOralce.json +676 -0
- package/build/abi/integral/factory.json +333 -0
- package/build/abi/integral/oracle.json +501 -0
- package/build/abi/integral/pool.json +1041 -0
- package/build/abi/integral/relayer.json +1536 -0
- package/build/abi/oswap/oswap.abi.json +452 -0
- package/build/dex/aave-v1/aave-v1.d.ts +1 -2
- package/build/dex/aave-v1/aave-v1.js +0 -23
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/compound.js +1 -1
- package/build/dex/compound.js.map +1 -1
- package/build/dex/concentrator-arusd/concentrator-arusd-event.d.ts +17 -0
- package/build/dex/concentrator-arusd/concentrator-arusd-event.js +66 -0
- package/build/dex/concentrator-arusd/concentrator-arusd-event.js.map +1 -0
- package/build/dex/concentrator-arusd/concentrator-arusd.d.ts +41 -0
- package/build/dex/concentrator-arusd/concentrator-arusd.js +188 -0
- package/build/dex/concentrator-arusd/concentrator-arusd.js.map +1 -0
- package/build/dex/concentrator-arusd/config.d.ts +3 -0
- package/build/dex/concentrator-arusd/config.js +14 -0
- package/build/dex/concentrator-arusd/config.js.map +1 -0
- package/build/dex/concentrator-arusd/types.d.ts +14 -0
- package/build/dex/concentrator-arusd/types.js +3 -0
- package/build/dex/concentrator-arusd/types.js.map +1 -0
- package/build/dex/concentrator-arusd/utils.d.ts +4 -0
- package/build/dex/concentrator-arusd/utils.js +27 -0
- package/build/dex/concentrator-arusd/utils.js.map +1 -0
- package/build/dex/etherfi/etherfi.d.ts +26 -0
- package/build/dex/etherfi/etherfi.js +96 -0
- package/build/dex/etherfi/etherfi.js.map +1 -0
- package/build/dex/fx-protocol-rusd/config.d.ts +3 -0
- package/build/dex/fx-protocol-rusd/config.js +15 -0
- package/build/dex/fx-protocol-rusd/config.js.map +1 -0
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd-event.d.ts +18 -0
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd-event.js +71 -0
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd-event.js.map +1 -0
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd.d.ts +39 -0
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd.js +201 -0
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd.js.map +1 -0
- package/build/dex/fx-protocol-rusd/types.d.ts +13 -0
- package/build/dex/fx-protocol-rusd/types.js +3 -0
- package/build/dex/fx-protocol-rusd/types.js.map +1 -0
- package/build/dex/fx-protocol-rusd/utils.d.ts +4 -0
- package/build/dex/fx-protocol-rusd/utils.js +26 -0
- package/build/dex/fx-protocol-rusd/utils.js.map +1 -0
- package/build/dex/index.js +4 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/integral/config.d.ts +4 -0
- package/build/dex/integral/config.js +20 -0
- package/build/dex/integral/config.js.map +1 -0
- package/build/dex/integral/context.d.ts +40 -0
- package/build/dex/integral/context.js +158 -0
- package/build/dex/integral/context.js.map +1 -0
- package/build/dex/integral/helpers.d.ts +17 -0
- package/build/dex/integral/helpers.js +157 -0
- package/build/dex/integral/helpers.js.map +1 -0
- package/build/dex/integral/integral-factory.d.ts +24 -0
- package/build/dex/integral/integral-factory.js +95 -0
- package/build/dex/integral/integral-factory.js.map +1 -0
- package/build/dex/integral/integral-pool.d.ts +50 -0
- package/build/dex/integral/integral-pool.js +149 -0
- package/build/dex/integral/integral-pool.js.map +1 -0
- package/build/dex/integral/integral-pricing.d.ts +18 -0
- package/build/dex/integral/integral-pricing.js +114 -0
- package/build/dex/integral/integral-pricing.js.map +1 -0
- package/build/dex/integral/integral-relayer.d.ts +42 -0
- package/build/dex/integral/integral-relayer.js +192 -0
- package/build/dex/integral/integral-relayer.js.map +1 -0
- package/build/dex/integral/integral-token.d.ts +27 -0
- package/build/dex/integral/integral-token.js +59 -0
- package/build/dex/integral/integral-token.js.map +1 -0
- package/build/dex/integral/integral.d.ts +41 -0
- package/build/dex/integral/integral.js +377 -0
- package/build/dex/integral/integral.js.map +1 -0
- package/build/dex/integral/types.d.ts +84 -0
- package/build/dex/integral/types.js +9 -0
- package/build/dex/integral/types.js.map +1 -0
- package/build/dex/integral/utils-e2e.d.ts +9 -0
- package/build/dex/integral/utils-e2e.js +131 -0
- package/build/dex/integral/utils-e2e.js.map +1 -0
- package/build/dex/integral/utils.d.ts +17 -0
- package/build/dex/integral/utils.js +94 -0
- package/build/dex/integral/utils.js.map +1 -0
- package/build/dex/oswap/config.d.ts +5 -0
- package/build/dex/oswap/config.js +31 -0
- package/build/dex/oswap/config.js.map +1 -0
- package/build/dex/oswap/oswap-pool.d.ts +51 -0
- package/build/dex/oswap/oswap-pool.js +150 -0
- package/build/dex/oswap/oswap-pool.js.map +1 -0
- package/build/dex/oswap/oswap.d.ts +46 -0
- package/build/dex/oswap/oswap.js +266 -0
- package/build/dex/oswap/oswap.js.map +1 -0
- package/build/dex/oswap/types.d.ts +20 -0
- package/build/dex/oswap/types.js +3 -0
- package/build/dex/oswap/types.js.map +1 -0
- package/build/dex/platypus/platypus.d.ts +1 -2
- package/build/dex/platypus/platypus.js +0 -45
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/sdai/config.d.ts +11 -0
- package/build/dex/sdai/config.js +21 -0
- package/build/dex/sdai/config.js.map +1 -0
- package/build/dex/sdai/constants.d.ts +2 -0
- package/build/dex/sdai/constants.js +6 -0
- package/build/dex/sdai/constants.js.map +1 -0
- package/build/dex/sdai/scripts/validate-state.js +102 -0
- package/build/dex/sdai/scripts/validate-state.js.map +1 -0
- package/build/dex/sdai/sdai-pool.d.ts +16 -0
- package/build/dex/sdai/sdai-pool.js +85 -0
- package/build/dex/sdai/sdai-pool.js.map +1 -0
- package/build/dex/sdai/sdai.d.ts +51 -0
- package/build/dex/sdai/sdai.js +172 -0
- package/build/dex/sdai/sdai.js.map +1 -0
- package/build/dex/sdai/types.d.ts +21 -0
- package/build/dex/sdai/types.js +11 -0
- package/build/dex/sdai/types.js.map +1 -0
- package/build/dex/sdai/utils.d.ts +4 -0
- package/build/dex/sdai/utils.js +39 -0
- package/build/dex/sdai/utils.js.map +1 -0
- package/build/dex/stable-pool.js +8 -1
- package/build/dex/stable-pool.js.map +1 -1
- package/build/dex/swaap-v1/swaap-v1.d.ts +1 -2
- package/build/dex/swaap-v1/swaap-v1.js +0 -14
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/executor/compressor/Compressor.d.ts +23 -0
- package/build/executor/compressor/Compressor.js +144 -0
- package/build/executor/compressor/Compressor.js.map +1 -0
- package/build/executor/compressor/compress.d.ts +17 -0
- package/build/executor/compressor/compress.js +187 -0
- package/build/executor/compressor/compress.js.map +1 -0
- package/build/executor/compressor/compress_functions/addressSubstitution.d.ts +6 -0
- package/build/executor/compressor/compress_functions/addressSubstitution.js +29 -0
- package/build/executor/compressor/compress_functions/addressSubstitution.js.map +1 -0
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.d.ts +10 -0
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js +40 -0
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js.map +1 -0
- package/build/executor/compressor/compress_functions/byteSubstitution.d.ts +11 -0
- package/build/executor/compressor/compress_functions/byteSubstitution.js +64 -0
- package/build/executor/compressor/compress_functions/byteSubstitution.js.map +1 -0
- package/build/executor/compressor/compress_functions/ffSubstitution.d.ts +7 -0
- package/build/executor/compressor/compress_functions/ffSubstitution.js +54 -0
- package/build/executor/compressor/compress_functions/ffSubstitution.js.map +1 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.d.ts +8 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js +67 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js.map +1 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.d.ts +8 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js +61 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js.map +1 -0
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.d.ts +6 -0
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js +37 -0
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js.map +1 -0
- package/build/executor/compressor/compress_functions/searchUnusedBytes.d.ts +9 -0
- package/build/executor/compressor/compress_functions/searchUnusedBytes.js +33 -0
- package/build/executor/compressor/compress_functions/searchUnusedBytes.js.map +1 -0
- package/build/executor/compressor/fetchSaved.js +17 -0
- package/build/executor/compressor/fetchSaved.js.map +1 -0
- package/build/executor/compressor/utils/computeCostL2.d.ts +2 -0
- package/build/executor/compressor/utils/computeCostL2.js +14 -0
- package/build/executor/compressor/utils/computeCostL2.js.map +1 -0
- package/build/executor/compressor/utils/findLongestDuplicatedString.d.ts +2 -0
- package/build/executor/compressor/utils/findLongestDuplicatedString.js +30 -0
- package/build/executor/compressor/utils/findLongestDuplicatedString.js.map +1 -0
- package/build/executor/compressor/utils/getAllIndexes.d.ts +2 -0
- package/build/executor/compressor/utils/getAllIndexes.js +12 -0
- package/build/executor/compressor/utils/getAllIndexes.js.map +1 -0
- package/build/executor/compressor/utils/getByteForAddress.d.ts +2 -0
- package/build/executor/compressor/utils/getByteForAddress.js +14 -0
- package/build/executor/compressor/utils/getByteForAddress.js.map +1 -0
- package/build/executor/compressor/utils/intTo2Bytes.d.ts +2 -0
- package/build/executor/compressor/utils/intTo2Bytes.js +14 -0
- package/build/executor/compressor/utils/intTo2Bytes.js.map +1 -0
- package/build/executor/compressor/utils/intTo3Bytes.d.ts +2 -0
- package/build/executor/compressor/utils/intTo3Bytes.js +18 -0
- package/build/executor/compressor/utils/intTo3Bytes.js.map +1 -0
- package/build/executor/compressor/utils/intToByte.d.ts +2 -0
- package/build/executor/compressor/utils/intToByte.js +10 -0
- package/build/executor/compressor/utils/intToByte.js.map +1 -0
- package/package.json +1 -1
- package/src/abi/concentrator/arUSD.json +568 -0
- package/src/abi/concentrator/arUSD5115.json +1746 -0
- package/src/abi/fx-protocol/FxMarket.json +1284 -0
- package/src/abi/fx-protocol/FxUSD.json +1227 -0
- package/src/abi/fx-protocol/weETHOralce.json +676 -0
- package/src/dex/concentrator-arusd/concentrator-arusd-e2e.test.ts +92 -0
- package/src/dex/concentrator-arusd/concentrator-arusd-event.ts +100 -0
- package/src/dex/concentrator-arusd/concentrator-arusd-integration.test.ts +104 -0
- package/src/dex/concentrator-arusd/concentrator-arusd.ts +269 -0
- package/src/dex/concentrator-arusd/concetrator-arusd-events.test.ts +97 -0
- package/src/dex/concentrator-arusd/config.ts +13 -0
- package/src/dex/concentrator-arusd/types.ts +16 -0
- package/src/dex/concentrator-arusd/utils.ts +36 -0
- package/src/dex/fx-protocol-rusd/config.ts +14 -0
- package/src/dex/fx-protocol-rusd/fx-protocol-e2e.test.ts +96 -0
- package/src/dex/fx-protocol-rusd/fx-protocol-events.test.ts +101 -0
- package/src/dex/fx-protocol-rusd/fx-protocol-integration.test.ts +104 -0
- package/src/dex/fx-protocol-rusd/fx-protocol-rusd-event.ts +112 -0
- package/src/dex/fx-protocol-rusd/fx-protocol-rusd.ts +282 -0
- package/src/dex/fx-protocol-rusd/types.ts +16 -0
- package/src/dex/fx-protocol-rusd/utils.ts +47 -0
- package/src/dex/index.ts +4 -0
- package/src/dex/wsteth/wsteth-integration.test.ts +0 -1
- package/tests/constants-e2e.ts +10 -0
- package/.vscode/tasks.json +0 -15
- package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +0 -52
- package/build/dex/aave-v2/tokens-avalanche.json +0 -44
- package/build/dex/aave-v2/tokens-mainnet.json +0 -188
- package/build/dex/aave-v2/tokens-polygon.json +0 -44
- package/build/dex/maker-psm/scripts/gem.abi.json +0 -136
- package/build/dex/maker-psm/scripts/validate-state.js +0 -185
- package/build/dex/maker-psm/scripts/validate-state.js.map +0 -1
- package/build/dex/maker-psm/scripts/vat.abi.json +0 -243
- package/build/dex/solidly-v3/scripts/check-event-pool-event.js +0 -53
- package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +0 -1
- package/build/dex/trader-joe-v2.1/base.d.ts +0 -18
- package/build/dex/trader-joe-v2.1/base.js +0 -99
- package/build/dex/trader-joe-v2.1/base.js.map +0 -1
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.d.ts +0 -7
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js +0 -20
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js.map +0 -1
- package/build/dex/trader-joe-v2.1/trader-joe-v2.2.d.ts +0 -7
- package/build/dex/trader-joe-v2.1/trader-joe-v2.2.js +0 -20
- package/build/dex/trader-joe-v2.1/trader-joe-v2.2.js.map +0 -1
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +0 -17
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +0 -64
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +0 -1
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +0 -17
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +0 -79
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +0 -1
- package/config.ts +0 -1946
- package/src/dex/dexs.txt +0 -58
- /package/build/dex/{solidly-v3/scripts/check-event-pool-event.d.ts → sdai/scripts/validate-state.d.ts} +0 -0
- /package/build/{dex/maker-psm/scripts/validate-state.d.ts → executor/compressor/fetchSaved.d.ts} +0 -0
|
@@ -0,0 +1,188 @@
|
|
|
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.ConcentratorArusd = void 0;
|
|
30
|
+
const constants_1 = require("../../constants");
|
|
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 arUSD_json_1 = __importDefault(require("../../abi/concentrator/arUSD.json"));
|
|
37
|
+
const arUSD5115_json_1 = __importDefault(require("../../abi/concentrator/arUSD5115.json"));
|
|
38
|
+
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
|
+
class ConcentratorArusd extends simple_exchange_1.SimpleExchange {
|
|
43
|
+
constructor(network, dexKey, dexHelper, adapters = {}) {
|
|
44
|
+
super(dexHelper, dexKey);
|
|
45
|
+
this.network = network;
|
|
46
|
+
this.dexKey = dexKey;
|
|
47
|
+
this.dexHelper = dexHelper;
|
|
48
|
+
this.adapters = adapters;
|
|
49
|
+
this.hasConstantPriceLargeAmounts = true;
|
|
50
|
+
this.needWrapNative = true;
|
|
51
|
+
this.isFeeOnTransferSupported = false;
|
|
52
|
+
const config = config_1.ConcentratorArusdConfig[dexKey][network];
|
|
53
|
+
this.config = {
|
|
54
|
+
rUSDAddress: config.rUSDAddress.toLowerCase(),
|
|
55
|
+
arUSDAddress: config.arUSDAddress.toLowerCase(),
|
|
56
|
+
arUSD5115Address: config.arUSD5115Address.toLowerCase(),
|
|
57
|
+
};
|
|
58
|
+
this.arUSD5115Iface = new abi_1.Interface(arUSD5115_json_1.default);
|
|
59
|
+
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
|
+
}
|
|
68
|
+
is_arUSD(token) {
|
|
69
|
+
return token.toLowerCase() === this.config.arUSDAddress;
|
|
70
|
+
}
|
|
71
|
+
is_rUSD(token) {
|
|
72
|
+
return token.toLowerCase() === this.config.rUSDAddress;
|
|
73
|
+
}
|
|
74
|
+
is_arUSD_swap_token(srcToken, destToken) {
|
|
75
|
+
if (this.is_rUSD(srcToken) && this.is_arUSD(destToken)) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
if (this.is_arUSD(srcToken) && this.is_rUSD(destToken)) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
getAdapters(side) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
|
|
87
|
+
if (!this.is_arUSD_swap_token(srcToken.address, destToken.address)) {
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
return [`${this.dexKey}_${this.config.arUSDAddress}`];
|
|
91
|
+
}
|
|
92
|
+
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
|
|
93
|
+
// note: BUY is not supported
|
|
94
|
+
if (side === constants_1.SwapSide.BUY)
|
|
95
|
+
return null;
|
|
96
|
+
const isArUSDSwapToken = this.is_arUSD_swap_token(srcToken.address, destToken.address);
|
|
97
|
+
if (!isArUSDSwapToken) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
const is_deposit = !!this.is_rUSD(srcToken.address);
|
|
101
|
+
const pool = this.concentratorArusdEvent;
|
|
102
|
+
const unitIn = bigint_constants_1.BI_POWS[18];
|
|
103
|
+
const unitOut = await pool.getPrice(blockNumber, unitIn, is_deposit);
|
|
104
|
+
const amountsOut = await Promise.all(amounts.map(async (amountIn) => {
|
|
105
|
+
const _newPrice = await pool.getPrice(blockNumber, amountIn, is_deposit);
|
|
106
|
+
return _newPrice;
|
|
107
|
+
}));
|
|
108
|
+
return [
|
|
109
|
+
{
|
|
110
|
+
unit: unitOut,
|
|
111
|
+
prices: amountsOut,
|
|
112
|
+
data: {},
|
|
113
|
+
poolAddresses: [this.config.arUSDAddress],
|
|
114
|
+
exchange: this.dexKey,
|
|
115
|
+
gasCost: 1000000,
|
|
116
|
+
},
|
|
117
|
+
];
|
|
118
|
+
}
|
|
119
|
+
// Returns estimated gas cost of calldata for this DEX in multiSwap
|
|
120
|
+
getCalldataGasCost(poolPrices) {
|
|
121
|
+
return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
|
|
122
|
+
}
|
|
123
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
124
|
+
const payload = '0x';
|
|
125
|
+
return {
|
|
126
|
+
targetExchange: this.config.rUSDAddress,
|
|
127
|
+
payload,
|
|
128
|
+
networkFee: '0',
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
async getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side, context, executorAddress) {
|
|
132
|
+
const is_rUSD_src = this.is_rUSD(srcToken);
|
|
133
|
+
const is_arUSD_src = this.is_arUSD(srcToken);
|
|
134
|
+
const is_rUSD_dest = this.is_rUSD(destToken);
|
|
135
|
+
const is_arUSD_dest = this.is_arUSD(destToken);
|
|
136
|
+
if (is_rUSD_src && is_arUSD_dest) {
|
|
137
|
+
const exchangeData = ConcentratorArusd.arUSDIface.encodeFunctionData('deposit', [srcAmount, recipient]);
|
|
138
|
+
return {
|
|
139
|
+
needWrapNative: false,
|
|
140
|
+
dexFuncHasRecipient: true,
|
|
141
|
+
exchangeData,
|
|
142
|
+
targetExchange: this.config.arUSDAddress,
|
|
143
|
+
returnAmountPos: (0, utils_2.extractReturnAmountPosition)(ConcentratorArusd.arUSDIface, 'deposit', 'shares'),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (is_arUSD_src && is_rUSD_dest) {
|
|
147
|
+
const exchangeData = ConcentratorArusd.arUSDIface.encodeFunctionData('redeem', [srcAmount, recipient, executorAddress]);
|
|
148
|
+
return {
|
|
149
|
+
needWrapNative: false,
|
|
150
|
+
dexFuncHasRecipient: true,
|
|
151
|
+
exchangeData,
|
|
152
|
+
targetExchange: this.config.arUSDAddress,
|
|
153
|
+
returnAmountPos: (0, utils_2.extractReturnAmountPosition)(ConcentratorArusd.arUSDIface, 'redeem', 'assets'),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
throw new Error('LOGIC ERROR');
|
|
157
|
+
}
|
|
158
|
+
// Returns list of top pools based on liquidity. Max
|
|
159
|
+
// limit number pools should be returned.
|
|
160
|
+
async getTopPoolsForToken(tokenAddress, limit) {
|
|
161
|
+
if (!this.is_rUSD(tokenAddress) && !this.is_arUSD(tokenAddress))
|
|
162
|
+
return [];
|
|
163
|
+
return [
|
|
164
|
+
{
|
|
165
|
+
exchange: this.dexKey,
|
|
166
|
+
address: this.config.arUSDAddress,
|
|
167
|
+
connectorTokens: this.is_rUSD(tokenAddress)
|
|
168
|
+
? [
|
|
169
|
+
{
|
|
170
|
+
decimals: 18,
|
|
171
|
+
address: this.config.arUSDAddress,
|
|
172
|
+
},
|
|
173
|
+
]
|
|
174
|
+
: [
|
|
175
|
+
{
|
|
176
|
+
decimals: 18,
|
|
177
|
+
address: this.config.rUSDAddress,
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
liquidityUSD: 1000000000, // Just returning a big number so this DEX will be preferred
|
|
181
|
+
},
|
|
182
|
+
];
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
exports.ConcentratorArusd = ConcentratorArusd;
|
|
186
|
+
ConcentratorArusd.arUSDIface = new abi_1.Interface(arUSD_json_1.default);
|
|
187
|
+
ConcentratorArusd.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.ConcentratorArusdConfig);
|
|
188
|
+
//# sourceMappingURL=concentrator-arusd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concentrator-arusd.js","sourceRoot":"","sources":["../../../src/dex/concentrator-arusd/concentrator-arusd.ts"],"names":[],"mappings":";;;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K;gBACrB,mBAAmB,EAAE,IAAI;gBACzB,YAAY;gBACZ,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;gBACxC,eAAe,EAAE,IAAA,mCAA2B,EAC1C,iBAAiB,CAAC,UAAU,EAC5B,QAAQ,EACR,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,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;YAAE,OAAO,EAAE,CAAC;QAE3E,OAAO;YACL;gBACE,QAAQ,EAAE,IAAI,CAAC,MAAM;gBACrB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;gBACjC,eAAe,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;oBACzC,CAAC,CAAC;wBACE;4BACE,QAAQ,EAAE,EAAE;4BACZ,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;yBAClC;qBACF;oBACH,CAAC,CAAC;wBACE;4BACE,QAAQ,EAAE,EAAE;4BACZ,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;yBACjC;qBACF;gBACL,YAAY,EAAE,UAAU,EAAE,4DAA4D;aACvF;SACF,CAAC;IACJ,CAAC;;AAhPH,8CAiPC;AA7OiB,4BAAU,GAAG,IAAI,eAAS,CAAC,oBAAS,CAAC,CAAC;AASxC,oCAAkB,GAC9B,IAAA,6BAAqB,EAAC,gCAAuB,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
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
|
+
arUSD5115Address: '0x549716F858aefF9CB845d4C78c67A7599B0Df240',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +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,gBAAgB,EAAE,4CAA4C;SAC/D;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Address } from '../../types';
|
|
2
|
+
export declare type ConcentratorArusdState = {
|
|
3
|
+
totalSupply: string;
|
|
4
|
+
totalAssets: string;
|
|
5
|
+
};
|
|
6
|
+
export declare type ConcentratorArusdNavState = {
|
|
7
|
+
nav: string;
|
|
8
|
+
};
|
|
9
|
+
export declare type ConcentratorArusdData = {};
|
|
10
|
+
export declare type DexParams = {
|
|
11
|
+
arUSDAddress: Address;
|
|
12
|
+
rUSDAddress: Address;
|
|
13
|
+
arUSD5115Address: Address;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/concentrator-arusd/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Contract } from 'web3-eth-contract';
|
|
2
|
+
import { ConcentratorArusdState } from './types';
|
|
3
|
+
import { Interface } from '@ethersproject/abi';
|
|
4
|
+
export declare function getOnChainState(multiContract: Contract, poolAddress: string, poolInterface: Interface, blockNumber: number | 'latest'): Promise<ConcentratorArusdState>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOnChainState = void 0;
|
|
4
|
+
const abi_1 = require("@ethersproject/abi");
|
|
5
|
+
const coder = new abi_1.AbiCoder();
|
|
6
|
+
async function getOnChainState(multiContract, poolAddress, poolInterface, blockNumber) {
|
|
7
|
+
const data = await multiContract.methods
|
|
8
|
+
.aggregate([
|
|
9
|
+
{
|
|
10
|
+
target: poolAddress,
|
|
11
|
+
callData: poolInterface.encodeFunctionData('totalSupply', []),
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
target: poolAddress,
|
|
15
|
+
callData: poolInterface.encodeFunctionData('getTotalAssets', []),
|
|
16
|
+
},
|
|
17
|
+
])
|
|
18
|
+
.call({}, blockNumber);
|
|
19
|
+
const totalSupply = BigInt(poolInterface.decodeFunctionResult('totalSupply', data.returnData[0])[0]).toString();
|
|
20
|
+
const totalAssets = BigInt(poolInterface.decodeFunctionResult('getTotalAssets', data.returnData[1])[0]).toString();
|
|
21
|
+
return {
|
|
22
|
+
totalSupply,
|
|
23
|
+
totalAssets,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.getOnChainState = getOnChainState;
|
|
27
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/dex/concentrator-arusd/utils.ts"],"names":[],"mappings":";;;AAEA,4CAAyD;AAEzD,MAAM,KAAK,GAAG,IAAI,cAAQ,EAAE,CAAC;AAEtB,KAAK,UAAU,eAAe,CACnC,aAAuB,EACvB,WAAmB,EACnB,aAAwB,EACxB,WAA8B;IAE9B,MAAM,IAAI,GAA0B,MAAM,aAAa,CAAC,OAAO;SAC5D,SAAS,CAAC;QACT;YACE,MAAM,EAAE,WAAW;YACnB,QAAQ,EAAE,aAAa,CAAC,kBAAkB,CAAC,aAAa,EAAE,EAAE,CAAC;SAC9D;QACD;YACE,MAAM,EAAE,WAAW;YACnB,QAAQ,EAAE,aAAa,CAAC,kBAAkB,CAAC,gBAAgB,EAAE,EAAE,CAAC;SACjE;KACF,CAAC;SACD,IAAI,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;IAEzB,MAAM,WAAW,GAAG,MAAM,CACxB,aAAa,CAAC,oBAAoB,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACzE,CAAC,QAAQ,EAAE,CAAC;IACb,MAAM,WAAW,GAAG,MAAM,CACxB,aAAa,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC5E,CAAC,QAAQ,EAAE,CAAC;IACb,OAAO;QACL,WAAW;QACX,WAAW;KACZ,CAAC;AACJ,CAAC;AA7BD,0CA6BC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { SwapSide } from '../../constants';
|
|
3
|
+
import { AdapterExchangeParam, SimpleExchangeParam } from '../../types';
|
|
4
|
+
import { IDexTxBuilder } from '../idex';
|
|
5
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
6
|
+
import { IDexHelper } from '../../dex-helper';
|
|
7
|
+
declare type EtherFiData = void;
|
|
8
|
+
declare type eETHPoolDepositParam = [];
|
|
9
|
+
declare type weETHWrap = [_eETHAmount: string];
|
|
10
|
+
declare type weETHUnwrap = [_weETHAmount: string];
|
|
11
|
+
declare type EtherFiParam = eETHPoolDepositParam | weETHWrap | weETHUnwrap;
|
|
12
|
+
export declare class EtherFi extends SimpleExchange implements IDexTxBuilder<EtherFiData, EtherFiParam> {
|
|
13
|
+
static dexKeys: string[];
|
|
14
|
+
eETHPoolInterface: Interface;
|
|
15
|
+
weETHInterface: Interface;
|
|
16
|
+
needWrapNative: boolean;
|
|
17
|
+
eETH: string;
|
|
18
|
+
eETHPool: string;
|
|
19
|
+
weETH: string;
|
|
20
|
+
constructor(dexHelper: IDexHelper);
|
|
21
|
+
is_eETH: (token: string) => boolean;
|
|
22
|
+
is_weETH: (token: string) => boolean;
|
|
23
|
+
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: EtherFiData, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
24
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: EtherFiData, side: SwapSide): AdapterExchangeParam;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
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.EtherFi = void 0;
|
|
7
|
+
const abi_1 = require("@ethersproject/abi");
|
|
8
|
+
const constants_1 = require("../../constants");
|
|
9
|
+
const simple_exchange_1 = require("../simple-exchange");
|
|
10
|
+
const eETHPool_json_1 = __importDefault(require("../../abi/etherfi/eETHPool.json"));
|
|
11
|
+
const weETH_json_1 = __importDefault(require("../../abi/etherfi/weETH.json"));
|
|
12
|
+
const utils_1 = require("../../utils");
|
|
13
|
+
const ts_essentials_1 = require("ts-essentials");
|
|
14
|
+
const types_1 = require("../weth/types");
|
|
15
|
+
var EtherFiFunctions;
|
|
16
|
+
(function (EtherFiFunctions) {
|
|
17
|
+
EtherFiFunctions["deposit"] = "deposit";
|
|
18
|
+
EtherFiFunctions["wrap"] = "wrap";
|
|
19
|
+
EtherFiFunctions["unwrap"] = "unwrap";
|
|
20
|
+
})(EtherFiFunctions || (EtherFiFunctions = {}));
|
|
21
|
+
const EtherFiConfig = {
|
|
22
|
+
1: {
|
|
23
|
+
eETH: '0x35fa164735182de50811e8e2e824cfb9b6118ac2',
|
|
24
|
+
eETHPool: '0x308861a430be4cce5502d0a12724771fc6daf216',
|
|
25
|
+
weETH: '0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
class EtherFi extends simple_exchange_1.SimpleExchange {
|
|
29
|
+
constructor(dexHelper) {
|
|
30
|
+
super(dexHelper, 'etherfi');
|
|
31
|
+
this.needWrapNative = false;
|
|
32
|
+
this.is_eETH = (token) => token.toLowerCase() === this.eETH;
|
|
33
|
+
this.is_weETH = (token) => token.toLowerCase() === this.weETH;
|
|
34
|
+
this.eETHPoolInterface = new abi_1.Interface(eETHPool_json_1.default);
|
|
35
|
+
this.weETHInterface = new abi_1.Interface(weETH_json_1.default);
|
|
36
|
+
this.eETH = EtherFiConfig[this.network].eETH.toLowerCase();
|
|
37
|
+
this.eETHPool = EtherFiConfig[this.network].eETHPool.toLowerCase();
|
|
38
|
+
this.weETH = EtherFiConfig[this.network].weETH.toLowerCase();
|
|
39
|
+
}
|
|
40
|
+
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
41
|
+
const [Interface, swapCallee, swapFunction, swapFunctionParams] = (() => {
|
|
42
|
+
if (this.is_weETH(destToken)) {
|
|
43
|
+
(0, ts_essentials_1.assert)(this.is_eETH(srcToken), 'srcToken should be eETH');
|
|
44
|
+
return [
|
|
45
|
+
this.weETHInterface,
|
|
46
|
+
this.weETH,
|
|
47
|
+
EtherFiFunctions.wrap,
|
|
48
|
+
[srcAmount],
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
if (this.is_weETH(srcToken)) {
|
|
52
|
+
(0, ts_essentials_1.assert)(this.is_eETH(destToken), 'destToken should be eETH');
|
|
53
|
+
return [
|
|
54
|
+
this.weETHInterface,
|
|
55
|
+
this.weETH,
|
|
56
|
+
EtherFiFunctions.unwrap,
|
|
57
|
+
[srcAmount],
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
if (this.is_eETH(destToken)) {
|
|
61
|
+
(0, ts_essentials_1.assert)(this.isWETH(srcToken) || (0, utils_1.isETHAddress)(srcToken), 'srcToken should be (w)eth');
|
|
62
|
+
return [
|
|
63
|
+
this.eETHPoolInterface,
|
|
64
|
+
this.eETHPool,
|
|
65
|
+
EtherFiFunctions.deposit,
|
|
66
|
+
[],
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
throw new Error('LOGIC ERROR');
|
|
70
|
+
})();
|
|
71
|
+
const swapData = Interface.encodeFunctionData(swapFunction, swapFunctionParams);
|
|
72
|
+
// if src token is WETH, we need to withdraw from weth and pass eth value on call. For other cases, we need to approve and perform call
|
|
73
|
+
const isSrcTokenWeth = this.isWETH(srcToken);
|
|
74
|
+
return this.buildSimpleParamWithoutWETHConversion(isSrcTokenWeth ? constants_1.ETHER_ADDRESS : srcToken, srcAmount, destToken, destAmount, swapData, swapCallee, swapCallee, '0', isSrcTokenWeth
|
|
75
|
+
? {
|
|
76
|
+
callees: [this.dexHelper.config.data.wrappedNativeTokenAddress],
|
|
77
|
+
calldata: [
|
|
78
|
+
this.erc20Interface.encodeFunctionData(types_1.WethFunctions.withdraw, [
|
|
79
|
+
srcAmount,
|
|
80
|
+
]),
|
|
81
|
+
],
|
|
82
|
+
values: ['0'],
|
|
83
|
+
}
|
|
84
|
+
: undefined);
|
|
85
|
+
}
|
|
86
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
87
|
+
return {
|
|
88
|
+
targetExchange: constants_1.NULL_ADDRESS,
|
|
89
|
+
payload: '0x',
|
|
90
|
+
networkFee: '0',
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.EtherFi = EtherFi;
|
|
95
|
+
EtherFi.dexKeys = ['etherfi'];
|
|
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C,CAAC;QACjC,CAAC,CAAC,EAAE,CAAC;QAEL,MAAM,QAAQ,GAAG,SAAS,CAAC,kBAAkB,CAC3C,YAAY,EACZ,kBAAkB,CACnB,CAAC;QAEF,uIAAuI;QACvI,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAE7C,OAAO,IAAI,CAAC,qCAAqC,CAC/C,cAAc,CAAC,CAAC,CAAC,yBAAa,CAAC,CAAC,CAAC,QAAQ,EACzC,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,UAAU,EACV,UAAU,EACV,GAAG,EACH,cAAc;YACZ,CAAC,CAAC;gBACE,OAAO,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC;gBAC/D,QAAQ,EAAE;oBACR,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,qBAAa,CAAC,QAAQ,EAAE;wBAC7D,SAAS;qBACV,CAAC;iBACH;gBACD,MAAM,EAAE,CAAC,GAAG,CAAC;aACd;YACH,CAAC,CAAC,SAAS,CACd,CAAC;IACJ,CAAC;IAED,eAAe,CACb,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAiB,EACjB,IAAc;QAEd,OAAO;YACL,cAAc,EAAE,wBAAY;YAC5B,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;;AA1HH,0BA2HC;AAvHQ,eAAO,GAAG,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
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
|
+
rUSDWeETHMarketAddress: '0x267c6a96db7422faa60aa7198ffeeec4169cd65f',
|
|
11
|
+
weETHOracleAddress: '0xddb6f90ffb4d3257dd666b69178e5b3c5bf41136',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +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,sBAAsB,EAAE,4CAA4C;YACpE,kBAAkB,EAAE,4CAA4C;SACjE;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { IDexHelper } from '../../dex-helper';
|
|
3
|
+
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
4
|
+
import { Address, Log, Logger } from '../../types';
|
|
5
|
+
import { AsyncOrSync, DeepReadonly } from 'ts-essentials';
|
|
6
|
+
import { FxProtocolPoolState } from './types';
|
|
7
|
+
export declare class FxProtocolRusdEvent extends StatefulEventSubscriber<FxProtocolPoolState> {
|
|
8
|
+
protected dexHelper: IDexHelper;
|
|
9
|
+
private marketAddress;
|
|
10
|
+
private marketInterface;
|
|
11
|
+
private weETHOracleAddress;
|
|
12
|
+
private weETHOracleIface;
|
|
13
|
+
constructor(parentName: string, dexHelper: IDexHelper, marketAddress: Address, marketInterface: Interface, weETHOracleAddress: Address, weETHOracleIface: Interface, logger: Logger);
|
|
14
|
+
protected processLog(state: DeepReadonly<FxProtocolPoolState>, log: Readonly<Log>): AsyncOrSync<DeepReadonly<FxProtocolPoolState> | null>;
|
|
15
|
+
generateState(blockNumber?: number | 'latest'): Promise<DeepReadonly<FxProtocolPoolState>>;
|
|
16
|
+
getPrice(blockNumber: number, amount: bigint, isRedeem: boolean): Promise<bigint>;
|
|
17
|
+
getOrGenerateState(blockNumber: number): Promise<DeepReadonly<FxProtocolPoolState> | null>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FxProtocolRusdEvent = void 0;
|
|
4
|
+
const abi_1 = require("@ethersproject/abi");
|
|
5
|
+
const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
|
|
6
|
+
const bigint_constants_1 = require("../../bigint-constants");
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
const ANSWER_UPDATED_TOPICHASH = `0x0559884fd3a460db3073b7fc896cc77986f16e378210ded43186175bf646fc5f`;
|
|
9
|
+
const UPDATE_REDEEM_FEE_TOPICHASH = `0xb3d49e95905d108ea668ffe62a85ee16bdc4ff9f122a7137964327ea8e0585ff`;
|
|
10
|
+
class FxProtocolRusdEvent extends stateful_event_subscriber_1.StatefulEventSubscriber {
|
|
11
|
+
constructor(parentName, dexHelper, marketAddress, marketInterface, weETHOracleAddress, weETHOracleIface, logger) {
|
|
12
|
+
super(parentName, 'fxProtocolRusd', dexHelper, logger);
|
|
13
|
+
this.dexHelper = dexHelper;
|
|
14
|
+
this.marketAddress = marketAddress;
|
|
15
|
+
this.marketInterface = marketInterface;
|
|
16
|
+
this.weETHOracleAddress = weETHOracleAddress;
|
|
17
|
+
this.weETHOracleIface = weETHOracleIface;
|
|
18
|
+
this.addressesSubscribed = [marketAddress, weETHOracleAddress];
|
|
19
|
+
}
|
|
20
|
+
processLog(state, log) {
|
|
21
|
+
if (log.topics[0] === UPDATE_REDEEM_FEE_TOPICHASH) {
|
|
22
|
+
const [defaultFeeRatio] = abi_1.defaultAbiCoder.decode(['uint256', 'int256'], log.data);
|
|
23
|
+
return {
|
|
24
|
+
...state,
|
|
25
|
+
redeemFee: BigInt(defaultFeeRatio).toString(),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if (log.topics[0] === ANSWER_UPDATED_TOPICHASH) {
|
|
29
|
+
return {
|
|
30
|
+
...state,
|
|
31
|
+
weETHPrice: BigInt(log.topics[1]).toString(),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
async generateState(blockNumber = 'latest') {
|
|
37
|
+
const state = await (0, utils_1.getOnChainState)(this.dexHelper.multiContract, this.marketAddress, this.marketInterface, this.weETHOracleAddress, this.weETHOracleIface, blockNumber);
|
|
38
|
+
return state;
|
|
39
|
+
}
|
|
40
|
+
async getPrice(blockNumber, amount, isRedeem) {
|
|
41
|
+
const state = await this.getOrGenerateState(blockNumber);
|
|
42
|
+
if (!state)
|
|
43
|
+
throw new Error('Cannot compute price');
|
|
44
|
+
const { nav, redeemFee, weETHPrice } = state;
|
|
45
|
+
const baseTokenPrice = BigInt(weETHPrice) * bigint_constants_1.BI_POWS[10];
|
|
46
|
+
if (isRedeem) {
|
|
47
|
+
return BigInt((amount * BigInt(nav) * (bigint_constants_1.BI_POWS[18] - BigInt(redeemFee))) /
|
|
48
|
+
bigint_constants_1.BI_POWS[18] /
|
|
49
|
+
baseTokenPrice);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return BigInt((baseTokenPrice * amount) / BigInt(nav));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async getOrGenerateState(blockNumber) {
|
|
56
|
+
const state = this.getState(blockNumber);
|
|
57
|
+
if (state) {
|
|
58
|
+
return state;
|
|
59
|
+
}
|
|
60
|
+
this.logger.debug(`No state found for ${this.addressesSubscribed[0]}, generating new one`);
|
|
61
|
+
const newState = await this.generateState(blockNumber);
|
|
62
|
+
if (!newState) {
|
|
63
|
+
this.logger.debug(`Could not regenerate state for ${this.addressesSubscribed[0]}`);
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
this.setState(newState, blockNumber);
|
|
67
|
+
return newState;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.FxProtocolRusdEvent = FxProtocolRusdEvent;
|
|
71
|
+
//# sourceMappingURL=fx-protocol-rusd-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fx-protocol-rusd-event.js","sourceRoot":"","sources":["../../../src/dex/fx-protocol-rusd/fx-protocol-rusd-event.ts"],"names":[],"mappings":";;;AACA,4CAAgE;AAEhE,+EAA0E;AAI1E,6DAAiD;AACjD,mCAA0C;AAE1C,MAAM,wBAAwB,GAAG,oEAAoE,CAAC;AACtG,MAAM,2BAA2B,GAAG,oEAAoE,CAAC;AAEzG,MAAa,mBAAoB,SAAQ,mDAA4C;IACnF,YACE,UAAkB,EACR,SAAqB,EACvB,aAAsB,EACtB,eAA0B,EAC1B,kBAA2B,EAC3B,gBAA2B,EACnC,MAAc;QAEd,KAAK,CAAC,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAP7C,cAAS,GAAT,SAAS,CAAY;QACvB,kBAAa,GAAb,aAAa,CAAS;QACtB,oBAAe,GAAf,eAAe,CAAW;QAC1B,uBAAkB,GAAlB,kBAAkB,CAAS;QAC3B,qBAAgB,GAAhB,gBAAgB,CAAW;QAInC,IAAI,CAAC,mBAAmB,GAAG,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;IACjE,CAAC;IAES,UAAU,CAClB,KAAwC,EACxC,GAAkB;QAElB,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,2BAA2B,EAAE;YACjD,MAAM,CAAC,eAAe,CAAC,GAAG,qBAAe,CAAC,MAAM,CAC9C,CAAC,SAAS,EAAE,QAAQ,CAAC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,EAAE,CAAC;gBACX,cAAc,CACjB,CAAC;SACH;aAAM;YACL,OAAO,MAAM,CAAC,CAAC,cAAc,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;SACxD;IACH,CAAC;IAED,KAAK,CAAC,kBAAkB,CACtB,WAAmB;QAEnB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACzC,IAAI,KAAK,EAAE;YACT,OAAO,KAAK,CAAC;SACd;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,sBAAsB,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,sBAAsB,CACxE,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAEvD,IAAI,CAAC,QAAQ,EAAE;YACb,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,kCAAkC,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,CAChE,CAAC;YACF,OAAO,IAAI,CAAC;SACb;QACD,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QACrC,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAlGD,kDAkGC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, Logger, NumberAsString, DexExchangeParam, PoolLiquidity } 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
|
+
import { FxProtocolRusdEvent } from './fx-protocol-rusd-event';
|
|
9
|
+
export declare class FxProtocolRusd extends SimpleExchange implements IDex<FxProtocolData> {
|
|
10
|
+
readonly network: Network;
|
|
11
|
+
readonly dexKey: string;
|
|
12
|
+
readonly dexHelper: IDexHelper;
|
|
13
|
+
protected config: DexParams;
|
|
14
|
+
readonly hasConstantPriceLargeAmounts = true;
|
|
15
|
+
readonly needWrapNative = false;
|
|
16
|
+
readonly isFeeOnTransferSupported = false;
|
|
17
|
+
static dexKeysWithNetwork: {
|
|
18
|
+
key: string;
|
|
19
|
+
networks: Network[];
|
|
20
|
+
}[];
|
|
21
|
+
fxUSDIface: Interface;
|
|
22
|
+
rUSDMarketIface: Interface;
|
|
23
|
+
weETHOracleIface: Interface;
|
|
24
|
+
fxProtocolRusdPool: FxProtocolRusdEvent;
|
|
25
|
+
logger: Logger;
|
|
26
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper);
|
|
27
|
+
initializePricing(blockNumber: number): Promise<void>;
|
|
28
|
+
getConfig(): DexParams;
|
|
29
|
+
is_weETH(token: string): boolean;
|
|
30
|
+
is_rUSD(token: string): boolean;
|
|
31
|
+
is_rUSD_swap_token(srcToken: string, destToken: string): boolean;
|
|
32
|
+
getAdapters(): 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
|
+
}
|