@defisaver/sdk 1.3.17 → 1.3.18-aave-v4-dev

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 (53) hide show
  1. package/esm/src/Recipe.js +1 -1
  2. package/esm/src/Strategy.d.ts +1 -0
  3. package/esm/src/Strategy.js +3 -0
  4. package/esm/src/actions/aavev4/AaveV4BorrowAction.d.ts +17 -0
  5. package/esm/src/actions/aavev4/AaveV4BorrowAction.js +26 -0
  6. package/esm/src/actions/aavev4/AaveV4CollateralSwitchAction.d.ts +16 -0
  7. package/esm/src/actions/aavev4/AaveV4CollateralSwitchAction.js +24 -0
  8. package/esm/src/actions/aavev4/AaveV4PaybackAction.d.ts +23 -0
  9. package/esm/src/actions/aavev4/AaveV4PaybackAction.js +46 -0
  10. package/esm/src/actions/aavev4/AaveV4StoreRatioAction.d.ts +14 -0
  11. package/esm/src/actions/aavev4/AaveV4StoreRatioAction.js +20 -0
  12. package/esm/src/actions/aavev4/AaveV4SupplyAction.d.ts +25 -0
  13. package/esm/src/actions/aavev4/AaveV4SupplyAction.js +49 -0
  14. package/esm/src/actions/aavev4/AaveV4WithdrawAction.d.ts +17 -0
  15. package/esm/src/actions/aavev4/AaveV4WithdrawAction.js +26 -0
  16. package/esm/src/actions/aavev4/index.d.ts +6 -0
  17. package/esm/src/actions/aavev4/index.js +6 -0
  18. package/esm/src/actions/checkers/AaveV4RatioCheckAction.d.ts +16 -0
  19. package/esm/src/actions/checkers/AaveV4RatioCheckAction.js +24 -0
  20. package/esm/src/actions/checkers/index.d.ts +1 -0
  21. package/esm/src/actions/checkers/index.js +1 -0
  22. package/esm/src/actions/index.d.ts +2 -1
  23. package/esm/src/actions/index.js +2 -1
  24. package/esm/src/addresses.d.ts +30 -5
  25. package/esm/src/addresses.js +6 -4
  26. package/esm/src/index.d.ts +120 -20
  27. package/esm/src/triggers/AaveV4QuotePriceRangeTrigger.d.ts +10 -0
  28. package/esm/src/triggers/AaveV4QuotePriceRangeTrigger.js +12 -0
  29. package/esm/src/triggers/AaveV4QuotePriceTrigger.d.ts +10 -0
  30. package/esm/src/triggers/AaveV4QuotePriceTrigger.js +12 -0
  31. package/esm/src/triggers/AaveV4RatioTrigger.d.ts +10 -0
  32. package/esm/src/triggers/AaveV4RatioTrigger.js +12 -0
  33. package/esm/src/triggers/index.d.ts +3 -0
  34. package/esm/src/triggers/index.js +3 -0
  35. package/package.json +1 -1
  36. package/src/Recipe.ts +1 -1
  37. package/src/Strategy.ts +4 -0
  38. package/src/actions/aavev4/AaveV4BorrowAction.ts +39 -0
  39. package/src/actions/aavev4/AaveV4CollateralSwitchAction.ts +36 -0
  40. package/src/actions/aavev4/AaveV4PaybackAction.ts +51 -0
  41. package/src/actions/aavev4/AaveV4StoreRatioAction.ts +30 -0
  42. package/src/actions/aavev4/AaveV4SupplyAction.ts +55 -0
  43. package/src/actions/aavev4/AaveV4WithdrawAction.ts +39 -0
  44. package/src/actions/aavev4/index.ts +6 -0
  45. package/src/actions/checkers/AaveV4RatioCheckAction.ts +36 -0
  46. package/src/actions/checkers/index.ts +2 -1
  47. package/src/actions/index.ts +2 -0
  48. package/src/addresses.ts +7 -5
  49. package/src/triggers/AaveV4QuotePriceRangeTrigger.ts +25 -0
  50. package/src/triggers/AaveV4QuotePriceTrigger.ts +25 -0
  51. package/src/triggers/AaveV4RatioTrigger.ts +24 -0
  52. package/src/triggers/index.ts +4 -1
  53. package/umd/index.js +960 -585
