@defisaver/sdk 0.3.16 → 0.3.18

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.16",
3
+ "version": "0.3.18",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,7 +1,5 @@
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');
5
3
 
6
4
  class ActionWithL2 extends Action {
7
5
  /**
@@ -12,12 +10,7 @@ class ActionWithL2 extends Action {
12
10
 
13
11
  encodeForL2Recipe() { return `0x${this.encodeInputs().slice(10)}`; } // cut the method id
14
12
 
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
- }
13
+ encodeInputs() { throw new Error('Use implementation from specific ActionWithL2'); }
21
14
 
22
15
  addressToBytes20(address) { return address.slice(2); }
23
16
 
@@ -0,0 +1,26 @@
1
+ const Action = require("../../Action");
2
+ const {requireAddress} = require("../../utils/general");
3
+ const { getAddr } = require('../../addresses.js');
4
+
5
+ /**
6
+ * CompoundV3AllowAction - Change if manager has authority over owner based on isAllowed from CompoundV3
7
+ */
8
+ class CompoundV3AllowAction extends Action {
9
+ /**
10
+ * @param market {EthAddress} Comet proxy address of the market
11
+ * @param manager {EthAddress} address of manager
12
+ * @param isAllowed {bool}
13
+ */
14
+ constructor(market, manager, isAllowed) {
15
+ requireAddress(manager);
16
+ super('CompV3Allow', getAddr('CompV3Allow'), ['address', 'address','bool'], [...arguments]);
17
+
18
+ this.mappableArgs = [
19
+ this.args[0],
20
+ this.args[1],
21
+ this.args[2],
22
+ ];
23
+ }
24
+ }
25
+
26
+ module.exports = CompoundV3AllowAction;
@@ -0,0 +1,26 @@
1
+ const Action = require("../../Action");
2
+ const {requireAddress} = require("../../utils/general");
3
+ const { getAddr } = require('../../addresses.js');
4
+
5
+ /**
6
+ * CompoundV3BorrowAction - Borrow base tokens from CompoundV3
7
+ */
8
+ class CompoundV3BorrowAction extends Action {
9
+ /**
10
+ * @param market {EthAddress} Comet proxy address of the market
11
+ * @param amount {string} Wei amount in underlying asset decimals (not cAsset) - ie. 18 dec for cETH, not 8
12
+ * @param to {EthAddress}
13
+ */
14
+ constructor(market, amount, to) {
15
+ requireAddress(to);
16
+ super('CompV3Borrow', getAddr('CompV3Borrow'), ['address','uint256','address'], [...arguments]);
17
+
18
+ this.mappableArgs = [
19
+ this.args[0],
20
+ this.args[1],
21
+ this.args[2],
22
+ ];
23
+ }
24
+ }
25
+
26
+ module.exports = CompoundV3BorrowAction;
@@ -0,0 +1,34 @@
1
+ const Action = require("../../Action");
2
+ const { requireAddress } = require("../../utils/general");
3
+ const { getAddr } = require("../../addresses.js");
4
+
5
+ /**
6
+ * CompoundV3ClaimAction - Claims Comp tokens to, and for, a specified address
7
+ */
8
+ class CompoundV3ClaimAction extends Action {
9
+ /**
10
+ * @param market {EthAddress} Comet proxy address of the market
11
+ * @param onBehalfOf {EthAddress} The owner to claim for
12
+ * @param to {EthAddress} The address to receive the rewards
13
+ * @param shouldAccrue {bool} If true, the protocol will account for the rewards owed to the account as of the current block before transferring
14
+ */
15
+ constructor(market, onBehalfOf, to, shouldAccrue) {
16
+ requireAddress(onBehalfOf);
17
+ requireAddress(to);
18
+ super(
19
+ "CompV3Claim",
20
+ getAddr("CompV3Claim"),
21
+ ["address","address", "address", "bool"],
22
+ [...arguments]
23
+ );
24
+
25
+ this.mappableArgs = [
26
+ this.args[0],
27
+ this.args[1],
28
+ this.args[2],
29
+ this.args[3],
30
+ ];
31
+ }
32
+ }
33
+
34
+ module.exports = CompoundV3ClaimAction;
@@ -0,0 +1,44 @@
1
+ const Action = require("../../Action");
2
+ const {requireAddress} = require("../../utils/general");
3
+ const { getAddr } = require('../../addresses.js');
4
+ const {getAssetInfoByAddress} = require("@defisaver/tokens");
5
+
6
+ /**
7
+ * CompoundV3PaybackAction - Repays specified amount of base token
8
+ */
9
+ class CompoundV3PaybackAction extends Action {
10
+ /**
11
+ * @param market {EthAddress} Comet proxy address of the market
12
+ * @param amount {uint256} amount of base token to be paid back
13
+ * @param from {EthAddress} address from which funds are paid
14
+ * @param onBehalf {EthAddress} address for which the funds are paid back
15
+ * @param asset {EthAddress} address for which the funds are paid back
16
+ */
17
+ constructor(market, amount, from, onBehalf,asset) {
18
+ requireAddress(from);
19
+ requireAddress(onBehalf);
20
+ requireAddress(asset)
21
+ super(
22
+ 'CompV3Payback',
23
+ getAddr('CompV3Payback'),
24
+ ['address','uint256','address','address'],
25
+ [...arguments].slice(0,4)
26
+ );
27
+ this.mappableArgs = [
28
+ this.args[0],
29
+ this.args[1],
30
+ this.args[2],
31
+ this.args[3],
32
+ ];
33
+ this.tokenForApproval = asset;
34
+ }
35
+
36
+ async getAssetsToApprove() {
37
+ const asset = getAssetInfoByAddress(this.tokenForApproval);
38
+
39
+ if (asset.symbol !== 'ETH') return [{asset: this.tokenForApproval, owner: this.args[2]}];
40
+ return [];
41
+ }
42
+ }
43
+
44
+ module.exports = CompoundV3PaybackAction;
@@ -0,0 +1,36 @@
1
+ const Action = require("../../Action");
2
+ const {requireAddress} = require("../../utils/general");
3
+ const { getAddr } = require('../../addresses.js');
4
+ const {getAssetInfoByAddress} = require("@defisaver/tokens");
5
+
6
+ /**
7
+ * CompoundV3SupplyAction - Supply specified amount of token (base or collateral)
8
+ */
9
+ class CompoundV3SupplyAction extends Action {
10
+ /**
11
+ * @param market {EthAddress} Comet proxy address of the market
12
+ * @param tokenAddr {EthAddress}
13
+ * @param amount {uint256} wei amount of asset to supply
14
+ * @param from {EthAddress}
15
+ */
16
+ constructor(market, tokenAddr, amount, from,) {
17
+ super('CompV3Supply', getAddr('CompV3Supply'), ['address','address','uint256','address'], [market, tokenAddr, amount, from]);
18
+
19
+ this.mappableArgs = [
20
+ this.args[0],
21
+ this.args[1],
22
+ this.args[2],
23
+ this.args[3]
24
+ ];
25
+ this.tokenForApproval = tokenAddr;
26
+ }
27
+
28
+ async getAssetsToApprove() {
29
+ const asset = getAssetInfoByAddress(this.tokenForApproval);
30
+
31
+ if (asset.symbol !== 'ETH') return [{asset: this.tokenForApproval, owner: this.args[1]}];
32
+ return [];
33
+ }
34
+ }
35
+
36
+ module.exports = CompoundV3SupplyAction;
@@ -0,0 +1,37 @@
1
+ const Action = require("../../Action");
2
+ const {requireAddress} = require("../../utils/general");
3
+ const { getAddr } = require('../../addresses.js');
4
+
5
+ /**
6
+ * CompoundV3TransferAction - Transfer specified amount of assets from src address to dst
7
+ */
8
+ class CompoundV3TransferAction extends Action {
9
+ /**
10
+ * @param market {EthAddress} Comet proxy address of the market
11
+ * @param from {EthAddress} address of src
12
+ * @param to {EthAddress} address of dst
13
+ * @param asset {EthAddress} address of ERC20 token
14
+ * @param amount {uint256} amount of assets to be transferred
15
+ */
16
+ constructor(market, from, to, asset, amount) {
17
+ requireAddress(from);
18
+ requireAddress(to);
19
+ requireAddress(asset);
20
+ super(
21
+ 'CompV3Transfer',
22
+ getAddr('CompV3Transfer'),
23
+ ['address','address','address','address','uint256'],
24
+ [...arguments]
25
+ );
26
+
27
+ this.mappableArgs = [
28
+ this.args[0],
29
+ this.args[1],
30
+ this.args[2],
31
+ this.args[3],
32
+ this.args[4],
33
+ ];
34
+ }
35
+ }
36
+
37
+ module.exports = CompoundV3TransferAction;
@@ -0,0 +1,34 @@
1
+ const Action = require("../../Action");
2
+ const { requireAddress } = require("../../utils/general");
3
+ const { getAddr } = require("../../addresses.js");
4
+
5
+ /**
6
+ * CompoundV3WithdrawAction - Withdraw token from an Compound position
7
+ */
8
+ class CompoundV3WithdrawAction extends Action {
9
+ /**
10
+ * @param market {EthAddress} Comet proxy address of the market
11
+ * @param to {EthAddress} Address of the recipient
12
+ * @param asset {EthAddress} Address of asset to withdraw
13
+ * @param amount {string} Wei amount in specified asset
14
+ */
15
+ constructor(market, to, asset, amount) {
16
+ requireAddress(to);
17
+ requireAddress(asset);
18
+ super(
19
+ "CompV3Withdraw",
20
+ getAddr("CompV3Withdraw"),
21
+ ["address","address", "address", "uint256"],
22
+ [...arguments]
23
+ );
24
+
25
+ this.mappableArgs = [
26
+ this.args[0],
27
+ this.args[1],
28
+ this.args[2],
29
+ this.args[3],
30
+ ];
31
+ }
32
+ }
33
+
34
+ module.exports = CompoundV3WithdrawAction;
@@ -0,0 +1,17 @@
1
+ const CompoundV3SupplyAction = require('./CompoundV3SupplyAction');
2
+ const CompoundV3BorrowAction = require('./CompoundV3BorrowAction');
3
+ const CompoundV3PaybackAction = require('./CompoundV3PaybackAction');
4
+ const CompoundV3WithdrawAction = require('./CompoundV3WithdrawAction');
5
+ const CompoundV3ClaimAction = require('./CompoundV3ClaimAction');
6
+ const CompoundV3AllowAction = require('./CompoundV3AllowAction');
7
+ const CompoundV3TransferAction = require('./CompoundV3TransferAction');
8
+
9
+ module.exports = {
10
+ CompoundV3SupplyAction,
11
+ CompoundV3BorrowAction,
12
+ CompoundV3PaybackAction,
13
+ CompoundV3WithdrawAction,
14
+ CompoundV3TransferAction,
15
+ CompoundV3AllowAction,
16
+ CompoundV3ClaimAction,
17
+ }
@@ -19,6 +19,7 @@ const mstable = require('./mstable');
19
19
  const rari = require('./rari');
20
20
  const aaveV3 = require('./aaveV3');
21
21
  const convex = require('./convex');
22
+ const compoundV3 = require('./compoundV3');
22
23
 
23
24
  module.exports = {
24
25
  maker,
@@ -42,4 +43,5 @@ module.exports = {
42
43
  rari,
43
44
  aaveV3,
44
45
  convex,
46
+ compoundV3,
45
47
  };
@@ -1,10 +1,10 @@
1
- const ActionWithL2 = require('../../ActionWithL2');
2
- const { getAddr } = require('../../addresses.js');
1
+ const Action = require("../../Action");
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 ActionWithL2 {
7
+ class UniswapV3CollectAction extends Action {
8
8
  /**
9
9
  * @param {string} tokenId
10
10
  * @param {EthAddress} recipient
@@ -1,12 +1,11 @@
1
- const { getAssetInfoByAddress } = require('@defisaver/tokens');
2
-
3
- const ActionWithL2 = require('../../ActionWithL2');
4
- const { getAddr } = require('../../addresses.js');
1
+ const Action = require("../../Action");
2
+ const {getAddr} = require('../../addresses.js');
3
+ const {getAssetInfoByAddress} = require("@defisaver/tokens");
5
4
 
6
5
  /**
7
6
  * Create a uniswap v3 pool
8
7
  */
9
- class UniswapV3CreatePoolAction extends ActionWithL2 {
8
+ class UniswapV3CreatePoolAction extends Action {
10
9
  /**
11
10
  * @param {EthAddress} token0
12
11
  * @param {EthAddress} token1
@@ -1,13 +1,12 @@
1
- const { getAssetInfoByAddress } = require('@defisaver/tokens');
2
-
3
- const ActionWithL2 = require('../../ActionWithL2');
4
- const { getAddr } = require('../../addresses.js');
1
+ const Action = require("../../Action");
2
+ const {getAddr} = require('../../addresses.js');
3
+ const {getAssetInfoByAddress} = require("@defisaver/tokens");
5
4
 
6
5
 
7
6
  /**
8
7
  * Creates a new Uniswap v3 LP supply position
9
8
  */
10
- class UniswapV3MintAction extends ActionWithL2 {
9
+ class UniswapV3MintAction extends Action {
11
10
  /**
12
11
  * @param {EthAddress} token0
13
12
  * @param {EthAddress} token1
@@ -1,12 +1,11 @@
1
- const { getAssetInfoByAddress } = require('@defisaver/tokens');
2
-
3
- const ActionWithL2 = require('../../ActionWithL2');
4
- const { getAddr } = require('../../addresses.js');
1
+ const {getAssetInfoByAddress} = require("@defisaver/tokens");
2
+ const Action = require("../../Action");
3
+ const {getAddr} = require('../../addresses.js');
5
4
 
6
5
  /**
7
6
  * Supplies a pair of tokens to an existing Uniswap v3 position identified by tokenId
8
7
  */
9
- class UniswapV3SupplyAction extends ActionWithL2 {
8
+ class UniswapV3SupplyAction extends Action {
10
9
  /**
11
10
  * @param {string} tokenId
12
11
  * @param {string} amount0Desired
@@ -1,10 +1,10 @@
1
- const ActionWithL2 = require('../../ActionWithL2');
2
- const { getAddr } = require('../../addresses.js');
1
+ const Action = require("../../Action");
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 ActionWithL2 {
7
+ class UniswapV3WithdrawAction extends Action {
8
8
  /**
9
9
  * @param {string} tokenId
10
10
  * @param {string} liquidity
package/src/addresses.js CHANGED
@@ -79,7 +79,7 @@ const actionAddresses = {
79
79
 
80
80
  // yearn
81
81
  YearnSupply: '0x837D6E7F469b3cC820B0a6Da25415D5aE0A861c4',
82
- YearnWithdraw: '0x563eF9b1075628E62aDc657702517dEA72ca08d6', // CHECK IF REDEPLOY
82
+ YearnWithdraw: '0x563eF9b1075628E62aDc657702517dEA72ca08d6',
83
83
 
84
84
  // liquity
85
85
  LiquityClose: '0x4B2d174129789a88e92D46342201F207132144b7',
@@ -136,6 +136,15 @@ const actionAddresses = {
136
136
  ConvexDeposit: '0x3Ecc4F1FD5aA09D2E13Ec9ebFdF102063d66F458',
137
137
  ConvexWithdraw: '0x2B2c235F9e27A121947c34A39d447bD4C585aA15',
138
138
  ConvexClaim: '0xA012afAA97B48894b8FCB2ECC007045Be7a8E8B6',
139
+
140
+ // CompV3
141
+ CompV3Allow: '0xC4a80f22bf56E0dFa2CB378561B934F41E14bc9f',
142
+ CompV3Borrow: '0xAb01C815063178C3021a516ecaf56915fD0E6534',
143
+ CompV3Claim: '0x4CEa369B63daAc0dA3423c5038a57483c5150986',
144
+ CompV3Payback: '0x6d14b9d69aADcb0d31a3e5d89fba75AB053fc9f0',
145
+ CompV3Supply: '0xAB53342d922Cc52b33486B92dC5dc361b7E4B436',
146
+ CompV3Transfer: '0x0fB2390AEDB2dBeE08cec363c0eD72e9D8e64535',
147
+ CompV3Withdraw: '0x59fED9975cd3bb07bB75490e86751D6025ce0bC2',
139
148
  },
140
149
  [NETWORKS.optimism.chainId]: {
141
150
  DFSSell: '0xBA0f6039b95CC0A02B5fc983eCf0FC4437BaacC7',
@@ -147,7 +156,6 @@ const actionAddresses = {
147
156
  PullToken: '0x392579E020a688068422A925c85f28bFD12a7EBB',
148
157
  SendTokenAndUnwrap: '0x8000174366066923D554cb466e190258A6FF3b1f',
149
158
  ToggleSub: '0x988C5C24AE6348404196267e19962f36961CAc29',
150
- TokenBalance: '0xC6FF5b01f7c7b35b6e093fF70D2332B361C5Be5A',
151
159
 
152
160
 
153
161
  // aave v3
@@ -162,16 +170,10 @@ const actionAddresses = {
162
170
  AaveV3ClaimRewards: '0xBE8e8cea67085F869C1C0040fD52F9F3115E962e',
163
171
 
164
172
  FLAaveV3: '0x352D4a1622f2DC34c738F542934372855f219F05',
173
+
165
174
  AaveV3RatioTrigger: '0xB76e3f7694589D0f34ba43b17AD0D15350Ab5f85',
166
175
  GasFeeTakerL2: '0xB3dB299622A9DB0E944ccda2Ef899d6fF365B082',
167
176
  AaveV3RatioCheck: '0x7A36779a7b5F1128B28932604057d5b63361297c',
168
-
169
- // uniswap V3
170
- UniCollectV3: '0xad1D55a73D6d8b2218a4aD599c88d9550fb54cd7',
171
- UniMintV3: '0x7548E3923A9f9e4e182C939CC78FA30050414D12',
172
- UniSupplyV3: '0x533aDec68Eed581F4a7F202493Eaf4Df77b89EC0',
173
- UniWithdrawV3: '0xE920235ED2d52EcF6157BBAFedfB5bbbcF7c5825',
174
- UniCreatePoolV3: '0xAF45d1380d89dB7260DC2684158c5dfA4E147d3e',
175
177
  },
176
178
  [NETWORKS.arbitrum.chainId]: {
177
179
  DFSSell: '0x77c02Bb7CbBb2F896c5Ea14e1b60D65f81e552db',
@@ -183,7 +185,7 @@ const actionAddresses = {
183
185
  PullToken: '0xD8B3769f74bd9F196C3416a42a91E786948898e6',
184
186
  SendTokenAndUnwrap: '0x0fb867A5Ee1CA9426D3dAb95e613Be166218b977',
185
187
  ToggleSub: '0x71015226EADFd4aC887fB56556F64338e352439b',
186
- TokenBalance: '0x483B903E702F60698Dd8124558C6199922737f1F',
188
+
187
189
 
188
190
  // aave v3
189
191
  AaveV3ATokenPayback: '0x261906e5E0D0D38D9cBb5c10dB9c4031aabdf8C1',
@@ -198,13 +200,6 @@ const actionAddresses = {
198
200
  FLAaveV3: '0x3Cc0d5DAE1B94e294152C3150aA732b97af603E1',
199
201
  GasFeeTakerL2: '0x2F64f73B222B4978CAfd0295c0fa106cE5f34996',
200
202
  AaveV3RatioCheck: '0x4a5c2cbCFB921b596Dec049389899CC8Eb4678ED',
201
-
202
- // uniswap V3
203
- UniCollectV3: '0xd521cbEfE58440d1C31FD0baF41fdfE18D028704',
204
- UniMintV3: '0x7AC778fB7CaB7D368f37d6E7CE3c293077969331',
205
- UniSupplyV3: '0x55675C6041A33EE9BDd796Edaa0f098AC7F3534f',
206
- UniWithdrawV3: '0xa004c22eFd0CD87847DE83Ce9ab92af5382c2efe',
207
- UniCreatePoolV3: '0x334Ab3C12a4c0315566fd9308880Dad71F838Dc5',
208
203
  }
209
204
  };
210
205
 
@@ -235,8 +230,6 @@ const otherAddresses = {
235
230
  AdminVault: '0x136b1bEAfff362530F98f10E3D8C38f3a3F3d38C',
236
231
  DefisaverLogger: '0xFc2f1355296ab7dd98a1260E3Ff5E906999d4Acb',
237
232
  Empty: '0x0000000000000000000000000000000000000000',
238
-
239
- UniswapV3PositionManager : '0xC36442b4a4522E871399CD717aBDD847Ab11FE88',
240
233
  },
241
234
  [NETWORKS.arbitrum.chainId]: {
242
235
  RecipeExecutor: '0xe775c59e5662597bcE8aB4432C06380709554883',
@@ -247,8 +240,6 @@ const otherAddresses = {
247
240
  AdminVault: '0xd47D8D97cAd12A866900eEc6Cde1962529F25351',
248
241
  DefisaverLogger: '0xE6f9A5C850dbcD12bc64f40d692F537250aDEC38',
249
242
  Empty: '0x0000000000000000000000000000000000000000',
250
-
251
- UniswapV3PositionManager : '0xC36442b4a4522E871399CD717aBDD847Ab11FE88',
252
243
  },
253
244
  };
254
245