@defisaver/sdk 0.1.21 → 0.1.24
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/ACTIONS.md +20 -254
- package/AccessLists/DyDxAccessLists.js +0 -4
- package/AccessLists/InstaAccessLists.js +0 -8
- package/AccessLists/UtilsAccessLists.js +0 -5
- package/DEV.md +0 -7
- package/index.js +15 -2
- package/package.json +1 -1
- package/src/Action.js +52 -12
- package/src/L2Action.js +44 -0
- package/src/Recipe.js +5 -4
- package/src/Strategy.js +63 -0
- package/src/abis/Action.json +157 -11
- package/src/abis/Recipe.json +92 -47
- package/src/actions/aave/AaveBorrowAction.js +11 -2
- package/src/actions/aave/AavePaybackAction.js +11 -2
- package/src/actions/aave/AaveSupplyAction.js +9 -1
- package/src/actions/aave/AaveWithdrawAction.js +8 -1
- package/src/actions/aaveV3/AaveV3ATokenPaybackAction.js +53 -0
- package/src/actions/aaveV3/AaveV3BorrowAction.js +54 -0
- package/src/actions/aaveV3/AaveV3CollateralSwitchAction.js +41 -0
- package/src/actions/aaveV3/AaveV3PaybackAction.js +63 -0
- package/src/actions/aaveV3/AaveV3SetEModeAction.js +35 -0
- package/src/actions/aaveV3/AaveV3SupplyAction.js +64 -0
- package/src/actions/aaveV3/AaveV3WithdrawAction.js +41 -0
- package/src/actions/aaveV3/index.js +17 -0
- package/src/actions/basic/GasFeeAction.js +27 -0
- package/src/actions/basic/PullTokenAction.js +9 -3
- package/src/actions/basic/SellAction.js +6 -5
- package/src/actions/basic/SendTokenAction.js +9 -3
- package/src/actions/basic/SumInputsAction.js +8 -3
- package/src/actions/basic/UnwrapEthAction.js +8 -3
- package/src/actions/basic/WrapEthAction.js +5 -1
- package/src/actions/basic/index.js +2 -2
- package/src/actions/checkers/MakerRatioCheckAction.js +29 -0
- package/src/actions/checkers/index.js +5 -0
- package/src/actions/compound/CompoundBorrowAction.js +7 -1
- package/src/actions/compound/CompoundClaimAction.js +6 -1
- package/src/actions/compound/CompoundPaybackAction.js +7 -1
- package/src/actions/compound/CompoundSupplyAction.js +7 -1
- package/src/actions/compound/CompoundWithdrawAction.js +7 -1
- package/src/actions/dydx/DyDxWithdrawAction.js +7 -1
- package/src/actions/dydx/index.js +0 -2
- package/src/actions/flashloan/AaveV2FlashLoanAction.js +2 -2
- package/src/actions/flashloan/BalancerFlashLoanAction.js +2 -2
- package/src/actions/flashloan/DyDxFlashLoanAction.js +1 -1
- package/src/actions/flashloan/MakerFlashLoanAction.js +2 -2
- package/src/actions/index.js +4 -0
- package/src/actions/insta/index.js +0 -2
- package/src/actions/liquity/LiquityClaimAction.js +6 -2
- package/src/actions/liquity/LiquityCloseAction.js +7 -2
- package/src/actions/maker/MakerGenerateAction.js +8 -1
- package/src/actions/maker/MakerGiveAction.js +7 -1
- package/src/actions/maker/MakerMergeAction.js +7 -1
- package/src/actions/maker/MakerOpenVaultAction.js +6 -1
- package/src/actions/maker/MakerPaybackAction.js +1 -0
- package/src/actions/maker/MakerRatioAction.js +20 -0
- package/src/actions/maker/MakerSupplyAction.js +9 -1
- package/src/actions/maker/MakerWithdrawAction.js +10 -2
- package/src/actions/maker/index.js +2 -0
- package/src/actions/mstable/MStableDepositAction.js +2 -2
- package/src/actions/mstable/MStableWithdrawAction.js +2 -2
- package/src/actions/reflexer/ReflexerGenerateAction.js +7 -1
- package/src/actions/reflexer/ReflexerOpenSafeAction.js +5 -1
- package/src/actions/reflexer/ReflexerPaybackAction.js +7 -1
- package/src/actions/reflexer/ReflexerSupplyAction.js +8 -1
- package/src/actions/reflexer/ReflexerWithdrawAction.js +8 -1
- package/src/addresses.js +179 -143
- package/src/config.js +74 -0
- package/src/triggers/ChainLinkPriceTrigger.js +12 -0
- package/src/triggers/CompoundRatioTrigger.js +11 -0
- package/src/triggers/GasPriceTrigger.js +11 -0
- package/src/triggers/LiquityRatioTrigger.js +16 -0
- package/src/triggers/MakerRatioTrigger.js +15 -0
- package/src/triggers/ReflexerRatioTrigger.js +11 -0
- package/src/triggers/TimestampTrigger.js +11 -0
- package/src/triggers/UniV3CurrentTickTrigger.js +12 -0
- package/src/triggers/index.js +19 -0
- package/src/types.js +33 -0
- package/src/utils/general.js +2 -0
- package/src/utils/zeroExExchange.js +2 -40
- package/test/accessLists/MockAccessLists.json +0 -72
- package/test/accessLists/Recipe.js +3 -3
- package/test/actions/insta/InstPullTokensAction.js +2 -2
- package/test/index.js +4 -1
- package/test/utils/zeroExExchange.js +0 -8
- package/src/actions/basic/BuyAction.js +0 -53
- package/src/actions/dydx/DyDxSupplyAction.js +0 -25
- package/src/actions/insta/ClaimInstMakerAction.js +0 -21
- package/test/actions/basic/BuyAction.js +0 -100
- package/test/actions/dydx/DyDxSupplyAction.js +0 -78
- package/test/actions/insta/ClaimInstMakerAction.js +0 -46
package/src/Strategy.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const Action = require('./Action');
|
|
2
|
+
|
|
3
|
+
// TODO: Code is a prototype should be cleaned up before use in prod.
|
|
4
|
+
|
|
5
|
+
class Strategy {
|
|
6
|
+
|
|
7
|
+
constructor(name) {
|
|
8
|
+
this.name = name;
|
|
9
|
+
this.subSlots = {};
|
|
10
|
+
this.actions = [];
|
|
11
|
+
this.triggers = [];
|
|
12
|
+
this.numSubSlots = 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
addSubSlot(name, type) {
|
|
16
|
+
this.subSlots[name] = { type, index: this.numSubSlots + 128 };
|
|
17
|
+
this.numSubSlots++;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
addTrigger(newTrigger) {
|
|
21
|
+
this.triggers.push(newTrigger);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
addAction(newAction) {
|
|
25
|
+
this.actions.push(newAction);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
print() {
|
|
29
|
+
console.log(`Name: ${this.name }`);
|
|
30
|
+
console.log(`Slots: ${this.subSlots }`);
|
|
31
|
+
console.log(`Action: ${this.actions[0]}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getSubSlots() {
|
|
35
|
+
return this.subSlots;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// TODO: Probably should be tied into Recipe obj. not directly with actions
|
|
39
|
+
encodeForDsProxyCall() {
|
|
40
|
+
const triggerIds = this.triggers.map((trigger) => trigger.getId());
|
|
41
|
+
|
|
42
|
+
const paramMappings = [];
|
|
43
|
+
const actionIds = [];
|
|
44
|
+
|
|
45
|
+
this.actions.forEach(action => {
|
|
46
|
+
const actionEncoded = action.encodeForStrategy(this.subSlots);
|
|
47
|
+
|
|
48
|
+
actionIds.push(actionEncoded[0]);
|
|
49
|
+
paramMappings.push(actionEncoded[1]);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return [
|
|
53
|
+
this.name,
|
|
54
|
+
triggerIds,
|
|
55
|
+
actionIds,
|
|
56
|
+
paramMappings
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = Strategy;
|
|
63
|
+
|
package/src/abis/Action.json
CHANGED
|
@@ -1,4 +1,55 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"inputs": [],
|
|
4
|
+
"name": "NonContractCall",
|
|
5
|
+
"type": "error"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"inputs": [],
|
|
9
|
+
"name": "ReturnIndexValueError",
|
|
10
|
+
"type": "error"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"inputs": [],
|
|
14
|
+
"name": "SenderNotAdmin",
|
|
15
|
+
"type": "error"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"inputs": [],
|
|
19
|
+
"name": "SenderNotOwner",
|
|
20
|
+
"type": "error"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"inputs": [],
|
|
24
|
+
"name": "SubIndexValueError",
|
|
25
|
+
"type": "error"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"inputs": [],
|
|
29
|
+
"name": "ADMIN_VAULT_ADDR",
|
|
30
|
+
"outputs": [
|
|
31
|
+
{
|
|
32
|
+
"internalType": "address",
|
|
33
|
+
"name": "",
|
|
34
|
+
"type": "address"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"stateMutability": "view",
|
|
38
|
+
"type": "function"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"inputs": [],
|
|
42
|
+
"name": "NO_PARAM_MAPPING",
|
|
43
|
+
"outputs": [
|
|
44
|
+
{
|
|
45
|
+
"internalType": "uint8",
|
|
46
|
+
"name": "",
|
|
47
|
+
"type": "uint8"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"stateMutability": "view",
|
|
51
|
+
"type": "function"
|
|
52
|
+
},
|
|
2
53
|
{
|
|
3
54
|
"inputs": [],
|
|
4
55
|
"name": "REGISTRY_ADDR",
|
|
@@ -12,6 +63,58 @@
|
|
|
12
63
|
"stateMutability": "view",
|
|
13
64
|
"type": "function"
|
|
14
65
|
},
|
|
66
|
+
{
|
|
67
|
+
"inputs": [],
|
|
68
|
+
"name": "RETURN_MAX_INDEX_VALUE",
|
|
69
|
+
"outputs": [
|
|
70
|
+
{
|
|
71
|
+
"internalType": "uint8",
|
|
72
|
+
"name": "",
|
|
73
|
+
"type": "uint8"
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
"stateMutability": "view",
|
|
77
|
+
"type": "function"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"inputs": [],
|
|
81
|
+
"name": "RETURN_MIN_INDEX_VALUE",
|
|
82
|
+
"outputs": [
|
|
83
|
+
{
|
|
84
|
+
"internalType": "uint8",
|
|
85
|
+
"name": "",
|
|
86
|
+
"type": "uint8"
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
"stateMutability": "view",
|
|
90
|
+
"type": "function"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"inputs": [],
|
|
94
|
+
"name": "SUB_MAX_INDEX_VALUE",
|
|
95
|
+
"outputs": [
|
|
96
|
+
{
|
|
97
|
+
"internalType": "uint8",
|
|
98
|
+
"name": "",
|
|
99
|
+
"type": "uint8"
|
|
100
|
+
}
|
|
101
|
+
],
|
|
102
|
+
"stateMutability": "view",
|
|
103
|
+
"type": "function"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"inputs": [],
|
|
107
|
+
"name": "SUB_MIN_INDEX_VALUE",
|
|
108
|
+
"outputs": [
|
|
109
|
+
{
|
|
110
|
+
"internalType": "uint8",
|
|
111
|
+
"name": "",
|
|
112
|
+
"type": "uint8"
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
"stateMutability": "view",
|
|
116
|
+
"type": "function"
|
|
117
|
+
},
|
|
15
118
|
{
|
|
16
119
|
"inputs": [],
|
|
17
120
|
"name": "actionType",
|
|
@@ -26,25 +129,38 @@
|
|
|
26
129
|
"type": "function"
|
|
27
130
|
},
|
|
28
131
|
{
|
|
29
|
-
"inputs": [
|
|
132
|
+
"inputs": [],
|
|
133
|
+
"name": "adminVault",
|
|
134
|
+
"outputs": [
|
|
30
135
|
{
|
|
31
|
-
"internalType": "
|
|
136
|
+
"internalType": "contract AdminVault",
|
|
32
137
|
"name": "",
|
|
33
|
-
"type": "
|
|
138
|
+
"type": "address"
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
"stateMutability": "view",
|
|
142
|
+
"type": "function"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"inputs": [
|
|
146
|
+
{
|
|
147
|
+
"internalType": "bytes",
|
|
148
|
+
"name": "_callData",
|
|
149
|
+
"type": "bytes"
|
|
34
150
|
},
|
|
35
151
|
{
|
|
36
|
-
"internalType": "
|
|
37
|
-
"name": "",
|
|
38
|
-
"type": "
|
|
152
|
+
"internalType": "bytes32[]",
|
|
153
|
+
"name": "_subData",
|
|
154
|
+
"type": "bytes32[]"
|
|
39
155
|
},
|
|
40
156
|
{
|
|
41
157
|
"internalType": "uint8[]",
|
|
42
|
-
"name": "",
|
|
158
|
+
"name": "_paramMapping",
|
|
43
159
|
"type": "uint8[]"
|
|
44
160
|
},
|
|
45
161
|
{
|
|
46
162
|
"internalType": "bytes32[]",
|
|
47
|
-
"name": "",
|
|
163
|
+
"name": "_returnValues",
|
|
48
164
|
"type": "bytes32[]"
|
|
49
165
|
}
|
|
50
166
|
],
|
|
@@ -62,9 +178,9 @@
|
|
|
62
178
|
{
|
|
63
179
|
"inputs": [
|
|
64
180
|
{
|
|
65
|
-
"internalType": "bytes
|
|
181
|
+
"internalType": "bytes",
|
|
66
182
|
"name": "_callData",
|
|
67
|
-
"type": "bytes
|
|
183
|
+
"type": "bytes"
|
|
68
184
|
}
|
|
69
185
|
],
|
|
70
186
|
"name": "executeActionDirect",
|
|
@@ -72,6 +188,13 @@
|
|
|
72
188
|
"stateMutability": "payable",
|
|
73
189
|
"type": "function"
|
|
74
190
|
},
|
|
191
|
+
{
|
|
192
|
+
"inputs": [],
|
|
193
|
+
"name": "kill",
|
|
194
|
+
"outputs": [],
|
|
195
|
+
"stateMutability": "nonpayable",
|
|
196
|
+
"type": "function"
|
|
197
|
+
},
|
|
75
198
|
{
|
|
76
199
|
"inputs": [],
|
|
77
200
|
"name": "logger",
|
|
@@ -97,5 +220,28 @@
|
|
|
97
220
|
],
|
|
98
221
|
"stateMutability": "view",
|
|
99
222
|
"type": "function"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"inputs": [
|
|
226
|
+
{
|
|
227
|
+
"internalType": "address",
|
|
228
|
+
"name": "_token",
|
|
229
|
+
"type": "address"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"internalType": "address",
|
|
233
|
+
"name": "_receiver",
|
|
234
|
+
"type": "address"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"internalType": "uint256",
|
|
238
|
+
"name": "_amount",
|
|
239
|
+
"type": "uint256"
|
|
240
|
+
}
|
|
241
|
+
],
|
|
242
|
+
"name": "withdrawStuckFunds",
|
|
243
|
+
"outputs": [],
|
|
244
|
+
"stateMutability": "nonpayable",
|
|
245
|
+
"type": "function"
|
|
100
246
|
}
|
|
101
|
-
]
|
|
247
|
+
]
|
package/src/abis/Recipe.json
CHANGED
|
@@ -1,4 +1,32 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"inputs": [],
|
|
4
|
+
"name": "NonContractCall",
|
|
5
|
+
"type": "error"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"inputs": [],
|
|
9
|
+
"name": "SenderNotAdmin",
|
|
10
|
+
"type": "error"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"inputs": [],
|
|
14
|
+
"name": "SenderNotOwner",
|
|
15
|
+
"type": "error"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"inputs": [],
|
|
19
|
+
"name": "ADMIN_VAULT_ADDR",
|
|
20
|
+
"outputs": [
|
|
21
|
+
{
|
|
22
|
+
"internalType": "address",
|
|
23
|
+
"name": "",
|
|
24
|
+
"type": "address"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"stateMutability": "view",
|
|
28
|
+
"type": "function"
|
|
29
|
+
},
|
|
2
30
|
{
|
|
3
31
|
"inputs": [],
|
|
4
32
|
"name": "DEFISAVER_LOGGER",
|
|
@@ -48,19 +76,19 @@
|
|
|
48
76
|
"type": "string"
|
|
49
77
|
},
|
|
50
78
|
{
|
|
51
|
-
"internalType": "bytes[]
|
|
79
|
+
"internalType": "bytes[]",
|
|
52
80
|
"name": "callData",
|
|
53
|
-
"type": "bytes[]
|
|
81
|
+
"type": "bytes[]"
|
|
54
82
|
},
|
|
55
83
|
{
|
|
56
|
-
"internalType": "
|
|
84
|
+
"internalType": "bytes32[]",
|
|
57
85
|
"name": "subData",
|
|
58
|
-
"type": "
|
|
86
|
+
"type": "bytes32[]"
|
|
59
87
|
},
|
|
60
88
|
{
|
|
61
|
-
"internalType": "
|
|
62
|
-
"name": "
|
|
63
|
-
"type": "
|
|
89
|
+
"internalType": "bytes4[]",
|
|
90
|
+
"name": "actionIds",
|
|
91
|
+
"type": "bytes4[]"
|
|
64
92
|
},
|
|
65
93
|
{
|
|
66
94
|
"internalType": "uint8[][]",
|
|
@@ -68,8 +96,8 @@
|
|
|
68
96
|
"type": "uint8[][]"
|
|
69
97
|
}
|
|
70
98
|
],
|
|
71
|
-
"internalType": "struct
|
|
72
|
-
"name": "
|
|
99
|
+
"internalType": "struct StrategyModel.Recipe",
|
|
100
|
+
"name": "_currRecipe",
|
|
73
101
|
"type": "tuple"
|
|
74
102
|
},
|
|
75
103
|
{
|
|
@@ -85,10 +113,10 @@
|
|
|
85
113
|
},
|
|
86
114
|
{
|
|
87
115
|
"inputs": [],
|
|
88
|
-
"name": "
|
|
116
|
+
"name": "adminVault",
|
|
89
117
|
"outputs": [
|
|
90
118
|
{
|
|
91
|
-
"internalType": "contract
|
|
119
|
+
"internalType": "contract AdminVault",
|
|
92
120
|
"name": "",
|
|
93
121
|
"type": "address"
|
|
94
122
|
}
|
|
@@ -96,24 +124,6 @@
|
|
|
96
124
|
"stateMutability": "view",
|
|
97
125
|
"type": "function"
|
|
98
126
|
},
|
|
99
|
-
{
|
|
100
|
-
"inputs": [
|
|
101
|
-
{
|
|
102
|
-
"internalType": "uint256",
|
|
103
|
-
"name": "_strategyId",
|
|
104
|
-
"type": "uint256"
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
"internalType": "bytes[][]",
|
|
108
|
-
"name": "_actionCallData",
|
|
109
|
-
"type": "bytes[][]"
|
|
110
|
-
}
|
|
111
|
-
],
|
|
112
|
-
"name": "executeStrategyTask",
|
|
113
|
-
"outputs": [],
|
|
114
|
-
"stateMutability": "payable",
|
|
115
|
-
"type": "function"
|
|
116
|
-
},
|
|
117
127
|
{
|
|
118
128
|
"inputs": [
|
|
119
129
|
{
|
|
@@ -124,19 +134,19 @@
|
|
|
124
134
|
"type": "string"
|
|
125
135
|
},
|
|
126
136
|
{
|
|
127
|
-
"internalType": "bytes[]
|
|
137
|
+
"internalType": "bytes[]",
|
|
128
138
|
"name": "callData",
|
|
129
|
-
"type": "bytes[]
|
|
139
|
+
"type": "bytes[]"
|
|
130
140
|
},
|
|
131
141
|
{
|
|
132
|
-
"internalType": "
|
|
142
|
+
"internalType": "bytes32[]",
|
|
133
143
|
"name": "subData",
|
|
134
|
-
"type": "
|
|
144
|
+
"type": "bytes32[]"
|
|
135
145
|
},
|
|
136
146
|
{
|
|
137
|
-
"internalType": "
|
|
138
|
-
"name": "
|
|
139
|
-
"type": "
|
|
147
|
+
"internalType": "bytes4[]",
|
|
148
|
+
"name": "actionIds",
|
|
149
|
+
"type": "bytes4[]"
|
|
140
150
|
},
|
|
141
151
|
{
|
|
142
152
|
"internalType": "uint8[][]",
|
|
@@ -144,27 +154,32 @@
|
|
|
144
154
|
"type": "uint8[][]"
|
|
145
155
|
}
|
|
146
156
|
],
|
|
147
|
-
"internalType": "struct
|
|
148
|
-
"name": "
|
|
157
|
+
"internalType": "struct StrategyModel.Recipe",
|
|
158
|
+
"name": "_currRecipe",
|
|
149
159
|
"type": "tuple"
|
|
150
160
|
}
|
|
151
161
|
],
|
|
152
|
-
"name": "
|
|
162
|
+
"name": "executeRecipe",
|
|
153
163
|
"outputs": [],
|
|
154
164
|
"stateMutability": "payable",
|
|
155
165
|
"type": "function"
|
|
156
166
|
},
|
|
157
167
|
{
|
|
158
|
-
"inputs": [
|
|
159
|
-
"name": "gasToken",
|
|
160
|
-
"outputs": [
|
|
168
|
+
"inputs": [
|
|
161
169
|
{
|
|
162
|
-
"internalType": "
|
|
163
|
-
"name": "",
|
|
164
|
-
"type": "
|
|
170
|
+
"internalType": "uint256",
|
|
171
|
+
"name": "_subId",
|
|
172
|
+
"type": "uint256"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"internalType": "bytes[]",
|
|
176
|
+
"name": "_actionCallData",
|
|
177
|
+
"type": "bytes[]"
|
|
165
178
|
}
|
|
166
179
|
],
|
|
167
|
-
"
|
|
180
|
+
"name": "executeRecipeFromStrategy",
|
|
181
|
+
"outputs": [],
|
|
182
|
+
"stateMutability": "payable",
|
|
168
183
|
"type": "function"
|
|
169
184
|
},
|
|
170
185
|
{
|
|
@@ -180,6 +195,13 @@
|
|
|
180
195
|
"stateMutability": "nonpayable",
|
|
181
196
|
"type": "function"
|
|
182
197
|
},
|
|
198
|
+
{
|
|
199
|
+
"inputs": [],
|
|
200
|
+
"name": "kill",
|
|
201
|
+
"outputs": [],
|
|
202
|
+
"stateMutability": "nonpayable",
|
|
203
|
+
"type": "function"
|
|
204
|
+
},
|
|
183
205
|
{
|
|
184
206
|
"inputs": [],
|
|
185
207
|
"name": "registry",
|
|
@@ -205,5 +227,28 @@
|
|
|
205
227
|
"outputs": [],
|
|
206
228
|
"stateMutability": "nonpayable",
|
|
207
229
|
"type": "function"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"inputs": [
|
|
233
|
+
{
|
|
234
|
+
"internalType": "address",
|
|
235
|
+
"name": "_token",
|
|
236
|
+
"type": "address"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"internalType": "address",
|
|
240
|
+
"name": "_receiver",
|
|
241
|
+
"type": "address"
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"internalType": "uint256",
|
|
245
|
+
"name": "_amount",
|
|
246
|
+
"type": "uint256"
|
|
247
|
+
}
|
|
248
|
+
],
|
|
249
|
+
"name": "withdrawStuckFunds",
|
|
250
|
+
"outputs": [],
|
|
251
|
+
"stateMutability": "nonpayable",
|
|
252
|
+
"type": "function"
|
|
208
253
|
}
|
|
209
|
-
]
|
|
254
|
+
]
|
|
@@ -19,9 +19,18 @@ class AaveBorrowAction extends Action {
|
|
|
19
19
|
super(
|
|
20
20
|
'AaveBorrow',
|
|
21
21
|
getAddr('AaveBorrow'),
|
|
22
|
-
['address', 'address', 'uint256', 'uint256', 'address', 'address'],
|
|
23
|
-
[market, tokenAddr, amount, rateMode, to, onBehalf],
|
|
22
|
+
[['address', 'address', 'uint256', 'uint256', 'address', 'address']],
|
|
23
|
+
[[market, tokenAddr, amount, rateMode, to, onBehalf]],
|
|
24
24
|
);
|
|
25
|
+
|
|
26
|
+
this.mappableArgs = [
|
|
27
|
+
this.args[0][0],
|
|
28
|
+
this.args[0][1],
|
|
29
|
+
this.args[0][2],
|
|
30
|
+
this.args[0][3],
|
|
31
|
+
this.args[0][4],
|
|
32
|
+
this.args[0][5],
|
|
33
|
+
];
|
|
25
34
|
}
|
|
26
35
|
}
|
|
27
36
|
|
|
@@ -17,9 +17,18 @@ class AavePaybackAction extends Action {
|
|
|
17
17
|
constructor(market, tokenAddr, amount, rateMode, from, onBehalf = getAddr('Empty')) {
|
|
18
18
|
super('AavePayback',
|
|
19
19
|
getAddr('AavePayback'),
|
|
20
|
-
['address', 'address', 'uint256', 'uint256', 'address', 'address'],
|
|
21
|
-
[market, tokenAddr, amount, rateMode, from, onBehalf],
|
|
20
|
+
[['address', 'address', 'uint256', 'uint256', 'address', 'address']],
|
|
21
|
+
[[market, tokenAddr, amount, rateMode, from, onBehalf]],
|
|
22
22
|
);
|
|
23
|
+
|
|
24
|
+
this.mappableArgs = [
|
|
25
|
+
this.args[0][0],
|
|
26
|
+
this.args[0][1],
|
|
27
|
+
this.args[0][2],
|
|
28
|
+
this.args[0][3],
|
|
29
|
+
this.args[0][4],
|
|
30
|
+
this.args[0][5],
|
|
31
|
+
];
|
|
23
32
|
}
|
|
24
33
|
|
|
25
34
|
async getAssetsToApprove() {
|
|
@@ -15,7 +15,15 @@ class AaveSupplyAction extends Action {
|
|
|
15
15
|
* @param enableAsColl {boolean} If we need to enable asset as collateral
|
|
16
16
|
*/
|
|
17
17
|
constructor(market, tokenAddr, amount, from, onBehalf = getAddr('Empty'), enableAsColl) {
|
|
18
|
-
super('AaveSupply', getAddr('AaveSupply'), ['address','address','uint256','address','address','bool'], [market, tokenAddr, amount, from, onBehalf, enableAsColl]);
|
|
18
|
+
super('AaveSupply', getAddr('AaveSupply'), [['address','address','uint256','address','address','bool']], [[market, tokenAddr, amount, from, onBehalf, enableAsColl]]);
|
|
19
|
+
|
|
20
|
+
this.mappableArgs = [
|
|
21
|
+
this.args[0][0],
|
|
22
|
+
this.args[0][1],
|
|
23
|
+
this.args[0][2],
|
|
24
|
+
this.args[0][3],
|
|
25
|
+
this.args[0][4],
|
|
26
|
+
];
|
|
19
27
|
}
|
|
20
28
|
|
|
21
29
|
async getAssetsToApprove() {
|
|
@@ -14,7 +14,14 @@ class AaveWithdrawAction extends Action {
|
|
|
14
14
|
*/
|
|
15
15
|
constructor(market, tokenAddr, amount, to) {
|
|
16
16
|
requireAddress(to);
|
|
17
|
-
super('AaveWithdraw', getAddr('AaveWithdraw'), ['address','address','uint256','address'], [...arguments]);
|
|
17
|
+
super('AaveWithdraw', getAddr('AaveWithdraw'), [['address','address','uint256','address']], [[...arguments]]);
|
|
18
|
+
|
|
19
|
+
this.mappableArgs = [
|
|
20
|
+
this.args[0][0],
|
|
21
|
+
this.args[0][1],
|
|
22
|
+
this.args[0][2],
|
|
23
|
+
this.args[0][3],
|
|
24
|
+
];
|
|
18
25
|
}
|
|
19
26
|
}
|
|
20
27
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const L2Action = require("../../L2Action");
|
|
2
|
+
const {getAssetInfoByAddress} = require("@defisaver/tokens");
|
|
3
|
+
const { getAddr } = require('../../addresses.js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* AaveV3ATokenPaybackAction - Repay Aave V3 debt using aTokens
|
|
7
|
+
*/
|
|
8
|
+
class AaveV3ATokenPaybackAction extends L2Action {
|
|
9
|
+
/**
|
|
10
|
+
* @param market {EthAddress} Address provider for specific market
|
|
11
|
+
* @param amount {string} Amount of tokens to be payed back (uint.max for full debt)
|
|
12
|
+
* @param from {EthAddress} Where are we pulling the payback aTokens from
|
|
13
|
+
* @param rateMode {number} Type of borrow debt [Stable: 1, Variable: 2]
|
|
14
|
+
* @param aTokenAddr {EthAddress} address of the aToken to be pulled
|
|
15
|
+
* @param assetId {number} The id of the underlying asset to be repaid
|
|
16
|
+
*/
|
|
17
|
+
constructor(market, amount, from, rateMode, aTokenAddr, assetId) {
|
|
18
|
+
super('AaveV3Payback', getAddr('AaveV3Payback'),
|
|
19
|
+
[['address','uint256','address','uint8','uint16']],
|
|
20
|
+
[[market, amount, from, rateMode, assetId]]
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
this.mappableArgs = [
|
|
24
|
+
this.args[0][0],
|
|
25
|
+
this.args[0][1],
|
|
26
|
+
this.args[0][2],
|
|
27
|
+
];
|
|
28
|
+
this.addressForApproval = aTokenAddr;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async getAssetsToApprove() {
|
|
32
|
+
const asset = getAssetInfoByAddress(this.addressForApproval);
|
|
33
|
+
if (asset.symbol !== 'ETH') return [{asset: this.addressForApproval, owner: this.args[0][2]}];
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
encodeInputs() {
|
|
37
|
+
// executeActionDirectL2
|
|
38
|
+
let encodedInput = "0x2895f3aa";
|
|
39
|
+
// market
|
|
40
|
+
encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][0]));
|
|
41
|
+
// amount
|
|
42
|
+
encodedInput = encodedInput.concat(this.numberToBytes32(this.args[0][1]));
|
|
43
|
+
// from
|
|
44
|
+
encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][2]));
|
|
45
|
+
// rateMode
|
|
46
|
+
encodedInput = encodedInput.concat(this.numberToBytes1(this.args[0][3]));
|
|
47
|
+
// assetId
|
|
48
|
+
encodedInput = encodedInput.concat(this.numberToBytes2(this.args[0][4]));
|
|
49
|
+
return encodedInput;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = AaveV3ATokenPaybackAction;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const L2Action = require("../../L2Action");
|
|
2
|
+
const { getAddr } = require('../../addresses.js');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* AaveV3BorrowAction - Borrow a token from AaveV3
|
|
6
|
+
*/
|
|
7
|
+
class AaveV3BorrowAction extends L2Action {
|
|
8
|
+
/**
|
|
9
|
+
* @param market {EthAddress} Address provider for specific market
|
|
10
|
+
* @param amount {string} Amount of tokens to be borrowed
|
|
11
|
+
* @param to {EthAddress} The address we are sending the borrowed tokens to
|
|
12
|
+
* @param rateMode {number} Type of borrow debt [Stable: 1, Variable: 2]
|
|
13
|
+
* @param assetId {number} The id of the token to be borrowed
|
|
14
|
+
* @param useOnBehalf {boolean} use on behalf or default to proxy
|
|
15
|
+
* @param onBehalf {EthAddress} On whose behalf we borrow the tokens, defaults to proxy
|
|
16
|
+
*/
|
|
17
|
+
constructor(market, amount, to, rateMode, assetId, useOnBehalf , onBehalf = getAddr('Empty')) {
|
|
18
|
+
super('AaveV3Borrow', getAddr('AaveV3Borrow'),
|
|
19
|
+
[['address','uint256','address','uint8','uint16','bool', 'address']],
|
|
20
|
+
[[market, amount, to, rateMode, assetId, useOnBehalf, onBehalf]]
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
this.mappableArgs = [
|
|
24
|
+
this.args[0][0],
|
|
25
|
+
this.args[0][1],
|
|
26
|
+
this.args[0][2],
|
|
27
|
+
this.args[0][6],
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
encodeInputs() {
|
|
32
|
+
// executeActionDirectL2
|
|
33
|
+
let encodedInput = "0x2895f3aa";
|
|
34
|
+
// market
|
|
35
|
+
encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][0]));
|
|
36
|
+
// amount
|
|
37
|
+
encodedInput = encodedInput.concat(this.numberToBytes32(this.args[0][1]));
|
|
38
|
+
// to
|
|
39
|
+
encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][2]));
|
|
40
|
+
// rateMode
|
|
41
|
+
encodedInput = encodedInput.concat(this.numberToBytes1(this.args[0][3]));
|
|
42
|
+
// assetId
|
|
43
|
+
encodedInput = encodedInput.concat(this.numberToBytes2(this.args[0][4]));
|
|
44
|
+
// useOnBehalf
|
|
45
|
+
encodedInput = encodedInput.concat(this.boolToBytes1(this.args[0][5]));
|
|
46
|
+
if (this.args[0][5]) {
|
|
47
|
+
// onBehalf
|
|
48
|
+
encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][6]));
|
|
49
|
+
}
|
|
50
|
+
return encodedInput;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
module.exports = AaveV3BorrowAction;
|