2021-09-20 12:47:03 +00:00
|
|
|
// SPDX-License-Identifier: agpl-3.0
|
|
|
|
pragma solidity 0.6.12;
|
|
|
|
pragma experimental ABIEncoderV2;
|
|
|
|
|
|
|
|
import {IERC20} from '../dependencies/openzeppelin/contracts/IERC20.sol';
|
2021-09-21 11:30:40 +00:00
|
|
|
import {ILendingPool} from './ILendingPool.sol';
|
|
|
|
import {IAaveIncentivesController} from './IAaveIncentivesController.sol';
|
|
|
|
import {IInitializableStaticATokenLM} from './IInitializableStaticATokenLM.sol';
|
2021-09-20 12:47:03 +00:00
|
|
|
|
2021-09-21 11:30:40 +00:00
|
|
|
interface IStaticATokenLM is IERC20, IInitializableStaticATokenLM {
|
2021-09-20 12:47:03 +00:00
|
|
|
struct SignatureParams {
|
|
|
|
uint8 v;
|
|
|
|
bytes32 r;
|
|
|
|
bytes32 s;
|
|
|
|
}
|
|
|
|
|
2021-09-20 13:12:27 +00:00
|
|
|
/**
|
|
|
|
* @notice Deposits `ASSET` in the Aave protocol and mints static aTokens to msg.sender
|
|
|
|
* @param recipient The address that will receive the static aTokens
|
|
|
|
* @param amount The amount of underlying `ASSET` to deposit (e.g. deposit of 100 USDC)
|
|
|
|
* @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 fromUnderlying 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
|
|
|
|
**/
|
2021-09-20 12:47:03 +00:00
|
|
|
function deposit(
|
|
|
|
address recipient,
|
|
|
|
uint256 amount,
|
|
|
|
uint16 referralCode,
|
|
|
|
bool fromUnderlying
|
|
|
|
) external returns (uint256);
|
|
|
|
|
2021-09-20 13:12:27 +00:00
|
|
|
/**
|
|
|
|
* @notice Burns `amount` of static aToken, with recipient receiving the corresponding amount of `ASSET`
|
|
|
|
* @param recipient The address that will receive the amount of `ASSET` withdrawn from the Aave protocol
|
|
|
|
* @param amount The amount to withdraw, in static balance of StaticAToken
|
|
|
|
* @param toUnderlying bool
|
|
|
|
* - `true` for the recipient to get underlying tokens (e.g. USDC)
|
|
|
|
* - `false` for the recipient to get aTokens (e.g. aUSDC)
|
|
|
|
* @return amountToBurn: StaticATokens burnt, static balance
|
|
|
|
* @return amountToWithdraw: underlying/aToken send to `recipient`, dynamic balance
|
|
|
|
**/
|
2021-09-20 12:47:03 +00:00
|
|
|
function withdraw(
|
|
|
|
address recipient,
|
|
|
|
uint256 amount,
|
|
|
|
bool toUnderlying
|
|
|
|
) external returns (uint256, uint256);
|
|
|
|
|
2021-09-20 13:12:27 +00:00
|
|
|
/**
|
|
|
|
* @notice Burns `amount` of static aToken, with recipient receiving the corresponding amount of `ASSET`
|
|
|
|
* @param recipient The address that will receive the amount of `ASSET` withdrawn from the Aave protocol
|
|
|
|
* @param amount The amount to withdraw, in dynamic balance of aToken/underlying asset
|
|
|
|
* @param toUnderlying bool
|
|
|
|
* - `true` for the recipient to get underlying tokens (e.g. USDC)
|
|
|
|
* - `false` for the recipient to get aTokens (e.g. aUSDC)
|
|
|
|
* @return amountToBurn: StaticATokens burnt, static balance
|
|
|
|
* @return amountToWithdraw: underlying/aToken send to `recipient`, dynamic balance
|
|
|
|
**/
|
2021-09-20 12:47:03 +00:00
|
|
|
function withdrawDynamicAmount(
|
|
|
|
address recipient,
|
|
|
|
uint256 amount,
|
|
|
|
bool toUnderlying
|
|
|
|
) external returns (uint256, uint256);
|
|
|
|
|
2021-09-20 13:12:27 +00:00
|
|
|
/**
|
|
|
|
* @notice Implements the permit function as for
|
|
|
|
* https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md
|
|
|
|
* @param owner The owner of the funds
|
|
|
|
* @param spender The spender
|
|
|
|
* @param value The amount
|
|
|
|
* @param deadline The deadline timestamp, type(uint256).max for max deadline
|
|
|
|
* @param v Signature param
|
|
|
|
* @param s Signature param
|
|
|
|
* @param r Signature param
|
|
|
|
*/
|
2021-09-20 12:47:03 +00:00
|
|
|
function permit(
|
|
|
|
address owner,
|
|
|
|
address spender,
|
|
|
|
uint256 value,
|
|
|
|
uint256 deadline,
|
|
|
|
uint8 v,
|
|
|
|
bytes32 r,
|
|
|
|
bytes32 s
|
|
|
|
) external;
|
|
|
|
|
2021-09-20 13:12:27 +00:00
|
|
|
/**
|
|
|
|
* @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 recipient Address that will receive the staticATokens, in the average case, same as the `depositor`
|
|
|
|
* @param value 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 fromUnderlying 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
|
|
|
|
*/
|
2021-09-20 12:47:03 +00:00
|
|
|
function metaDeposit(
|
|
|
|
address depositor,
|
|
|
|
address recipient,
|
|
|
|
uint256 value,
|
|
|
|
uint16 referralCode,
|
|
|
|
bool fromUnderlying,
|
|
|
|
uint256 deadline,
|
|
|
|
SignatureParams calldata sigParams
|
|
|
|
) external returns (uint256);
|
|
|
|
|
2021-09-20 13:12:27 +00:00
|
|
|
/**
|
|
|
|
* @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 recipient Address that will receive the underlying withdrawn from Aave
|
|
|
|
* @param staticAmount The amount of staticAToken to withdraw. If > 0, `dynamicAmount` needs to be 0
|
|
|
|
* @param dynamicAmount The amount of underlying/aToken to withdraw. If > 0, `staticAmount` needs to be 0
|
|
|
|
* @param toUnderlying bool
|
|
|
|
* - `true` for the recipient to get underlying tokens (e.g. USDC)
|
|
|
|
* - `false` for the recipient 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 `recipient`, dynamic balance
|
|
|
|
*/
|
2021-09-20 12:47:03 +00:00
|
|
|
function metaWithdraw(
|
|
|
|
address owner,
|
|
|
|
address recipient,
|
|
|
|
uint256 staticAmount,
|
|
|
|
uint256 dynamicAmount,
|
|
|
|
bool toUnderlying,
|
|
|
|
uint256 deadline,
|
|
|
|
SignatureParams calldata sigParams
|
|
|
|
) external returns (uint256, uint256);
|
|
|
|
|
2021-09-20 13:12:27 +00:00
|
|
|
/**
|
|
|
|
* @notice Utility method to get the current aToken balance of an user, from his staticAToken balance
|
|
|
|
* @param account The address of the user
|
|
|
|
* @return uint256 The aToken balance
|
|
|
|
**/
|
2021-09-20 12:47:03 +00:00
|
|
|
function dynamicBalanceOf(address account) external view returns (uint256);
|
|
|
|
|
2021-09-20 13:12:27 +00:00
|
|
|
/**
|
|
|
|
* @notice Converts a static amount (scaled balance on aToken) to the aToken/underlying value,
|
|
|
|
* using the current liquidity index on Aave
|
|
|
|
* @param amount The amount to convert from
|
|
|
|
* @return uint256 The dynamic amount
|
|
|
|
**/
|
2021-09-20 12:47:03 +00:00
|
|
|
function staticToDynamicAmount(uint256 amount) external view returns (uint256);
|
|
|
|
|
2021-09-20 13:12:27 +00:00
|
|
|
/**
|
|
|
|
* @notice Converts an aToken or underlying amount to the what it is denominated on the aToken as
|
|
|
|
* scaled balance, function of the principal and the liquidity index
|
|
|
|
* @param amount The amount to convert from
|
|
|
|
* @return uint256 The static (scaled) amount
|
|
|
|
**/
|
2021-09-20 12:47:03 +00:00
|
|
|
function dynamicToStaticAmount(uint256 amount) external view returns (uint256);
|
|
|
|
|
2021-09-20 13:12:27 +00:00
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
**/
|
2021-09-20 12:47:03 +00:00
|
|
|
function rate() external view returns (uint256);
|
|
|
|
|
2021-09-20 13:12:27 +00:00
|
|
|
/**
|
|
|
|
* @notice Function to return a dynamic domain separator, in order to be compatible with forks changing chainId
|
|
|
|
* @return bytes32 The domain separator
|
|
|
|
**/
|
2021-09-20 12:47:03 +00:00
|
|
|
function getDomainSeparator() external view returns (bytes32);
|
|
|
|
|
2021-09-20 13:12:27 +00:00
|
|
|
/**
|
|
|
|
* @notice Claims rewards from `INCENTIVES_CONTROLLER` and updates internal accounting of rewards.
|
|
|
|
*/
|
2021-09-20 12:47:03 +00:00
|
|
|
function collectAndUpdateRewards() external;
|
|
|
|
|
2021-09-20 13:12:27 +00:00
|
|
|
/**
|
|
|
|
* @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 forceUpdate Flag to retrieve latest rewards from `INCENTIVES_CONTROLLER`
|
|
|
|
*/
|
2021-09-20 12:47:03 +00:00
|
|
|
function claimRewardsOnBehalf(
|
|
|
|
address onBehalfOf,
|
|
|
|
address receiver,
|
|
|
|
bool forceUpdate
|
|
|
|
) external;
|
|
|
|
|
2021-09-20 13:12:27 +00:00
|
|
|
/**
|
|
|
|
* @notice Claim rewards and send them to a receiver
|
|
|
|
* @param receiver The address to receive the rewards
|
|
|
|
* @param forceUpdate Flag to retrieve latest rewards from `INCENTIVES_CONTROLLER`
|
|
|
|
*/
|
2021-09-20 12:47:03 +00:00
|
|
|
function claimRewards(address receiver, bool forceUpdate) external;
|
|
|
|
|
2021-09-20 13:12:27 +00:00
|
|
|
/**
|
|
|
|
* @notice Claim rewards
|
|
|
|
* @param forceUpdate Flag to retrieve latest rewards from `INCENTIVES_CONTROLLER`
|
|
|
|
*/
|
2021-09-20 12:47:03 +00:00
|
|
|
function claimRewardsToSelf(bool forceUpdate) external;
|
|
|
|
|
2021-09-20 13:12:27 +00:00
|
|
|
/**
|
|
|
|
* @notice Get the total claimable rewards of the contract.
|
|
|
|
* @return The current balance + pending rewards from the `_incentivesController`
|
|
|
|
*/
|
2021-09-20 12:47:03 +00:00
|
|
|
function getTotalClaimableRewards() external view returns (uint256);
|
|
|
|
|
2021-09-20 13:12:27 +00:00
|
|
|
/**
|
|
|
|
* @notice Get the total claimable rewards for a user in WAD
|
|
|
|
* @param user The address of the user
|
|
|
|
* @return The claimable amount of rewards in WAD
|
|
|
|
*/
|
2021-09-20 12:47:03 +00:00
|
|
|
function getClaimableRewards(address user) external view returns (uint256);
|
|
|
|
|
2021-09-20 13:12:27 +00:00
|
|
|
/**
|
|
|
|
* @notice The unclaimed rewards for a user in WAD
|
|
|
|
* @param user The address of the user
|
|
|
|
* @return The unclaimed amount of rewards in WAD
|
|
|
|
*/
|
2021-09-20 12:47:03 +00:00
|
|
|
function getUnclaimedRewards(address user) external view returns (uint256);
|
|
|
|
|
|
|
|
function getAccRewardsPerToken() external view returns (uint256);
|
|
|
|
|
|
|
|
function getLifetimeRewardsClaimed() external view returns (uint256);
|
|
|
|
|
|
|
|
function getLifetimeRewards() external view returns (uint256);
|
|
|
|
|
|
|
|
function getLastRewardBlock() external view returns (uint256);
|
2021-09-21 11:30:40 +00:00
|
|
|
|
|
|
|
function LENDING_POOL() external returns (ILendingPool);
|
|
|
|
|
|
|
|
function INCENTIVES_CONTROLLER() external returns (IAaveIncentivesController);
|
|
|
|
|
|
|
|
function ATOKEN() external returns (IERC20);
|
|
|
|
|
|
|
|
function ASSET() external returns (IERC20);
|
|
|
|
|
|
|
|
function REWARD_TOKEN() external returns (IERC20);
|
2021-09-20 12:47:03 +00:00
|
|
|
}
|