@defisaver/sdk 1.2.9-dev-2-morpho → 1.2.9-dev-ether-fi

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.
Files changed (31) hide show
  1. package/esm/src/actions/etherfi/EtherFiStakeAction.d.ts +20 -0
  2. package/esm/src/actions/etherfi/EtherFiStakeAction.js +41 -0
  3. package/esm/src/actions/etherfi/EtherFiUnwrapAction.d.ts +19 -0
  4. package/esm/src/actions/etherfi/EtherFiUnwrapAction.js +39 -0
  5. package/esm/src/actions/etherfi/EtherFiWrapAction.d.ts +19 -0
  6. package/esm/src/actions/etherfi/EtherFiWrapAction.js +39 -0
  7. package/esm/src/actions/etherfi/index.d.ts +3 -0
  8. package/esm/src/actions/etherfi/index.js +3 -0
  9. package/esm/src/actions/index.d.ts +2 -1
  10. package/esm/src/actions/index.js +2 -1
  11. package/esm/src/actions/morpho-blue/index.d.ts +0 -1
  12. package/esm/src/actions/morpho-blue/index.js +0 -1
  13. package/esm/src/addresses.d.ts +12 -4
  14. package/esm/src/addresses.js +5 -2
  15. package/esm/src/index.d.ts +48 -16
  16. package/package.json +1 -1
  17. package/src/actions/etherfi/EtherFiStakeAction.ts +38 -0
  18. package/src/actions/etherfi/EtherFiUnwrapAction.ts +31 -0
  19. package/src/actions/etherfi/EtherFiWrapAction.ts +36 -0
  20. package/src/actions/etherfi/index.ts +3 -0
  21. package/src/actions/index.ts +2 -0
  22. package/src/actions/morpho-blue/index.ts +1 -2
  23. package/src/addresses.ts +6 -2
  24. package/test/actions/etherFi/EtherFiStakeAction.js +66 -0
  25. package/test/actions/etherFi/EtherFiUnwrapAction.js +35 -0
  26. package/test/actions/etherFi/EtherFiWrapAction.js +35 -0
  27. package/umd/index.js +287 -153
  28. package/esm/src/actions/morpho-blue/MorphoTokenWrapAction.d.ts +0 -14
  29. package/esm/src/actions/morpho-blue/MorphoTokenWrapAction.js +0 -20
  30. package/src/actions/morpho-blue/MorphoTokenWrapAction.ts +0 -23
  31. package/test/actions/morpho-blue/MorphoTokenWrapAction.js +0 -37
@@ -0,0 +1,31 @@
1
+ import { getAssetInfo } from '@defisaver/tokens';
2
+ import { Action } from '../../Action';
3
+ import { getAddr } from '../../addresses';
4
+ import { EthAddress, uint256 } from '../../types';
5
+ import { requireAddress } from '../../utils/general';
6
+
7
+ /**
8
+ * EtherFiUnwrapAction - Unwrap weETH and receive eETH
9
+ *
10
+ * @category EtherFi
11
+ */
12
+ export class EtherFiUnwrapAction extends Action {
13
+ /**
14
+ * @param amount - amount of weETH to pull
15
+ * @param from - address from which to pull weETH from
16
+ * @param to - address where received eETH will be sent to
17
+ */
18
+ constructor(amount:uint256, from:EthAddress, to:EthAddress) {
19
+ requireAddress(to);
20
+ super('EtherFiUnwrap', getAddr('EtherFiUnwrap'), ['uint256', 'address', 'address'], [amount, from, to]);
21
+ this.mappableArgs = [
22
+ this.args[0],
23
+ this.args[1],
24
+ this.args[2],
25
+ ];
26
+ }
27
+
28
+ async getAssetsToApprove() {
29
+ return [{ asset: getAssetInfo('weETH').address, owner: this.args[1] }];
30
+ }
31
+ }
@@ -0,0 +1,36 @@
1
+ import { getAssetInfo } from '@defisaver/tokens';
2
+ import { Action } from '../../Action';
3
+ import { getAddr } from '../../addresses';
4
+ import { EthAddress, uint256 } from '../../types';
5
+ import { requireAddress } from '../../utils/general';
6
+
7
+ /**
8
+ * EtherFiWrapAction - Wraps eETH into Wrapped eETH (weETH)
9
+ *
10
+ * @category EtherFi
11
+ */
12
+ export class EtherFiWrapAction extends Action {
13
+ /**
14
+ * @param amount - amount of eETH to pull
15
+ * @param from - address from which to pull eETH from
16
+ * @param to - address where received weETH will be sent to
17
+ */
18
+ constructor(amount:uint256, from:EthAddress, to:EthAddress) {
19
+ requireAddress(to);
20
+ super(
21
+ 'EtherFiWrap',
22
+ getAddr('EtherFiWrap'),
23
+ ['uint256', 'address', 'address'],
24
+ [amount, from, to],
25
+ );
26
+ this.mappableArgs = [
27
+ this.args[0],
28
+ this.args[1],
29
+ this.args[2],
30
+ ];
31
+ }
32
+
33
+ async getAssetsToApprove() {
34
+ return [{ asset: getAssetInfo('eETH').address, owner: this.args[1] }];
35
+ }
36
+ }
@@ -0,0 +1,3 @@
1
+ export * from './EtherFiStakeAction';
2
+ export * from './EtherFiWrapAction';
3
+ export * from './EtherFiUnwrapAction';
@@ -32,6 +32,7 @@ import * as merkl from './merkl';
32
32
  import * as eulerV2 from './eulerV2';
