forked from bgd-labs/static-a-token-v3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IStaticATokenLM.sol
216 lines (193 loc) · 8.09 KB
/
IStaticATokenLM.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
// SPDX-License-Identifier: agpl-3.0
pragma solidity ^0.8.10;
import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol';
import {IPool} from 'aave-v3-core/contracts/interfaces/IPool.sol';
import {IAaveIncentivesController} from 'aave-v3-core/contracts/interfaces/IAaveIncentivesController.sol';
import {IInitializableStaticATokenLM} from './IInitializableStaticATokenLM.sol';
interface IStaticATokenLM is IInitializableStaticATokenLM {
struct SignatureParams {
uint8 v;
bytes32 r;
bytes32 s;
}
struct PermitParams {
address owner;
address spender;
uint256 value;
uint256 deadline;
uint8 v;
bytes32 r;
bytes32 s;
}
struct UserRewardsData {
uint128 rewardsIndexOnLastInteraction; // (in RAYs)
uint128 unclaimedRewards; // (in RAYs)
}
struct RewardIndexCache {
bool isRegistered;
uint248 lastUpdatedIndex;
}
event RewardTokenRegistered(address indexed reward, uint256 startIndex);
/**
* @notice Burns `amount` of static aToken, with receiver receiving the corresponding amount of `ASSET`
* @param shares The amount to withdraw, in static balance of StaticAToken
* @param receiver The address that will receive the amount of `ASSET` withdrawn from the Aave protocol
* @param withdrawFromAave bool
* - `true` for the receiver to get underlying tokens (e.g. USDC)
* - `false` for the receiver to get aTokens (e.g. aUSDC)
* @return amountToBurn: StaticATokens burnt, static balance
* @return amountToWithdraw: underlying/aToken send to `receiver`, dynamic balance
**/
function redeem(
uint256 shares,
address receiver,
address owner,
bool withdrawFromAave
) external returns (uint256, uint256);
/**
* @notice Deposits `ASSET` in the Aave protocol and mints static aTokens to msg.sender
* @param assets The amount of underlying `ASSET` to deposit (e.g. deposit of 100 USDC)
* @param receiver The address that will receive the static aTokens
* @param referralCode Code used to register the integrator originating the operation, for potential rewards.
* 0 if the action is executed directly by the user, without any middle-man
* @param depositToAave bool
* - `true` if the msg.sender comes with underlying tokens (e.g. USDC)
* - `false` if the msg.sender comes already with aTokens (e.g. aUSDC)
* @return uint256 The amount of StaticAToken minted, static balance
**/
function deposit(
uint256 assets,
address receiver,
uint16 referralCode,
bool depositToAave
) external returns (uint256);
/**
* @notice Allows to deposit on Aave via meta-transaction
* https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md
* @param depositor Address from which the funds to deposit are going to be pulled
* @param receiver Address that will receive the staticATokens, in the average case, same as the `depositor`
* @param assets The amount to deposit
* @param referralCode Code used to register the integrator originating the operation, for potential rewards.
* 0 if the action is executed directly by the user, without any middle-man
* @param depositToAave bool
* - `true` if the msg.sender comes with underlying tokens (e.g. USDC)
* - `false` if the msg.sender comes already with aTokens (e.g. aUSDC)
* @param deadline The deadline timestamp, type(uint256).max for max deadline
* @param sigParams Signature params: v,r,s
* @return uint256 The amount of StaticAToken minted, static balance
*/
function metaDeposit(
address depositor,
address receiver,
uint256 assets,
uint16 referralCode,
bool depositToAave,
uint256 deadline,
PermitParams calldata permit,
SignatureParams calldata sigParams
) external returns (uint256);
/**
* @notice Allows to withdraw from Aave via meta-transaction
* https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md
* @param owner Address owning the staticATokens
* @param receiver Address that will receive the underlying withdrawn from Aave
* @param shares The amount of staticAToken to withdraw. If > 0, `assets` needs to be 0
* @param assets The amount of underlying/aToken to withdraw. If > 0, `shares` needs to be 0
* @param withdrawFromAave bool
* - `true` for the receiver to get underlying tokens (e.g. USDC)
* - `false` for the receiver to get aTokens (e.g. aUSDC)
* @param deadline The deadline timestamp, type(uint256).max for max deadline
* @param sigParams Signature params: v,r,s
* @return amountToBurn: StaticATokens burnt, static balance
* @return amountToWithdraw: underlying/aToken send to `receiver`, dynamic balance
*/
function metaWithdraw(
address owner,
address receiver,
uint256 shares,
uint256 assets,
bool withdrawFromAave,
uint256 deadline,
SignatureParams calldata sigParams
) external returns (uint256, uint256);
/**
* @notice Returns the Aave liquidity index of the underlying aToken, denominated rate here
* as it can be considered as an ever-increasing exchange rate
* @return The liquidity index
**/
function rate() external view returns (uint256);
/**
* @notice Claims rewards from `INCENTIVES_CONTROLLER` and updates internal accounting of rewards.
* @param reward The reward to claim
* @return uint256 Amount collected
*/
function collectAndUpdateRewards(address reward) external returns (uint256);
/**
* @notice Claim rewards on behalf of a user and send them to a receiver
* @dev Only callable by if sender is onBehalfOf or sender is approved claimer
* @param onBehalfOf The address to claim on behalf of
* @param receiver The address to receive the rewards
* @param rewards The rewards to claim
*/
function claimRewardsOnBehalf(
address onBehalfOf,
address receiver,
address[] memory rewards
) external;
/**
* @notice Claim rewards and send them to a receiver
* @param receiver The address to receive the rewards
* @param rewards The rewards to claim
*/
function claimRewards(address receiver, address[] memory rewards) external;
/**
* @notice Claim rewards
* @param rewards The rewards to claim
*/
function claimRewardsToSelf(address[] memory rewards) external;
/**
* @notice Get the total claimable rewards of the contract.
* @param reward The reward to claim
* @return uint256 The current balance + pending rewards from the `_incentivesController`
*/
function getTotalClaimableRewards(address reward) external view returns (uint256);
/**
* @notice Get the total claimable rewards for a user in WAD
* @param user The address of the user
* @param reward The reward to claim
* @return uint256 The claimable amount of rewards in WAD
*/
function getClaimableRewards(address user, address reward) external view returns (uint256);
/**
* @notice The unclaimed rewards for a user in WAD
* @param user The address of the user
* @param reward The reward to claim
* @return uint256 The unclaimed amount of rewards in WAD
*/
function getUnclaimedRewards(address user, address reward) external view returns (uint256);
/**
* @notice The underlying asset reward index in RAY
* @param reward The reward to claim
* @return uint256 The underlying asset reward index in RAY
*/
function getCurrentRewardsIndex(address reward) external view returns (uint256);
/**
* @notice The aToken used inside the 4626 vault.
* @return IERC20 The aToken IERC20.
*/
function aToken() external view returns (IERC20);
/**
* @notice The IERC20s that are currently rewarded to addresses of the vault via LM on incentivescontroller.
* @return IERC20 The IERC20s of the rewards.
*/
function rewardTokens() external view returns (address[] memory);
/**
* @notice Fetches all rewardTokens from the incentivecontroller and registers the missing ones.
*/
function refreshRewardTokens() external;
/**
* @notice Checks if the passed token is a registered reward.
* @return bool signaling if token is a registered reward.
*/
function isRegisteredRewardToken(address reward) external view returns (bool);
}