@defisaver/sdk 0.3.12 → 0.3.14

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.12",
3
+ "version": "0.3.14",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,5 +1,7 @@
1
1
  const Action = require('./Action');
2
2
  const Dec = require('decimal.js');
3
+ const AbiCoder = require('web3-eth-abi');
4
+ const ActionAbi = require('./abis/Action.json');
3
5
 
4
6
  class ActionWithL2 extends Action {
5
7
  /**
@@ -10,7 +12,12 @@ class ActionWithL2 extends Action {
10
12
 
11
13
  encodeForL2Recipe() { return `0x${this.encodeInputs().slice(10)}`; } // cut the method id
12
14
 
13
- encodeInputs() { throw new Error('Use implementation from specific ActionWithL2'); }
15
+ encodeInputs() {
16
+ let _arg = this._replaceWithPlaceholders(this.args, this.paramTypes);
17
+ let _paramType = this._formatType(this.paramTypes);
18
+ const executeActionDirectAbi = ActionAbi.find(({ name }) => name === 'executeActionDirect');
19
+ return AbiCoder.encodeFunctionCall(executeActionDirectAbi, [AbiCoder.encodeParameter(_paramType, _arg)]);
20
+ }
14
21
 
15
22
  addressToBytes20(address) { return address.slice(2); }
16
23
 
@@ -1,10 +1,10 @@
1
- const Action = require("../../Action");
2
- const {getAddr} = require('../../addresses.js');
1
+ const ActionWithL2 = require('../../ActionWithL2');
2
+ const { getAddr } = require('../../addresses.js');
3
3
 
4
4
  /**
5
5
  * Collects fees earned by user on position identified by tokenId
6
6
  */
7
- class UniswapV3CollectAction extends Action {
7
+ class UniswapV3CollectAction extends ActionWithL2 {
8
8
  /**
9
9
  * @param {string} tokenId
10
10
  * @param {EthAddress} recipient
@@ -1,11 +1,12 @@
1
- const Action = require("../../Action");
2
- const {getAddr} = require('../../addresses.js');
3
- const {getAssetInfoByAddress} = require("@defisaver/tokens");
1
+ const { getAssetInfoByAddress } = require('@defisaver/tokens');
2
+
3
+ const ActionWithL2 = require('../../ActionWithL2');
4
+ const { getAddr } = require('../../addresses.js');
4
5
 
5
6
  /**
6
7
  * Create a uniswap v3 pool
7
8
  */
8
- class UniswapV3CreatePoolAction extends Action {
9
+ class UniswapV3CreatePoolAction extends ActionWithL2 {
9
10
  /**
10
11
  * @param {EthAddress} token0
11
12
  * @param {EthAddress} token1
@@ -1,12 +1,13 @@
1
- const Action = require("../../Action");
2
- const {getAddr} = require('../../addresses.js');
3
- const {getAssetInfoByAddress} = require("@defisaver/tokens");
1
+ const { getAssetInfoByAddress } = require('@defisaver/tokens');
2
+
3
+ const ActionWithL2 = require('../../ActionWithL2');
4
+ const { getAddr } = require('../../addresses.js');
4
5
 
5
6
 
6
7
  /**
7
8
  * Creates a new Uniswap v3 LP supply position
8
9
  */
9
- class UniswapV3MintAction extends Action {
10
+ class UniswapV3MintAction extends ActionWithL2 {
10
11
  /**
11
12
  * @param {EthAddress} token0
12
13
  * @param {EthAddress} token1
@@ -1,11 +1,12 @@
1
- const {getAssetInfoByAddress} = require("@defisaver/tokens");
2
- const Action = require("../../Action");
3
- const {getAddr} = require('../../addresses.js');
1
+ const { getAssetInfoByAddress } = require('@defisaver/tokens');
2
+
3
+ const ActionWithL2 = require('../../ActionWithL2');
4
+ const { getAddr } = require('../../addresses.js');
4
5
 
5
6
  /**
6
7
  * Supplies a pair of tokens to an existing Uniswap v3 position identified by tokenId
7
8
  */
8
- class UniswapV3SupplyAction extends Action {
9
+ class UniswapV3SupplyAction extends ActionWithL2 {
9
10
  /**
10
11
  * @param {string} tokenId
11
12
  * @param {string} amount0Desired
@@ -1,10 +1,10 @@
1
- const Action = require("../../Action");
2
- const {getAddr} = require('../../addresses.js');
1
+ const ActionWithL2 = require('../../ActionWithL2');
2
+ const { getAddr } = require('../../addresses.js');
3
3
 
4
4
  /**
5
5
  * Burns liquidity, and returns underlying tokens to recipient
6
6
  */
7
- class UniswapV3WithdrawAction extends Action {
7
+ class UniswapV3WithdrawAction extends ActionWithL2 {
8
8
  /**
9
9
  * @param {string} tokenId
10
10
  * @param {string} liquidity
package/src/addresses.js CHANGED
@@ -161,10 +161,16 @@ const actionAddresses = {
161
161
  AaveV3ClaimRewards: '0xBE8e8cea67085F869C1C0040fD52F9F3115E962e',
162
162
 
163
163
  FLAaveV3: '0x352D4a1622f2DC34c738F542934372855f219F05',
164
-
165
164
  AaveV3RatioTrigger: '0xB76e3f7694589D0f34ba43b17AD0D15350Ab5f85',
166
165
  GasFeeTakerL2: '0xB3dB299622A9DB0E944ccda2Ef899d6fF365B082',
167
166
  AaveV3RatioCheck: '0x7A36779a7b5F1128B28932604057d5b63361297c',
167
+
168
+ // uniswap V3
169
+ UniCollectV3: '0xad1D55a73D6d8b2218a4aD599c88d9550fb54cd7',
170
+ UniMintV3: '0x7548E3923A9f9e4e182C939CC78FA30050414D12',
171
+ UniSupplyV3: '0x533aDec68Eed581F4a7F202493Eaf4Df77b89EC0',
172
+ UniWithdrawV3: '0xE920235ED2d52EcF6157BBAFedfB5bbbcF7c5825',
173
+ UniCreatePoolV3: '0xAF45d1380d89dB7260DC2684158c5dfA4E147d3e',
168
174
  },
169
175
  [NETWORKS.arbitrum.chainId]: {
170
176
  DFSSell: '0x77c02Bb7CbBb2F896c5Ea14e1b60D65f81e552db',
@@ -177,7 +183,6 @@ const actionAddresses = {
177
183
  SendTokenAndUnwrap: '0x0fb867A5Ee1CA9426D3dAb95e613Be166218b977',
178
184
  ToggleSub: '0x71015226EADFd4aC887fB56556F64338e352439b',
179
185
 
180
-
181
186
  // aave v3
182
187
  AaveV3ATokenPayback: '0x261906e5E0D0D38D9cBb5c10dB9c4031aabdf8C1',
183
188
  AaveV3Borrow: '0x5786809DA660dB613994460F096F19fcd19eD4c9',
@@ -191,6 +196,13 @@ const actionAddresses = {
191
196
  FLAaveV3: '0x3Cc0d5DAE1B94e294152C3150aA732b97af603E1',
192
197
  GasFeeTakerL2: '0x2F64f73B222B4978CAfd0295c0fa106cE5f34996',
193
198
  AaveV3RatioCheck: '0x4a5c2cbCFB921b596Dec049389899CC8Eb4678ED',
199
+
200
+ // uniswap V3
201
+ UniCollectV3: '0xd521cbEfE58440d1C31FD0baF41fdfE18D028704',
202
+ UniMintV3: '0x7AC778fB7CaB7D368f37d6E7CE3c293077969331',
203
+ UniSupplyV3: '0x55675C6041A33EE9BDd796Edaa0f098AC7F3534f',
204
+ UniWithdrawV3: '0xa004c22eFd0CD87847DE83Ce9ab92af5382c2efe',
205
+ UniCreatePoolV3: '0x334Ab3C12a4c0315566fd9308880Dad71F838Dc5',
194
206
  }
195
207
  };
196
208
 
@@ -221,6 +233,8 @@ const otherAddresses = {
221
233
  AdminVault: '0x136b1bEAfff362530F98f10E3D8C38f3a3F3d38C',
222
234
  DefisaverLogger: '0xFc2f1355296ab7dd98a1260E3Ff5E906999d4Acb',
223
235
  Empty: '0x0000000000000000000000000000000000000000',
236
+
237
+ UniswapV3PositionManager : '0xC36442b4a4522E871399CD717aBDD847Ab11FE88',
224
238
  },
225
239
  [NETWORKS.arbitrum.chainId]: {
226
240
  RecipeExecutor: '0xe775c59e5662597bcE8aB4432C06380709554883',
@@ -231,6 +245,8 @@ const otherAddresses = {
231
245
  AdminVault: '0xd47D8D97cAd12A866900eEc6Cde1962529F25351',
232
246
  DefisaverLogger: '0xE6f9A5C850dbcD12bc64f40d692F537250aDEC38',
233
247
  Empty: '0x0000000000000000000000000000000000000000',
248
+
249
+ UniswapV3PositionManager : '0xC36442b4a4522E871399CD717aBDD847Ab11FE88',
234
250
  },
235
251
  };
236
252