@defisaver/sdk 1.3.17 → 1.3.18-aave-v4-1-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 (56) 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/AaveV4RefreshPremiumAction.d.ts +15 -0
  11. package/esm/src/actions/aavev4/AaveV4RefreshPremiumAction.js +22 -0
  12. package/esm/src/actions/aavev4/AaveV4StoreRatioAction.d.ts +14 -0
  13. package/esm/src/actions/aavev4/AaveV4StoreRatioAction.js +20 -0
  14. package/esm/src/actions/aavev4/AaveV4SupplyAction.d.ts +25 -0
  15. package/esm/src/actions/aavev4/AaveV4SupplyAction.js +49 -0
  16. package/esm/src/actions/aavev4/AaveV4WithdrawAction.d.ts +17 -0
  17. package/esm/src/actions/aavev4/AaveV4WithdrawAction.js +26 -0
  18. package/esm/src/actions/aavev4/index.d.ts +7 -0
  19. package/esm/src/actions/aavev4/index.js +7 -0
  20. package/esm/src/actions/checkers/AaveV4RatioCheckAction.d.ts +16 -0
  21. package/esm/src/actions/checkers/AaveV4RatioCheckAction.js +24 -0
  22. package/esm/src/actions/checkers/index.d.ts +1 -0
  23. package/esm/src/actions/checkers/index.js +1 -0
  24. package/esm/src/actions/index.d.ts +2 -1
  25. package/esm/src/actions/index.js +2 -1
  26. package/esm/src/addresses.d.ts +36 -5
  27. package/esm/src/addresses.js +7 -4
  28. package/esm/src/index.d.ts +144 -20
  29. package/esm/src/triggers/AaveV4QuotePriceRangeTrigger.d.ts +10 -0
  30. package/esm/src/triggers/AaveV4QuotePriceRangeTrigger.js +12 -0
  31. package/esm/src/triggers/AaveV4QuotePriceTrigger.d.ts +10 -0
  32. package/esm/src/triggers/AaveV4QuotePriceTrigger.js +12 -0
  33. package/esm/src/triggers/AaveV4RatioTrigger.d.ts +10 -0
  34. package/esm/src/triggers/AaveV4RatioTrigger.js +12 -0
  35. package/esm/src/triggers/index.d.ts +3 -0
  36. package/esm/src/triggers/index.js +3 -0
  37. package/package.json +1 -1
  38. package/src/Recipe.ts +1 -1
  39. package/src/Strategy.ts +4 -0
  40. package/src/actions/aavev4/AaveV4BorrowAction.ts +39 -0
  41. package/src/actions/aavev4/AaveV4CollateralSwitchAction.ts +36 -0
  42. package/src/actions/aavev4/AaveV4PaybackAction.ts +51 -0
  43. package/src/actions/aavev4/AaveV4RefreshPremiumAction.ts +33 -0
  44. package/src/actions/aavev4/AaveV4StoreRatioAction.ts +30 -0
  45. package/src/actions/aavev4/AaveV4SupplyAction.ts +55 -0
  46. package/src/actions/aavev4/AaveV4WithdrawAction.ts +39 -0
  47. package/src/actions/aavev4/index.ts +7 -0
  48. package/src/actions/checkers/AaveV4RatioCheckAction.ts +36 -0
  49. package/src/actions/checkers/index.ts +2 -1
  50. package/src/actions/index.ts +2 -0
  51. package/src/addresses.ts +8 -5
  52. package/src/triggers/AaveV4QuotePriceRangeTrigger.ts +25 -0
  53. package/src/triggers/AaveV4QuotePriceTrigger.ts +25 -0
  54. package/src/triggers/AaveV4RatioTrigger.ts +24 -0
  55. package/src/triggers/index.ts +4 -1
  56. package/umd/index.js +993 -585
