@defisaver/sdk 1.3.16 → 1.3.17-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.
- package/esm/src/Strategy.d.ts +1 -0
- package/esm/src/Strategy.js +3 -0
- package/esm/src/actions/aavev4/AaveV4BorrowAction.d.ts +17 -0
- package/esm/src/actions/aavev4/AaveV4BorrowAction.js +26 -0
- package/esm/src/actions/aavev4/AaveV4CollateralSwitchAction.d.ts +16 -0
- package/esm/src/actions/aavev4/AaveV4CollateralSwitchAction.js +24 -0
- package/esm/src/actions/aavev4/AaveV4PaybackAction.d.ts +23 -0
- package/esm/src/actions/aavev4/AaveV4PaybackAction.js +46 -0
- package/esm/src/actions/aavev4/AaveV4StoreRatioAction.d.ts +14 -0
- package/esm/src/actions/aavev4/AaveV4StoreRatioAction.js +20 -0
- package/esm/src/actions/aavev4/AaveV4SupplyAction.d.ts +25 -0
- package/esm/src/actions/aavev4/AaveV4SupplyAction.js +49 -0
- package/esm/src/actions/aavev4/AaveV4WithdrawAction.d.ts +17 -0
- package/esm/src/actions/aavev4/AaveV4WithdrawAction.js +26 -0
- package/esm/src/actions/aavev4/index.d.ts +6 -0
- package/esm/src/actions/aavev4/index.js +6 -0
- package/esm/src/actions/checkers/AaveV4RatioCheckAction.d.ts +16 -0
- package/esm/src/actions/checkers/AaveV4RatioCheckAction.js +24 -0
- package/esm/src/actions/checkers/index.d.ts +1 -0
- package/esm/src/actions/checkers/index.js +1 -0
- package/esm/src/actions/index.d.ts +2 -1
- package/esm/src/actions/index.js +2 -1
- package/esm/src/addresses.d.ts +35 -0
- package/esm/src/addresses.js +10 -0
- package/esm/src/index.d.ts +140 -0
- package/esm/src/triggers/AaveV4QuotePriceRangeTrigger.d.ts +10 -0
- package/esm/src/triggers/AaveV4QuotePriceRangeTrigger.js +12 -0
- package/esm/src/triggers/AaveV4QuotePriceTrigger.d.ts +10 -0
- package/esm/src/triggers/AaveV4QuotePriceTrigger.js +12 -0
- package/esm/src/triggers/AaveV4RatioTrigger.d.ts +10 -0
- package/esm/src/triggers/AaveV4RatioTrigger.js +12 -0
- package/esm/src/triggers/index.d.ts +3 -0
- package/esm/src/triggers/index.js +3 -0
- package/package.json +1 -1
- package/src/Strategy.ts +4 -0
- package/src/actions/aavev4/AaveV4BorrowAction.ts +39 -0
- package/src/actions/aavev4/AaveV4CollateralSwitchAction.ts +36 -0
- package/src/actions/aavev4/AaveV4PaybackAction.ts +51 -0
- package/src/actions/aavev4/AaveV4StoreRatioAction.ts +30 -0
- package/src/actions/aavev4/AaveV4SupplyAction.ts +55 -0
- package/src/actions/aavev4/AaveV4WithdrawAction.ts +39 -0
- package/src/actions/aavev4/index.ts +6 -0
- package/src/actions/checkers/AaveV4RatioCheckAction.ts +36 -0
- package/src/actions/checkers/index.ts +2 -1
- package/src/actions/index.ts +2 -0
- package/src/addresses.ts +15 -2
- package/src/triggers/AaveV4QuotePriceRangeTrigger.ts +25 -0
- package/src/triggers/AaveV4QuotePriceTrigger.ts +25 -0
- package/src/triggers/AaveV4RatioTrigger.ts +24 -0
- package/src/triggers/index.ts +4 -1
- package/umd/index.js +964 -581
|
@@ -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,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';
|
package/src/actions/index.ts
CHANGED
|
@@ -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,15 +766,18 @@ export const actionAddresses = {
|
|
|
759
766
|
export const otherAddresses = {
|
|
760
767
|
[NETWORKS.ethereum.chainId]: {
|
|
761
768
|
RecipeExecutor: '0xbc3Fc959FeF3F12a41738f406c02198cdeE7481F',
|
|
762
|
-
RecipeExecutorForTxSaver:
|
|
769
|
+
RecipeExecutorForTxSaver:
|
|
770
|
+
'0x2ee96cf53ae5fbd5309284704f978d0ca66cb963',
|
|
763
771
|
DFSRegistry: '0x287778F121F134C66212FB16c9b53eC991D32f5b',
|
|
764
772
|
DFSProxyRegistry: '0x29474FdaC7142f9aB7773B8e38264FA15E3805ed',
|
|
765
773
|
ProxyRegistry: '0x4678f0a6958e4D2Bc4F1BAF7Bc52E8F3564f3fE4',
|
|
774
|
+
SFProxyEntryPoint: '0xAa15ca459659F35B1064EC546A44d962d54bA89e',
|
|
766
775
|
|
|
767
776
|
McdCdpManager: '0x5ef30b9986345249bc32d8928b7ee64de9435e39',
|
|
768
777
|
BCdpManager: '0x3f30c2381CD8B917Dd96EB2f1A4F96D91324BBed',
|
|
769
778
|
AaveDefaultMarket: '0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5',
|
|
770
|
-
UniswapV3PositionManager:
|
|
779
|
+
UniswapV3PositionManager:
|
|
780
|
+
'0xC36442b4a4522E871399CD717aBDD847Ab11FE88',
|
|
771
781
|
RaiWethUniV2LPToken: '0x8aE720a71622e824F576b4A8C03031066548A3B1',
|
|
772
782
|
BalancerToken: '0xba100000625a3754423978a60c9317c58a424e3D',
|
|
773
783
|
CrvToken: '0xD533a949740bb3306d119CC777fa900bA034cd52',
|
|
@@ -783,6 +793,7 @@ export const otherAddresses = {
|
|
|
783
793
|
RecipeExecutorForTxSaver: '0x993A8c81142044E1CB0Cf0c3d84BEa235d842Fb0',
|
|
784
794
|
DFSRegistry: '0xAf707Ee480204Ed6e2640B53cE86F680D28Afcbd',
|
|
785
795
|
ProxyRegistry: '0x283Cc5C26e53D66ed2Ea252D986F094B37E6e895',
|
|
796
|
+
SFProxyEntryPoint: '0x06299D4A07E8C6D7C1aEc14Ab2F46DF05Dd9588E',
|
|
786
797
|
|
|
787
798
|
DSGuardFactory: '0xc19d0F1E2b38AA283E226Ca4044766A43aA7B02b',
|
|
788
799
|
AdminVault: '0x136b1bEAfff362530F98f10E3D8C38f3a3F3d38C',
|
|
@@ -796,6 +807,7 @@ export const otherAddresses = {
|
|
|
796
807
|
RecipeExecutorForTxSaver: '0x7a25174229ea402d8ccd35fc6d55af079c399884',
|
|
797
808
|
DFSRegistry: '0xBF1CaC12DB60819Bfa71A328282ecbc1D40443aA',
|
|
798
809
|
ProxyRegistry: '0x283Cc5C26e53D66ed2Ea252D986F094B37E6e895',
|
|
810
|
+
SFProxyEntryPoint: '0x15D776C062bF292f8F70A81533E49adC7C06Cb69',
|
|
799
811
|
|
|
800
812
|
DSGuardFactory: '0x5261abC3a94a6475D0A1171daE94A5f84fbaEcD2',
|
|
801
813
|
AdminVault: '0xd47D8D97cAd12A866900eEc6Cde1962529F25351',
|
|
@@ -809,6 +821,7 @@ export const otherAddresses = {
|
|
|
809
821
|
RecipeExecutorForTxSaver: '0x7a87565b77dd65bbc153fe20e97743842f1a6e0c',
|
|
810
822
|
DFSRegistry: '0x347FB634271F666353F23A3362f3935D96F97476',
|
|
811
823
|
ProxyRegistry: '0x425fA97285965E01Cc5F951B62A51F6CDEA5cc0d',
|
|
824
|
+
SFProxyEntryPoint: '0xab6e5cde983fF98Cdb0F61f5F99cb58D40D0c837',
|
|
812
825
|
|
|
813
826
|
DSGuardFactory: '0x7783da8958013a57a5514737a4FBDFF06A0056e1',
|
|
814
827
|
AdminVault: '0xD8E67968d8a0df4beCf2D50daE1e34d4d80C701C',
|
|
@@ -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
|
+
}
|
package/src/triggers/index.ts
CHANGED
|
@@ -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';
|