@@ -0,0 +1,30 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ import { EthAddress } from '../../types';
4
+
5
+ /**
6
+ * AaveV4StoreRatioAction - Stores the ratio for a user in transient storage so it can be checked later after strategy execution.
7
+ *
8
+ * @category AaveV4
9
+ */
10
+ export class AaveV4StoreRatioAction extends Action {
11
+ /**
12
+ * @param spoke Address of the spoke.
13
+ * @param user Address of the user to store the ratio for.
14
+ */
15
+ constructor(
16
+ spoke: EthAddress,
17
+ user: EthAddress,
18
+ ) {
19
+ super(
20
+ 'AaveV4StoreRatio',
21
+ getAddr('Empty'),
22
+ ['address', 'address'],
23
+ [spoke, user],
24
+ );
25
+ this.mappableArgs = [
26
+ this.args[0],
27
+ this.args[1],
28
+ ];
29
+ }
30
+ }
@@ -0,0 +1,55 @@
1
+ import { getAssetInfoByAddress } from '@defisaver/tokens';
2
+ import { Action } from '../../Action';
3
+ import { getAddr } from '../../addresses';
4
+ import { EthAddress, uint256 } from '../../types';
5
+
6
+ /**
7
+ * AaveV4SupplyAction
8
+ *
9
+ * @category AaveV4
10
+ */
11
+ export class AaveV4SupplyAction extends Action {
12
+ tokenForApproval: EthAddress;
13
+
14
+ /**
15
+ * @param spoke Address of the spoke.
16
+ * @param onBehalf Address to supply tokens on behalf of. Defaults to the user's wallet if not provided.
17
+ * @param from Address from which to pull collateral asset.
18
+ * @param reserveId Reserve id.
19
+ * @param amount Amount of tokens to supply.
20
+ * @param useAsCollateral Whether to use the tokens as collateral.
21
+ * @param tokenAddress Address of the token to approve. Optional, as it is only used for token approval, not part of encoding.
22
+ *
23
+ */
24
+ constructor(
25
+ spoke: EthAddress,
26
+ onBehalf: EthAddress,
27
+ from: EthAddress,
28
+ reserveId: uint256,
29
+ amount: uint256,
30
+ useAsCollateral: boolean,
31
+ tokenAddress: EthAddress = getAddr('Empty'),
32
+ ) {
33
+ super(
34
+ 'AaveV4Supply',
35
+ getAddr('AaveV4Supply'),
36
+ ['address', 'address', 'address', 'uint256', 'uint256', 'bool'],
37
+ [spoke, onBehalf, from, reserveId, amount, useAsCollateral],
38
+ );
39
+ this.mappableArgs = [
40
+ this.args[0],
41
+ this.args[1],
42
+ this.args[2],
43
+ this.args[3],
44
+ this.args[4],
45
+ this.args[5],
46
+ ];
47
+ this.tokenForApproval = tokenAddress;
48
+ }
49
+
50
+ async getAssetsToApprove() {
51
+ const asset = getAssetInfoByAddress(this.tokenForApproval);
52
+ if (asset.symbol !== 'ETH') return [{ asset: this.tokenForApproval, owner: this.args[2] }];
53
+ return [];
54
+ }
55
+ }
@@ -0,0 +1,39 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ import { EthAddress, uint256 } from '../../types';
4
+
5
+ /**
6
+ * AaveV4WithdrawAction
7
+ *
8
+ * @category AaveV4
9
+ */
10
+ export class AaveV4WithdrawAction extends Action {
11
+ /**
12
+ * @param spoke Address of the spoke.
13
+ * @param onBehalf Address to withdraw tokens on behalf of. Defaults to the user's wallet if not provided.
14
+ * @param to Address that will receive the withdrawn tokens.
15
+ * @param reserveId Reserve id.
16
+ * @param amount Amount of tokens to withdraw. Send type(uint).max to withdraw whole amount.
17
+ */
18
+ constructor(
19
+ spoke: EthAddress,
20
+ onBehalf: EthAddress,
21
+ to: EthAddress,
22
+ reserveId: uint256,
23
+ amount: uint256,
24
+ ) {
25
+ super(
26
+ 'AaveV4Withdraw',
27
+ getAddr('AaveV4Withdraw'),
28
+ ['address', 'address', 'address', 'uint256', 'uint256'],
29
+ [spoke, onBehalf, to, reserveId, amount],
30
+ );
31
+ this.mappableArgs = [
32
+ this.args[0],
33
+ this.args[1],
34
+ this.args[2],
35
+ this.args[3],
36
+ this.args[4],
37
+ ];
38
+ }
39
+ }
@@ -0,0 +1,6 @@
1
+ export * from './AaveV4SupplyAction';
2
+ export * from './AaveV4WithdrawAction';
3
+ export * from './AaveV4BorrowAction';
4
+ export * from './AaveV4PaybackAction';
5
+ export * from './AaveV4CollateralSwitchAction';
6
+ export * from './AaveV4StoreRatioAction';
@@ -0,0 +1,36 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ import { EthAddress, uint256, uint8 } from '../../types';
4
+
5
+ /**
6
+ * AaveV4RatioCheckAction - Checks aave V4 ratio for user position
7
+ *
8
+ * @category AaveV4RatioCheck
9
+ */
10
+ export class AaveV4RatioCheckAction extends Action {
11
+ /**
12
+ * @param ratioState State of the ratio (IN_BOOST or IN_REPAY)
13
+ * @param targetRatio Target ratio.
14
+ * @param spoke Aave V4 spoke address.
15
+ * @param user User address.
16
+ */
17
+ constructor(
18
+ ratioState: uint8,
19
+ targetRatio: uint256,
20
+ spoke: EthAddress,
21
+ user: EthAddress,
22
+ ) {
23
+ super(
24
+ 'AaveV4RatioCheck',
25
+ getAddr('Empty'),
26
+ ['uint8', 'uint256', 'address', 'address'],
27
+ [ratioState, targetRatio, spoke, user],
28
+ );
29
+ this.mappableArgs = [
30
+ this.args[0],
31
+ this.args[1],
32
+ this.args[2],
33
+ this.args[3],
34
+ ];
35
+ }
36
+ }
@@ -14,4 +14,5 @@ export * from './MorphoBlueTargetRatioCheckAction';
14
14
  export * from './LiquityV2RatioCheckAction';
