@paraswap/dex-lib 3.8.13 → 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 +16 -0
- package/.vscode/settings.json +3 -0
- package/build/abi/Uncompressor.json +250 -0
- package/build/abi/concentrator/arUSD5115.json +1746 -0
- package/build/abi/fx-protocol/FxMarket.json +1284 -0
- 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/{inception/inception-ineth-pool.json → integral/pool.json} +522 -543
- package/build/abi/integral/relayer.json +1536 -0
- package/build/abi/maverick-v2/MaverickV2Router.json +778 -0
- package/build/dex/aave-v1/aave-v1.d.ts +1 -2
- package/build/dex/aave-v1/aave-v1.js +0 -22
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/bProtocol.d.ts +18 -0
- package/build/dex/bProtocol.js +39 -0
- package/build/dex/bProtocol.js.map +1 -0
- package/build/dex/bancor.d.ts +26 -0
- package/build/dex/bancor.js +58 -0
- package/build/dex/bancor.js.map +1 -0
- package/build/dex/compound.d.ts +18 -0
- package/build/dex/compound.js +46 -0
- package/build/dex/compound.js.map +1 -0
- 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 +6 -3
- package/build/dex/concentrator-arusd/concentrator-arusd.js +45 -41
- package/build/dex/concentrator-arusd/concentrator-arusd.js.map +1 -1
- package/build/dex/concentrator-arusd/config.d.ts +1 -2
- package/build/dex/concentrator-arusd/config.js +2 -6
- package/build/dex/concentrator-arusd/config.js.map +1 -1
- package/build/dex/concentrator-arusd/types.d.ts +7 -3
- 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/curve-v2.d.ts +58 -0
- package/build/dex/curve-v2.js +180 -0
- package/build/dex/curve-v2.js.map +1 -0
- package/build/dex/dodo-v1.d.ts +33 -0
- package/build/dex/dodo-v1.js +63 -0
- package/build/dex/dodo-v1.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 +1 -2
- package/build/dex/fx-protocol-rusd/config.js +3 -6
- package/build/dex/fx-protocol-rusd/config.js.map +1 -1
- 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 +10 -10
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd.js +75 -70
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd.js.map +1 -1
- package/build/dex/fx-protocol-rusd/types.d.ts +6 -3
- 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/{infusion → integral}/config.d.ts +1 -1
- 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/{inception/inception-native.d.ts → integral/integral.d.ts} +19 -21
- 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/lido.d.ts +19 -0
- package/build/dex/lido.js +42 -0
- package/build/dex/lido.js.map +1 -0
- package/build/dex/onebit.d.ts +25 -0
- package/build/dex/onebit.js +42 -0
- package/build/dex/onebit.js.map +1 -0
- package/build/dex/oswap/oswap.js +4 -1
- package/build/dex/oswap/oswap.js.map +1 -1
- package/build/dex/platypus/platypus.d.ts +1 -2
- package/build/dex/platypus/platypus.js +0 -31
- 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.d.ts +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/smoothy.d.ts +26 -0
- package/build/dex/smoothy.js +48 -0
- package/build/dex/smoothy.js.map +1 -0
- package/build/dex/stable-pool.d.ts +28 -0
- package/build/dex/stable-pool.js +62 -0
- package/build/dex/stable-pool.js.map +1 -0
- package/build/dex/swaap-v1/swaap-v1.d.ts +1 -2
- package/build/dex/swaap-v1/swaap-v1.js +0 -10
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/dex/trader-joe-v2.1.d.ts +43 -0
- package/build/dex/trader-joe-v2.1.js +79 -0
- package/build/dex/trader-joe-v2.1.js.map +1 -0
- package/build/executor/Executor01BytecodeBuilder.js +4 -5
- package/build/executor/Executor01BytecodeBuilder.js.map +1 -1
- package/build/executor/Executor02BytecodeBuilder.js +2 -3
- package/build/executor/Executor02BytecodeBuilder.js.map +1 -1
- package/build/executor/Executor03BytecodeBuilder.js +24 -14
- package/build/executor/Executor03BytecodeBuilder.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.d.ts +0 -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/build/generic-swap-transaction-builder.d.ts +1 -1
- package/build/generic-swap-transaction-builder.js +10 -10
- package/build/generic-swap-transaction-builder.js.map +1 -1
- 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/src/executor/Executor01BytecodeBuilder.ts +4 -8
- package/src/executor/Executor02BytecodeBuilder.ts +2 -7
- package/src/executor/Executor03BytecodeBuilder.ts +34 -19
- package/src/generic-swap-transaction-builder.ts +3 -5
- package/tests/constants-e2e.ts +10 -0
- package/build/abi/inception/inception-ineth.json +0 -609
- package/build/abi/inception/inception-ratio-feed.json +0 -93
- package/build/abi/inception/inception-vault.json +0 -991
- package/build/abi/infusion/InfusionFactory.json +0 -147
- package/build/abi/infusion/InfusionPair.json +0 -658
- package/build/abi/infusion/InfusionRouter.json +0 -442
- package/build/dex/idle-dao/idle-dao-pool.d.ts +0 -56
- package/build/dex/idle-dao/idle-dao-pool.js +0 -176
- package/build/dex/idle-dao/idle-dao-pool.js.map +0 -1
- package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +0 -16
- package/build/dex/idle-dao/idle-dao-pooling-pool.js +0 -57
- package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +0 -1
- package/build/dex/idle-dao/scripts.d.ts +0 -9
- package/build/dex/idle-dao/scripts.js +0 -552
- package/build/dex/idle-dao/scripts.js.map +0 -1
- package/build/dex/inception/config.d.ts +0 -5
- package/build/dex/inception/config.js +0 -112
- package/build/dex/inception/config.js.map +0 -1
- package/build/dex/inception/inception-event-pool.d.ts +0 -23
- package/build/dex/inception/inception-event-pool.js +0 -34
- package/build/dex/inception/inception-event-pool.js.map +0 -1
- package/build/dex/inception/inception-native.js +0 -131
- package/build/dex/inception/inception-native.js.map +0 -1
- package/build/dex/inception/inception-pool.d.ts +0 -18
- package/build/dex/inception/inception-pool.js +0 -32
- package/build/dex/inception/inception-pool.js.map +0 -1
- package/build/dex/inception/inception-price-feed.d.ts +0 -19
- package/build/dex/inception/inception-price-feed.js +0 -51
- package/build/dex/inception/inception-price-feed.js.map +0 -1
- package/build/dex/inception/inception.d.ts +0 -44
- package/build/dex/inception/inception.js +0 -162
- package/build/dex/inception/inception.js.map +0 -1
- package/build/dex/inception/tokens.d.ts +0 -9
- package/build/dex/inception/tokens.js +0 -28
- package/build/dex/inception/tokens.js.map +0 -1
- package/build/dex/inception/types.d.ts +0 -22
- package/build/dex/inception/types.js +0 -3
- package/build/dex/inception/types.js.map +0 -1
- package/build/dex/inception/utils.d.ts +0 -7
- package/build/dex/inception/utils.js +0 -58
- package/build/dex/inception/utils.js.map +0 -1
- package/build/dex/infusion/config.js +0 -25
- package/build/dex/infusion/config.js.map +0 -1
- package/build/dex/infusion/infusion-stable-pool.d.ts +0 -4
- package/build/dex/infusion/infusion-stable-pool.js +0 -74
- package/build/dex/infusion/infusion-stable-pool.js.map +0 -1
- package/build/dex/infusion/infusion.d.ts +0 -54
- package/build/dex/infusion/infusion.js +0 -532
- package/build/dex/infusion/infusion.js.map +0 -1
- package/build/dex/infusion/types.d.ts +0 -47
- package/build/dex/infusion/types.js +0 -3
- package/build/dex/infusion/types.js.map +0 -1
- package/build/dex/infusion/utils/isStablePair.d.ts +0 -2
- package/build/dex/infusion/utils/isStablePair.js +0 -18
- package/build/dex/infusion/utils/isStablePair.js.map +0 -1
|
@@ -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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,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"}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam,
|
|
1
|
+
import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, Logger, NumberAsString, DexExchangeParam, PoolLiquidity } 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';
|
|
8
9
|
export declare class FxProtocolRusd extends SimpleExchange implements IDex<FxProtocolData> {
|
|
9
10
|
readonly network: Network;
|
|
10
11
|
readonly dexKey: string;
|
|
11
12
|
readonly dexHelper: IDexHelper;
|
|
12
|
-
protected adapters: import("../../types").AdapterMappings;
|
|
13
|
-
static readonly fxUSDIface: Interface;
|
|
14
13
|
protected config: DexParams;
|
|
15
14
|
readonly hasConstantPriceLargeAmounts = true;
|
|
16
15
|
readonly needWrapNative = false;
|
|
@@ -19,17 +18,18 @@ export declare class FxProtocolRusd extends SimpleExchange implements IDex<FxPro
|
|
|
19
18
|
key: string;
|
|
20
19
|
networks: Network[];
|
|
21
20
|
}[];
|
|
21
|
+
fxUSDIface: Interface;
|
|
22
|
+
rUSDMarketIface: Interface;
|
|
23
|
+
weETHOracleIface: Interface;
|
|
24
|
+
fxProtocolRusdPool: FxProtocolRusdEvent;
|
|
22
25
|
logger: Logger;
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper);
|
|
27
|
+
initializePricing(blockNumber: number): Promise<void>;
|
|
28
|
+
getConfig(): DexParams;
|
|
25
29
|
is_weETH(token: string): boolean;
|
|
26
30
|
is_rUSD(token: string): boolean;
|
|
27
|
-
is_ezETH(token: string): boolean;
|
|
28
31
|
is_rUSD_swap_token(srcToken: string, destToken: string): boolean;
|
|
29
|
-
getAdapters(
|
|
30
|
-
name: string;
|
|
31
|
-
index: number;
|
|
32
|
-
}[] | null;
|
|
32
|
+
getAdapters(): 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,106 +27,92 @@ 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 constants_1 = require("../../constants");
|
|
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
|
|
37
|
+
const FxMarket_json_1 = __importDefault(require("../../abi/fx-protocol/FxMarket.json"));
|
|
38
|
+
const weETHOralce_json_1 = __importDefault(require("../../abi/fx-protocol/weETHOralce.json"));
|
|
38
39
|
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
|
+
const utils_3 = require("./utils");
|
|
39
43
|
class FxProtocolRusd extends simple_exchange_1.SimpleExchange {
|
|
40
|
-
constructor(network, dexKey, dexHelper
|
|
44
|
+
constructor(network, dexKey, dexHelper) {
|
|
41
45
|
super(dexHelper, dexKey);
|
|
42
46
|
this.network = network;
|
|
43
47
|
this.dexKey = dexKey;
|
|
44
48
|
this.dexHelper = dexHelper;
|
|
45
|
-
this.adapters = adapters;
|
|
46
49
|
this.hasConstantPriceLargeAmounts = true;
|
|
47
50
|
this.needWrapNative = false;
|
|
48
51
|
this.isFeeOnTransferSupported = false;
|
|
49
|
-
this.state = {
|
|
50
|
-
blockNumber: 0,
|
|
51
|
-
nav: 0n,
|
|
52
|
-
};
|
|
53
52
|
const config = config_1.FxProtocolConfig[dexKey][network];
|
|
53
|
+
this.fxUSDIface = new abi_1.Interface(FxUSD_json_1.default);
|
|
54
|
+
this.rUSDMarketIface = new abi_1.Interface(FxMarket_json_1.default);
|
|
55
|
+
this.weETHOracleIface = new abi_1.Interface(weETHOralce_json_1.default);
|
|
54
56
|
this.config = {
|
|
55
57
|
rUSDAddress: config.rUSDAddress.toLowerCase(),
|
|
56
58
|
weETHAddress: config.weETHAddress.toLowerCase(),
|
|
57
|
-
|
|
59
|
+
rUSDWeETHMarketAddress: config.rUSDWeETHMarketAddress.toLowerCase(),
|
|
60
|
+
weETHOracleAddress: config.weETHOracleAddress.toLowerCase(),
|
|
58
61
|
};
|
|
59
62
|
this.logger = dexHelper.getLogger(dexKey);
|
|
63
|
+
this.fxProtocolRusdPool = new fx_protocol_rusd_event_1.FxProtocolRusdEvent(this.dexKey, dexHelper, this.config.rUSDWeETHMarketAddress, this.rUSDMarketIface, this.config.weETHOracleAddress, this.weETHOracleIface, this.logger);
|
|
64
|
+
}
|
|
65
|
+
async initializePricing(blockNumber) {
|
|
66
|
+
const poolState = await (0, utils_3.getOnChainState)(this.dexHelper.multiContract, this.config.rUSDWeETHMarketAddress, this.rUSDMarketIface, this.config.weETHOracleAddress, this.weETHOracleIface, blockNumber);
|
|
67
|
+
await this.fxProtocolRusdPool.initialize(blockNumber, {
|
|
68
|
+
state: poolState,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
getConfig() {
|
|
72
|
+
return this.config;
|
|
60
73
|
}
|
|
61
74
|
is_weETH(token) {
|
|
62
|
-
return token.toLowerCase() === this.config.weETHAddress;
|
|
75
|
+
return token.toLowerCase() === this.config.weETHAddress.toLowerCase();
|
|
63
76
|
}
|
|
64
77
|
is_rUSD(token) {
|
|
65
|
-
return token.toLowerCase() === this.config.rUSDAddress;
|
|
66
|
-
}
|
|
67
|
-
is_ezETH(token) {
|
|
68
|
-
return token.toLowerCase() === this.config.ezETHAddress;
|
|
78
|
+
return token.toLowerCase() === this.config.rUSDAddress.toLowerCase();
|
|
69
79
|
}
|
|
70
80
|
is_rUSD_swap_token(srcToken, destToken) {
|
|
71
|
-
|
|
72
|
-
|
|
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
|
+
return ((this.is_weETH(srcToken) && this.is_rUSD(destToken)) ||
|
|
82
|
+
(this.is_rUSD(srcToken) && this.is_weETH(destToken)));
|
|
81
83
|
}
|
|
82
|
-
|
|
84
|
+
// Returns the list of contract adapters (name and index)
|
|
85
|
+
// for a buy/sell. Return null if there are no adapters.
|
|
86
|
+
getAdapters() {
|
|
83
87
|
return null;
|
|
84
88
|
}
|
|
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
89
|
async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
|
|
90
90
|
if (!this.is_rUSD_swap_token(srcToken.address, destToken.address)) {
|
|
91
91
|
return [];
|
|
92
92
|
}
|
|
93
|
-
return [this.dexKey];
|
|
93
|
+
return [`${this.dexKey}_${this.config.rUSDAddress}`];
|
|
94
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
95
|
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
|
|
96
|
+
// note: BUY is not supported
|
|
97
|
+
if (side === constants_1.SwapSide.BUY)
|
|
98
|
+
return null;
|
|
100
99
|
const isRUSDSwapToken = this.is_rUSD_swap_token(srcToken.address, destToken.address);
|
|
101
100
|
if (!isRUSDSwapToken) {
|
|
102
101
|
return null;
|
|
103
102
|
}
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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;
|
|
103
|
+
const pool = this.fxProtocolRusdPool;
|
|
104
|
+
const is_redeem = this.is_weETH(destToken.address);
|
|
105
|
+
const unitIn = bigint_constants_1.BI_POWS[18];
|
|
106
|
+
const unitOut = await pool.getPrice(blockNumber, unitIn, is_redeem);
|
|
107
|
+
const amountsOut = await Promise.all(amounts.map(_amountIn => pool.getPrice(blockNumber, _amountIn, is_redeem)));
|
|
122
108
|
return [
|
|
123
109
|
{
|
|
124
|
-
unit:
|
|
125
|
-
prices:
|
|
110
|
+
unit: unitOut,
|
|
111
|
+
prices: amountsOut,
|
|
126
112
|
data: {},
|
|
127
113
|
poolAddresses: [this.config.rUSDAddress],
|
|
128
114
|
exchange: this.dexKey,
|
|
129
|
-
gasCost:
|
|
115
|
+
gasCost: 1000000,
|
|
130
116
|
},
|
|
131
117
|
];
|
|
132
118
|
}
|
|
@@ -134,6 +120,10 @@ class FxProtocolRusd extends simple_exchange_1.SimpleExchange {
|
|
|
134
120
|
getCalldataGasCost(poolPrices) {
|
|
135
121
|
return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
|
|
136
122
|
}
|
|
123
|
+
// Encode params required by the exchange adapter
|
|
124
|
+
// V5: Used for multiSwap, buy & megaSwap
|
|
125
|
+
// V6: Not used, can be left blank
|
|
126
|
+
// Hint: abiCoder.encodeParameter() could be useful
|
|
137
127
|
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
138
128
|
const payload = '0x';
|
|
139
129
|
return {
|
|
@@ -147,27 +137,34 @@ class FxProtocolRusd extends simple_exchange_1.SimpleExchange {
|
|
|
147
137
|
const is_weETH_src = this.is_weETH(srcToken);
|
|
148
138
|
const is_rUSD_dest = this.is_rUSD(destToken);
|
|
149
139
|
const is_weETH_dest = this.is_weETH(destToken);
|
|
150
|
-
const is_eETH_dest = this.is_ezETH(destToken);
|
|
151
140
|
if (is_weETH_src && is_rUSD_dest) {
|
|
152
|
-
|
|
153
|
-
|
|
141
|
+
const exchangeData = this.fxUSDIface.encodeFunctionData('mint', [
|
|
142
|
+
this.config.weETHAddress,
|
|
143
|
+
srcAmount,
|
|
144
|
+
recipient,
|
|
145
|
+
'0',
|
|
146
|
+
]);
|
|
154
147
|
return {
|
|
155
148
|
needWrapNative: false,
|
|
156
149
|
dexFuncHasRecipient: true,
|
|
157
150
|
exchangeData,
|
|
158
151
|
targetExchange: this.config.rUSDAddress,
|
|
159
|
-
returnAmountPos: (0, utils_2.extractReturnAmountPosition)(
|
|
152
|
+
returnAmountPos: (0, utils_2.extractReturnAmountPosition)(this.fxUSDIface, 'mint', '_amountOut'),
|
|
160
153
|
};
|
|
161
154
|
}
|
|
162
|
-
if (is_rUSD_src &&
|
|
163
|
-
|
|
164
|
-
|
|
155
|
+
if (is_rUSD_src && is_weETH_dest) {
|
|
156
|
+
const exchangeData = this.fxUSDIface.encodeFunctionData('redeem', [
|
|
157
|
+
this.config.weETHAddress,
|
|
158
|
+
srcAmount,
|
|
159
|
+
recipient,
|
|
160
|
+
'0',
|
|
161
|
+
]);
|
|
165
162
|
return {
|
|
166
163
|
needWrapNative: false,
|
|
167
164
|
dexFuncHasRecipient: true,
|
|
168
165
|
exchangeData,
|
|
169
166
|
targetExchange: this.config.rUSDAddress,
|
|
170
|
-
returnAmountPos: (0, utils_2.extractReturnAmountPosition)(
|
|
167
|
+
returnAmountPos: (0, utils_2.extractReturnAmountPosition)(this.fxUSDIface, 'redeem', '_amountOut'),
|
|
171
168
|
};
|
|
172
169
|
}
|
|
173
170
|
throw new Error('LOGIC ERROR');
|
|
@@ -175,22 +172,30 @@ class FxProtocolRusd extends simple_exchange_1.SimpleExchange {
|
|
|
175
172
|
// Returns list of top pools based on liquidity. Max
|
|
176
173
|
// limit number pools should be returned.
|
|
177
174
|
async getTopPoolsForToken(tokenAddress, limit) {
|
|
175
|
+
if (!this.is_rUSD(tokenAddress) && !this.is_weETH(tokenAddress))
|
|
176
|
+
return [];
|
|
178
177
|
return [
|
|
179
178
|
{
|
|
180
179
|
exchange: this.dexKey,
|
|
181
180
|
address: this.config.rUSDAddress,
|
|
182
|
-
connectorTokens:
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
181
|
+
connectorTokens: this.is_weETH(tokenAddress)
|
|
182
|
+
? [
|
|
183
|
+
{
|
|
184
|
+
decimals: 18,
|
|
185
|
+
address: this.config.rUSDAddress,
|
|
186
|
+
},
|
|
187
|
+
]
|
|
188
|
+
: [
|
|
189
|
+
{
|
|
190
|
+
decimals: 18,
|
|
191
|
+
address: this.config.weETHAddress,
|
|
192
|
+
},
|
|
193
|
+
],
|
|
188
194
|
liquidityUSD: 1000000000, // Just returning a big number so this DEX will be preferred
|
|
189
195
|
},
|
|
190
196
|
];
|
|
191
197
|
}
|
|
192
198
|
}
|
|
193
199
|
exports.FxProtocolRusd = FxProtocolRusd;
|
|
194
|
-
FxProtocolRusd.fxUSDIface = new abi_1.Interface(FxUSD_json_1.default);
|
|
195
200
|
FxProtocolRusd.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.FxProtocolConfig);
|
|
196
201
|
//# 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,+CAAoD;AACpD,2EAA6D;AAC7D,uCAAoD;AAIpD,wDAAoD;AACpD,qCAA4C;AAC5C,4CAA6D;AAC7D,kFAAyD;AACzD,wFAA+D;AAC/D,8FAAwE;AAExE,gDAAmE;AACnE,qEAA+D;AAC/D,6DAAiD;AACjD,mCAA0C;AAE1C,MAAa,cACX,SAAQ,gCAAc;IAoBtB,YACW,O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nav: string;
|
|
4
|
+
redeemFee: string;
|
|
5
|
+
weETHPrice: string;
|
|
4
6
|
};
|
|
5
7
|
export declare type FxProtocolData = {};
|
|
6
8
|
export declare type DexParams = {
|
|
7
9
|
rUSDAddress: Address;
|
|
8
10
|
weETHAddress: Address;
|
|
9
|
-
|
|
11
|
+
rUSDWeETHMarketAddress: Address;
|
|
12
|
+
weETHOracleAddress: Address;
|
|
10
13
|
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Contract } from 'web3-eth-contract';
|
|
2
|
+
import { FxProtocolPoolState } from './types';
|
|
3
|
+
import { Interface } from '@ethersproject/abi';
|
|
4
|
+
export declare function getOnChainState(multiContract: Contract, marketAddress: string, marketInterface: Interface, ethWeETHOracleAddress: string, ethWeETHOracleIface: Interface, blockNumber: number | 'latest'): Promise<FxProtocolPoolState>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOnChainState = void 0;
|
|
4
|
+
async function getOnChainState(multiContract, marketAddress, marketInterface, ethWeETHOracleAddress, ethWeETHOracleIface, blockNumber) {
|
|
5
|
+
const data = await multiContract.methods
|
|
6
|
+
.aggregate([
|
|
7
|
+
{
|
|
8
|
+
target: marketAddress,
|
|
9
|
+
callData: marketInterface.encodeFunctionData('fTokenRedeemFeeRatio', []),
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
target: ethWeETHOracleAddress,
|
|
13
|
+
callData: ethWeETHOracleIface.encodeFunctionData('latestAnswer', []),
|
|
14
|
+
},
|
|
15
|
+
])
|
|
16
|
+
.call({}, blockNumber);
|
|
17
|
+
const redeemFee = BigInt(marketInterface.decodeFunctionResult('fTokenRedeemFeeRatio', data.returnData[0])[0]).toString();
|
|
18
|
+
const weETHPrice = BigInt(ethWeETHOracleIface.decodeFunctionResult('latestAnswer', data.returnData[1])[0]).toString();
|
|
19
|
+
return {
|
|
20
|
+
nav: '1000000000000000000',
|
|
21
|
+
redeemFee,
|
|
22
|
+
weETHPrice,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
exports.getOnChainState = getOnChainState;
|
|
26
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/dex/fx-protocol-rusd/utils.ts"],"names":[],"mappings":";;;AAIO,KAAK,UAAU,eAAe,CACnC,aAAuB,EACvB,aAAqB,EACrB,eAA0B,EAC1B,qBAA6B,EAC7B,mBAA8B,EAC9B,WAA8B;IAE9B,MAAM,IAAI,GAA0B,MAAM,aAAa,CAAC,OAAO;SAC5D,SAAS,CAAC;QACT;YACE,MAAM,EAAE,aAAa;YACrB,QAAQ,EAAE,eAAe,CAAC,kBAAkB,CAC1C,sBAAsB,EACtB,EAAE,CACH;SACF;QACD;YACE,MAAM,EAAE,qBAAqB;YAC7B,QAAQ,EAAE,mBAAmB,CAAC,kBAAkB,CAAC,cAAc,EAAE,EAAE,CAAC;SACrE;KACF,CAAC;SACD,IAAI,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;IAEzB,MAAM,SAAS,GAAG,MAAM,CACtB,eAAe,CAAC,oBAAoB,CAClC,sBAAsB,EACtB,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CACnB,CAAC,CAAC,CAAC,CACL,CAAC,QAAQ,EAAE,CAAC;IACb,MAAM,UAAU,GAAG,MAAM,CACvB,mBAAmB,CAAC,oBAAoB,CACtC,cAAc,EACd,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CACnB,CAAC,CAAC,CAAC,CACL,CAAC,QAAQ,EAAE,CAAC;IAEb,OAAO;QACL,GAAG,EAAE,qBAAqB;QAC1B,SAAS;QACT,UAAU;KACX,CAAC;AACJ,CAAC;AA1CD,0CA0CC"}
|
package/build/dex/index.js
CHANGED
|
@@ -83,6 +83,8 @@ const etherfi_1 = require("./etherfi");
|
|
|
83
83
|
const spark_1 = require("./spark/spark");
|
|
84
84
|
const velodrome_slipstream_1 = require("./uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream");
|
|
85
85
|
const aave_v3_stata_1 = require("./aave-v3-stata/aave-v3-stata");
|
|
86
|
+
const concentrator_arusd_1 = require("./concentrator-arusd/concentrator-arusd");
|
|
87
|
+
const fx_protocol_rusd_1 = require("./fx-protocol-rusd/fx-protocol-rusd");
|
|
86
88
|
const LegacyDexes = [
|
|
87
89
|
curve_v2_1.CurveV2,
|
|
88
90
|
stable_pool_1.StablePool,
|
|
@@ -157,6 +159,8 @@ const Dexes = [
|
|
|
157
159
|
pharaohV1_1.PharaohV1,
|
|
158
160
|
spark_1.Spark,
|
|
159
161
|
aave_v3_stata_1.AaveV3Stata,
|
|
162
|
+
concentrator_arusd_1.ConcentratorArusd,
|
|
163
|
+
fx_protocol_rusd_1.FxProtocolRusd,
|
|
160
164
|
];
|
|
161
165
|
class DexAdapterService {
|
|
162
166
|
constructor(dexHelper, network, sellAdapters = {}, buyAdapters = {}) {
|
package/build/dex/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dex/index.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAEvB,kDAA8C;AAE9C,qDAAiD;AACjD,2DAAuD;AACvD,sCAAmC;AACnC,0EAAsE;AACtE,wDAAoD;AACpD,2DAAuD;AACvD,uDAA0D;AAC1D,wDAAoD;AACpD,sDAAwD;AACxD,sDAAsD;AACtD,gDAA6C;AAC7C,4CAAyC;AACzC,4CAAyC;AACzC,4CAAyC;AACzC,kDAA+C;AAC/C,+CAA2C;AAC3C,+CAA2C;AAC3C,kDAA8C;AAC9C,+CAA2C;AAC3C,uCAAmC;AACnC,+CAA4C;AAC5C,yCAAsC;AAEtC,4CAAwC;AAExC,sCAAmC;AACnC,sDAAmD;AACnD,qDAAiD;AACjD,kDAA+C;AAC/C,mCAAgC;AAChC,qDAAgD;AAChD,yFAAoF;AACpF,iDAAkD;AAClD,+CAA4C;AAC5C,wDAAoD;AACpD,4DAAyD;AACzD,0DAAuD;AACvD,8DAA2D;AAC3D,kEAA+D;AAC/D,sEAAmE;AACnE,kEAA+D;AAC/D,wEAAqE;AACrE,qDAAkD;AAClD,0DAAuD;AACvD,kEAA+D;AAC/D,sEAAmE;AACnE,2DAAuD;AACvD,uDAA0D;AAC1D,kDAA8C;AAC9C,0EAAqE;AACrE,2DAAwD;AACxD,0EAAqE;AACrE,gFAA0E;AAC1E,4DAA4D;AAC5D,2DAAuD;AACvD,4CAAyC;AACzC,+CAA4C;AAC5C,kDAA+C;AAC/C,iEAA6D;AAC7D,2DAAuD;AACvD,2DAAuD;AACvD,2DAAuD;AACvD,2DAAuD;AACvD,kDAA8C;AAC9C,uEAAiE;AACjE,oEAAgE;AAChE,+CAA4C;AAC5C,0EAAsE;AACtE,mFAA8E;AAC9E,2DAAuD;AACvD,0DAAsD;AACtD,+CAA4C;AAC5C,4CAAyC;AACzC,yCAAsC;AACtC,kEAA+D;AAC/D,uCAAoC;AACpC,yCAAsC;AACtC,uGAAmG;AACnG,iEAA4D;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dex/index.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAEvB,kDAA8C;AAE9C,qDAAiD;AACjD,2DAAuD;AACvD,sCAAmC;AACnC,0EAAsE;AACtE,wDAAoD;AACpD,2DAAuD;AACvD,uDAA0D;AAC1D,wDAAoD;AACpD,sDAAwD;AACxD,sDAAsD;AACtD,gDAA6C;AAC7C,4CAAyC;AACzC,4CAAyC;AACzC,4CAAyC;AACzC,kDAA+C;AAC/C,+CAA2C;AAC3C,+CAA2C;AAC3C,kDAA8C;AAC9C,+CAA2C;AAC3C,uCAAmC;AACnC,+CAA4C;AAC5C,yCAAsC;AAEtC,4CAAwC;AAExC,sCAAmC;AACnC,sDAAmD;AACnD,qDAAiD;AACjD,kDAA+C;AAC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AAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC1D,OAAO,IAAI,KAAK,oBAAQ,CAAC,IAAI;YAC3B,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC;YAClC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IACtC,CAAC;IAED,qCAAqC,CAAC,MAAc;QAClD,IAAI;YACF,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YACrC,OAAO,CAAC,CAAC,GAAG,CAAC,4BAA4B,CAAC;SAC3C;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,KAAK,CAAC;SACd;IACH,CAAC;CACF;AApLD,8CAoLC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { DexParams } from './types';
|
|
2
2
|
import { DexConfigMap, AdapterMappings } from '../../types';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const IntegralConfig: DexConfigMap<DexParams>;
|
|
4
4
|
export declare const Adapters: Record<number, AdapterMappings>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Adapters = exports.IntegralConfig = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
exports.IntegralConfig = {
|
|
6
|
+
Integral: {
|
|
7
|
+
[constants_1.Network.MAINNET]: {
|
|
8
|
+
factoryAddress: '0xC480b33eE5229DE3FbDFAD1D2DCD3F3BAD0C56c6',
|
|
9
|
+
relayerAddress: '0xd17b3c9784510E33cD5B87b490E79253BcD81e2E',
|
|
10
|
+
subgraphURL: 'ANd5QJuYtyfngmXvBMu9kZAv935vhcqp4xAGBkmCADN3',
|
|
11
|
+
},
|
|
12
|
+
[constants_1.Network.ARBITRUM]: {
|
|
13
|
+
factoryAddress: '0x717EF162cf831db83c51134734A15D1EBe9E516a',
|
|
14
|
+
relayerAddress: '0x3c6951FDB433b5b8442e7aa126D50fBFB54b5f42',
|
|
15
|
+
subgraphURL: 'HXeVedRK7VgogXwbK5Sc4mjyLkhBAS5akskRvbSYnkHU',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
exports.Adapters = {};
|
|
20
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/integral/config.ts"],"names":[],"mappings":";;;AAEA,+CAA0C;AAE7B,QAAA,cAAc,GAA4B;IACrD,QAAQ,EAAE;QACR,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,cAAc,EAAE,4CAA4C;YAC5D,cAAc,EAAE,4CAA4C;YAC5D,WAAW,EAAE,8CAA8C;SAC5D;QACD,CAAC,mBAAO,CAAC,QAAQ,CAAC,EAAE;YAClB,cAAc,EAAE,4CAA4C;YAC5D,cAAc,EAAE,4CAA4C;YAC5D,WAAW,EAAE,8CAA8C;SAC5D;KACF;CACF,CAAC;AAEW,QAAA,QAAQ,GAAoC,EAAE,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Address } from '@paraswap/core';
|
|
2
|
+
import { IntegralFactory } from './integral-factory';
|
|
3
|
+
import { IntegralRelayer } from './integral-relayer';
|
|
4
|
+
import { Network } from '../../constants';
|
|
5
|
+
import { IDexHelper } from '../../dex-helper';
|
|
6
|
+
import { Logger } from 'log4js';
|
|
7
|
+
import { Interface } from '@ethersproject/abi';
|
|
8
|
+
import { IntegralPool, PoolInitProps, RelayerPoolState } from './types';
|
|
9
|
+
import { IntegralToken } from './integral-token';
|
|
10
|
+
export declare class IntegralContext {
|
|
11
|
+
readonly network: Network;
|
|
12
|
+
readonly dexKey: string;
|
|
13
|
+
readonly dexHelper: IDexHelper;
|
|
14
|
+
readonly erc20Interface: Interface;
|
|
15
|
+
readonly factoryAddress: Address;
|
|
16
|
+
readonly relayerAddress: Address;
|
|
17
|
+
static instances: {
|
|
18
|
+
[network: number]: IntegralContext;
|
|
19
|
+
};
|
|
20
|
+
pools: {
|
|
21
|
+
[poolId: string]: IntegralPool;
|
|
22
|
+
};
|
|
23
|
+
tokens: {
|
|
24
|
+
[tokenAddress: Address]: IntegralToken;
|
|
25
|
+
};
|
|
26
|
+
factory: IntegralFactory;
|
|
27
|
+
relayer: IntegralRelayer;
|
|
28
|
+
logger: Logger;
|
|
29
|
+
private constructor();
|
|
30
|
+
addPools(pools: PoolInitProps, blockNumber: number, initPhase?: boolean): Promise<void>;
|
|
31
|
+
getPoolAddresses(): string[];
|
|
32
|
+
private removeDisabledPoolInitProps;
|
|
33
|
+
static initialize(network: Network, dexKey: string, dexHelper: IDexHelper, erc20Interface: Interface, factoryAddress: Address, relayerAddress: Address): IntegralContext;
|
|
34
|
+
static getInstance(network: Network): IntegralContext;
|
|
35
|
+
onRelayerPoolEnabledSet(poolAddress: Address, state: RelayerPoolState, blockNumber: number): Promise<void>;
|
|
36
|
+
onRebalanceSellOrderExecuted(blockNumber: number, orderId: bigint): void;
|
|
37
|
+
onPoolCreatedAddPool(token0: Address, token1: Address, poolAddress: Address, blockNumber: number): Promise<void>;
|
|
38
|
+
onPoolSwapForRelayer(blockNumber: number, poolAddress: Address, recipient: Address, amount0Out: bigint, amount1Out: bigint): Promise<void>;
|
|
39
|
+
onTransferUpdateBalance(token: Address, from: Address, to: Address, amount: bigint, blockNumber: number): Promise<void>;
|
|
40
|
+
}
|