33
33
  import * as sky from './sky';
34
34
  import * as stkgho from './stkgho';
35
+ import * as etherfi from './etherfi';
35
36
 
36
37
  export {
37
38
  aave,
@@ -68,4 +69,5 @@ export {
68
69
  eulerV2,
69
70
  sky,
70
71
  stkgho,
72
+ etherfi,
71
73
  };
@@ -5,5 +5,4 @@ export * from './MorphoBluePaybackAction';
5
5
  export * from './MorphoBlueWithdrawCollateralAction';
6
6
  export * from './MorphoBlueWithdrawAction';
7
7
  export * from './MorphoBlueSetAuthAction';
8
- export * from './MorphoBlueSetAuthWithSigAction';
9
- export * from './MorphoTokenWrapAction';
8
+ export * from './MorphoBlueSetAuthWithSigAction';
package/src/addresses.ts CHANGED
@@ -89,7 +89,7 @@ export const actionAddresses = {
89
89
  LSVBorrow: '0x7dFB434527Fdb39854156cDBa9bF4799E36E7e82',
90
90
  LSVSupply: '0x984c00DC098c98bed1CDfe2Ed786Fe1443da6671',
91
91
  LSVPayback: '0x10749CE97583dBcEb54a083386CC8438C4e0FE65',
92
- LSVSell: '0x0c1bb9A39d4A0EF4215Ade19Ce4F954E8419Dfd7',
92
+ LSVSell: '0x10B748Dc504C2515Bb6A9e23CB2F686090b6c584',
93
93
 
94
94
  // morpho aave v2
95
95
  MorphoAaveV2Borrow: '0xa85C3E41Bf9F75a381927e1Aa9b00f77C4631109',
@@ -271,7 +271,6 @@ export const actionAddresses = {
271
271
  MorphoBluePayback: '0x9f437E5F705E02d77adC2e72C34926978776b085',
272
272
  MorphoBlueSetAuth: '0xf30935e20c6357c7bcecd5e58ad6de26d54b9f64',
273
273
  MorphoBlueSetAuthWithSig: '0xE2d5fCDBf73BAd24A0FCAf6B2733933A98021808',
274
- MorphoTokenWrap: '0x10B748Dc504C2515Bb6A9e23CB2F686090b6c584',
275
274
 
276
275
  // llamalend
277
276
  LlamaLendCreate: '0x4349be191ea63173eD98b7fC1b0DeC1ef9Bc6c11',
@@ -295,6 +294,11 @@ export const actionAddresses = {
295
294
  EulerV2View: '0x8932E46Ecf96b5Fe033F5e27Ab6dC755Cb668967',
296
295
 
297
296
  MerklClaim: '0xE88036F3F0D7e216D63726356cA2bC334e305fe5',
297
+
298
+ // etherFi
299
+ EtherFiStake: '0x8D9cDA62DC7Bf75f687c6C8729ABB51ac82E20d5',
300
+ EtherFiWrap: '0x2b10B000292745099Deb15304A247c0816bd8b73',
301
+ EtherFiUnwrap: '0xDd5F7bf1009Edc3EE55AfcD70D417968bf4647C6',
298
302
  },
299
303
  [NETWORKS.optimism.chainId]: {
300
304
  DFSSell: '0x9f234af5c10c136863a20865ba00b26951ab8269',
@@ -0,0 +1,66 @@
1
+ const dfs = require('../../../src');
2
+ const {getAssetInfo} = require("@defisaver/tokens");
3
+ const {encodeForDsProxyCall, encodeForRecipe} = require('../../_actionUtils');
4
+ const {assert} = require('chai');
5
+
6
+ describe('Action: EtherFiStakeAction', () => {
7
+ let action;
8
+ const from = '0x80788de454ad3681d357dc7FcB13c72333f684a7';
9
+ const to = '0x968Cc941aD9074EE687E0423a33E6f2D33d7c327';
10
+ context('Stake 100 WETH tokens without wrapping', () => {
11
+ it('constructor', () => {
12
+ const amount = 100;
13
+ const shouldWrap = false;
14
+ action = new dfs.actions.etherfi.EtherFiStakeAction(
15
+ amount,
16
+ from,
17
+ to,
18
+ shouldWrap,
19
+ );
20
+ assert.equal(action.args[0], amount);
21
+ assert.equal(action.args[1], from);
22
+ assert.equal(action.args[2], to);
23
+ assert.equal(action.args[3], shouldWrap);
24
+ })
25
+ it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
26
+ it('encodeForRecipe', () => encodeForRecipe(action));
27
+ it('getEthValue', async () => {
28
+ const ethValue = await action.getEthValue();
29
+ assert.equal(ethValue, '0');
30
+ })
31
+ it('getAssetsToApprove', async () => {
32
+ const assetOwnerPairs = await action.getAssetsToApprove();
33
+ assert.lengthOf(assetOwnerPairs, 1);
34
+ assert.equal(assetOwnerPairs[0].asset, getAssetInfo('WETH').address);
35
+ assert.equal(assetOwnerPairs[0].owner, from);
36
+ })
37
+ })
38
+ context('Stake maxUint256 WETH with wrapping', () => {
39
+ it('constructor', () => {
40
+ const amount = '115792089237316195423570985008687907853269984665640564039457584007913129639935';
41
+ const shouldWrap = true;
42
+ action = new dfs.actions.etherfi.EtherFiStakeAction(
43
+ amount,
44
+ from,
45
+ to,
46
+ shouldWrap,
47
+ );
48
+ assert.equal(action.args[0], amount);
49
+ assert.equal(action.args[1], from);
50
+ assert.equal(action.args[2], to);
51
+ assert.equal(action.args[3], shouldWrap);
52
+ })
53
+ it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
54
+ it('encodeForRecipe', () => encodeForRecipe(action));
55
+ it('getEthValue', async () => {
56
+ const ethValue = await action.getEthValue();
57
+ assert.equal(ethValue, '0');
58
+ })
59
+ it('getAssetsToApprove', async () => {
60
+ const assetOwnerPairs = await action.getAssetsToApprove();
61
+ assert.lengthOf(assetOwnerPairs, 1);
62
+ assert.equal(assetOwnerPairs[0].asset, getAssetInfo('WETH').address);
63
+ assert.equal(assetOwnerPairs[0].owner, from);
64
+ })
65
+ })
66
+ })
@@ -0,0 +1,35 @@
1
+ const dfs = require('../../../src');
2
+ const {getAssetInfo} = require("@defisaver/tokens");
3
+ const {encodeForDsProxyCall, encodeForRecipe} = require('../../_actionUtils');
4
+ const {assert} = require('chai');
5
+
6
+ describe('Action: EtherFiUnwrap', () => {
7
+ let action;
8
+ const from = '0x80788de454ad3681d357dc7FcB13c72333f684a7';
9
+ const to = '0x968Cc941aD9074EE687E0423a33E6f2D33d7c327';
10
+ context('Unwrap 100 weETH tokens', () => {
11
+ it('constructor', () => {
12
+ const amount = 100;
13
+ action = new dfs.actions.etherfi.EtherFiUnwrapAction(
14
+ amount,
15
+ from,
16
+ to,
17
+ );
18
+ assert.equal(action.args[0], amount);
19
+ assert.equal(action.args[1], from);
20
+ assert.equal(action.args[2], to);
21
+ })
22
+ it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
23
+ it('encodeForRecipe', () => encodeForRecipe(action));
24
+ it('getEthValue', async () => {
25
+ const ethValue = await action.getEthValue();
26
+ assert.equal(ethValue, '0');
27
+ })
28
+ it('getAssetsToApprove', async () => {
29
+ const assetOwnerPairs = await action.getAssetsToApprove();
30
+ assert.lengthOf(assetOwnerPairs, 1);
31
+ assert.equal(assetOwnerPairs[0].asset, getAssetInfo('weETH').address);
32
+ assert.equal(assetOwnerPairs[0].owner, from);
33
+ })
34
+ })
35
+ })
@@ -0,0 +1,35 @@
1
+ const dfs = require('../../../src');
2
+ const {getAssetInfo} = require("@defisaver/tokens");
3
+ const {encodeForDsProxyCall, encodeForRecipe} = require('../../_actionUtils');
4
+ const {assert} = require('chai');
5
+
6
+ describe('Action: EtherFiWrap', () => {
7
+ let action;
8
+ const from = '0x80788de454ad3681d357dc7FcB13c72333f684a7';
9
+ const to = '0x968Cc941aD9074EE687E0423a33E6f2D33d7c327';
10
+ context('Wrap 100 eETH tokens', () => {
11
+ it('constructor', () => {
12
+ const amount = 100;
13
+ action = new dfs.actions.etherfi.EtherFiWrapAction(
14
+ amount,
15
+ from,
16
+ to,
17
+ );
18
+ assert.equal(action.args[0], amount);
19
+ assert.equal(action.args[1], from);
20
+ assert.equal(action.args[2], to);
21
+ })
22
+ it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
23
+ it('encodeForRecipe', () => encodeForRecipe(action));
24
+ it('getEthValue', async () => {
25
+ const ethValue = await action.getEthValue();
26
+ assert.equal(ethValue, '0');
27
+ })
28
+ it('getAssetsToApprove', async () => {
29
+ const assetOwnerPairs = await action.getAssetsToApprove();
30
+ assert.lengthOf(assetOwnerPairs, 1);
31
+ assert.equal(assetOwnerPairs[0].asset, getAssetInfo('eETH').address);
32
+ assert.equal(assetOwnerPairs[0].owner, from);
33
+ })
34
+ })
35
+ })