15
15
  export * from './LiquityV2TargetRatioCheckAction';
16
16
  export * from './LiquityV2NewInterestRateCheckerAction';
17
- export * from './FluidRatioCheckAction';
17
+ export * from './FluidRatioCheckAction';
18
+ export * from './AaveV4RatioCheckAction';
@@ -39,6 +39,7 @@ import * as etherfi from './etherfi';
39
39
  import * as fluid from './fluid';
40
40
  import * as pendle from './pendle';
41
41
  import * as umbrella from './umbrella';
42
+ import * as aaveV4 from './aavev4';
42
43
 
43
44
  export {
44
45
  aave,
@@ -82,4 +83,5 @@ export {
82
83
  fluid,
83
84
  pendle,
84
85
  umbrella,
86
+ aaveV4,
85
87
  };
package/src/addresses.ts CHANGED
@@ -389,6 +389,13 @@ export const actionAddresses = {
389
389
  SFApproveTokens: '0x0aC29D44eeC8e8f3b010c2e8FC960957db0c8298',
390
390
  SummerfiUnsub: '0x926405D69b77A514ED974901095AcFf9e5131366',
391
391
  SummerfiUnsubV2: '0x5E805eD9B7581a9f1398F75833f9663a459F5E30',
392
+
393
+ // AaveV4
394
+ AaveV4Supply: '0x30f333997eA08CA7Af95E32F4f90DACEf284D746',
395
+ AaveV4Withdraw: '0x8fc7F5dCeb5da1B0293A246ed6aeDc44EB37dB38',
396
+ AaveV4Borrow: '0x0a58710A67837E6d026B83c434519c5f0A0cD7a1',
397
+ AaveV4Payback: '0xCbcbD3b3e0D704Ad26b7dCfe1BdA6e85CDd8DBf0',
398
+ AaveV4CollateralSwitch: '0x19Ef19d6b8818103b8Cae086BB23e183EF7E433f',
392
399
  },
393
400
  [NETWORKS.optimism.chainId]: {
394
401
  DFSSell: '0x9f234af5c10c136863a20865ba00b26951ab8269',
@@ -759,8 +766,6 @@ export const actionAddresses = {
759
766
  export const otherAddresses = {
760
767
  [NETWORKS.ethereum.chainId]: {
761
768
  RecipeExecutor: '0xbc3Fc959FeF3F12a41738f406c02198cdeE7481F',
762
- RecipeExecutorForTxSaver:
763
- '0x2ee96cf53ae5fbd5309284704f978d0ca66cb963',
764
769
  DFSRegistry: '0x287778F121F134C66212FB16c9b53eC991D32f5b',
765
770
  DFSProxyRegistry: '0x29474FdaC7142f9aB7773B8e38264FA15E3805ed',
766
771
  ProxyRegistry: '0x4678f0a6958e4D2Bc4F1BAF7Bc52E8F3564f3fE4',
@@ -783,7 +788,6 @@ export const otherAddresses = {
783
788
  },
784
789
  [NETWORKS.optimism.chainId]: {
785
790
  RecipeExecutor: '0xEC891E6b5A93F5f29241De6B234a4e77A5456A1C',
786
- RecipeExecutorForTxSaver: '0x993A8c81142044E1CB0Cf0c3d84BEa235d842Fb0',
787
791
  DFSRegistry: '0xAf707Ee480204Ed6e2640B53cE86F680D28Afcbd',
788
792
  ProxyRegistry: '0x283Cc5C26e53D66ed2Ea252D986F094B37E6e895',
789
793
  SFProxyEntryPoint: '0x06299D4A07E8C6D7C1aEc14Ab2F46DF05Dd9588E',
@@ -797,7 +801,6 @@ export const otherAddresses = {
797
801
  },
798
802
  [NETWORKS.arbitrum.chainId]: {
799
803
  RecipeExecutor: '0x667609f05DdC5E9Fb939eC376F07953403745cf3',
800
- RecipeExecutorForTxSaver: '0x7a25174229ea402d8ccd35fc6d55af079c399884',
801
804
  DFSRegistry: '0xBF1CaC12DB60819Bfa71A328282ecbc1D40443aA',
802
805
  ProxyRegistry: '0x283Cc5C26e53D66ed2Ea252D986F094B37E6e895',
803
806
  SFProxyEntryPoint: '0x15D776C062bF292f8F70A81533E49adC7C06Cb69',
@@ -811,7 +814,6 @@ export const otherAddresses = {
811
814
  },
812
815
  [NETWORKS.base.chainId]: {
813
816
  RecipeExecutor: '0xc91305DdE651c899EF8eE1D0C33E7dab1B5ABF0D',
814
- RecipeExecutorForTxSaver: '0x7a87565b77dd65bbc153fe20e97743842f1a6e0c',
815
817
  DFSRegistry: '0x347FB634271F666353F23A3362f3935D96F97476',
816
818
  ProxyRegistry: '0x425fA97285965E01Cc5F951B62A51F6CDEA5cc0d',
817
819
  SFProxyEntryPoint: '0xab6e5cde983fF98Cdb0F61f5F99cb58D40D0c837',
@@ -0,0 +1,25 @@
1
+ import { Action } from '../Action';
2
+ import { getAddr } from '../addresses';
3
+ import { EthAddress, uint256 } from '../types';
4
+
5
+ /**
6
+ * AaveV4QuotePriceRangeTrigger - Verifies if current token price ratio for aaveV4 spoke is within a subbed price range.
7
+ *
8
+ * @category Triggers
9
+ */
10
+ export class AaveV4QuotePriceRangeTrigger extends Action {
11
+ constructor(
12
+ spoke:EthAddress,
13
+ baseTokenId:uint256,
14
+ quoteTokenId:uint256,
15
+ lowerPrice:uint256,
16
+ upperPrice:uint256,
17
+ ) {
18
+ super(
19
+ 'AaveV4QuotePriceRangeTrigger',
20
+ getAddr('Empty'),
21
+ [['address', 'uint256', 'uint256', 'uint256', 'uint256']],
22
+ [[spoke, baseTokenId, quoteTokenId, lowerPrice, upperPrice]],
23
+ );
24
+ }
25
+ }
@@ -0,0 +1,25 @@
1
+ import { Action } from '../Action';
2
+ import { getAddr } from '../addresses';
3
+ import { EthAddress, uint256, uint8 } from '../types';
4
+
5
+ /**
6
+ * AaveV4QuotePriceTrigger - Verifies if current token price ratio for aaveV4 spoke is over/under a subbed price ratio.
7
+ *
8
+ * @category Triggers
9
+ */
10
+ export class AaveV4QuotePriceTrigger extends Action {
11
+ constructor(
12
+ spoke:EthAddress,
13
+ baseTokenId:uint256,
14
+ quoteTokenId:uint256,
15
+ price:uint256,
16
+ state:uint8,
17
+ ) {
18
+ super(
19
+ 'AaveV4QuotePriceTrigger',
20
+ getAddr('Empty'),
21
+ [['address', 'uint256', 'uint256', 'uint256', 'uint8']],
22
+ [[spoke, baseTokenId, quoteTokenId, price, state]],
23
+ );
24
+ }
25
+ }
@@ -0,0 +1,24 @@
1
+ import { Action } from '../Action';
2
+ import { getAddr } from '../addresses';
3
+ import { EthAddress, uint256, uint8 } from '../types';
4
+
5
+ /**
6
+ * AaveV4RatioTrigger - Triggers when the user's ratio is over/under a subbed ratio.
7
+ *
8
+ * @category Triggers
9
+ */
10
+ export class AaveV4RatioTrigger extends Action {
11
+ constructor(
12
+ user:EthAddress,
13
+ spoke:EthAddress,
14
+ ratio:uint256,
15
+ state:uint8,
16
+ ) {
17
+ super(
18
+ 'AaveV4RatioTrigger',
19
+ getAddr('Empty'),
20
+ [['address', 'address', 'uint256', 'uint8']],
21
+ [[user, spoke, ratio, state]],
22
+ );
23
+ }
24
+ }
@@ -30,4 +30,7 @@ export * from './CompV3PriceRangeTrigger';
30
30
  export * from './LiquityV2AdjustRateDebtInFrontTrigger';
31
31
  export * from './AaveV3QuotePriceRangeTrigger';
32
32
  export * from './SparkQuotePriceRangeTrigger';
33
- export * from './MorphoBluePriceRangeTrigger';
33
+ export * from './MorphoBluePriceRangeTrigger';
34
+ export * from './AaveV4QuotePriceTrigger';
35
+ export * from './AaveV4QuotePriceRangeTrigger';
36
+ export * from './AaveV4RatioTrigger';