@@ -0,0 +1,51 @@
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
+ * AaveV4PaybackAction
8
+ *
9
+ * @category AaveV4
10
+ */
11
+ export class AaveV4PaybackAction extends Action {
12
+ tokenForApproval: EthAddress;
13
+
14
+ /**
15
+ * @param spoke Address of the spoke.
16
+ * @param onBehalf Address to payback tokens on behalf of. Defaults to the user's wallet if not provided.
17
+ * @param from Address from which to pull the payback tokens.
18
+ * @param reserveId Reserve id.
19
+ * @param amount Amount of tokens to payback. Send type(uint).max to payback whole amount.
20
+ * @param tokenAddress Address of the token to approve. Optional, as it is only used for token approval, not part of encoding.
21
+ */
22
+ constructor(
23
+ spoke: EthAddress,
24
+ onBehalf: EthAddress,
25
+ from: EthAddress,
26
+ reserveId: uint256,
27
+ amount: uint256,
28
+ tokenAddress: EthAddress = getAddr('Empty'),
29
+ ) {
30
+ super(
31
+ 'AaveV4Payback',
32
+ getAddr('AaveV4Payback'),
33
+ ['address', 'address', 'address', 'uint256', 'uint256'],
34
+ [spoke, onBehalf, from, reserveId, amount],
35
+ );
36
+ this.mappableArgs = [
37
+ this.args[0],
38
+ this.args[1],
39
+ this.args[2],
40
+ this.args[3],
41
+ this.args[4],
42
+ ];
43
+ this.tokenForApproval = tokenAddress;
44
+ }
45
+
46
+ async getAssetsToApprove() {
47
+ const asset = getAssetInfoByAddress(this.tokenForApproval);
48
+ if (asset.symbol !== 'ETH') return [{ asset: this.tokenForApproval, owner: this.args[2] }];
49
+ return [];
50
+ }
51
+ }
@@ -0,0 +1,33 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ import { EthAddress } from '../../types';
4
+
5
+ /**
6
+ * AaveV4RefreshPremiumAction - Refresh the risk premium for user's position
7
+ *
8
+ * @category AaveV4RefreshPremium
9
+ */
10
+ export class AaveV4RefreshPremiumAction extends Action {
11
+ /**
12
+ * @param spoke Address of the spoke.
13
+ * @param onBehalf Address to refresh the config on behalf of. Defaults to the user's wallet if not provided.
14
+ * @param refreshDynamicReserveConfig Whether to also refresh the dynamic reserve config for all collateral reserves.
15
+ */
16
+ constructor(
17
+ spoke: EthAddress,
18
+ onBehalf: EthAddress,
19
+ refreshDynamicReserveConfig: boolean,
20
+ ) {
21
+ super(
22
+ 'AaveV4RefreshPremium',
23
+ getAddr('AaveV4RefreshPremium'),
24
+ ['address', 'address', 'bool'],
25
+ [spoke, onBehalf, refreshDynamicReserveConfig],
26
+ );
27
+ this.mappableArgs = [
28
+ this.args[0],
29
+ this.args[1],
30
+ this.args[2],
31
+ ];
32
+ }
33
+ }
@@ -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,7 @@
1
+ export * from './AaveV4SupplyAction';
2
+ export * from './AaveV4WithdrawAction';
3
+ export * from './AaveV4BorrowAction';
4
+ export * from './AaveV4PaybackAction';
5
+ export * from './AaveV4CollateralSwitchAction';
6
+ export * from './AaveV4StoreRatioAction';
7
+ export * from './AaveV4RefreshPremiumAction';
@@ -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,14 @@ export const actionAddresses = {
389
389
  SFApproveTokens: '0x0aC29D44eeC8e8f3b010c2e8FC960957db0c8298',
390
390
  SummerfiUnsub: '0x926405D69b77A514ED974901095AcFf9e5131366',
391
391
  SummerfiUnsubV2: '0x5E805eD9B7581a9f1398F75833f9663a459F5E30',
392
+
393
+ // AaveV4
394
+ AaveV4Supply: '0x270A0C7eBd1C0a98FdA613782b51419300AB6322',
395
+ AaveV4Withdraw: '0x561013c605A17f5dC5b738C8a3fF9c5F33DbC3d8',
396
+ AaveV4Borrow: '0xC6C627c63389D8bB7913b55CD62fa451703AD1E1',
397
+ AaveV4Payback: '0x6e31Dd331571209043c8CF997f86b4291F648537',
398
+ AaveV4CollateralSwitch: '0x26C39FE05466dBA72A98d095d019dC5e067F6b28',
399
+ AaveV4RefreshPremium: '0xb080DC160415Ffe1a4b80d75b0Be92EE38a0b426',
392
400
  },
