@paraswap/dex-lib 3.7.3-idle.2 → 3.7.3-idle.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dex/aave-v3-stata/aave-v3-stata.d.ts +1 -2
- package/build/dex/aave-v3-stata/aave-v3-stata.js +46 -20
- package/build/dex/aave-v3-stata/aave-v3-stata.js.map +1 -1
- package/build/dex/aave-v3-stata/tokens.js +3 -3
- package/build/dex/aave-v3-stata/tokens.js.map +1 -1
- package/build/dex/aave-v3-stata/utils.d.ts +1 -1
- package/build/dex/aave-v3-stata/utils.js +3 -3
- package/build/dex/aave-v3-stata/utils.js.map +1 -1
- package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
- package/build/dex/idle-dao/config.d.ts +1 -2
- package/build/dex/idle-dao/config.js +1 -283
- package/build/dex/idle-dao/config.js.map +1 -1
- package/build/dex/idle-dao/idle-dao.d.ts +1 -0
- package/build/dex/idle-dao/idle-dao.js +43 -20
- package/build/dex/idle-dao/idle-dao.js.map +1 -1
- package/build/dex/idle-dao/token_list.d.ts +4 -0
- package/build/dex/idle-dao/token_list.js +289 -0
- package/build/dex/idle-dao/token_list.js.map +1 -0
- package/build/dex/idle-dao/tokens.d.ts +1 -1
- package/build/dex/idle-dao/tokens.js +8 -5
- package/build/dex/idle-dao/tokens.js.map +1 -1
- package/build/dex/idle-dao/utils.d.ts +1 -1
- package/build/dex/idle-dao/utils.js +8 -7
- package/build/dex/idle-dao/utils.js.map +1 -1
- package/build/dex/index.js +2 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js +1 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js.map +1 -1
- package/build/dex/solidly-v3/solidly-v3.js +1 -0
- package/build/dex/solidly-v3/solidly-v3.js.map +1 -1
- package/build/dex/uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream.js +1 -0
- package/build/dex/uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3.js +1 -0
- package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/aavev3stata/Factory.json +128 -0
- package/src/abi/aavev3stata/Token.json +735 -0
- package/src/dex/aave-v3-stata/aave-v3-stata-e2e.test.ts +355 -0
- package/src/dex/aave-v3-stata/aave-v3-stata-integration.test.ts +282 -0
- package/src/dex/aave-v3-stata/aave-v3-stata.ts +529 -0
- package/src/dex/aave-v3-stata/config.ts +61 -0
- package/src/dex/aave-v3-stata/tokens.ts +48 -0
- package/src/dex/aave-v3-stata/types.ts +69 -0
- package/src/dex/aave-v3-stata/utils.ts +84 -0
- package/src/dex/balancer-v2/balancer-v2.ts +0 -1
- package/src/dex/idle-dao/config.ts +0 -283
- package/src/dex/idle-dao/idle-dao.ts +62 -22
- package/src/dex/idle-dao/token_list.ts +287 -0
- package/src/dex/idle-dao/tokens.ts +15 -6
- package/src/dex/idle-dao/utils.ts +8 -7
- package/src/dex/index.ts +2 -0
- package/src/dex/pancakeswap-v3/pancakeswap-v3.ts +2 -0
- package/src/dex/solidly-v3/solidly-v3.ts +2 -0
- package/src/dex/uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream.ts +2 -0
- package/src/dex/uniswap-v3/uniswap-v3.ts +2 -0
- package/tests/constants-e2e.ts +78 -0
- package/src/dex/idle-dao/scripts.ts +0 -553
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// import {
|
|
2
|
+
// IStaticATokenFactory_ABI,
|
|
3
|
+
// IStaticATokenLM_ABI,
|
|
4
|
+
// } from '@bgd-labs/aave-address-book';
|
|
5
|
+
import { Interface } from '@ethersproject/abi';
|
|
6
|
+
import Web3 from 'web3';
|
|
7
|
+
import { MultiCallParams, MultiWrapper } from '../../lib/multi-wrapper';
|
|
8
|
+
import { stringDecode, uint8ToNumber, addressDecode } from '../../lib/decoders';
|
|
9
|
+
import { StataToken } from './types';
|
|
10
|
+
import FactoryABI from '../../abi/aavev3stata/Factory.json';
|
|
11
|
+
import TokenABI from '../../abi/aavev3stata/Token.json';
|
|
12
|
+
import { AbiItem } from 'web3-utils';
|
|
13
|
+
|
|
14
|
+
// const stataInterface = new Interface(IStaticATokenLM_ABI);
|
|
15
|
+
const stataInterface = new Interface(TokenABI);
|
|
16
|
+
|
|
17
|
+
async function getTokenMetaData(
|
|
18
|
+
stataTokens: string[],
|
|
19
|
+
multiWrapper: MultiWrapper,
|
|
20
|
+
blockNumber?: number,
|
|
21
|
+
): Promise<StataToken[]> {
|
|
22
|
+
const calls: MultiCallParams<any>[] = stataTokens
|
|
23
|
+
.map(token => {
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
target: token,
|
|
27
|
+
callData: stataInterface.encodeFunctionData('symbol'),
|
|
28
|
+
decodeFunction: stringDecode,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
target: token,
|
|
32
|
+
callData: stataInterface.encodeFunctionData('decimals'),
|
|
33
|
+
decodeFunction: uint8ToNumber,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
target: token,
|
|
37
|
+
callData: stataInterface.encodeFunctionData('asset'),
|
|
38
|
+
decodeFunction: addressDecode,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
target: token,
|
|
42
|
+
callData: stataInterface.encodeFunctionData('aToken'),
|
|
43
|
+
decodeFunction: addressDecode,
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
})
|
|
47
|
+
.flat();
|
|
48
|
+
|
|
49
|
+
const results = await multiWrapper.aggregate<string | number>(
|
|
50
|
+
calls,
|
|
51
|
+
blockNumber,
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
let tokenList: StataToken[] = [];
|
|
55
|
+
for (let i = 0, x = 0; i < stataTokens.length; ++i, x += 4) {
|
|
56
|
+
tokenList.push({
|
|
57
|
+
address: stataTokens[i].toLowerCase(),
|
|
58
|
+
stataSymbol: results[x] as string,
|
|
59
|
+
decimals: results[x + 1] as number,
|
|
60
|
+
underlying: (results[x + 2] as string).toLowerCase(),
|
|
61
|
+
underlyingAToken: (results[x + 3] as string).toLowerCase(),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return tokenList;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const fetchTokenList = async (
|
|
68
|
+
web3Provider: Web3,
|
|
69
|
+
factoryAddress: string,
|
|
70
|
+
multiWrapper: MultiWrapper,
|
|
71
|
+
blockNumber?: number,
|
|
72
|
+
): Promise<StataToken[]> => {
|
|
73
|
+
let factoryContract = new web3Provider.eth.Contract(
|
|
74
|
+
FactoryABI as AbiItem[],
|
|
75
|
+
// IStaticATokenFactory_ABI as any,
|
|
76
|
+
factoryAddress,
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
let stataList: string[] = await factoryContract.methods
|
|
80
|
+
.getStaticATokens()
|
|
81
|
+
.call();
|
|
82
|
+
|
|
83
|
+
return getTokenMetaData(stataList, multiWrapper, blockNumber);
|
|
84
|
+
};
|
|
@@ -82,7 +82,6 @@ import { hexConcat, hexlify, hexZeroPad, solidityPack } from 'ethers/lib/utils';
|
|
|
82
82
|
import BalancerVaultABI from '../../abi/balancer-v2/vault.json';
|
|
83
83
|
import { BigNumber } from 'ethers';
|
|
84
84
|
import { SpecialDex } from '../../executor/types';
|
|
85
|
-
import { S } from '@bgd-labs/aave-address-book/dist/AaveV2Ethereum-timF4kft';
|
|
86
85
|
import { extractReturnAmountPosition } from '../../executor/utils';
|
|
87
86
|
|
|
88
87
|
// If you disable some pool, don't forget to clear the cache, otherwise changes won't be applied immediately
|
|
@@ -24,286 +24,3 @@ export const endpoints: Record<number, string> = {
|
|
|
24
24
|
[Network.OPTIMISM]: 'https://api-optimism.idle.finance/pools',
|
|
25
25
|
[Network.ZKEVM]: 'https://api-zkevm.idle.finance/pools',
|
|
26
26
|
};
|
|
27
|
-
|
|
28
|
-
export const TOKEN_LISTS: IdleToken[] = [
|
|
29
|
-
{
|
|
30
|
-
blockNumber: 0,
|
|
31
|
-
idleDecimals: 18,
|
|
32
|
-
cdoAddress: '0x34dCd573C5dE4672C8248cd12A99f875Ca112Ad8',
|
|
33
|
-
idleAddress: '0x2688fc68c4eac90d9e5e1b94776cf14eade8d877',
|
|
34
|
-
address: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
|
|
35
|
-
decimals: 18,
|
|
36
|
-
idleSymbol: 'AA_wstETH',
|
|
37
|
-
tokenType: 'AA',
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
blockNumber: 0,
|
|
41
|
-
idleDecimals: 18,
|
|
42
|
-
cdoAddress: '0x34dCd573C5dE4672C8248cd12A99f875Ca112Ad8',
|
|
43
|
-
idleAddress: '0x3a52fa30c33caf05faee0f9c5dfe5fd5fe8b3978',
|
|
44
|
-
address: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
|
|
45
|
-
decimals: 18,
|
|
46
|
-
idleSymbol: 'BB_wstETH',
|
|
47
|
-
tokenType: 'BB',
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
blockNumber: 0,
|
|
51
|
-
idleDecimals: 18,
|
|
52
|
-
cdoAddress: '0x8E0A8A5c1e5B3ac0670Ea5a613bB15724D51Fc37',
|
|
53
|
-
idleAddress: '0xdf17c739b666b259da3416d01f0310a6e429f592',
|
|
54
|
-
address: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
|
|
55
|
-
decimals: 18,
|
|
56
|
-
idleSymbol: 'AA_iETHv2',
|
|
57
|
-
tokenType: 'AA',
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
blockNumber: 0,
|
|
61
|
-
idleDecimals: 18,
|
|
62
|
-
cdoAddress: '0x8E0A8A5c1e5B3ac0670Ea5a613bB15724D51Fc37',
|
|
63
|
-
idleAddress: '0x990b3af34ddb502715e1070ce6778d8eb3c8ea82',
|
|
64
|
-
address: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
|
|
65
|
-
decimals: 18,
|
|
66
|
-
idleSymbol: 'BB_iETHv2',
|
|
67
|
-
tokenType: 'BB',
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
blockNumber: 0,
|
|
71
|
-
idleDecimals: 18,
|
|
72
|
-
cdoAddress: '0x1329E8DB9Ed7a44726572D44729427F132Fa290D',
|
|
73
|
-
idleAddress: '0x9cacd44cfdf22731bc99facf3531c809d56bd4a2',
|
|
74
|
-
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
75
|
-
decimals: 6,
|
|
76
|
-
idleSymbol: 'AA_idle_cpPOR-USDC',
|
|
77
|
-
tokenType: 'AA',
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
blockNumber: 0,
|
|
81
|
-
idleDecimals: 18,
|
|
82
|
-
cdoAddress: '0x1329E8DB9Ed7a44726572D44729427F132Fa290D',
|
|
83
|
-
idleAddress: '0xf85fd280b301c0a6232d515001da8b6c8503d714',
|
|
84
|
-
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
85
|
-
decimals: 6,
|
|
86
|
-
idleSymbol: 'BB_idle_cpPOR-USDC',
|
|
87
|
-
tokenType: 'BB',
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
blockNumber: 0,
|
|
91
|
-
idleDecimals: 18,
|
|
92
|
-
cdoAddress: '0xc4574C60a455655864aB80fa7638561A756C5E61',
|
|
93
|
-
idleAddress: '0x0a6f2449c09769950cfb76f905ad11c341541f70',
|
|
94
|
-
address: '0xdac17f958d2ee523a2206206994597c13d831ec7',
|
|
95
|
-
decimals: 6,
|
|
96
|
-
idleSymbol: 'AA_idle_cpFAS-USDT',
|
|
97
|
-
tokenType: 'AA',
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
blockNumber: 0,
|
|
101
|
-
idleDecimals: 18,
|
|
102
|
-
cdoAddress: '0xc4574C60a455655864aB80fa7638561A756C5E61',
|
|
103
|
-
idleAddress: '0x3eb6318b8d9f362a0e1d99f6032edb1c4c602500',
|
|
104
|
-
address: '0xdac17f958d2ee523a2206206994597c13d831ec7',
|
|
105
|
-
decimals: 6,
|
|
106
|
-
idleSymbol: 'BB_idle_cpFAS-USDT',
|
|
107
|
-
tokenType: 'BB',
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
blockNumber: 0,
|
|
111
|
-
idleDecimals: 18,
|
|
112
|
-
cdoAddress: '0xE7C6A4525492395d65e736C3593aC933F33ee46e',
|
|
113
|
-
idleAddress: '0xdca1dae87f5c733c84e0593984967ed756579bee',
|
|
114
|
-
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
115
|
-
decimals: 6,
|
|
116
|
-
idleSymbol: 'AA_idle_cpFASA-USDC',
|
|
117
|
-
tokenType: 'AA',
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
blockNumber: 0,
|
|
121
|
-
idleDecimals: 18,
|
|
122
|
-
cdoAddress: '0xE7C6A4525492395d65e736C3593aC933F33ee46e',
|
|
123
|
-
idleAddress: '0xbcc845bb731632ebe8ac0bfacde056170aaaaa06',
|
|
124
|
-
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
125
|
-
decimals: 6,
|
|
126
|
-
idleSymbol: 'BB_idle_cpFASA-USDC',
|
|
127
|
-
tokenType: 'BB',
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
blockNumber: 0,
|
|
131
|
-
idleDecimals: 18,
|
|
132
|
-
cdoAddress: '0x5dcA0B3Ed7594A6613c1A2acd367d56E1f74F92D',
|
|
133
|
-
idleAddress: '0x43ed68703006add5f99ce36b5182392362369c1c',
|
|
134
|
-
address: '0x6b175474e89094c44da98b954eedeac495271d0f',
|
|
135
|
-
decimals: 18,
|
|
136
|
-
idleSymbol: 'AA_idle_cpPOR-USDC',
|
|
137
|
-
tokenType: 'AA',
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
blockNumber: 0,
|
|
141
|
-
idleDecimals: 18,
|
|
142
|
-
cdoAddress: '0x5dcA0B3Ed7594A6613c1A2acd367d56E1f74F92D',
|
|
143
|
-
idleAddress: '0x38d36353d07cfb92650822d9c31fb4ada1c73d6e',
|
|
144
|
-
address: '0x6b175474e89094c44da98b954eedeac495271d0f',
|
|
145
|
-
decimals: 18,
|
|
146
|
-
idleSymbol: 'BB_idle_cpPOR-USDC',
|
|
147
|
-
tokenType: 'BB',
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
blockNumber: 0,
|
|
151
|
-
idleDecimals: 18,
|
|
152
|
-
cdoAddress: '0xF87ec7e1Ee467d7d78862089B92dd40497cBa5B8',
|
|
153
|
-
idleAddress: '0xaef4fcc4e5f2dc270760063446d4116d24704ad1',
|
|
154
|
-
address: '0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0',
|
|
155
|
-
decimals: 18,
|
|
156
|
-
idleSymbol: 'AA_stMATIC',
|
|
157
|
-
tokenType: 'AA',
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
blockNumber: 0,
|
|
161
|
-
idleDecimals: 18,
|
|
162
|
-
cdoAddress: '0xF87ec7e1Ee467d7d78862089B92dd40497cBa5B8',
|
|
163
|
-
idleAddress: '0x077212c69a66261cf7bd1fd3b5c5db7cffa948ee',
|
|
164
|
-
address: '0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0',
|
|
165
|
-
decimals: 18,
|
|
166
|
-
idleSymbol: 'BB_stMATIC',
|
|
167
|
-
tokenType: 'BB',
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
blockNumber: 0,
|
|
171
|
-
idleDecimals: 18,
|
|
172
|
-
cdoAddress: '0x87E53bE99975DA318056af5c4933469a6B513768',
|
|
173
|
-
idleAddress: '0x2b0e31b8ee653d2077db86dea3acf3f34ae9d5d2',
|
|
174
|
-
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
175
|
-
decimals: 6,
|
|
176
|
-
idleSymbol: 'AA_steakUSDC',
|
|
177
|
-
tokenType: 'AA',
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
blockNumber: 0,
|
|
181
|
-
idleDecimals: 18,
|
|
182
|
-
cdoAddress: '0x87E53bE99975DA318056af5c4933469a6B513768',
|
|
183
|
-
idleAddress: '0x7b713b1cb6eafd4061064581579ffccf7df21545',
|
|
184
|
-
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
185
|
-
decimals: 6,
|
|
186
|
-
idleSymbol: 'BB_steakUSDC',
|
|
187
|
-
tokenType: 'BB',
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
blockNumber: 0,
|
|
191
|
-
idleDecimals: 18,
|
|
192
|
-
cdoAddress: '0xA8d747Ef758469e05CF505D708b2514a1aB9Cc08',
|
|
193
|
-
idleAddress: '0x454bb3cb427b21e1c052a080e21a57753cd6969e',
|
|
194
|
-
address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
195
|
-
decimals: 18,
|
|
196
|
-
idleSymbol: 'AA_Re7WETH',
|
|
197
|
-
tokenType: 'AA',
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
blockNumber: 0,
|
|
201
|
-
idleDecimals: 18,
|
|
202
|
-
cdoAddress: '0xA8d747Ef758469e05CF505D708b2514a1aB9Cc08',
|
|
203
|
-
idleAddress: '0x20aa3cd83044d2903181f7ef5c2b498a017d1c4a',
|
|
204
|
-
address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
205
|
-
decimals: 18,
|
|
206
|
-
idleSymbol: 'BB_Re7WETH',
|
|
207
|
-
tokenType: 'BB',
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
blockNumber: 0,
|
|
211
|
-
idleDecimals: 18,
|
|
212
|
-
cdoAddress: '0xD071EA5D2575E155E4e9c2234968D1E11B8a920E',
|
|
213
|
-
idleAddress: '0xb9d321b26095195610707597aab416925c598aab',
|
|
214
|
-
address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
215
|
-
decimals: 18,
|
|
216
|
-
idleSymbol: 'AA_Re7WETH',
|
|
217
|
-
tokenType: 'AA',
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
blockNumber: 0,
|
|
221
|
-
idleDecimals: 18,
|
|
222
|
-
cdoAddress: '0xD071EA5D2575E155E4e9c2234968D1E11B8a920E',
|
|
223
|
-
idleAddress: '0xf529f10fe24367d3a123faf0e9d5f6d80980b46f',
|
|
224
|
-
address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
225
|
-
decimals: 18,
|
|
226
|
-
idleSymbol: 'BB_Re7WETH',
|
|
227
|
-
tokenType: 'BB',
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
blockNumber: 0,
|
|
231
|
-
idleDecimals: 18,
|
|
232
|
-
cdoAddress: '0x9e0c5ee5e4B187Cf18B23745FCF2b6aE66a9B52f',
|
|
233
|
-
idleAddress: '0x28d8a22c6689ac1e2ddc43ca6f85c520457351c1',
|
|
234
|
-
address: '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
235
|
-
decimals: 18,
|
|
236
|
-
idleSymbol: 'AA_ampr-LP-ETH',
|
|
237
|
-
tokenType: 'AA',
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
blockNumber: 0,
|
|
241
|
-
idleDecimals: 18,
|
|
242
|
-
cdoAddress: '0x9e0c5ee5e4B187Cf18B23745FCF2b6aE66a9B52f',
|
|
243
|
-
idleAddress: '0xefc4f43737fd336fa8a8254454ced1e421804b16',
|
|
244
|
-
address: '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
245
|
-
decimals: 18,
|
|
246
|
-
idleSymbol: 'BB_ampr-LP-ETH',
|
|
247
|
-
tokenType: 'BB',
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
blockNumber: 0,
|
|
251
|
-
idleDecimals: 18,
|
|
252
|
-
cdoAddress: '0x1EB1b47D0d8BCD9D761f52D26FCD90bBa225344C',
|
|
253
|
-
idleAddress: '0xf3188697bd35df73e4293d04a07ebaaf1ffc4018',
|
|
254
|
-
address: '0x4c9edd5852cd905f086c759e8383e09bff1e68b3',
|
|
255
|
-
decimals: 18,
|
|
256
|
-
idleSymbol: 'AA_sUSDe',
|
|
257
|
-
tokenType: 'AA',
|
|
258
|
-
},
|
|
259
|
-
{
|
|
260
|
-
blockNumber: 0,
|
|
261
|
-
idleDecimals: 18,
|
|
262
|
-
cdoAddress: '0x1EB1b47D0d8BCD9D761f52D26FCD90bBa225344C',
|
|
263
|
-
idleAddress: '0xb8d0be502a8f12cc5213733285b430a43d07349d',
|
|
264
|
-
address: '0x4c9edd5852cd905f086c759e8383e09bff1e68b3',
|
|
265
|
-
decimals: 18,
|
|
266
|
-
idleSymbol: 'BB_sUSDe',
|
|
267
|
-
tokenType: 'BB',
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
blockNumber: 0,
|
|
271
|
-
idleDecimals: 18,
|
|
272
|
-
cdoAddress: '0xbc48967C34d129a2ef25DD4dc693Cc7364d02eb9',
|
|
273
|
-
idleAddress: '0x0f09a04ad551dd941b589625bd2360fc962ff9f7',
|
|
274
|
-
address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
275
|
-
decimals: 18,
|
|
276
|
-
idleSymbol: 'AA_dWETHV3',
|
|
277
|
-
tokenType: 'AA',
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
blockNumber: 0,
|
|
281
|
-
idleDecimals: 18,
|
|
282
|
-
cdoAddress: '0xbc48967C34d129a2ef25DD4dc693Cc7364d02eb9',
|
|
283
|
-
idleAddress: '0x1223ddeee77f8f379ea7a49e7650ff1ec1e2de8a',
|
|
284
|
-
address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
285
|
-
decimals: 18,
|
|
286
|
-
idleSymbol: 'BB_dWETHV3',
|
|
287
|
-
tokenType: 'BB',
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
blockNumber: 0,
|
|
291
|
-
idleDecimals: 18,
|
|
292
|
-
cdoAddress: '0xdd4D030A4337CE492B55bc5169F6A9568242C0Bc',
|
|
293
|
-
idleAddress: '0x450c055a00226f1eba09e8d9627034565b7c4c8a',
|
|
294
|
-
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
295
|
-
decimals: 6,
|
|
296
|
-
idleSymbol: 'AA_dUSDCV3',
|
|
297
|
-
tokenType: 'AA',
|
|
298
|
-
},
|
|
299
|
-
{
|
|
300
|
-
blockNumber: 0,
|
|
301
|
-
idleDecimals: 18,
|
|
302
|
-
cdoAddress: '0xdd4D030A4337CE492B55bc5169F6A9568242C0Bc',
|
|
303
|
-
idleAddress: '0x2a84a042db06222c486bcb815e961f26599d0df6',
|
|
304
|
-
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
305
|
-
decimals: 6,
|
|
306
|
-
idleSymbol: 'BB_dUSDCV3',
|
|
307
|
-
tokenType: 'BB',
|
|
308
|
-
},
|
|
309
|
-
];
|
|
@@ -25,13 +25,14 @@ import {
|
|
|
25
25
|
setTokensOnNetwork,
|
|
26
26
|
getPoolsByTokenAddress,
|
|
27
27
|
getTokenFromIdleToken,
|
|
28
|
+
getIdleTokenByAddress,
|
|
28
29
|
} from './tokens';
|
|
29
30
|
import FACTORY_ABI from '../../abi/idle-dao/idle-cdo-factory.json';
|
|
30
31
|
import CDO_ABI from '../../abi/idle-dao/idle-cdo.json';
|
|
32
|
+
import { extractReturnAmountPosition } from '../../executor/utils';
|
|
31
33
|
|
|
32
34
|
export const TOKEN_LIST_CACHE_KEY = 'token-list';
|
|
33
35
|
const TOKEN_LIST_TTL_SECONDS = 24 * 60 * 60;
|
|
34
|
-
const TOKEN_LIST_LOCAL_TTL_SECONDS = 3 * 60 * 60;
|
|
35
36
|
|
|
36
37
|
export class IdleDao extends SimpleExchange implements IDex<IdleDaoData> {
|
|
37
38
|
readonly hasConstantPriceLargeAmounts = false;
|
|
@@ -76,7 +77,6 @@ export class IdleDao extends SimpleExchange implements IDex<IdleDaoData> {
|
|
|
76
77
|
this.tokenList = await fetchTokenList_api(
|
|
77
78
|
this.network,
|
|
78
79
|
this.dexHelper,
|
|
79
|
-
blockNumber,
|
|
80
80
|
this.cdo,
|
|
81
81
|
this.erc20Interface,
|
|
82
82
|
this.dexHelper.multiWrapper,
|
|
@@ -96,10 +96,15 @@ export class IdleDao extends SimpleExchange implements IDex<IdleDaoData> {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
async initializePricing(blockNumber: number) {
|
|
99
|
-
|
|
99
|
+
await this.initializeTokens(blockNumber);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async initializeTokens(blockNumber?: number) {
|
|
103
|
+
let cachedTokenList = await this.dexHelper.cache.getAndCacheLocally(
|
|
100
104
|
this.dexKey,
|
|
101
105
|
this.network,
|
|
102
106
|
TOKEN_LIST_CACHE_KEY,
|
|
107
|
+
TOKEN_LIST_TTL_SECONDS,
|
|
103
108
|
);
|
|
104
109
|
|
|
105
110
|
if (cachedTokenList !== null) {
|
|
@@ -113,14 +118,14 @@ export class IdleDao extends SimpleExchange implements IDex<IdleDaoData> {
|
|
|
113
118
|
this.tokenList = await fetchTokenList_api(
|
|
114
119
|
this.network,
|
|
115
120
|
this.dexHelper,
|
|
116
|
-
blockNumber,
|
|
117
121
|
this.cdo,
|
|
118
122
|
this.erc20Interface,
|
|
119
123
|
this.dexHelper.multiWrapper,
|
|
120
124
|
this.idleDaoAuthToken,
|
|
125
|
+
blockNumber,
|
|
121
126
|
);
|
|
122
127
|
|
|
123
|
-
await this.dexHelper.cache.
|
|
128
|
+
await this.dexHelper.cache.setexAndCacheLocally(
|
|
124
129
|
this.dexKey,
|
|
125
130
|
this.network,
|
|
126
131
|
TOKEN_LIST_CACHE_KEY,
|
|
@@ -132,12 +137,13 @@ export class IdleDao extends SimpleExchange implements IDex<IdleDaoData> {
|
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
getAdapters(side: SwapSide): { name: string; index: number }[] | null {
|
|
135
|
-
return
|
|
140
|
+
return null;
|
|
136
141
|
}
|
|
137
142
|
|
|
138
143
|
private _getPoolIdentifier(srcToken: Token, destToken: Token): string {
|
|
139
144
|
return (
|
|
140
145
|
this.dexKey +
|
|
146
|
+
'_' +
|
|
141
147
|
[srcToken.address.toLowerCase(), destToken.address.toLowerCase()]
|
|
142
148
|
.sort((a, b) => (a > b ? 1 : -1))
|
|
143
149
|
.join('_')
|
|
@@ -300,6 +306,8 @@ export class IdleDao extends SimpleExchange implements IDex<IdleDaoData> {
|
|
|
300
306
|
_: Context,
|
|
301
307
|
executorAddress: Address,
|
|
302
308
|
): DexExchangeParam {
|
|
309
|
+
let returnAmountPos = undefined;
|
|
310
|
+
|
|
303
311
|
const [Interface, swapCallee, swapFunction, swapFunctionParams] = ((): [
|
|
304
312
|
Interface,
|
|
305
313
|
Address,
|
|
@@ -307,6 +315,10 @@ export class IdleDao extends SimpleExchange implements IDex<IdleDaoData> {
|
|
|
307
315
|
Param,
|
|
308
316
|
] => {
|
|
309
317
|
if (data.fromIdleToken) {
|
|
318
|
+
returnAmountPos = extractReturnAmountPosition(
|
|
319
|
+
this.cdo,
|
|
320
|
+
PoolFunctions[`withdraw${data.idleToken.tokenType}`],
|
|
321
|
+
);
|
|
310
322
|
return [
|
|
311
323
|
this.cdo,
|
|
312
324
|
data.idleToken.cdoAddress,
|
|
@@ -315,6 +327,10 @@ export class IdleDao extends SimpleExchange implements IDex<IdleDaoData> {
|
|
|
315
327
|
];
|
|
316
328
|
}
|
|
317
329
|
|
|
330
|
+
returnAmountPos = extractReturnAmountPosition(
|
|
331
|
+
this.cdo,
|
|
332
|
+
PoolFunctions[`deposit${data.idleToken.tokenType}`],
|
|
333
|
+
);
|
|
318
334
|
return [
|
|
319
335
|
this.cdo,
|
|
320
336
|
data.idleToken.cdoAddress,
|
|
@@ -333,7 +349,7 @@ export class IdleDao extends SimpleExchange implements IDex<IdleDaoData> {
|
|
|
333
349
|
dexFuncHasRecipient: false,
|
|
334
350
|
exchangeData,
|
|
335
351
|
targetExchange: swapCallee,
|
|
336
|
-
returnAmountPos: undefined,
|
|
352
|
+
returnAmountPos: side === SwapSide.SELL ? returnAmountPos : undefined,
|
|
337
353
|
};
|
|
338
354
|
}
|
|
339
355
|
|
|
@@ -341,21 +357,45 @@ export class IdleDao extends SimpleExchange implements IDex<IdleDaoData> {
|
|
|
341
357
|
tokenAddress: Address,
|
|
342
358
|
limit: number,
|
|
343
359
|
): Promise<PoolLiquidity[]> {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
360
|
+
await this.initializeTokens();
|
|
361
|
+
const idleTokens: IdleToken[] = getPoolsByTokenAddress(
|
|
362
|
+
this.network,
|
|
363
|
+
tokenAddress,
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
if (idleTokens.length > 0) {
|
|
367
|
+
return idleTokens
|
|
368
|
+
.map((idleToken: IdleToken) => ({
|
|
369
|
+
// liquidity is infinite, tokens are minted when swapping for idle tokens
|
|
370
|
+
liquidityUSD: 1e9,
|
|
371
|
+
exchange: this.dexKey,
|
|
372
|
+
address: idleToken.cdoAddress,
|
|
373
|
+
connectorTokens: [getTokenFromIdleToken(idleToken)],
|
|
374
|
+
}))
|
|
375
|
+
.slice(0, limit);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
const idleToken = getIdleTokenByAddress(
|
|
379
|
+
this.network,
|
|
380
|
+
tokenAddress.toLowerCase(),
|
|
381
|
+
);
|
|
382
|
+
|
|
383
|
+
if (idleToken) {
|
|
384
|
+
return [
|
|
385
|
+
{
|
|
386
|
+
liquidityUSD: 1e9,
|
|
387
|
+
exchange: this.dexKey,
|
|
388
|
+
address: idleToken.cdoAddress,
|
|
389
|
+
connectorTokens: [
|
|
390
|
+
{
|
|
391
|
+
address: idleToken.address,
|
|
392
|
+
decimals: idleToken.decimals,
|
|
393
|
+
},
|
|
394
|
+
],
|
|
395
|
+
},
|
|
396
|
+
];
|
|
348
397
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
return idleTokens
|
|
352
|
-
.map((idleToken: IdleToken) => ({
|
|
353
|
-
// liquidity is infinite, tokens are minted when swapping for idle tokens
|
|
354
|
-
liquidityUSD: 1e12,
|
|
355
|
-
exchange: this.dexKey,
|
|
356
|
-
address: idleToken.cdoAddress,
|
|
357
|
-
connectorTokens: [getTokenFromIdleToken(idleToken)],
|
|
358
|
-
}))
|
|
359
|
-
.slice(0, limit);
|
|
398
|
+
|
|
399
|
+
return [];
|
|
360
400
|
}
|
|
361
401
|
}
|