@shift-defi/strategies 0.1.0

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.
@@ -0,0 +1,141 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
5
+ import {IScaledBalanceToken} from "./IScaledBalanceToken.sol";
6
+ import {IInitializableAToken} from "./IInitializableAToken.sol";
7
+
8
+ /**
9
+ * @title IAToken
10
+ * @author Aave
11
+ * @notice Defines the basic interface for an AToken.
12
+ */
13
+ interface IAToken is IERC20, IScaledBalanceToken, IInitializableAToken {
14
+ /**
15
+ * @dev Emitted during the transfer action
16
+ * @param from The user whose tokens are being transferred
17
+ * @param to The recipient
18
+ * @param value The scaled amount being transferred
19
+ * @param index The next liquidity index of the reserve
20
+ */
21
+ event BalanceTransfer(address indexed from, address indexed to, uint256 value, uint256 index);
22
+
23
+ /**
24
+ * @notice Mints `amount` aTokens to `user`
25
+ * @param caller The address performing the mint
26
+ * @param onBehalfOf The address of the user that will receive the minted aTokens
27
+ * @param scaledAmount The scaled amount of tokens getting minted
28
+ * @param index The next liquidity index of the reserve
29
+ * @return `true` if the the previous balance of the user was 0
30
+ */
31
+ function mint(address caller, address onBehalfOf, uint256 scaledAmount, uint256 index) external returns (bool);
32
+
33
+ /**
34
+ * @notice Burns aTokens from `user` and sends the equivalent amount of underlying to `receiverOfUnderlying`.
35
+ * @dev Passing both the unscaled and scaled amounts enhances precision. The `scaledAmount` is used for precise balance updates,
36
+ * while the `amount` is used for the underlying asset transfer, preventing cumulative rounding errors.
37
+ * @dev In some instances, a mint event may be emitted from a burn transaction if the amount to burn is less than the interest that the user accrued.
38
+ * @param from The address from which the aTokens will be burned
39
+ * @param receiverOfUnderlying The address that will receive the underlying
40
+ * @param amount The amount of underlying to be burned (non scaled)
41
+ * @param scaledAmount The scaled amount of aTokens to be burned (scaled)
42
+ * @param index The next liquidity index of the reserve
43
+ * @return `true` if the the new balance of the user is 0
44
+ */
45
+ function burn(
46
+ address from,
47
+ address receiverOfUnderlying,
48
+ uint256 amount,
49
+ uint256 scaledAmount,
50
+ uint256 index
51
+ ) external returns (bool);
52
+
53
+ /**
54
+ * @notice Mints aTokens to the reserve treasury
55
+ * @param scaledAmount The scaled amount of tokens getting minted
56
+ * @param index The next liquidity index of the reserve
57
+ */
58
+ function mintToTreasury(uint256 scaledAmount, uint256 index) external;
59
+
60
+ /**
61
+ * @notice Transfers aTokens in the event of a borrow being liquidated, in case the liquidator reclaims the aToken.
62
+ * @dev Passing both the unscaled and scaled amounts enhances precision. The `scaledAmount` is used for precise balance updates,
63
+ * while the `amount` is used for logging and consistency, preventing cumulative rounding errors.
64
+ * @param from The address getting liquidated, current owner of the aTokens
65
+ * @param to The recipient
66
+ * @param amount The amount of tokens getting transferred (non-scaled)
67
+ * @param scaledAmount The scaled amount of tokens getting transferred (scaled)
68
+ * @param index The next liquidity index of the reserve
69
+ */
70
+ function transferOnLiquidation(
71
+ address from,
72
+ address to,
73
+ uint256 amount,
74
+ uint256 scaledAmount,
75
+ uint256 index
76
+ ) external;
77
+
78
+ /**
79
+ * @notice Transfers the underlying asset to `target`.
80
+ * @dev Used by the Pool to transfer assets in borrow(), withdraw() and flashLoan()
81
+ * @param target The recipient of the underlying
82
+ * @param amount The amount getting transferred
83
+ */
84
+ function transferUnderlyingTo(address target, uint256 amount) external;
85
+
86
+ /**
87
+ * @notice Allow passing a signed message to approve spending
88
+ * @dev implements the permit function as for
89
+ * https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md
90
+ * @param owner The owner of the funds
91
+ * @param spender The spender
92
+ * @param value The amount
93
+ * @param deadline The deadline timestamp, type(uint256).max for max deadline
94
+ * @param v Signature param
95
+ * @param s Signature param
96
+ * @param r Signature param
97
+ */
98
+ function permit(
99
+ address owner,
100
+ address spender,
101
+ uint256 value,
102
+ uint256 deadline,
103
+ uint8 v,
104
+ bytes32 r,
105
+ bytes32 s
106
+ ) external;
107
+
108
+ /**
109
+ * @notice Returns the address of the underlying asset of this aToken (E.g. WETH for aWETH)
110
+ * @return The address of the underlying asset
111
+ */
112
+ function UNDERLYING_ASSET_ADDRESS() external view returns (address);
113
+
114
+ /**
115
+ * @notice Returns the address of the Aave treasury, receiving the fees on this aToken.
116
+ * @return Address of the Aave treasury
117
+ */
118
+ function RESERVE_TREASURY_ADDRESS() external view returns (address);
119
+
120
+ /**
121
+ * @notice Get the domain separator for the token
122
+ * @dev Return cached value if chainId matches cache, otherwise recomputes separator
123
+ * @return The domain separator of the token at current chain
124
+ */
125
+ function DOMAIN_SEPARATOR() external view returns (bytes32);
126
+
127
+ /**
128
+ * @notice Returns the nonce for owner.
129
+ * @param owner The address of the owner
130
+ * @return The nonce of the owner
131
+ */
132
+ function nonces(address owner) external view returns (uint256);
133
+
134
+ /**
135
+ * @notice Rescue and transfer tokens locked in this contract
136
+ * @param token The address of the token
137
+ * @param to The address of the recipient
138
+ * @param amount The amount of token to transfer
139
+ */
140
+ function rescueTokens(address token, address to, uint256 amount) external;
141
+ }
@@ -0,0 +1,51 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import {IPool} from "./IPool.sol";
5
+
6
+ /**
7
+ * @title IInitializableAToken
8
+ * @author Aave
9
+ * @notice Interface for the initialize function on AToken
10
+ */
11
+ interface IInitializableAToken {
12
+ /**
13
+ * @dev Emitted when an aToken is initialized
14
+ * @param underlyingAsset The address of the underlying asset
15
+ * @param pool The address of the associated pool
16
+ * @param treasury The address of the treasury
17
+ * @param incentivesController The address of the incentives controller for this aToken
18
+ * @param aTokenDecimals The decimals of the underlying
19
+ * @param aTokenName The name of the aToken
20
+ * @param aTokenSymbol The symbol of the aToken
21
+ * @param params A set of encoded parameters for additional initialization
22
+ */
23
+ event Initialized(
24
+ address indexed underlyingAsset,
25
+ address indexed pool,
26
+ address treasury,
27
+ address incentivesController,
28
+ uint8 aTokenDecimals,
29
+ string aTokenName,
30
+ string aTokenSymbol,
31
+ bytes params
32
+ );
33
+
34
+ /**
35
+ * @notice Initializes the aToken
36
+ * @param pool The pool contract that is initializing this contract
37
+ * @param underlyingAsset The address of the underlying asset of this aToken (E.g. WETH for aWETH)
38
+ * @param aTokenDecimals The decimals of the aToken, same as the underlying asset's
39
+ * @param aTokenName The name of the aToken
40
+ * @param aTokenSymbol The symbol of the aToken
41
+ * @param params A set of encoded parameters for additional initialization
42
+ */
43
+ function initialize(
44
+ IPool pool,
45
+ address underlyingAsset,
46
+ uint8 aTokenDecimals,
47
+ string calldata aTokenName,
48
+ string calldata aTokenSymbol,
49
+ bytes calldata params
50
+ ) external;
51
+ }