@paraswap/dex-lib 3.4.1 → 3.4.2-idle
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/abi/Redstone.json +739 -0
- package/build/abi/angle-transmuter/MorphoOracle.json +193 -0
- package/build/abi/angle-transmuter/MorphoVault.json +2506 -0
- package/build/abi/angle-transmuter/Pyth.json +1534 -0
- package/build/abi/angle-transmuter/Transmuter.json +1711 -0
- package/build/abi/angle-transmuter/TransmuterSidechain.json +1798 -0
- package/build/abi/idle-dao/idle-cdo-factory.json +38 -0
- package/build/abi/idle-dao/idle-cdo.json +1245 -0
- package/build/abi/pharaoh/PharaohPool.abi.json +1582 -0
- package/build/abi/smardex/smardex-factory.json +185 -0
- package/build/abi/smardex/smardex-pool.json +578 -0
- package/build/abi/smardex/smardex-router.json +648 -0
- package/build/abi/trader-joe-v2_1/FactoryABI.json +1208 -0
- package/build/abi/trader-joe-v2_1/PairABI.json +1493 -0
- package/build/abi/trader-joe-v2_1/RouterABI.json +1489 -0
- package/build/abi/trader-joe-v2_1/StateMulticall.json +193 -0
- package/build/config.js +11 -5
- package/build/config.js.map +1 -1
- package/build/dex/aave-v1/aave-v1.js +0 -1
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/angle-transmuter/angle-transmuter-pool.d.ts +61 -0
- package/build/dex/angle-transmuter/angle-transmuter-pool.js +424 -0
- package/build/dex/angle-transmuter/angle-transmuter-pool.js.map +1 -0
- package/build/dex/angle-transmuter/angle-transmuter.d.ts +60 -0
- package/build/dex/angle-transmuter/angle-transmuter.js +281 -0
- package/build/dex/angle-transmuter/angle-transmuter.js.map +1 -0
- package/build/dex/angle-transmuter/backedOracle.d.ts +19 -0
- package/build/dex/angle-transmuter/backedOracle.js +56 -0
- package/build/dex/angle-transmuter/backedOracle.js.map +1 -0
- package/build/dex/angle-transmuter/config.d.ts +4 -0
- package/build/dex/angle-transmuter/config.js +50 -0
- package/build/dex/angle-transmuter/config.js.map +1 -0
- package/build/dex/angle-transmuter/constants.d.ts +10 -0
- package/build/dex/angle-transmuter/constants.js +137 -0
- package/build/dex/angle-transmuter/constants.js.map +1 -0
- package/build/dex/angle-transmuter/morphoOracle.d.ts +42 -0
- package/build/dex/angle-transmuter/morphoOracle.js +179 -0
- package/build/dex/angle-transmuter/morphoOracle.js.map +1 -0
- package/build/dex/angle-transmuter/morphoVault.d.ts +20 -0
- package/build/dex/angle-transmuter/morphoVault.js +84 -0
- package/build/dex/angle-transmuter/morphoVault.js.map +1 -0
- package/build/dex/angle-transmuter/pyth.d.ts +19 -0
- package/build/dex/angle-transmuter/pyth.js +70 -0
- package/build/dex/angle-transmuter/pyth.js.map +1 -0
- package/build/dex/angle-transmuter/redstone.d.ts +20 -0
- package/build/dex/angle-transmuter/redstone.js +73 -0
- package/build/dex/angle-transmuter/redstone.js.map +1 -0
- package/build/dex/angle-transmuter/transmuter.d.ts +55 -0
- package/build/dex/angle-transmuter/transmuter.js +412 -0
- package/build/dex/angle-transmuter/transmuter.js.map +1 -0
- package/build/dex/angle-transmuter/types.d.ts +189 -0
- package/build/dex/angle-transmuter/types.js +33 -0
- package/build/dex/angle-transmuter/types.js.map +1 -0
- package/build/dex/angle-transmuter/utils.d.ts +9 -0
- package/build/dex/angle-transmuter/utils.js +257 -0
- package/build/dex/angle-transmuter/utils.js.map +1 -0
- package/build/dex/idle-dao/config.d.ts +7 -0
- package/build/dex/idle-dao/config.js +571 -0
- package/build/dex/idle-dao/config.js.map +1 -0
- package/build/dex/idle-dao/idle-dao-pool.d.ts +56 -0
- package/build/dex/idle-dao/idle-dao-pool.js +176 -0
- package/build/dex/idle-dao/idle-dao-pool.js.map +1 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +16 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.js +57 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +1 -0
- package/build/dex/idle-dao/idle-dao.d.ts +52 -0
- package/build/dex/idle-dao/idle-dao.js +321 -0
- package/build/dex/idle-dao/idle-dao.js.map +1 -0
- package/build/dex/idle-dao/tokens.d.ts +16 -0
- package/build/dex/idle-dao/tokens.js +87 -0
- package/build/dex/idle-dao/tokens.js.map +1 -0
- package/build/dex/idle-dao/types.d.ts +37 -0
- package/build/dex/idle-dao/types.js +11 -0
- package/build/dex/idle-dao/types.js.map +1 -0
- package/build/dex/idle-dao/utils.d.ts +8 -0
- package/build/dex/idle-dao/utils.js +147 -0
- package/build/dex/idle-dao/utils.js.map +1 -0
- package/build/dex/index.js +2 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/platypus/platypus.js +3 -17
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/smardex/subgraph-queries.d.ts +1 -0
- package/build/dex/smardex/subgraph-queries.js +17 -0
- package/build/dex/smardex/subgraph-queries.js.map +1 -0
- package/build/dex/smardex/usd-reserves.d.ts +23 -0
- package/build/dex/smardex/usd-reserves.js +86 -0
- package/build/dex/smardex/usd-reserves.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.js +0 -4
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/dex/swaap-v2/config.js +15 -0
- package/build/dex/swaap-v2/config.js.map +1 -1
- package/build/dex/trader-joe-v2-1-2/config.d.ts +4 -0
- package/build/dex/trader-joe-v2-1-2/config.js +47 -0
- package/build/dex/trader-joe-v2-1-2/config.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/constants.d.ts +20 -0
- package/build/dex/trader-joe-v2-1-2/constants.js +22 -0
- package/build/dex/trader-joe-v2-1-2/constants.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/math/index.d.ts +37 -0
- package/build/dex/trader-joe-v2-1-2/math/index.js +291 -0
- package/build/dex/trader-joe-v2-1-2/math/index.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.d.ts +60 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js +248 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.d.ts +53 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js +307 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/types.d.ts +82 -0
- package/build/dex/trader-joe-v2-1-2/types.js +9 -0
- package/build/dex/trader-joe-v2-1-2/types.js.map +1 -0
- package/build/dex/trader-joe-v2_1/config.d.ts +4 -0
- package/build/dex/trader-joe-v2_1/config.js +47 -0
- package/build/dex/trader-joe-v2_1/config.js.map +1 -0
- package/build/dex/trader-joe-v2_1/constants.d.ts +20 -0
- package/build/dex/trader-joe-v2_1/constants.js +22 -0
- package/build/dex/trader-joe-v2_1/constants.js.map +1 -0
- package/build/dex/trader-joe-v2_1/math/index.d.ts +37 -0
- package/build/dex/trader-joe-v2_1/math/index.js +291 -0
- package/build/dex/trader-joe-v2_1/math/index.js.map +1 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.d.ts +0 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js +384 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js.map +1 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.d.ts +60 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js +247 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js.map +1 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.d.ts +53 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js +307 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js.map +1 -0
- package/build/dex/trader-joe-v2_1/types.d.ts +82 -0
- package/build/dex/trader-joe-v2_1/types.js +9 -0
- package/build/dex/trader-joe-v2_1/types.js.map +1 -0
- package/build/dex/wombat/wombat-pool-poller.d.ts +22 -0
- package/build/dex/wombat/wombat-pool-poller.js +164 -0
- package/build/dex/wombat/wombat-pool-poller.js.map +1 -0
- package/build/dex-helper/Cache.d.ts +31 -0
- package/build/dex-helper/Cache.js +106 -0
- package/build/dex-helper/Cache.js.map +1 -0
- package/build/dex-helper/RedisBatcher.d.ts +20 -0
- package/build/dex-helper/RedisBatcher.js +75 -0
- package/build/dex-helper/RedisBatcher.js.map +1 -0
- package/build/dex-helper/RedisWrapper.d.ts +37 -0
- package/build/dex-helper/RedisWrapper.js +165 -0
- package/build/dex-helper/RedisWrapper.js.map +1 -0
- package/build/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/abi/idle-dao/idle-cdo-factory.json +38 -0
- package/src/abi/idle-dao/idle-cdo.json +1245 -0
- package/src/config.ts +12 -5
- package/src/dex/idle-dao/config.ts +574 -0
- package/src/dex/idle-dao/idle-dao-e2e.test.ts +113 -0
- package/src/dex/idle-dao/idle-dao-events.test.ts +133 -0
- package/src/dex/idle-dao/idle-dao-integration.test.ts +166 -0
- package/src/dex/idle-dao/idle-dao-pool.ts +304 -0
- package/src/dex/idle-dao/idle-dao-pooling-pool.ts +87 -0
- package/src/dex/idle-dao/idle-dao.ts +509 -0
- package/src/dex/idle-dao/tokens.ts +117 -0
- package/src/dex/idle-dao/types.ts +48 -0
- package/src/dex/idle-dao/utils.ts +216 -0
- package/src/dex/index.ts +2 -0
- package/src/dex/swaap-v2/config.ts +15 -0
- package/src/dex/swaap-v2/swaap-v2-e2e.test.ts +233 -17
- package/src/dex/swaap-v2/swaap-v2-integration.test.ts +1 -1
- package/src/types.ts +1 -0
- package/tests/constants-e2e.ts +82 -6
- package/.vscode/launch.json +0 -53
- package/.vscode/settings.json +0 -2
- package/.vscode/tasks.json +0 -15
- package/abis.txt +0 -92
- package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +0 -52
- package/build/dex/solidly-v3/scripts/check-event-pool-event.d.ts +0 -1
- 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/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
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Address } from '@paraswap/core';
|
|
2
|
+
import BigNumber from 'bignumber.js';
|
|
3
|
+
|
|
4
|
+
export type PoolState = {
|
|
5
|
+
tokenPrice: BigInt;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type PoolsState = Record<string, PoolState>;
|
|
9
|
+
|
|
10
|
+
export type DexParams = {
|
|
11
|
+
fromBlock: number;
|
|
12
|
+
lendingGasCost: number;
|
|
13
|
+
factoryAddress: Address;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type IdleToken = {
|
|
17
|
+
idleSymbol: string;
|
|
18
|
+
idleAddress: string;
|
|
19
|
+
cdoAddress: string;
|
|
20
|
+
tokenType: 'AA' | 'BB';
|
|
21
|
+
blockNumber: number;
|
|
22
|
+
address: string;
|
|
23
|
+
decimals: number;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type TrancheToken = {
|
|
27
|
+
idleAddress: IdleToken['idleAddress'];
|
|
28
|
+
cdoAddress: IdleToken['cdoAddress'];
|
|
29
|
+
tokenType: IdleToken['tokenType'];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type IdleDaoData = {
|
|
33
|
+
idleToken: IdleToken;
|
|
34
|
+
fromIdleToken: boolean;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type Deposit = [amount: string, referral?: string];
|
|
38
|
+
|
|
39
|
+
export type Withdraw = [amount: string];
|
|
40
|
+
|
|
41
|
+
export type Param = Deposit | Withdraw;
|
|
42
|
+
|
|
43
|
+
export enum PoolFunctions {
|
|
44
|
+
withdrawAA = 'withdrawAA',
|
|
45
|
+
depositAA = 'depositAARef',
|
|
46
|
+
withdrawBB = 'withdrawBB',
|
|
47
|
+
depositBB = 'depositBBRef',
|
|
48
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { endpoints, TOKEN_LISTS } from './config';
|
|
2
|
+
import { BytesLike } from 'ethers';
|
|
3
|
+
import BigNumber from 'bignumber.js';
|
|
4
|
+
import { Interface } from '@ethersproject/abi';
|
|
5
|
+
import { stringDecode, addressDecode, uint8ToNumber } from '../../lib/decoders';
|
|
6
|
+
import {
|
|
7
|
+
MultiCallParams,
|
|
8
|
+
MultiResult,
|
|
9
|
+
MultiWrapper,
|
|
10
|
+
} from '../../lib/multi-wrapper';
|
|
11
|
+
import { IdleToken, TrancheToken } from './types';
|
|
12
|
+
import axios from 'axios';
|
|
13
|
+
import { Network } from '../../constants';
|
|
14
|
+
import { IDexHelper } from '../../dex-helper';
|
|
15
|
+
|
|
16
|
+
export const BNify = (s: any): BigNumber =>
|
|
17
|
+
new BigNumber(typeof s === 'object' ? s : String(s));
|
|
18
|
+
|
|
19
|
+
async function _getIdleTokenSymbols(
|
|
20
|
+
blockNumber: number,
|
|
21
|
+
idleTokens: string[],
|
|
22
|
+
erc20Interface: Interface,
|
|
23
|
+
multiWrapper: MultiWrapper,
|
|
24
|
+
): Promise<any> {
|
|
25
|
+
let calls: MultiCallParams<any>[] = [];
|
|
26
|
+
|
|
27
|
+
for (const idleAddress of idleTokens) {
|
|
28
|
+
calls.push({
|
|
29
|
+
target: idleAddress,
|
|
30
|
+
callData: erc20Interface.encodeFunctionData('symbol', []),
|
|
31
|
+
decodeFunction: (result: MultiResult<BytesLike> | BytesLike): any => {
|
|
32
|
+
return {
|
|
33
|
+
idleAddress,
|
|
34
|
+
idleSymbol: stringDecode(result),
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const results = await multiWrapper.aggregate<any>(calls, blockNumber);
|
|
40
|
+
|
|
41
|
+
return results.reduce((output, item) => {
|
|
42
|
+
return {
|
|
43
|
+
...output,
|
|
44
|
+
[item.idleAddress]: item.idleSymbol,
|
|
45
|
+
};
|
|
46
|
+
}, {});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function _getIdleTokenDecimals(
|
|
50
|
+
blockNumber: number,
|
|
51
|
+
underlyingTokens: string[],
|
|
52
|
+
erc20Interface: Interface,
|
|
53
|
+
multiWrapper: MultiWrapper,
|
|
54
|
+
): Promise<any> {
|
|
55
|
+
let calls: MultiCallParams<any>[] = [];
|
|
56
|
+
|
|
57
|
+
for (const address of underlyingTokens) {
|
|
58
|
+
calls.push({
|
|
59
|
+
target: address,
|
|
60
|
+
callData: erc20Interface.encodeFunctionData('decimals', []),
|
|
61
|
+
decodeFunction: (result: MultiResult<BytesLike> | BytesLike): any => {
|
|
62
|
+
return {
|
|
63
|
+
address,
|
|
64
|
+
decimals: uint8ToNumber(result),
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const results = await multiWrapper.aggregate<any>(calls, blockNumber);
|
|
70
|
+
|
|
71
|
+
return results.reduce((output, item) => {
|
|
72
|
+
return {
|
|
73
|
+
...output,
|
|
74
|
+
[item.address]: item.decimals,
|
|
75
|
+
};
|
|
76
|
+
}, {});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const getDataWithAuth = async (
|
|
80
|
+
endpoint: string,
|
|
81
|
+
token: string,
|
|
82
|
+
error_callback?: Function,
|
|
83
|
+
) => {
|
|
84
|
+
const config = {
|
|
85
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const data = await axios.post(endpoint, {}, config).catch(err => {
|
|
89
|
+
if (typeof error_callback === 'function') {
|
|
90
|
+
error_callback(err);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return data?.data;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const fetchTokenList_api = async (
|
|
97
|
+
network: Network,
|
|
98
|
+
dexHelper: IDexHelper,
|
|
99
|
+
blockNumber: number,
|
|
100
|
+
cdoInterface: Interface,
|
|
101
|
+
erc20Interface: Interface,
|
|
102
|
+
multiWrapper: MultiWrapper,
|
|
103
|
+
token: string,
|
|
104
|
+
): Promise<IdleToken[]> => {
|
|
105
|
+
// const AUTH_TOKEN_DECODED = atob(idleDaoAuthToken!);
|
|
106
|
+
const data = await getDataWithAuth(endpoints[network], token);
|
|
107
|
+
// console.log('api_response_data', data);
|
|
108
|
+
|
|
109
|
+
// Fetch tokenslist from static file
|
|
110
|
+
if (!data) {
|
|
111
|
+
return TOKEN_LISTS;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const deployedContract = data
|
|
115
|
+
.filter((d: any) => !!d.cdoAddress)
|
|
116
|
+
.map((d: any) => d.cdoAddress);
|
|
117
|
+
|
|
118
|
+
const calls = deployedContract.reduce(
|
|
119
|
+
(calls: MultiCallParams<any>[], cdoAddress: string) => {
|
|
120
|
+
calls.push({
|
|
121
|
+
target: cdoAddress,
|
|
122
|
+
callData: cdoInterface.encodeFunctionData('AATranche', []),
|
|
123
|
+
decodeFunction: (
|
|
124
|
+
result: MultiResult<BytesLike> | BytesLike,
|
|
125
|
+
): TrancheToken => {
|
|
126
|
+
return {
|
|
127
|
+
cdoAddress,
|
|
128
|
+
tokenType: 'AA',
|
|
129
|
+
idleAddress: addressDecode(result),
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
calls.push({
|
|
135
|
+
target: cdoAddress,
|
|
136
|
+
callData: cdoInterface.encodeFunctionData('BBTranche', []),
|
|
137
|
+
decodeFunction: (
|
|
138
|
+
result: MultiResult<BytesLike> | BytesLike,
|
|
139
|
+
): TrancheToken => {
|
|
140
|
+
return {
|
|
141
|
+
cdoAddress,
|
|
142
|
+
tokenType: 'BB',
|
|
143
|
+
idleAddress: addressDecode(result),
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
calls.push({
|
|
149
|
+
target: cdoAddress,
|
|
150
|
+
callData: cdoInterface.encodeFunctionData('token', []),
|
|
151
|
+
decodeFunction: (result: MultiResult<BytesLike> | BytesLike): any => {
|
|
152
|
+
return {
|
|
153
|
+
cdoAddress,
|
|
154
|
+
address: addressDecode(result),
|
|
155
|
+
};
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
return calls;
|
|
160
|
+
},
|
|
161
|
+
[],
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const results = await multiWrapper.aggregate<Record<string, string>>(
|
|
165
|
+
calls,
|
|
166
|
+
blockNumber,
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
const cdosUnderlying: Record<string, string> = results.reduce(
|
|
170
|
+
(cdosUnderlying, result: any) => {
|
|
171
|
+
if (!result.address) return cdosUnderlying;
|
|
172
|
+
return {
|
|
173
|
+
...cdosUnderlying,
|
|
174
|
+
[result.cdoAddress]: result.address,
|
|
175
|
+
};
|
|
176
|
+
},
|
|
177
|
+
{},
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
const idleTokenSymbolsList = await _getIdleTokenSymbols(
|
|
181
|
+
blockNumber,
|
|
182
|
+
results
|
|
183
|
+
.filter(result => !!result.tokenType)
|
|
184
|
+
.map(result => result.idleAddress),
|
|
185
|
+
erc20Interface,
|
|
186
|
+
multiWrapper,
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
const idleTokenDecimals = await _getIdleTokenDecimals(
|
|
190
|
+
blockNumber,
|
|
191
|
+
results.filter(result => !result.tokenType).map(result => result.address),
|
|
192
|
+
erc20Interface,
|
|
193
|
+
multiWrapper,
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
// console.log('idleTokenDecimals', idleTokenDecimals)
|
|
197
|
+
// console.log('cdosUnderlying', cdosUnderlying)
|
|
198
|
+
|
|
199
|
+
const output: IdleToken[] = [];
|
|
200
|
+
for (const result of results) {
|
|
201
|
+
if (result.tokenType) {
|
|
202
|
+
const idleToken: IdleToken = {
|
|
203
|
+
decimals: 18,
|
|
204
|
+
blockNumber: 0,
|
|
205
|
+
cdoAddress: result.cdoAddress,
|
|
206
|
+
idleAddress: result.idleAddress,
|
|
207
|
+
address: cdosUnderlying[result.cdoAddress],
|
|
208
|
+
idleSymbol: idleTokenSymbolsList[result.idleAddress],
|
|
209
|
+
tokenType: result.tokenType as IdleToken['tokenType'],
|
|
210
|
+
};
|
|
211
|
+
output.push(idleToken);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return output;
|
|
216
|
+
};
|
package/src/dex/index.ts
CHANGED
|
@@ -25,6 +25,7 @@ import { Onebit } from './onebit/onebit';
|
|
|
25
25
|
import { Compound } from './compound/compound';
|
|
26
26
|
import { AaveV2 } from './aave-v2/aave-v2';
|
|
27
27
|
import { AaveV3 } from './aave-v3/aave-v3';
|
|
28
|
+
import { IdleDao } from './idle-dao/idle-dao';
|
|
28
29
|
import { OneInchLp } from './OneInchLp';
|
|
29
30
|
import { DodoV1 } from './dodo-v1/dodo-v1';
|
|
30
31
|
import { DodoV2 } from './dodo-v2';
|
|
@@ -126,6 +127,7 @@ const Dexes = [
|
|
|
126
127
|
Excalibur,
|
|
127
128
|
AaveV2,
|
|
128
129
|
AaveV3,
|
|
130
|
+
IdleDao,
|
|
129
131
|
KyberDmm,
|
|
130
132
|
Weth,
|
|
131
133
|
PolygonMigrator,
|
|
@@ -7,6 +7,9 @@ export const SwaapV2Config: DexConfigMap<DexParams> = {
|
|
|
7
7
|
[Network.MAINNET]: {},
|
|
8
8
|
[Network.POLYGON]: {},
|
|
9
9
|
[Network.ARBITRUM]: {},
|
|
10
|
+
[Network.BASE]: {},
|
|
11
|
+
[Network.BSC]: {},
|
|
12
|
+
[Network.OPTIMISM]: {},
|
|
10
13
|
},
|
|
11
14
|
};
|
|
12
15
|
|
|
@@ -23,4 +26,16 @@ export const Adapters: Record<number, AdapterMappings> = {
|
|
|
23
26
|
[SwapSide.SELL]: [{ name: 'ArbitrumAdapter02', index: 6 }],
|
|
24
27
|
[SwapSide.BUY]: [{ name: 'ArbitrumBuyAdapter', index: 8 }],
|
|
25
28
|
},
|
|
29
|
+
[Network.BASE]: {
|
|
30
|
+
[SwapSide.SELL]: [{ name: 'BaseAdapter02', index: 1 }],
|
|
31
|
+
[SwapSide.BUY]: [{ name: 'BaseBuyAdapter', index: 8 }],
|
|
32
|
+
},
|
|
33
|
+
[Network.BSC]: {
|
|
34
|
+
[SwapSide.SELL]: [{ name: 'BscAdapter02', index: 11 }],
|
|
35
|
+
[SwapSide.BUY]: [{ name: 'BscBuyAdapter', index: 9 }],
|
|
36
|
+
},
|
|
37
|
+
[Network.OPTIMISM]: {
|
|
38
|
+
[SwapSide.SELL]: [{ name: 'OptimismAdapter02', index: 2 }],
|
|
39
|
+
[SwapSide.BUY]: [{ name: 'OptimismBuyAdapter', index: 7 }],
|
|
40
|
+
},
|
|
26
41
|
};
|
|
@@ -60,18 +60,6 @@ describe('SwaapV2 E2E', () => {
|
|
|
60
60
|
buyAmount: '100000000',
|
|
61
61
|
},
|
|
62
62
|
],
|
|
63
|
-
[
|
|
64
|
-
{
|
|
65
|
-
name: 'USDT',
|
|
66
|
-
sellAmount: '45410357',
|
|
67
|
-
buyAmount: '100000000',
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: 'USDC',
|
|
71
|
-
sellAmount: '100000000',
|
|
72
|
-
buyAmount: '100000000',
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
63
|
];
|
|
76
64
|
|
|
77
65
|
sideToContractMethods.forEach((contractMethods, side) =>
|
|
@@ -138,7 +126,7 @@ describe('SwaapV2 E2E', () => {
|
|
|
138
126
|
const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [
|
|
139
127
|
[
|
|
140
128
|
{
|
|
141
|
-
name: '
|
|
129
|
+
name: 'USDCe',
|
|
142
130
|
sellAmount: '45410357',
|
|
143
131
|
buyAmount: '1000000000000000000',
|
|
144
132
|
},
|
|
@@ -155,7 +143,7 @@ describe('SwaapV2 E2E', () => {
|
|
|
155
143
|
buyAmount: '100000000',
|
|
156
144
|
},
|
|
157
145
|
{
|
|
158
|
-
name: '
|
|
146
|
+
name: 'USDCe',
|
|
159
147
|
sellAmount: '100000000',
|
|
160
148
|
buyAmount: '150000000000000000000',
|
|
161
149
|
},
|
|
@@ -167,7 +155,7 @@ describe('SwaapV2 E2E', () => {
|
|
|
167
155
|
buyAmount: '100000000',
|
|
168
156
|
},
|
|
169
157
|
{
|
|
170
|
-
name: '
|
|
158
|
+
name: 'USDCe',
|
|
171
159
|
sellAmount: '100000000',
|
|
172
160
|
buyAmount: '150000000000000000000',
|
|
173
161
|
},
|
|
@@ -243,9 +231,237 @@ describe('SwaapV2 E2E', () => {
|
|
|
243
231
|
buyAmount: '1000000000000000000',
|
|
244
232
|
},
|
|
245
233
|
{
|
|
246
|
-
name: '
|
|
234
|
+
name: 'USDC',
|
|
235
|
+
sellAmount: '1000000',
|
|
236
|
+
buyAmount: '1000000',
|
|
237
|
+
},
|
|
238
|
+
],
|
|
239
|
+
];
|
|
240
|
+
|
|
241
|
+
sideToContractMethods.forEach((contractMethods, side) =>
|
|
242
|
+
describe(`${side}`, () => {
|
|
243
|
+
contractMethods.forEach((contractMethod: ContractMethod) => {
|
|
244
|
+
pairs.forEach(pair => {
|
|
245
|
+
describe(`${contractMethod}`, () => {
|
|
246
|
+
it(`${pair[0].name} -> ${pair[1].name}`, async () => {
|
|
247
|
+
await testE2E(
|
|
248
|
+
tokens[pair[0].name],
|
|
249
|
+
tokens[pair[1].name],
|
|
250
|
+
holders[pair[0].name],
|
|
251
|
+
side === SwapSide.SELL
|
|
252
|
+
? pair[0].sellAmount
|
|
253
|
+
: pair[0].buyAmount,
|
|
254
|
+
side,
|
|
255
|
+
dexKey,
|
|
256
|
+
contractMethod,
|
|
257
|
+
network,
|
|
258
|
+
provider,
|
|
259
|
+
undefined,
|
|
260
|
+
undefined,
|
|
261
|
+
undefined,
|
|
262
|
+
undefined,
|
|
263
|
+
sleepMs,
|
|
264
|
+
);
|
|
265
|
+
});
|
|
266
|
+
it(`${pair[1].name} -> ${pair[0].name}`, async () => {
|
|
267
|
+
await testE2E(
|
|
268
|
+
tokens[pair[1].name],
|
|
269
|
+
tokens[pair[0].name],
|
|
270
|
+
holders[pair[1].name],
|
|
271
|
+
side === SwapSide.SELL
|
|
272
|
+
? pair[1].sellAmount
|
|
273
|
+
: pair[1].buyAmount,
|
|
274
|
+
side,
|
|
275
|
+
dexKey,
|
|
276
|
+
contractMethod,
|
|
277
|
+
network,
|
|
278
|
+
provider,
|
|
279
|
+
undefined,
|
|
280
|
+
undefined,
|
|
281
|
+
undefined,
|
|
282
|
+
undefined,
|
|
283
|
+
sleepMs,
|
|
284
|
+
);
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
}),
|
|
290
|
+
);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
describe.only('Base', () => {
|
|
294
|
+
const network = Network.BASE;
|
|
295
|
+
const provider = new StaticJsonRpcProvider(
|
|
296
|
+
generateConfig(network).privateHttpProvider,
|
|
297
|
+
network,
|
|
298
|
+
);
|
|
299
|
+
const tokens = Tokens[network];
|
|
300
|
+
const holders = Holders[network];
|
|
301
|
+
|
|
302
|
+
const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [
|
|
303
|
+
[
|
|
304
|
+
{
|
|
305
|
+
name: 'AERO',
|
|
306
|
+
sellAmount: '100000000000000000000',
|
|
307
|
+
buyAmount: '100000000',
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
name: 'USDC',
|
|
311
|
+
sellAmount: '100000000',
|
|
312
|
+
buyAmount: '100000000000000000000',
|
|
313
|
+
},
|
|
314
|
+
],
|
|
315
|
+
];
|
|
316
|
+
|
|
317
|
+
sideToContractMethods.forEach((contractMethods, side) =>
|
|
318
|
+
describe(`${side}`, () => {
|
|
319
|
+
contractMethods.forEach((contractMethod: ContractMethod) => {
|
|
320
|
+
pairs.forEach(pair => {
|
|
321
|
+
describe(`${contractMethod}`, () => {
|
|
322
|
+
it(`${pair[0].name} -> ${pair[1].name}`, async () => {
|
|
323
|
+
await testE2E(
|
|
324
|
+
tokens[pair[0].name],
|
|
325
|
+
tokens[pair[1].name],
|
|
326
|
+
holders[pair[0].name],
|
|
327
|
+
side === SwapSide.SELL
|
|
328
|
+
? pair[0].sellAmount
|
|
329
|
+
: pair[0].buyAmount,
|
|
330
|
+
side,
|
|
331
|
+
dexKey,
|
|
332
|
+
contractMethod,
|
|
333
|
+
network,
|
|
334
|
+
provider,
|
|
335
|
+
undefined,
|
|
336
|
+
undefined,
|
|
337
|
+
undefined,
|
|
338
|
+
undefined,
|
|
339
|
+
sleepMs,
|
|
340
|
+
);
|
|
341
|
+
});
|
|
342
|
+
it(`${pair[1].name} -> ${pair[0].name}`, async () => {
|
|
343
|
+
await testE2E(
|
|
344
|
+
tokens[pair[1].name],
|
|
345
|
+
tokens[pair[0].name],
|
|
346
|
+
holders[pair[1].name],
|
|
347
|
+
side === SwapSide.SELL
|
|
348
|
+
? pair[1].sellAmount
|
|
349
|
+
: pair[1].buyAmount,
|
|
350
|
+
side,
|
|
351
|
+
dexKey,
|
|
352
|
+
contractMethod,
|
|
353
|
+
network,
|
|
354
|
+
provider,
|
|
355
|
+
undefined,
|
|
356
|
+
undefined,
|
|
357
|
+
undefined,
|
|
358
|
+
undefined,
|
|
359
|
+
sleepMs,
|
|
360
|
+
);
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
}),
|
|
366
|
+
);
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
describe.only('BSC', () => {
|
|
370
|
+
const network = Network.BSC;
|
|
371
|
+
const provider = new StaticJsonRpcProvider(
|
|
372
|
+
generateConfig(network).privateHttpProvider,
|
|
373
|
+
network,
|
|
374
|
+
);
|
|
375
|
+
const tokens = Tokens[network];
|
|
376
|
+
const holders = Holders[network];
|
|
377
|
+
|
|
378
|
+
const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [
|
|
379
|
+
[
|
|
380
|
+
{
|
|
381
|
+
name: 'WBNB',
|
|
247
382
|
sellAmount: '1000000000000000000',
|
|
248
|
-
buyAmount: '
|
|
383
|
+
buyAmount: '100000000000000000000',
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
name: 'USDT',
|
|
387
|
+
sellAmount: '100000000000000000000',
|
|
388
|
+
buyAmount: '1000000000000000000',
|
|
389
|
+
},
|
|
390
|
+
],
|
|
391
|
+
];
|
|
392
|
+
|
|
393
|
+
sideToContractMethods.forEach((contractMethods, side) =>
|
|
394
|
+
describe(`${side}`, () => {
|
|
395
|
+
contractMethods.forEach((contractMethod: ContractMethod) => {
|
|
396
|
+
pairs.forEach(pair => {
|
|
397
|
+
describe(`${contractMethod}`, () => {
|
|
398
|
+
it(`${pair[0].name} -> ${pair[1].name}`, async () => {
|
|
399
|
+
await testE2E(
|
|
400
|
+
tokens[pair[0].name],
|
|
401
|
+
tokens[pair[1].name],
|
|
402
|
+
holders[pair[0].name],
|
|
403
|
+
side === SwapSide.SELL
|
|
404
|
+
? pair[0].sellAmount
|
|
405
|
+
: pair[0].buyAmount,
|
|
406
|
+
side,
|
|
407
|
+
dexKey,
|
|
408
|
+
contractMethod,
|
|
409
|
+
network,
|
|
410
|
+
provider,
|
|
411
|
+
undefined,
|
|
412
|
+
undefined,
|
|
413
|
+
undefined,
|
|
414
|
+
undefined,
|
|
415
|
+
sleepMs,
|
|
416
|
+
);
|
|
417
|
+
});
|
|
418
|
+
it(`${pair[1].name} -> ${pair[0].name}`, async () => {
|
|
419
|
+
await testE2E(
|
|
420
|
+
tokens[pair[1].name],
|
|
421
|
+
tokens[pair[0].name],
|
|
422
|
+
holders[pair[1].name],
|
|
423
|
+
side === SwapSide.SELL
|
|
424
|
+
? pair[1].sellAmount
|
|
425
|
+
: pair[1].buyAmount,
|
|
426
|
+
side,
|
|
427
|
+
dexKey,
|
|
428
|
+
contractMethod,
|
|
429
|
+
network,
|
|
430
|
+
provider,
|
|
431
|
+
undefined,
|
|
432
|
+
undefined,
|
|
433
|
+
undefined,
|
|
434
|
+
undefined,
|
|
435
|
+
sleepMs,
|
|
436
|
+
);
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
});
|
|
441
|
+
}),
|
|
442
|
+
);
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
describe.only('Optimism', () => {
|
|
446
|
+
const network = Network.OPTIMISM;
|
|
447
|
+
const provider = new StaticJsonRpcProvider(
|
|
448
|
+
generateConfig(network).privateHttpProvider,
|
|
449
|
+
network,
|
|
450
|
+
);
|
|
451
|
+
const tokens = Tokens[network];
|
|
452
|
+
const holders = Holders[network];
|
|
453
|
+
|
|
454
|
+
const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [
|
|
455
|
+
[
|
|
456
|
+
{
|
|
457
|
+
name: 'WETH',
|
|
458
|
+
sellAmount: '1000000000000000000',
|
|
459
|
+
buyAmount: '100000000',
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
name: 'USDC',
|
|
463
|
+
sellAmount: '45410357',
|
|
464
|
+
buyAmount: '1000000000000000000',
|
|
249
465
|
},
|
|
250
466
|
],
|
|
251
467
|
];
|