@defisaver/sdk 0.3.3 → 0.3.6
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/package.json +1 -1
- package/src/Action.js +11 -7
- package/src/ActionWithL2.js +2 -0
- package/src/Strategy.js +0 -4
- package/src/actions/aaveV3/AaveV3BorrowAction.js +4 -0
- package/src/actions/aaveV3/AaveV3PaybackAction.js +4 -0
- package/src/actions/aaveV3/AaveV3SupplyAction.js +4 -0
- package/src/actions/aaveV3/AaveV3WithdrawAction.js +2 -0
- package/src/actions/basic/GasFeeActionL2.js +28 -0
- package/src/actions/basic/index.js +2 -0
- package/src/actions/checkers/AaveV3RatioCheckAction.js +24 -0
- package/src/actions/checkers/index.js +2 -0
- package/src/addresses.js +16 -5
- package/src/triggers/AaveV3RatioTrigger.js +11 -0
- package/src/triggers/index.js +2 -0
package/package.json
CHANGED
package/src/Action.js
CHANGED
|
@@ -114,7 +114,11 @@ class Action {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
encodeForL2DsProxyCall() {
|
|
117
|
-
|
|
117
|
+
return this._encodeForCall()[0];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
encodeForL2Recipe() {
|
|
121
|
+
return this._encodeForCall()[0];
|
|
118
122
|
}
|
|
119
123
|
|
|
120
124
|
/**
|
|
@@ -138,12 +142,12 @@ class Action {
|
|
|
138
142
|
* @returns {Array<string>}
|
|
139
143
|
*/
|
|
140
144
|
encodeForRecipe() {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
return [
|
|
146
|
+
this._encodeForCall()[0], // actionCallData
|
|
147
|
+
"0x0000000000000000000000000000000000000000000000000000000000000000", // subData
|
|
148
|
+
this.getId(), // actionIds
|
|
149
|
+
this._getArgumentMapping(), // paramMappings
|
|
150
|
+
]
|
|
147
151
|
}
|
|
148
152
|
|
|
149
153
|
encodeForStrategy(subSlots) {
|
package/src/ActionWithL2.js
CHANGED
|
@@ -8,6 +8,8 @@ class ActionWithL2 extends Action {
|
|
|
8
8
|
*/
|
|
9
9
|
encodeForL2DsProxyCall() { return this.encodeInputs(); }
|
|
10
10
|
|
|
11
|
+
encodeForL2Recipe() { return `0x${this.encodeInputs().slice(10)}`; } // cut the method id
|
|
12
|
+
|
|
11
13
|
encodeInputs() { throw new Error('Use implementation from specific ActionWithL2'); }
|
|
12
14
|
|
|
13
15
|
addressToBytes20(address) { return address.slice(2); }
|
package/src/Strategy.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
const Action = require('./Action');
|
|
2
|
-
|
|
3
|
-
// TODO: Code is a prototype should be cleaned up before use in prod.
|
|
4
|
-
|
|
5
2
|
class Strategy {
|
|
6
3
|
|
|
7
4
|
constructor(name) {
|
|
@@ -35,7 +32,6 @@ class Strategy {
|
|
|
35
32
|
return this.subSlots;
|
|
36
33
|
}
|
|
37
34
|
|
|
38
|
-
// TODO: Probably should be tied into Recipe obj. not directly with actions
|
|
39
35
|
encodeForDsProxyCall() {
|
|
40
36
|
const triggerIds = this.triggers.map((trigger) => trigger.getId());
|
|
41
37
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const Action = require("../../Action");
|
|
2
|
+
const {getAddr} = require("../../addresses.js");
|
|
3
|
+
|
|
4
|
+
class GasFeeActionL2 extends Action {
|
|
5
|
+
/**
|
|
6
|
+
* @param gasStart {string} Always 0 will be inject value
|
|
7
|
+
* @param feeToken {string} Address of the token we are taken the fee in
|
|
8
|
+
* @param availableAmount Amount we have available to pay the gas fee
|
|
9
|
+
* @param dfsFeeDivider Additional fee for DFS, default is 5bps
|
|
10
|
+
* @param l1GasCostInEth Additional tx cost for L1 in eth
|
|
11
|
+
*/
|
|
12
|
+
constructor(gasStart, feeToken, availableAmount, dfsFeeDivider = 2000, l1GasCostInEth = 0) {
|
|
13
|
+
super("GasFeeTakerL2",
|
|
14
|
+
getAddr("GasFeeTakerL2"),
|
|
15
|
+
["uint256", "address", "uint256", "uint256", "uint256"],
|
|
16
|
+
[gasStart, feeToken, availableAmount, dfsFeeDivider, l1GasCostInEth],
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
this.mappableArgs = [
|
|
20
|
+
this.args[1],
|
|
21
|
+
this.args[2],
|
|
22
|
+
this.args[3],
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = GasFeeActionL2;
|
|
@@ -12,6 +12,7 @@ const AutomationV2Unsub = require('./AutomationV2Unsub');
|
|
|
12
12
|
const GasFeeAction = require('./GasFeeAction');
|
|
13
13
|
const UpdateSubAction = require('./UpdateSubAction');
|
|
14
14
|
const ToggleSubAction = require('./ToggleSubAction');
|
|
15
|
+
const GasFeeActionL2 = require('./GasFeeActionL2');
|
|
15
16
|
|
|
16
17
|
module.exports = {
|
|
17
18
|
SellAction,
|
|
@@ -28,4 +29,5 @@ module.exports = {
|
|
|
28
29
|
UpdateSubAction,
|
|
29
30
|
SendTokenAndUnwrapAction,
|
|
30
31
|
ToggleSubAction,
|
|
32
|
+
GasFeeActionL2,
|
|
31
33
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const Action = require("../../Action");
|
|
2
|
+
const {getAddr} = require("../../addresses.js");
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* AaveV3RatioCheckAction - Checks aave V3 ratio for users proxy position and reverts if faulty
|
|
6
|
+
*/
|
|
7
|
+
class AaveV3RatioCheckAction extends Action {
|
|
8
|
+
/**
|
|
9
|
+
* @param ratioState {uint8} If it should lower/higher
|
|
10
|
+
* @param targetRatio {string} The ratio user want to be at
|
|
11
|
+
*/
|
|
12
|
+
constructor(ratioState, targetRatio) {
|
|
13
|
+
super("AaveV3RatioCheck", getAddr("AaveV3RatioCheck"), ["uint8","uint256"], [ratioState, targetRatio]);
|
|
14
|
+
|
|
15
|
+
this.mappableArgs = [
|
|
16
|
+
this.args[0],
|
|
17
|
+
this.args[1],
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = AaveV3RatioCheckAction;
|
|
24
|
+
|
package/src/addresses.js
CHANGED
|
@@ -131,6 +131,11 @@ const actionAddresses = {
|
|
|
131
131
|
|
|
132
132
|
CurveDeposit: '0x160225c24300bD9fAA03Bc007D5e72bDbbcA9257',
|
|
133
133
|
CurveWithdraw: '0xA2A6D75417807ebAf8364613018D697f88021771',
|
|
134
|
+
|
|
135
|
+
// Convex
|
|
136
|
+
ConvexDeposit: '0x3Ecc4F1FD5aA09D2E13Ec9ebFdF102063d66F458',
|
|
137
|
+
ConvexWithdraw: '0x2B2c235F9e27A121947c34A39d447bD4C585aA15',
|
|
138
|
+
ConvexClaim: '0xA012afAA97B48894b8FCB2ECC007045Be7a8E8B6',
|
|
134
139
|
},
|
|
135
140
|
[NETWORKS.optimism.chainId]: {
|
|
136
141
|
DFSSell: '0xBA0f6039b95CC0A02B5fc983eCf0FC4437BaacC7',
|
|
@@ -144,15 +149,19 @@ const actionAddresses = {
|
|
|
144
149
|
|
|
145
150
|
// aave v3
|
|
146
151
|
AaveV3ATokenPayback: '0x71B27114D1777298bD46c3770C42F9f807C49847',
|
|
147
|
-
AaveV3Borrow: '
|
|
152
|
+
AaveV3Borrow: '0x8CaDc8A911D19B9e4D36c9bAdE47d970f362BcEa',
|
|
148
153
|
AaveV3CollateralSwitch: '0x20D1388Ffa0A2D6ff6328AD014C67051542ca3a8',
|
|
149
|
-
AaveV3Payback: '
|
|
154
|
+
AaveV3Payback: '0x88eb4050e89FecE4DF940109B0e58daF9B59e551',
|
|
150
155
|
AaveV3SetEMode: '0x7F264737066b9b7D9729Fe9715abB97423D8b35B',
|
|
151
|
-
AaveV3Supply: '
|
|
156
|
+
AaveV3Supply: '0x4Ad0cf94e82b58C414266b84ACB061b41bf1bdF7',
|
|
152
157
|
AaveV3SwapBorrowRateMode: '0xB8f0243b492f0e80feF5315Ba8692e7635481845',
|
|
153
|
-
AaveV3Withdraw: '
|
|
158
|
+
AaveV3Withdraw: '0xf19d045f6cFc04A5Ee5E0e8837b565b9f276e3F7',
|
|
154
159
|
|
|
155
160
|
FLAaveV3: '0x352D4a1622f2DC34c738F542934372855f219F05',
|
|
161
|
+
|
|
162
|
+
AaveV3RatioTrigger: '0xB76e3f7694589D0f34ba43b17AD0D15350Ab5f85',
|
|
163
|
+
GasFeeTakerL2: '0xB3dB299622A9DB0E944ccda2Ef899d6fF365B082',
|
|
164
|
+
AaveV3RatioCheck: '0x7A36779a7b5F1128B28932604057d5b63361297c',
|
|
156
165
|
},
|
|
157
166
|
[NETWORKS.arbitrum.chainId]: {
|
|
158
167
|
DFSSell: '0x77c02Bb7CbBb2F896c5Ea14e1b60D65f81e552db',
|
|
@@ -175,6 +184,8 @@ const actionAddresses = {
|
|
|
175
184
|
AaveV3Withdraw: '0x204ae0d3f7cB0db44A297DC4aD433298ed2042F3',
|
|
176
185
|
|
|
177
186
|
FLAaveV3: '0x3Cc0d5DAE1B94e294152C3150aA732b97af603E1',
|
|
187
|
+
GasFeeTakerL2: '0x0000000000000000000000000000000000000000',
|
|
188
|
+
AaveV3RatioCheck: '0x0000000000000000000000000000000000000000',
|
|
178
189
|
}
|
|
179
190
|
};
|
|
180
191
|
|
|
@@ -197,7 +208,7 @@ const otherAddresses = {
|
|
|
197
208
|
Empty: '0x0000000000000000000000000000000000000000',
|
|
198
209
|
},
|
|
199
210
|
[NETWORKS.optimism.chainId]: {
|
|
200
|
-
RecipeExecutor: '
|
|
211
|
+
RecipeExecutor: '0x44FDe16DDCd7c02bE28de52CEc08997336051735',
|
|
201
212
|
DFSRegistry: '0xAf707Ee480204Ed6e2640B53cE86F680D28Afcbd',
|
|
202
213
|
ProxyRegistry: '0x283Cc5C26e53D66ed2Ea252D986F094B37E6e895',
|
|
203
214
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const Action = require("../Action");
|
|
2
|
+
const { getAddr } = require("../addresses.js");
|
|
3
|
+
|
|
4
|
+
class AaveV3RatioTrigger extends Action {
|
|
5
|
+
|
|
6
|
+
constructor(user, market, ratio, state) {
|
|
7
|
+
super("AaveV3RatioTrigger", getAddr("AaveV3RatioTrigger"), [["address", "address", "uint256", "uint8"]], [[...arguments]]);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = AaveV3RatioTrigger;
|
package/src/triggers/index.js
CHANGED
|
@@ -6,6 +6,7 @@ const GasPriceTrigger = require('./GasPriceTrigger');
|
|
|
6
6
|
const CompoundRatioTrigger = require('./CompoundRatioTrigger');
|
|
7
7
|
const ReflexerRatioTrigger = require('./ReflexerRatioTrigger');
|
|
8
8
|
const LiquityRatioTrigger = require('./LiquityRatioTrigger');
|
|
9
|
+
const AaveV3RatioTrigger = require('./AaveV3RatioTrigger');
|
|
9
10
|
|
|
10
11
|
module.exports = {
|
|
11
12
|
MakerRatioTrigger,
|
|
@@ -16,4 +17,5 @@ module.exports = {
|
|
|
16
17
|
CompoundRatioTrigger,
|
|
17
18
|
ReflexerRatioTrigger,
|
|
18
19
|
LiquityRatioTrigger,
|
|
20
|
+
AaveV3RatioTrigger,
|
|
19
21
|
}
|