393
401
  [NETWORKS.optimism.chainId]: {
394
402
  DFSSell: '0x9f234af5c10c136863a20865ba00b26951ab8269',
@@ -759,8 +767,6 @@ export const actionAddresses = {
759
767
  export const otherAddresses = {
760
768
  [NETWORKS.ethereum.chainId]: {
761
769
  RecipeExecutor: '0xbc3Fc959FeF3F12a41738f406c02198cdeE7481F',
762
- RecipeExecutorForTxSaver:
763
- '0x2ee96cf53ae5fbd5309284704f978d0ca66cb963',
764
770
  DFSRegistry: '0x287778F121F134C66212FB16c9b53eC991D32f5b',
765
771
  DFSProxyRegistry: '0x29474FdaC7142f9aB7773B8e38264FA15E3805ed',
766
772
  ProxyRegistry: '0x4678f0a6958e4D2Bc4F1BAF7Bc52E8F3564f3fE4',
@@ -783,7 +789,6 @@ export const otherAddresses = {
783
789
  },
784
790
  [NETWORKS.optimism.chainId]: {
785
791
  RecipeExecutor: '0xEC891E6b5A93F5f29241De6B234a4e77A5456A1C',
786
- RecipeExecutorForTxSaver: '0x993A8c81142044E1CB0Cf0c3d84BEa235d842Fb0',
787
792
  DFSRegistry: '0xAf707Ee480204Ed6e2640B53cE86F680D28Afcbd',
788
793
  ProxyRegistry: '0x283Cc5C26e53D66ed2Ea252D986F094B37E6e895',
789
794
  SFProxyEntryPoint: '0x06299D4A07E8C6D7C1aEc14Ab2F46DF05Dd9588E',
@@ -797,7 +802,6 @@ export const otherAddresses = {
797
802
  },
798
803
  [NETWORKS.arbitrum.chainId]: {
799
804
  RecipeExecutor: '0x667609f05DdC5E9Fb939eC376F07953403745cf3',
800
- RecipeExecutorForTxSaver: '0x7a25174229ea402d8ccd35fc6d55af079c399884',
801
805
  DFSRegistry: '0xBF1CaC12DB60819Bfa71A328282ecbc1D40443aA',
802
806
  ProxyRegistry: '0x283Cc5C26e53D66ed2Ea252D986F094B37E6e895',
803
807
  SFProxyEntryPoint: '0x15D776C062bF292f8F70A81533E49adC7C06Cb69',
@@ -811,7 +815,6 @@ export const otherAddresses = {
811
815
  },
812
816
  [NETWORKS.base.chainId]: {
813
817
  RecipeExecutor: '0xc91305DdE651c899EF8eE1D0C33E7dab1B5ABF0D',
814
- RecipeExecutorForTxSaver: '0x7a87565b77dd65bbc153fe20e97743842f1a6e0c',
815
818
  DFSRegistry: '0x347FB634271F666353F23A3362f3935D96F97476',
816
819
  ProxyRegistry: '0x425fA97285965E01Cc5F951B62A51F6CDEA5cc0d',
817
820
  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';