@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,282 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Token,
|
|
3
|
+
Address,
|
|
4
|
+
ExchangePrices,
|
|
5
|
+
PoolPrices,
|
|
6
|
+
AdapterExchangeParam,
|
|
7
|
+
Logger,
|
|
8
|
+
NumberAsString,
|
|
9
|
+
DexExchangeParam,
|
|
10
|
+
PoolLiquidity,
|
|
11
|
+
} from '../../types';
|
|
12
|
+
import { SwapSide, Network } from '../../constants';
|
|
13
|
+
import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
|
|
14
|
+
import { getDexKeysWithNetwork } from '../../utils';
|
|
15
|
+
import { IDex } from '../idex';
|
|
16
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
17
|
+
import { DexParams, FxProtocolData } from './types';
|
|
18
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
19
|
+
import { FxProtocolConfig } from './config';
|
|
20
|
+
import { Interface, JsonFragment } from '@ethersproject/abi';
|
|
21
|
+
import FxUSD_ABI from '../../abi/fx-protocol/FxUSD.json';
|
|
22
|
+
import FxMarket_ABI from '../../abi/fx-protocol/FxMarket.json';
|
|
23
|
+
import EthWeETHOralce_ABI from '../../abi/fx-protocol/weETHOralce.json';
|
|
24
|
+
|
|
25
|
+
import { extractReturnAmountPosition } from '../../executor/utils';
|
|
26
|
+
import { FxProtocolRusdEvent } from './fx-protocol-rusd-event';
|
|
27
|
+
import { BI_POWS } from '../../bigint-constants';
|
|
28
|
+
import { getOnChainState } from './utils';
|
|
29
|
+
|
|
30
|
+
export class FxProtocolRusd
|
|
31
|
+
extends SimpleExchange
|
|
32
|
+
implements IDex<FxProtocolData>
|
|
33
|
+
{
|
|
34
|
+
protected config: DexParams;
|
|
35
|
+
|
|
36
|
+
readonly hasConstantPriceLargeAmounts = true;
|
|
37
|
+
|
|
38
|
+
readonly needWrapNative = false;
|
|
39
|
+
|
|
40
|
+
readonly isFeeOnTransferSupported = false;
|
|
41
|
+
|
|
42
|
+
public static dexKeysWithNetwork: { key: string; networks: Network[] }[] =
|
|
43
|
+
getDexKeysWithNetwork(FxProtocolConfig);
|
|
44
|
+
|
|
45
|
+
fxUSDIface: Interface;
|
|
46
|
+
rUSDMarketIface: Interface;
|
|
47
|
+
weETHOracleIface: Interface;
|
|
48
|
+
fxProtocolRusdPool: FxProtocolRusdEvent;
|
|
49
|
+
logger: Logger;
|
|
50
|
+
|
|
51
|
+
constructor(
|
|
52
|
+
readonly network: Network,
|
|
53
|
+
readonly dexKey: string,
|
|
54
|
+
readonly dexHelper: IDexHelper,
|
|
55
|
+
) {
|
|
56
|
+
super(dexHelper, dexKey);
|
|
57
|
+
const config = FxProtocolConfig[dexKey][network];
|
|
58
|
+
this.fxUSDIface = new Interface(FxUSD_ABI as JsonFragment[]);
|
|
59
|
+
this.rUSDMarketIface = new Interface(FxMarket_ABI as JsonFragment[]);
|
|
60
|
+
this.weETHOracleIface = new Interface(EthWeETHOralce_ABI as JsonFragment[]);
|
|
61
|
+
this.config = {
|
|
62
|
+
rUSDAddress: config.rUSDAddress.toLowerCase(),
|
|
63
|
+
weETHAddress: config.weETHAddress.toLowerCase(),
|
|
64
|
+
rUSDWeETHMarketAddress: config.rUSDWeETHMarketAddress.toLowerCase(),
|
|
65
|
+
weETHOracleAddress: config.weETHOracleAddress.toLowerCase(),
|
|
66
|
+
};
|
|
67
|
+
this.logger = dexHelper.getLogger(dexKey);
|
|
68
|
+
this.fxProtocolRusdPool = new FxProtocolRusdEvent(
|
|
69
|
+
this.dexKey,
|
|
70
|
+
dexHelper,
|
|
71
|
+
this.config.rUSDWeETHMarketAddress,
|
|
72
|
+
this.rUSDMarketIface,
|
|
73
|
+
this.config.weETHOracleAddress,
|
|
74
|
+
this.weETHOracleIface,
|
|
75
|
+
this.logger,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async initializePricing(blockNumber: number) {
|
|
80
|
+
const poolState = await getOnChainState(
|
|
81
|
+
this.dexHelper.multiContract,
|
|
82
|
+
this.config.rUSDWeETHMarketAddress,
|
|
83
|
+
this.rUSDMarketIface,
|
|
84
|
+
this.config.weETHOracleAddress,
|
|
85
|
+
this.weETHOracleIface,
|
|
86
|
+
blockNumber,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
await this.fxProtocolRusdPool.initialize(blockNumber, {
|
|
90
|
+
state: poolState,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
getConfig() {
|
|
95
|
+
return this.config;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
is_weETH(token: string) {
|
|
99
|
+
return token.toLowerCase() === this.config.weETHAddress.toLowerCase();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
is_rUSD(token: string) {
|
|
103
|
+
return token.toLowerCase() === this.config.rUSDAddress.toLowerCase();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
is_rUSD_swap_token(srcToken: string, destToken: string) {
|
|
107
|
+
return (
|
|
108
|
+
(this.is_weETH(srcToken) && this.is_rUSD(destToken)) ||
|
|
109
|
+
(this.is_rUSD(srcToken) && this.is_weETH(destToken))
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
// Returns the list of contract adapters (name and index)
|
|
113
|
+
// for a buy/sell. Return null if there are no adapters.
|
|
114
|
+
getAdapters() {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async getPoolIdentifiers(
|
|
119
|
+
srcToken: Token,
|
|
120
|
+
destToken: Token,
|
|
121
|
+
side: SwapSide,
|
|
122
|
+
blockNumber: number,
|
|
123
|
+
): Promise<string[]> {
|
|
124
|
+
if (!this.is_rUSD_swap_token(srcToken.address, destToken.address)) {
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
return [`${this.dexKey}_${this.config.rUSDAddress}`];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async getPricesVolume(
|
|
131
|
+
srcToken: Token,
|
|
132
|
+
destToken: Token,
|
|
133
|
+
amounts: bigint[],
|
|
134
|
+
side: SwapSide,
|
|
135
|
+
blockNumber: number,
|
|
136
|
+
limitPools?: string[],
|
|
137
|
+
): Promise<null | ExchangePrices<FxProtocolData>> {
|
|
138
|
+
// note: BUY is not supported
|
|
139
|
+
if (side === SwapSide.BUY) return null;
|
|
140
|
+
|
|
141
|
+
const isRUSDSwapToken = this.is_rUSD_swap_token(
|
|
142
|
+
srcToken.address,
|
|
143
|
+
destToken.address,
|
|
144
|
+
);
|
|
145
|
+
if (!isRUSDSwapToken) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
const pool = this.fxProtocolRusdPool;
|
|
149
|
+
const is_redeem = this.is_weETH(destToken.address);
|
|
150
|
+
const unitIn = BI_POWS[18];
|
|
151
|
+
const unitOut = await pool.getPrice(blockNumber, unitIn, is_redeem);
|
|
152
|
+
const amountsOut = await Promise.all(
|
|
153
|
+
amounts.map(_amountIn =>
|
|
154
|
+
pool.getPrice(blockNumber, _amountIn, is_redeem),
|
|
155
|
+
),
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
return [
|
|
159
|
+
{
|
|
160
|
+
unit: unitOut,
|
|
161
|
+
prices: amountsOut,
|
|
162
|
+
data: {},
|
|
163
|
+
poolAddresses: [this.config.rUSDAddress],
|
|
164
|
+
exchange: this.dexKey,
|
|
165
|
+
gasCost: 1000000,
|
|
166
|
+
},
|
|
167
|
+
];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Returns estimated gas cost of calldata for this DEX in multiSwap
|
|
171
|
+
getCalldataGasCost(
|
|
172
|
+
poolPrices: PoolPrices<FxProtocolData>,
|
|
173
|
+
): number | number[] {
|
|
174
|
+
return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Encode params required by the exchange adapter
|
|
178
|
+
// V5: Used for multiSwap, buy & megaSwap
|
|
179
|
+
// V6: Not used, can be left blank
|
|
180
|
+
// Hint: abiCoder.encodeParameter() could be useful
|
|
181
|
+
getAdapterParam(
|
|
182
|
+
srcToken: string,
|
|
183
|
+
destToken: string,
|
|
184
|
+
srcAmount: string,
|
|
185
|
+
destAmount: string,
|
|
186
|
+
data: FxProtocolData,
|
|
187
|
+
side: SwapSide,
|
|
188
|
+
): AdapterExchangeParam {
|
|
189
|
+
const payload = '0x';
|
|
190
|
+
|
|
191
|
+
return {
|
|
192
|
+
targetExchange: this.config.rUSDAddress,
|
|
193
|
+
payload,
|
|
194
|
+
networkFee: '0',
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
async getDexParam(
|
|
199
|
+
srcToken: Address,
|
|
200
|
+
destToken: Address,
|
|
201
|
+
srcAmount: NumberAsString,
|
|
202
|
+
destAmount: NumberAsString,
|
|
203
|
+
recipient: Address,
|
|
204
|
+
data: FxProtocolData,
|
|
205
|
+
side: SwapSide,
|
|
206
|
+
): Promise<DexExchangeParam> {
|
|
207
|
+
const is_rUSD_src = this.is_rUSD(srcToken);
|
|
208
|
+
const is_weETH_src = this.is_weETH(srcToken);
|
|
209
|
+
const is_rUSD_dest = this.is_rUSD(destToken);
|
|
210
|
+
const is_weETH_dest = this.is_weETH(destToken);
|
|
211
|
+
|
|
212
|
+
if (is_weETH_src && is_rUSD_dest) {
|
|
213
|
+
const exchangeData = this.fxUSDIface.encodeFunctionData('mint', [
|
|
214
|
+
this.config.weETHAddress,
|
|
215
|
+
srcAmount,
|
|
216
|
+
recipient,
|
|
217
|
+
'0',
|
|
218
|
+
]);
|
|
219
|
+
return {
|
|
220
|
+
needWrapNative: false,
|
|
221
|
+
dexFuncHasRecipient: true,
|
|
222
|
+
exchangeData,
|
|
223
|
+
targetExchange: this.config.rUSDAddress,
|
|
224
|
+
returnAmountPos: extractReturnAmountPosition(
|
|
225
|
+
this.fxUSDIface,
|
|
226
|
+
'mint',
|
|
227
|
+
'_amountOut',
|
|
228
|
+
),
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
if (is_rUSD_src && is_weETH_dest) {
|
|
232
|
+
const exchangeData = this.fxUSDIface.encodeFunctionData('redeem', [
|
|
233
|
+
this.config.weETHAddress,
|
|
234
|
+
srcAmount,
|
|
235
|
+
recipient,
|
|
236
|
+
'0',
|
|
237
|
+
]);
|
|
238
|
+
return {
|
|
239
|
+
needWrapNative: false,
|
|
240
|
+
dexFuncHasRecipient: true,
|
|
241
|
+
exchangeData,
|
|
242
|
+
targetExchange: this.config.rUSDAddress,
|
|
243
|
+
returnAmountPos: extractReturnAmountPosition(
|
|
244
|
+
this.fxUSDIface,
|
|
245
|
+
'redeem',
|
|
246
|
+
'_amountOut',
|
|
247
|
+
),
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
throw new Error('LOGIC ERROR');
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Returns list of top pools based on liquidity. Max
|
|
254
|
+
// limit number pools should be returned.
|
|
255
|
+
async getTopPoolsForToken(
|
|
256
|
+
tokenAddress: Address,
|
|
257
|
+
limit: number,
|
|
258
|
+
): Promise<PoolLiquidity[]> {
|
|
259
|
+
if (!this.is_rUSD(tokenAddress) && !this.is_weETH(tokenAddress)) return [];
|
|
260
|
+
|
|
261
|
+
return [
|
|
262
|
+
{
|
|
263
|
+
exchange: this.dexKey,
|
|
264
|
+
address: this.config.rUSDAddress,
|
|
265
|
+
connectorTokens: this.is_weETH(tokenAddress)
|
|
266
|
+
? [
|
|
267
|
+
{
|
|
268
|
+
decimals: 18,
|
|
269
|
+
address: this.config.rUSDAddress,
|
|
270
|
+
},
|
|
271
|
+
]
|
|
272
|
+
: [
|
|
273
|
+
{
|
|
274
|
+
decimals: 18,
|
|
275
|
+
address: this.config.weETHAddress,
|
|
276
|
+
},
|
|
277
|
+
],
|
|
278
|
+
liquidityUSD: 1000000000, // Just returning a big number so this DEX will be preferred
|
|
279
|
+
},
|
|
280
|
+
];
|
|
281
|
+
}
|
|
282
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Address } from '../../types';
|
|
2
|
+
|
|
3
|
+
export type FxProtocolPoolState = {
|
|
4
|
+
nav: string;
|
|
5
|
+
redeemFee: string;
|
|
6
|
+
weETHPrice: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type FxProtocolData = {};
|
|
10
|
+
|
|
11
|
+
export type DexParams = {
|
|
12
|
+
rUSDAddress: Address;
|
|
13
|
+
weETHAddress: Address;
|
|
14
|
+
rUSDWeETHMarketAddress: Address;
|
|
15
|
+
weETHOracleAddress: Address;
|
|
16
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Contract } from 'web3-eth-contract';
|
|
2
|
+
import { FxProtocolPoolState } from './types';
|
|
3
|
+
import { Interface } from '@ethersproject/abi';
|
|
4
|
+
|
|
5
|
+
export async function getOnChainState(
|
|
6
|
+
multiContract: Contract,
|
|
7
|
+
marketAddress: string,
|
|
8
|
+
marketInterface: Interface,
|
|
9
|
+
ethWeETHOracleAddress: string,
|
|
10
|
+
ethWeETHOracleIface: Interface,
|
|
11
|
+
blockNumber: number | 'latest',
|
|
12
|
+
): Promise<FxProtocolPoolState> {
|
|
13
|
+
const data: { returnData: any[] } = await multiContract.methods
|
|
14
|
+
.aggregate([
|
|
15
|
+
{
|
|
16
|
+
target: marketAddress,
|
|
17
|
+
callData: marketInterface.encodeFunctionData(
|
|
18
|
+
'fTokenRedeemFeeRatio',
|
|
19
|
+
[],
|
|
20
|
+
),
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
target: ethWeETHOracleAddress,
|
|
24
|
+
callData: ethWeETHOracleIface.encodeFunctionData('latestAnswer', []),
|
|
25
|
+
},
|
|
26
|
+
])
|
|
27
|
+
.call({}, blockNumber);
|
|
28
|
+
|
|
29
|
+
const redeemFee = BigInt(
|
|
30
|
+
marketInterface.decodeFunctionResult(
|
|
31
|
+
'fTokenRedeemFeeRatio',
|
|
32
|
+
data.returnData[0],
|
|
33
|
+
)[0],
|
|
34
|
+
).toString();
|
|
35
|
+
const weETHPrice = BigInt(
|
|
36
|
+
ethWeETHOracleIface.decodeFunctionResult(
|
|
37
|
+
'latestAnswer',
|
|
38
|
+
data.returnData[1],
|
|
39
|
+
)[0],
|
|
40
|
+
).toString();
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
nav: '1000000000000000000',
|
|
44
|
+
redeemFee,
|
|
45
|
+
weETHPrice,
|
|
46
|
+
};
|
|
47
|
+
}
|
package/src/dex/index.ts
CHANGED
|
@@ -81,6 +81,8 @@ import { EtherFi } from './etherfi';
|
|
|
81
81
|
import { Spark } from './spark/spark';
|
|
82
82
|
import { VelodromeSlipstream } from './uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream';
|
|
83
83
|
import { AaveV3Stata } from './aave-v3-stata/aave-v3-stata';
|
|
84
|
+
import { ConcentratorArusd } from './concentrator-arusd/concentrator-arusd';
|
|
85
|
+
import { FxProtocolRusd } from './fx-protocol-rusd/fx-protocol-rusd';
|
|
84
86
|
|
|
85
87
|
const LegacyDexes = [
|
|
86
88
|
CurveV2,
|
|
@@ -157,6 +159,8 @@ const Dexes = [
|
|
|
157
159
|
PharaohV1,
|
|
158
160
|
Spark,
|
|
159
161
|
AaveV3Stata,
|
|
162
|
+
ConcentratorArusd,
|
|
163
|
+
FxProtocolRusd,
|
|
160
164
|
];
|
|
161
165
|
|
|
162
166
|
export type LegacyDexConstructor = new (dexHelper: IDexHelper) => IDexTxBuilder<
|
package/tests/constants-e2e.ts
CHANGED
|
@@ -499,6 +499,14 @@ export const Tokens: {
|
|
|
499
499
|
address: '0x23878914efe38d27c4d67ab83ed1b93a74d4086a',
|
|
500
500
|
decimals: 6,
|
|
501
501
|
},
|
|
502
|
+
rUSD: {
|
|
503
|
+
address: '0x65D72AA8DA931F047169112fcf34f52DbaAE7D18',
|
|
504
|
+
decimals: 18,
|
|
505
|
+
},
|
|
506
|
+
arUSD: {
|
|
507
|
+
address: '0x07D1718fF05a8C53C8F05aDAEd57C0d672945f9a',
|
|
508
|
+
decimals: 18,
|
|
509
|
+
},
|
|
502
510
|
},
|
|
503
511
|
[Network.POLYGON]: {
|
|
504
512
|
jGBP: {
|
|
@@ -1569,6 +1577,8 @@ export const Holders: {
|
|
|
1569
1577
|
stataUSDT: '0x6803364AceD5181877abC11E865FB27cB654a426',
|
|
1570
1578
|
aaveUSDT: '0x32c98a981Fe7C333Bd4e8E7630E8e0CF5ce20987',
|
|
1571
1579
|
weETH: '0x267ed5f71EE47D3E45Bb1569Aa37889a2d10f91e',
|
|
1580
|
+
rUSD: '0xEC2eda1C4F981E468ABF62424a10B69B738b498E',
|
|
1581
|
+
arUSD: '0xeFc24206053a452e2299BF3b8f964512b041Db4C',
|
|
1572
1582
|
},
|
|
1573
1583
|
[Network.POLYGON]: {
|
|
1574
1584
|
jGBP: '0x02aa0B826c7BA6386DdBE04C0a8715A1c0A16B24',
|
package/.vscode/tasks.json
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"inputs": [
|
|
4
|
-
{
|
|
5
|
-
"components": [
|
|
6
|
-
{ "internalType": "bytes", "name": "path", "type": "bytes" },
|
|
7
|
-
{ "internalType": "address", "name": "recipient", "type": "address" },
|
|
8
|
-
{ "internalType": "uint256", "name": "amountIn", "type": "uint256" },
|
|
9
|
-
{
|
|
10
|
-
"internalType": "uint256",
|
|
11
|
-
"name": "amountOutMinimum",
|
|
12
|
-
"type": "uint256"
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
"internalType": "struct ISwapRouter.ExactInputParams",
|
|
16
|
-
"name": "params",
|
|
17
|
-
"type": "tuple"
|
|
18
|
-
}
|
|
19
|
-
],
|
|
20
|
-
"name": "exactInput",
|
|
21
|
-
"outputs": [
|
|
22
|
-
{ "internalType": "uint256", "name": "amountOut", "type": "uint256" }
|
|
23
|
-
],
|
|
24
|
-
"stateMutability": "payable",
|
|
25
|
-
"type": "function"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"inputs": [
|
|
29
|
-
{
|
|
30
|
-
"components": [
|
|
31
|
-
{ "internalType": "bytes", "name": "path", "type": "bytes" },
|
|
32
|
-
{ "internalType": "address", "name": "recipient", "type": "address" },
|
|
33
|
-
{ "internalType": "uint256", "name": "amountOut", "type": "uint256" },
|
|
34
|
-
{
|
|
35
|
-
"internalType": "uint256",
|
|
36
|
-
"name": "amountInMaximum",
|
|
37
|
-
"type": "uint256"
|
|
38
|
-
}
|
|
39
|
-
],
|
|
40
|
-
"internalType": "struct ISwapRouter.ExactOutputParams",
|
|
41
|
-
"name": "params",
|
|
42
|
-
"type": "tuple"
|
|
43
|
-
}
|
|
44
|
-
],
|
|
45
|
-
"name": "exactOutput",
|
|
46
|
-
"outputs": [
|
|
47
|
-
{ "internalType": "uint256", "name": "amountIn", "type": "uint256" }
|
|
48
|
-
],
|
|
49
|
-
"stateMutability": "payable",
|
|
50
|
-
"type": "function"
|
|
51
|
-
}
|
|
52
|
-
]
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"aSymbol": "avWETH",
|
|
4
|
-
"aAddress": "0x53f7c5869a859f0aec3d334ee8b4cf01e3492f21",
|
|
5
|
-
"address": "0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab",
|
|
6
|
-
"decimals": 18
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"aSymbol": "avDAI",
|
|
10
|
-
"aAddress": "0x47afa96cdc9fab46904a55a6ad4bf6660b53c38a",
|
|
11
|
-
"address": "0xd586e7f844cea2f87f50152665bcbc2c279d8d70",
|
|
12
|
-
"decimals": 18
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"aSymbol": "avUSDT",
|
|
16
|
-
"aAddress": "0x532e6537fea298397212f09a61e03311686f548e",
|
|
17
|
-
"address": "0xc7198437980c041c805a1edcba50c1ce5db95118",
|
|
18
|
-
"decimals": 6
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"aSymbol": "avUSDC",
|
|
22
|
-
"aAddress": "0x46a51127c3ce23fb7ab1de06226147f446e4a857",
|
|
23
|
-
"address": "0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664",
|
|
24
|
-
"decimals": 6
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"aSymbol": "avAAVE",
|
|
28
|
-
"aAddress": "0xd45b7c061016102f9fa220502908f2c0f1add1d7",
|
|
29
|
-
"address": "0x63a72806098bd3d9520cc43356dd78afe5d386d9",
|
|
30
|
-
"decimals": 18
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"aSymbol": "avWBTC",
|
|
34
|
-
"aAddress": "0x686bef2417b6dc32c50a3cbfbcc3bb60e1e9a15d",
|
|
35
|
-
"address": "0x50b7545627a5162f82a992c33b87adc75187b218",
|
|
36
|
-
"decimals": 8
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"aSymbol": "avWAVAX",
|
|
40
|
-
"aAddress": "0xdfe521292ece2a4f44242efbcd66bc594ca9714b",
|
|
41
|
-
"address": "0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7",
|
|
42
|
-
"decimals": 18
|
|
43
|
-
}
|
|
44
|
-
]
|