@defisaver/sdk 0.3.4 → 0.3.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/sdk",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/Action.js CHANGED
@@ -114,7 +114,11 @@ class Action {
114
114
  }
115
115
 
116
116
  encodeForL2DsProxyCall() {
117
- throw new Error('Not L2'); // TODO improve this
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
- return [
142
- this._encodeForCall()[0], // actionCallData
143
- "0x0000000000000000000000000000000000000000000000000000000000000000", // subData
144
- this.getId(), // actionIds
145
- this._getArgumentMapping(), // paramMappings
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) {
@@ -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
 
@@ -24,6 +24,10 @@ class AaveV3BorrowAction extends ActionWithL2 {
24
24
  this.mappableArgs = [
25
25
  this.args[0],
26
26
  this.args[1],
27
+ this.args[2],
28
+ this.args[3],
29
+ this.args[4],
30
+ this.args[5],
27
31
  this.args[6],
28
32
  this.args[7],
29
33
  ];
@@ -26,6 +26,10 @@ class AaveV3PaybackAction extends ActionWithL2 {
26
26
  this.mappableArgs = [
27
27
  this.args[0],
28
28
  this.args[1],
29
+ this.args[2],
30
+ this.args[3],
31
+ this.args[4],
32
+ this.args[5],
29
33
  this.args[6],
30
34
  this.args[7],
31
35
  ];
@@ -27,6 +27,10 @@ class AaveV3SupplyAction extends ActionWithL2 {
27
27
  this.mappableArgs = [
28
28
  this.args[0],
29
29
  this.args[1],
30
+ this.args[2],
31
+ this.args[3],
32
+ this.args[4],
33
+ this.args[5],
30
34
  this.args[6],
31
35
  this.args[7],
32
36
  ];
@@ -19,6 +19,8 @@ class AaveV3WithdrawAction extends ActionWithL2 {
19
19
  );
20
20
 
21
21
  this.mappableArgs = [
22
+ this.args[0],
23
+ this.args[1],
22
24
  this.args[2],
23
25
  this.args[3],
24
26
  this.args[4],
@@ -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;
@@ -1,6 +1,6 @@
1
1
  const ActionAbi = require('../../abis/Action.json');
2
2
  const AbiCoder = require('web3-eth-abi');
3
- const ActionWithL2 = require("../../ActionWithL2");
3
+ const Action = require("../../Action");
4
4
  const { requireAddress } = require("../../utils/general");
5
5
  const { getAssetInfoByAddress } = require("@defisaver/tokens");
6
6
  const { getAddr } = require('../../addresses.js');
@@ -8,7 +8,7 @@ const { getAddr } = require('../../addresses.js');
8
8
  /**
9
9
  * Sells token on DeFi Saver exchange aggregator
10
10
  */
11
- class SellAction extends ActionWithL2 {
11
+ class SellAction extends Action {
12
12
  /**
13
13
  * @param exchangeOrder {Array} Standard DFS Exchange data
14
14
  * @param from {string} Order sender
@@ -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
+
@@ -1,5 +1,7 @@
1
1
  const MakerRatioCheckAction = require('./MakerRatioCheckAction');
2
+ const AaveV3RatioCheckAction = require('./AaveV3RatioCheckAction');
2
3
 
3
4
  module.exports = {
4
5
  MakerRatioCheckAction,
6
+ AaveV3RatioCheckAction,
5
7
  };
package/src/addresses.js CHANGED
@@ -149,15 +149,19 @@ const actionAddresses = {
149
149
 
150
150
  // aave v3
151
151
  AaveV3ATokenPayback: '0x71B27114D1777298bD46c3770C42F9f807C49847',
152
- AaveV3Borrow: '0x4d3F58460aE2bC71fFaeb33838BFA3b5610083Db',
152
+ AaveV3Borrow: '0x8CaDc8A911D19B9e4D36c9bAdE47d970f362BcEa',
153
153
  AaveV3CollateralSwitch: '0x20D1388Ffa0A2D6ff6328AD014C67051542ca3a8',
154
- AaveV3Payback: '0x09DC201A6380882752bCdC7bC721D384f716A5a4',
154
+ AaveV3Payback: '0x88eb4050e89FecE4DF940109B0e58daF9B59e551',
155
155
  AaveV3SetEMode: '0x7F264737066b9b7D9729Fe9715abB97423D8b35B',
156
- AaveV3Supply: '0xe431c1C673Be123045c8635b0196d51a5bFE55c1',
156
+ AaveV3Supply: '0x4Ad0cf94e82b58C414266b84ACB061b41bf1bdF7',
157
157
  AaveV3SwapBorrowRateMode: '0xB8f0243b492f0e80feF5315Ba8692e7635481845',
158
- AaveV3Withdraw: '0xD0130ecB810C6F8d58e60DC417357F6048Ea32e7',
158
+ AaveV3Withdraw: '0xf19d045f6cFc04A5Ee5E0e8837b565b9f276e3F7',
159
159
 
160
160
  FLAaveV3: '0x352D4a1622f2DC34c738F542934372855f219F05',
161
+
162
+ AaveV3RatioTrigger: '0xB76e3f7694589D0f34ba43b17AD0D15350Ab5f85',
163
+ GasFeeTakerL2: '0xB3dB299622A9DB0E944ccda2Ef899d6fF365B082',
164
+ AaveV3RatioCheck: '0x7A36779a7b5F1128B28932604057d5b63361297c',
161
165
  },
162
166
  [NETWORKS.arbitrum.chainId]: {
163
167
  DFSSell: '0x77c02Bb7CbBb2F896c5Ea14e1b60D65f81e552db',
@@ -180,6 +184,8 @@ const actionAddresses = {
180
184
  AaveV3Withdraw: '0x204ae0d3f7cB0db44A297DC4aD433298ed2042F3',
181
185
 
182
186
  FLAaveV3: '0x3Cc0d5DAE1B94e294152C3150aA732b97af603E1',
187
+ GasFeeTakerL2: '0x0000000000000000000000000000000000000000',
188
+ AaveV3RatioCheck: '0x0000000000000000000000000000000000000000',
183
189
  }
184
190
  };
185
191
 
@@ -202,7 +208,7 @@ const otherAddresses = {
202
208
  Empty: '0x0000000000000000000000000000000000000000',
203
209
  },
204
210
  [NETWORKS.optimism.chainId]: {
205
- RecipeExecutor: '0xe91ff198bA6DFA97A7B4Fa43e5a606c915B0471f',
211
+ RecipeExecutor: '0x44FDe16DDCd7c02bE28de52CEc08997336051735',
206
212
  DFSRegistry: '0xAf707Ee480204Ed6e2640B53cE86F680D28Afcbd',
207
213
  ProxyRegistry: '0x283Cc5C26e53D66ed2Ea252D986F094B37E6e895',
208
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;
@@ -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
  }