@defisaver/sdk 0.2.11 → 0.3.0
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/index.js +11 -2
- package/package.json +4 -4
- package/src/Action.js +14 -5
- package/src/ActionWithL2.js +36 -0
- package/src/actions/aaveV3/AaveV3ATokenPaybackAction.js +58 -0
- package/src/actions/aaveV3/AaveV3BorrowAction.js +59 -0
- package/src/actions/aaveV3/AaveV3ClaimRewardsAction.js +45 -0
- package/src/actions/aaveV3/AaveV3CollateralSwitchAction.js +45 -0
- package/src/actions/aaveV3/AaveV3PaybackAction.js +68 -0
- package/src/actions/aaveV3/AaveV3SetEModeAction.js +40 -0
- package/src/actions/aaveV3/AaveV3SupplyAction.js +69 -0
- package/src/actions/aaveV3/AaveV3SwapBorrowRateModeAction.js +43 -0
- package/src/actions/aaveV3/AaveV3WithdrawAction.js +46 -0
- package/src/actions/aaveV3/index.js +21 -0
- package/src/actions/basic/SellAction.js +11 -5
- package/src/actions/basic/SendTokenAction.js +0 -1
- package/src/actions/basic/UnwrapEthAction.js +10 -2
- package/src/actions/basic/WrapEthAction.js +10 -3
- package/src/actions/compound/CompoundPaybackAction.js +1 -1
- package/src/actions/flashloan/AaveV3FlashLoanAction.js +26 -0
- package/src/actions/flashloan/AaveV3FlashLoanPaybackAction.js +17 -0
- package/src/actions/flashloan/index.js +4 -0
- package/src/actions/index.js +2 -0
- package/src/addresses.js +224 -152
- package/src/config.js +83 -0
- package/src/types.js +33 -0
- package/test/index.js +4 -1
- package/package-lock.json +0 -5415
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const
|
|
1
|
+
const ActionWithL2 = require("../../ActionWithL2");
|
|
2
2
|
const {requireAddress} = require("../../utils/general");
|
|
3
3
|
const {getAddr} = require('../../addresses.js');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Unwraps a specified amount of WETH from the proxy
|
|
7
7
|
*/
|
|
8
|
-
class UnwrapEthAction extends
|
|
8
|
+
class UnwrapEthAction extends ActionWithL2 {
|
|
9
9
|
/**
|
|
10
10
|
* @param amount {string} Token address
|
|
11
11
|
* @param to {string} Transfer recipient
|
|
@@ -22,6 +22,14 @@ class UnwrapEthAction extends Action {
|
|
|
22
22
|
[...arguments]
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
|
+
encodeInputs(){
|
|
26
|
+
// executeActionDirectL2
|
|
27
|
+
let encodedInput = "0x2895f3aa";
|
|
28
|
+
// amount
|
|
29
|
+
encodedInput = encodedInput.concat(this.numberToBytes32(this.args[0][0]));
|
|
30
|
+
// to
|
|
31
|
+
encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][1]));
|
|
32
|
+
}
|
|
25
33
|
}
|
|
26
34
|
|
|
27
35
|
module.exports = UnwrapEthAction;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
2
|
-
const {getAddr} = require("../../addresses.js");
|
|
1
|
+
const ActionWithL2 = require("../../ActionWithL2");
|
|
2
|
+
const { getAddr } = require("../../addresses.js");
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Wraps a specified amount of ETH from the wallet to WETH on the recipe
|
|
6
6
|
*/
|
|
7
|
-
class WrapEthAction extends
|
|
7
|
+
class WrapEthAction extends ActionWithL2 {
|
|
8
8
|
/**
|
|
9
9
|
* @param amount {string} Transfer amount
|
|
10
10
|
*/
|
|
@@ -15,6 +15,13 @@ class WrapEthAction extends Action {
|
|
|
15
15
|
async getEthValue() {
|
|
16
16
|
return this.args[0];
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
encodeInputs() {
|
|
20
|
+
// executeActionDirectL2
|
|
21
|
+
let encodedInput = "0x2895f3aa";
|
|
22
|
+
// amount
|
|
23
|
+
encodedInput = encodedInput.concat(this.numberToBytes32(this.args[0]));
|
|
24
|
+
}
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
module.exports = WrapEthAction;
|
|
@@ -13,7 +13,7 @@ class CompoundPaybackAction extends Action {
|
|
|
13
13
|
* @param onBehalf {EthAddress} Defaults to DsProxy address if 0x0
|
|
14
14
|
*/
|
|
15
15
|
constructor(cTokenAddr, amount, from, onBehalf = getAddr('Empty')) {
|
|
16
|
-
super('
|
|
16
|
+
super('CompPayback', getAddr('CompPayback'), ['address', 'uint256', 'address', 'address'], [cTokenAddr, amount, from, onBehalf]);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
async getAssetsToApprove() {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const ActionWithL2 = require("../../ActionWithL2");
|
|
2
|
+
const { getAddr } = require('../../addresses.js');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Gets a flashloan from Aave v2
|
|
6
|
+
*/
|
|
7
|
+
class AaveV3FlashLoanAction extends ActionWithL2 {
|
|
8
|
+
/**
|
|
9
|
+
* @param loanAmounts {Array<string>}
|
|
10
|
+
* @param tokens {Array<EthAddress>}
|
|
11
|
+
* @param modes {Array<number>}
|
|
12
|
+
* @param loanPayer {EthAddress}
|
|
13
|
+
* @param flParamGetterAddr {EthAddress}
|
|
14
|
+
* @param flParamGetterData {bytes}
|
|
15
|
+
*/
|
|
16
|
+
constructor(loanAmounts, tokens, modes, loanPayer, flParamGetterAddr = getAddr('Empty'), flParamGetterData= []) {
|
|
17
|
+
super(
|
|
18
|
+
'FLAaveV3',
|
|
19
|
+
getAddr('FLAaveV3'),
|
|
20
|
+
['address[]','uint256[]', 'uint256[]', 'address', 'address', 'bytes', 'bytes'],
|
|
21
|
+
[tokens, loanAmounts, modes, loanPayer, flParamGetterAddr, flParamGetterData, []]
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = AaveV3FlashLoanAction;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const SendTokenAction = require("../basic/SendTokenAction");
|
|
2
|
+
const { getAddr } = require('../../addresses.js');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Pays back a single flashloan from Aave v3
|
|
6
|
+
*/
|
|
7
|
+
class AaveV3FlashLoanPaybackAction extends SendTokenAction {
|
|
8
|
+
/**
|
|
9
|
+
* @param loanAmount {string}
|
|
10
|
+
* @param tokenAddr {EthAddress}
|
|
11
|
+
*/
|
|
12
|
+
constructor(loanAmount, tokenAddr) {
|
|
13
|
+
super(tokenAddr, getAddr('FLAaveV3'), loanAmount);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = AaveV3FlashLoanPaybackAction;
|
|
@@ -2,6 +2,8 @@ const DyDxFlashLoanAction = require('./DyDxFlashLoanAction');
|
|
|
2
2
|
const DyDxFlashLoanPaybackAction = require('./DyDxFlashLoanPaybackAction');
|
|
3
3
|
const AaveV2FlashLoanAction = require('./AaveV2FlashLoanAction');
|
|
4
4
|
const AaveV2FlashLoanPaybackAction = require('./AaveV2FlashLoanPaybackAction');
|
|
5
|
+
const AaveV3FlashLoanAction = require('./AaveV3FlashLoanAction');
|
|
6
|
+
const AaveV3FlashLoanPaybackAction = require('./AaveV3FlashLoanPaybackAction');
|
|
5
7
|
const MakerFlashLoanAction = require('./MakerFlashLoanAction');
|
|
6
8
|
const MakerFlashLoanPaybackAction = require('./MakerFlashLoanPaybackAction');
|
|
7
9
|
const BalancerFlashLoanAction = require('./BalancerFlashLoanAction');
|
|
@@ -12,6 +14,8 @@ module.exports = {
|
|
|
12
14
|
DyDxFlashLoanPaybackAction,
|
|
13
15
|
AaveV2FlashLoanAction,
|
|
14
16
|
AaveV2FlashLoanPaybackAction,
|
|
17
|
+
AaveV3FlashLoanAction,
|
|
18
|
+
AaveV3FlashLoanPaybackAction,
|
|
15
19
|
MakerFlashLoanAction,
|
|
16
20
|
MakerFlashLoanPaybackAction,
|
|
17
21
|
BalancerFlashLoanAction,
|
package/src/actions/index.js
CHANGED
|
@@ -17,6 +17,7 @@ const curve = require('./curve');
|
|
|
17
17
|
const guni = require('./guni');
|
|
18
18
|
const mstable = require('./mstable');
|
|
19
19
|
const rari = require('./rari');
|
|
20
|
+
const aaveV3 = require('./aaveV3');
|
|
20
21
|
const convex = require('./convex');
|
|
21
22
|
|
|
22
23
|
module.exports = {
|
|
@@ -39,5 +40,6 @@ module.exports = {
|
|
|
39
40
|
guni,
|
|
40
41
|
mstable,
|
|
41
42
|
rari,
|
|
43
|
+
aaveV3,
|
|
42
44
|
convex,
|
|
43
45
|
};
|
package/src/addresses.js
CHANGED
|
@@ -1,163 +1,235 @@
|
|
|
1
|
-
|
|
1
|
+
const { CONFIG, NETWORKS } = require('./config');
|
|
2
2
|
|
|
3
3
|
const actionAddresses = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
4
|
+
[NETWORKS.ethereum.chainId]: {
|
|
5
|
+
// utils
|
|
6
|
+
WrapEth: '0x8EbBd35f84D7f0DFCBEf08fD30CD09176133251A',
|
|
7
|
+
UnwrapEth: '0xDB6C8cFDd7c1C0F8895CDBC01Dbf4A6D4B6d2a29',
|
|
8
|
+
PullToken: '0x254cA89a00d53ab61de2Ba5641DBDC01aE48aed4',
|
|
9
|
+
SendToken: '0x5612e490c9549486dF16b34EBfD0E8b6cF6a1717',
|
|
10
|
+
SumInputs: '0x70907d840aBBc984Fd949311d2f005e6aC4a4D7a',
|
|
11
|
+
SubInputs: '0xe1804b756188F63f723d2FECc02988D0Cc1aB823',
|
|
12
|
+
ChangeProxyOwner: '0x81cA52CfE66421d0ceF82d5F33230e43b5F23D2B',
|
|
13
|
+
TokenBalance: '0xa92B177950F1460119940436515FD857C24494BC',
|
|
14
|
+
AutomationV2Unsub: '0xe35Fb12fE9796847751076aCf5ee7d124108612C',
|
|
15
|
+
SendTokenAndUnwrap: '0xeecd376026335261c89faD40D89625391b1eFF6a',
|
|
16
|
+
ToggleSub: '0x9A78E9d6538cfDbA0242Ca5eC46771E6132E8085',
|
|
17
|
+
UpdateSub: '0x94D707f411B852082a5ce49C3f47c49c7757761f',
|
|
18
|
+
|
|
19
|
+
// exchange
|
|
20
|
+
DFSSell: '0xB744474Bdd7226736ACa4Ba87593e32d8315e5c9',
|
|
21
|
+
|
|
22
|
+
// maker
|
|
23
|
+
McdGenerate: '0xCb50a91C0f12f439b8bf11E9474B9c1ED62Bf7a3',
|
|
24
|
+
McdGive: '0xf9556A87BF424834FDe7De0547b58E36Cb42EF01',
|
|
25
|
+
McdMerge: '0x6D06C6c2BCeaEC31b0F8Cd68C594120dDCcCC427',
|
|
26
|
+
McdOpen: '0x1b54e8b6073ac7382c42830BE715466aDA11Cf37',
|
|
27
|
+
McdPayback: '0xE68AeD979Af6f85516fF485D098804c0f9eD9A5b',
|
|
28
|
+
McdSupply: '0x84372e73e1A2E95510869D2D81A3ef1AEC9e0Da8',
|
|
29
|
+
McdWithdraw: '0xa704FBBe2f7ea8eF45a8280f6Bf96939eBC73252',
|
|
30
|
+
McdClaim: '0xc0FC0f5Ba156E16217F8C7f400AEc0a658419C13',
|
|
31
|
+
|
|
32
|
+
// reflexer
|
|
33
|
+
ReflexerSupply: '0xd7a36CD4ce7CCc2F1376Dc5C48BaC84380A4f698',
|
|
34
|
+
ReflexerWithdraw: '0xD8a14d447AB6789F3bf1Eb763b6306db3FC3d666',
|
|
35
|
+
ReflexerPayback: '0xcC6838d8a61a4b29Ea565d39C38b830f1491cb29',
|
|
36
|
+
ReflexerGenerate: '0x8e8Fd178A5FAE3A29F9CB1A06aBBBCFd5B83beb7',
|
|
37
|
+
ReflexerOpen: '0x4704a7cBd4d913d1233765B70531D601b4384011',
|
|
38
|
+
|
|
39
|
+
// not deployed as currently not used
|
|
40
|
+
ReflexerNativeUniV2SaviourDeposit: '0x0000000000000000000000000000000000000000',
|
|
41
|
+
ReflexerNativeUniV2SaviourGetReserves: '0x0000000000000000000000000000000000000000',
|
|
42
|
+
ReflexerNativeUniV2SaviourWithdraw: '0x0000000000000000000000000000000000000000',
|
|
43
|
+
|
|
44
|
+
// aave
|
|
45
|
+
AaveBorrow: '0x1B95E800a869bc3F89914470a7901D93D1401cD1',
|
|
46
|
+
AavePayback: '0x066225964999F1D07C888c5Ac4a6C885bDa88b9A',
|
|
47
|
+
AaveSupply: '0xEbB200a529058B561B42Eab510DA157a63243CEc',
|
|
48
|
+
AaveWithdraw: '0x754C58fA92246414a448c1ed44ea3D1AD446d482',
|
|
49
|
+
AaveCollateralSwitch: '0xFf5dfF1B90bd5Aa6E12768AB497dB90cc9DE6F5d',
|
|
50
|
+
|
|
51
|
+
// compound
|
|
52
|
+
CompBorrow: '0x8495579BF6Ae848f7E59686536F834f1d2CCd79C',
|
|
53
|
+
CompClaim: '0x81F488cF7A0128A9DB5e7207042cCAB1CB0ac902',
|
|
54
|
+
CompPayback: '0xa2Fa682f44BE40a11d69Eb738CBB91148f0D9742',
|
|
55
|
+
CompSupply: '0xB4CEDe40b249b756Ce0EAa3e14F6af89f25f9a3d',
|
|
56
|
+
CompWithdraw: '0x3792F83D6A82091cb53052458038CC86e206463F',
|
|
57
|
+
CompGetDebt: '0xc2B8f8423bc8Fe2e9A44cA9d364d835D1751b725',
|
|
58
|
+
CompCollateralSwitch: '0xC3d89139508A3883775D3d1E62E2A0fea363b448',
|
|
59
|
+
|
|
60
|
+
// flashloan
|
|
61
|
+
FLAaveV2: '0xa4d52ED15018a5be4adE5796899e5d75cc8759C1',
|
|
62
|
+
FLDyDx: '0x08AC78B418fCB0DDF1096533856A757C28d430d7',
|
|
63
|
+
FLMaker: '0xd393582bE148A45585aB202Fa7Cc789Fa5127223',
|
|
64
|
+
FLBalancer: '0x5C7a9f4635AE4F95da2e45317311AAe255FB71B3',
|
|
65
|
+
|
|
66
|
+
// uniswap
|
|
67
|
+
UniSupply: '0x9935e12F0218E61c27D7f23eAC9A9D6881a078eC',
|
|
68
|
+
UniWithdraw: '0xf8bb8F68b0A45DC315F3f7602a60cfb274B00951',
|
|
69
|
+
|
|
70
|
+
// uniswap V3
|
|
71
|
+
UniCollectV3: '0x331D7C3F6E710cB6cFE94c4Aa04AC3345AC00e00',
|
|
72
|
+
UniMintV3: '0x3dF75BE8Fb0a6186BE9705cACaa6dD2a4Ec3e40C',
|
|
73
|
+
UniSupplyV3: '0x0CA4255b37DD083dBD48Ca74d575F46037992520',
|
|
74
|
+
UniWithdrawV3: '0xe06224593D9c860B2fBF39eEA3b9B8A85b77Fbc4',
|
|
75
|
+
UniCreatePoolV3: '0x9058aAbEdEfe652b1d85DBBAB48Dfa78db613C44',
|
|
76
|
+
|
|
77
|
+
// dydx
|
|
78
|
+
DyDxWithdraw: '0x827089C5Fc7653655c4080c660Cd8f755F818443',
|
|
79
|
+
|
|
80
|
+
// yearn
|
|
81
|
+
YearnSupply: '0x837D6E7F469b3cC820B0a6Da25415D5aE0A861c4',
|
|
82
|
+
YearnWithdraw: '0x563eF9b1075628E62aDc657702517dEA72ca08d6', // CHECK IF REDEPLOY
|
|
83
|
+
|
|
84
|
+
// liquity
|
|
85
|
+
LiquityClose: '0x4B2d174129789a88e92D46342201F207132144b7',
|
|
86
|
+
LiquityBorrow: '0xF978d6C5c8af80a059AdB85EEb64F14C9c436D68',
|
|
87
|
+
LiquityOpen: '0x4EFF392cc69B31Ad159EcfA10305251b2d8E40E0',
|
|
88
|
+
LiquityPayback: '0x8fc7D24414e9740ed9841d9205D458e3677e71f7',
|
|
89
|
+
LiquityWithdraw: '0x733F53579bEcdd3Ed07e745A55Ee9af8B9669048',
|
|
90
|
+
LiquitySupply: '0xD539943e080C2a29e3f1DB2d45Ea7240d7ddDEE2',
|
|
91
|
+
LiquitySPDeposit: '0x5aB0244a00a733f16E6b238B462bdF3538C698E1',
|
|
92
|
+
LiquitySPWithdraw: '0xa71817957eaF993fAA9a1F4B5c2402c0aeFCd9C6',
|
|
93
|
+
LiquityStake: '0x671280800B540cbF073561d84A297a2c4c5D529F',
|
|
94
|
+
LiquityUnstake: '0x86FDD4A6438D448a794A44ABBe47D57590b3350d',
|
|
95
|
+
LiquityEthGainToTrove: '0x65e19f967B3F3cB6466110aD238039F5423E3177',
|
|
96
|
+
LiquityClaim: '0x526735aDcBe5c9059275c5ED2E0574b4a24b875e',
|
|
97
|
+
LiquityRedeem: '0x20B78854658011394C931EF2BF3cEEA2Fe62E7f0',
|
|
98
|
+
|
|
99
|
+
// lido
|
|
100
|
+
LidoStake: '0x4a7dd38D2BcA817fb68165155F869ca4179d8060',
|
|
101
|
+
LidoWrap: '0xE637544390db79EdDE0a9CAF352ED0FfF7451bDB',
|
|
102
|
+
LidoUnwrap: '0x910F73Fb8C0Bd15423c0D0BaD9F1ed95187a48fD',
|
|
103
|
+
|
|
104
|
+
// insta
|
|
105
|
+
InstPullTokens: '0xf2c87782D6Eff0511e82007119BAC40e9ba86F69',
|
|
106
|
+
|
|
107
|
+
// balancer
|
|
108
|
+
BalancerV2Supply: '0xE48123018Db5e9075841C61EA702cEca51621191',
|
|
109
|
+
BalancerV2Withdraw: '0xbED38692438b90AF738F8A7A3142C217DE8fB069',
|
|
110
|
+
BalancerV2Claim: '0xEac7c5bEFaA6E17f1A2e86947eEd6419c74A7C03',
|
|
111
|
+
|
|
112
|
+
// GUni
|
|
113
|
+
GUniWithdraw: '0x6F7cD7C0Dd3634E14bAB91FDF3bCE0a4315b3C59',
|
|
114
|
+
GUniDeposit: '0xb247cD4cab056800cCDa7cE1AFB781a8bFA9b57A',
|
|
115
|
+
|
|
116
|
+
// Rari
|
|
117
|
+
RariDeposit: '0x77A05c15f62F1fA6471D466001E21C1B189fcA9F',
|
|
118
|
+
RariWithdraw: '0xa052eD427EFa63B5bb87c409449a47e7C50317e3',
|
|
119
|
+
|
|
120
|
+
// mStable
|
|
121
|
+
MStableDeposit: '0xdf24ed1250fbfa274316b50Bc9A009aFA8F61E16',
|
|
122
|
+
MStableWithdraw: '0xa4d5d3e56012C1eD8aba4bE246964962DC3F735f',
|
|
123
|
+
|
|
124
|
+
MStableClaim: '0xD56F0EC66267958e08c91547c259cCAC006BF118',
|
|
125
|
+
|
|
126
|
+
McdRatioCheck: '0x3f09773e5e945C6Aa1bc8a8B3492f507620DE1e1',
|
|
127
|
+
GasFeeTaker: '0x431F1E1A9859EF99953801dbdeB31d2846ADcc0d',
|
|
128
|
+
|
|
129
|
+
CurveStethPoolDeposit: '0x5Ae5870dC0C780e9eb68bE7a223eCd7F3BDad12B', // REDEPLOY
|
|
130
|
+
CurveStethPoolWithdraw: '0x4089731d843Ce52699Fe64F68556aBbD95D70D00', // REDEPLOY
|
|
131
|
+
},
|
|
132
|
+
[NETWORKS.optimism.chainId]: {
|
|
133
|
+
DFSSell: '0xfA015aD97E25247c2144F1C89AeD449cc3Fd1FCB',
|
|
134
|
+
|
|
135
|
+
// basic
|
|
136
|
+
WrapEth: '0x6D735db054AC4a1F10f96b99f8550E9eefbC2AC5',
|
|
137
|
+
UnwrapEth: '0x1Fa75B00A05C2EbBd0EDF253a63c209966337A0d',
|
|
138
|
+
SendToken: '0xEbA499702856f1EFda2546e9fEFC1319A3b40538',
|
|
139
|
+
PullToken: '0x392579E020a688068422A925c85f28bFD12a7EBB',
|
|
140
|
+
SendTokenAndUnwrap: '0x8000174366066923D554cb466e190258A6FF3b1f',
|
|
141
|
+
|
|
142
|
+
// aave v3
|
|
143
|
+
AaveV3ATokenPayback: '0x71B27114D1777298bD46c3770C42F9f807C49847',
|
|
144
|
+
AaveV3Borrow: '0x4d3F58460aE2bC71fFaeb33838BFA3b5610083Db',
|
|
145
|
+
AaveV3CollateralSwitch: '0x20D1388Ffa0A2D6ff6328AD014C67051542ca3a8',
|
|
146
|
+
AaveV3Payback: '0x09DC201A6380882752bCdC7bC721D384f716A5a4',
|
|
147
|
+
AaveV3SetEMode: '0x7F264737066b9b7D9729Fe9715abB97423D8b35B',
|
|
148
|
+
AaveV3Supply: '0xe431c1C673Be123045c8635b0196d51a5bFE55c1',
|
|
149
|
+
AaveV3SwapBorrowRateMode: '0xB8f0243b492f0e80feF5315Ba8692e7635481845',
|
|
150
|
+
AaveV3Withdraw: '0xD0130ecB810C6F8d58e60DC417357F6048Ea32e7',
|
|
151
|
+
|
|
152
|
+
FLAaveV3: '0x352D4a1622f2DC34c738F542934372855f219F05',
|
|
153
|
+
},
|
|
154
|
+
[NETWORKS.arbitrum.chainId]: {
|
|
155
|
+
DFSSell: '0x49E1574Ba6b8134c29B1EbC010784A01D91b794F',
|
|
156
|
+
|
|
157
|
+
// basic
|
|
158
|
+
WrapEth: '0x35136b25bFA7CCC8f5b94E3181a16B61c06980F0',
|
|
159
|
+
UnwrapEth: '0x2B69d494536098700910D167902D1d397dcA2B61',
|
|
160
|
+
SendToken: '0xb022BaFfcEdc0ceA15aF6B2B744795A12D21F2a9',
|
|
161
|
+
PullToken: '0xD8B3769f74bd9F196C3416a42a91E786948898e6',
|
|
162
|
+
SendTokenAndUnwrap: '0x0fb867A5Ee1CA9426D3dAb95e613Be166218b977',
|
|
163
|
+
|
|
164
|
+
// aave v3
|
|
165
|
+
AaveV3ATokenPayback: '0x261906e5E0D0D38D9cBb5c10dB9c4031aabdf8C1',
|
|
166
|
+
AaveV3Borrow: '0xe729954e40546557Fa547ecd163644457Da28A04',
|
|
167
|
+
AaveV3CollateralSwitch: '0x7AcdD66C13f87b1cBcE7B106a8C34E426475BADd',
|
|
168
|
+
AaveV3Payback: '0x05dD6025d4075bBCA3260C5eDBeFcF7574d4AF70',
|
|
169
|
+
AaveV3SetEMode: '0x99D5068d9520316e8D3B5136c0B6EA33C5E0c27e',
|
|
170
|
+
AaveV3Supply: '0xd4AE9d95faca89B235B8A71F410501104fF16E56',
|
|
171
|
+
AaveV3SwapBorrowRateMode: '0x738042389A8d6B0F6D6ab009c42dfF84ebB737C0',
|
|
172
|
+
AaveV3Withdraw: '0x204ae0d3f7cB0db44A297DC4aD433298ed2042F3',
|
|
173
|
+
|
|
174
|
+
FLAaveV3: '0x3Cc0d5DAE1B94e294152C3150aA732b97af603E1',
|
|
175
|
+
}
|
|
139
176
|
};
|
|
140
177
|
|
|
141
178
|
const otherAddresses = {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
179
|
+
[NETWORKS.ethereum.chainId]: {
|
|
180
|
+
RecipeExecutor: '0xe822d76c2632FC52f3eaa686bDA9Cea3212579D8',
|
|
181
|
+
DFSRegistry: '0x287778F121F134C66212FB16c9b53eC991D32f5b',
|
|
182
|
+
DFSProxyRegistry: '0x29474FdaC7142f9aB7773B8e38264FA15E3805ed',
|
|
183
|
+
ProxyRegistry: '0x4678f0a6958e4D2Bc4F1BAF7Bc52E8F3564f3fE4',
|
|
184
|
+
|
|
185
|
+
McdCdpManager: '0x5ef30b9986345249bc32d8928b7ee64de9435e39',
|
|
186
|
+
BCdpManager: '0x3f30c2381CD8B917Dd96EB2f1A4F96D91324BBed',
|
|
187
|
+
AaveDefaultMarket: '0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5',
|
|
188
|
+
UniswapV3PositionManager : '0xC36442b4a4522E871399CD717aBDD847Ab11FE88',
|
|
189
|
+
RaiWethUniV2LPToken : '0x8aE720a71622e824F576b4A8C03031066548A3B1',
|
|
190
|
+
BalancerToken : '0xba100000625a3754423978a60c9317c58a424e3D',
|
|
191
|
+
CrvToken: '0xD533a949740bb3306d119CC777fa900bA034cd52',
|
|
192
|
+
DAI: '0x6b175474e89094c44da98b954eedeac495271d0f',
|
|
193
|
+
Empty: '0x0000000000000000000000000000000000000000',
|
|
194
|
+
},
|
|
195
|
+
[NETWORKS.optimism.chainId]: {
|
|
196
|
+
RecipeExecutor: '0xe91ff198bA6DFA97A7B4Fa43e5a606c915B0471f',
|
|
197
|
+
DFSRegistry: '0xAf707Ee480204Ed6e2640B53cE86F680D28Afcbd',
|
|
198
|
+
ProxyRegistry: '0x283Cc5C26e53D66ed2Ea252D986F094B37E6e895',
|
|
199
|
+
|
|
200
|
+
DSGuardFactory: '0xc19d0F1E2b38AA283E226Ca4044766A43aA7B02b',
|
|
201
|
+
AdminVault: '0x136b1bEAfff362530F98f10E3D8C38f3a3F3d38C',
|
|
202
|
+
DefisaverLogger: '0xFc2f1355296ab7dd98a1260E3Ff5E906999d4Acb',
|
|
203
|
+
Empty: '0x0000000000000000000000000000000000000000',
|
|
204
|
+
},
|
|
205
|
+
[NETWORKS.arbitrum.chainId]: {
|
|
206
|
+
RecipeExecutor: '0xc1cB462033D8319016dF4e8A1810f1afB06b50bB',
|
|
207
|
+
DFSRegistry: '0xBF1CaC12DB60819Bfa71A328282ecbc1D40443aA',
|
|
208
|
+
ProxyRegistry: '0x283Cc5C26e53D66ed2Ea252D986F094B37E6e895',
|
|
209
|
+
|
|
210
|
+
DSGuardFactory: '0x5261abC3a94a6475D0A1171daE94A5f84fbaEcD2',
|
|
211
|
+
AdminVault: '0xd47D8D97cAd12A866900eEc6Cde1962529F25351',
|
|
212
|
+
DefisaverLogger: '0xE6f9A5C850dbcD12bc64f40d692F537250aDEC38',
|
|
213
|
+
Empty: '0x0000000000000000000000000000000000000000',
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
*
|
|
219
|
+
* @param {string} name
|
|
220
|
+
* @param {chainId} [chainId]
|
|
221
|
+
* @returns {EthAddress}
|
|
222
|
+
*/
|
|
223
|
+
const getAddr = (name, chainId) => {
|
|
224
|
+
const _chainId = typeof chainId === 'undefined' ? CONFIG.chainId : chainId;
|
|
155
225
|
|
|
226
|
+
const actions = actionAddresses[_chainId];
|
|
227
|
+
const other = otherAddresses[_chainId];
|
|
156
228
|
|
|
157
|
-
|
|
158
|
-
if (!
|
|
229
|
+
if (!actions && !other) throw new Error(`Cannot find address for chainId: ${_chainId}.`);
|
|
230
|
+
if (!actions[name] && !other[name]) throw new Error(`Cannot find address for name: ${name} (chainId: ${_chainId}).`);
|
|
159
231
|
|
|
160
|
-
return
|
|
232
|
+
return actions[name] || other[name];
|
|
161
233
|
};
|
|
162
234
|
|
|
163
235
|
module.exports = {
|
package/src/config.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const Dec = require("decimal.js");
|
|
2
|
+
const dfsTokensSetConfig = require("@defisaver/tokens").set;
|
|
3
|
+
|
|
4
|
+
Dec.set({
|
|
5
|
+
rounding: Dec.ROUND_DOWN,
|
|
6
|
+
toExpPos: 9e15,
|
|
7
|
+
toExpNeg: -9e15,
|
|
8
|
+
precision: 100,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @type {Networks}
|
|
14
|
+
*/
|
|
15
|
+
const NETWORKS = {
|
|
16
|
+
ethereum: {
|
|
17
|
+
chainId: 1,
|
|
18
|
+
chainName: 'Ethereum Mainnet',
|
|
19
|
+
blockExplorerUrls: ['https://etherscan.io/'],
|
|
20
|
+
iconUrls: [],
|
|
21
|
+
rpcUrls: [],
|
|
22
|
+
nativeCurrency: { name: 'Ethereum', decimals: 18, symbol: 'ETH' },
|
|
23
|
+
},
|
|
24
|
+
optimism: {
|
|
25
|
+
chainId: 10,
|
|
26
|
+
chainName: 'Optimism',
|
|
27
|
+
blockExplorerUrls: ['https://optimistic.etherscan.io/'],
|
|
28
|
+
iconUrls: ['https://gateway.optimism.io/favicon.ico'],
|
|
29
|
+
rpcUrls: ['https://mainnet.optimism.io'],
|
|
30
|
+
nativeCurrency: { name: 'Ethereum', decimals: 18, symbol: 'ETH' },
|
|
31
|
+
},
|
|
32
|
+
arbitrum: {
|
|
33
|
+
chainId: 42161,
|
|
34
|
+
chainName: 'Arbitrum One',
|
|
35
|
+
blockExplorerUrls: ['https://arbiscan.io/'],
|
|
36
|
+
iconUrls: ['https://bridge.arbitrum.io/logo.png'],
|
|
37
|
+
rpcUrls: ['https://arb1.arbitrum.io/rpc'],
|
|
38
|
+
nativeCurrency: { name: 'Ethereum', decimals: 18, symbol: 'ETH' },
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @type {Config}
|
|
45
|
+
*/
|
|
46
|
+
const CONFIG = {
|
|
47
|
+
chainId: NETWORKS.ethereum.chainId,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @param {chainId} chainId
|
|
53
|
+
* @returns {Network}
|
|
54
|
+
*/
|
|
55
|
+
const getNetworkData = (chainId) => {
|
|
56
|
+
const networkData = Object.values(NETWORKS).find((network) => network.chainId === +chainId);
|
|
57
|
+
|
|
58
|
+
if (!networkData) throw new Error(`Cannot find network data for chainId: ${chainId}`);
|
|
59
|
+
|
|
60
|
+
return networkData;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* @param {Config} config
|
|
66
|
+
*/
|
|
67
|
+
const configure = (config) => {
|
|
68
|
+
if (!config || typeof config !== 'object') throw new Error('Object expected');
|
|
69
|
+
|
|
70
|
+
const newKeys = Object.keys(config);
|
|
71
|
+
|
|
72
|
+
newKeys.forEach((key) => {
|
|
73
|
+
CONFIG[key] = config[key]
|
|
74
|
+
if (key === 'chainId') dfsTokensSetConfig('network', config[key]);
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
module.exports = {
|
|
79
|
+
configure,
|
|
80
|
+
CONFIG,
|
|
81
|
+
NETWORKS,
|
|
82
|
+
getNetworkData,
|
|
83
|
+
}
|