2020-08-20 12:32:20 +00:00
|
|
|
// SPDX-License-Identifier: agpl-3.0
|
|
|
|
pragma solidity ^0.6.8;
|
|
|
|
|
|
|
|
import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
|
|
|
|
|
|
|
|
interface IAToken is IERC20 {
|
2020-08-21 14:03:01 +00:00
|
|
|
/**
|
|
|
|
* @dev emitted after aTokens are burned
|
|
|
|
* @param from the address performing the redeem
|
|
|
|
* @param value the amount to be redeemed
|
|
|
|
* @param fromBalanceIncrease the cumulated balance since the last update of the user
|
|
|
|
* @param fromIndex the last index of the user
|
|
|
|
**/
|
|
|
|
event Burn(
|
|
|
|
address indexed from,
|
|
|
|
address indexed target,
|
|
|
|
uint256 value,
|
|
|
|
uint256 fromBalanceIncrease,
|
|
|
|
uint256 fromIndex
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev emitted after the mint action
|
|
|
|
* @param from the address performing the mint
|
|
|
|
* @param value the amount to be minted
|
|
|
|
* @param fromBalanceIncrease the cumulated balance since the last update of the user
|
|
|
|
* @param fromIndex the last index of the user
|
|
|
|
**/
|
|
|
|
event Mint(address indexed from, uint256 value, uint256 fromBalanceIncrease, uint256 fromIndex);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev emitted during the transfer action
|
|
|
|
* @param from the address from which the tokens are being transferred
|
|
|
|
* @param to the adress of the destination
|
|
|
|
* @param value the amount to be minted
|
|
|
|
* @param fromBalanceIncrease the cumulated balance since the last update of the user
|
|
|
|
* @param toBalanceIncrease the cumulated balance since the last update of the destination
|
|
|
|
* @param fromIndex the last index of the user
|
|
|
|
* @param toIndex the last index of the liquidator
|
|
|
|
**/
|
|
|
|
event BalanceTransfer(
|
|
|
|
address indexed from,
|
|
|
|
address indexed to,
|
|
|
|
uint256 value,
|
|
|
|
uint256 fromBalanceIncrease,
|
|
|
|
uint256 toBalanceIncrease,
|
|
|
|
uint256 fromIndex,
|
|
|
|
uint256 toIndex
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev emitted when the accumulation of the interest
|
|
|
|
* by an user is redirected to another user
|
|
|
|
* @param from the address from which the interest is being redirected
|
|
|
|
* @param to the adress of the destination
|
|
|
|
* @param fromBalanceIncrease the cumulated balance since the last update of the user
|
|
|
|
* @param fromIndex the last index of the user
|
|
|
|
**/
|
|
|
|
event InterestStreamRedirected(
|
|
|
|
address indexed from,
|
|
|
|
address indexed to,
|
|
|
|
uint256 redirectedBalance,
|
|
|
|
uint256 fromBalanceIncrease,
|
|
|
|
uint256 fromIndex
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev emitted when the redirected balance of an user is being updated
|
|
|
|
* @param targetAddress the address of which the balance is being updated
|
|
|
|
* @param targetBalanceIncrease the cumulated balance since the last update of the target
|
|
|
|
* @param targetIndex the last index of the user
|
|
|
|
* @param redirectedBalanceAdded the redirected balance being added
|
|
|
|
* @param redirectedBalanceRemoved the redirected balance being removed
|
|
|
|
**/
|
|
|
|
event RedirectedBalanceUpdated(
|
|
|
|
address indexed targetAddress,
|
|
|
|
uint256 targetBalanceIncrease,
|
|
|
|
uint256 targetIndex,
|
|
|
|
uint256 redirectedBalanceAdded,
|
|
|
|
uint256 redirectedBalanceRemoved
|
|
|
|
);
|
|
|
|
|
|
|
|
event InterestRedirectionAllowanceChanged(address indexed from, address indexed to);
|
|
|
|
|
2020-08-20 12:32:20 +00:00
|
|
|
/**
|
|
|
|
* @dev redirects the interest generated to a target address.
|
|
|
|
* when the interest is redirected, the user balance is added to
|
|
|
|
* the recepient redirected balance.
|
2020-08-21 13:38:47 +00:00
|
|
|
* @param to the address to which the interest will be redirected
|
2020-08-20 12:32:20 +00:00
|
|
|
**/
|
2020-08-21 13:38:47 +00:00
|
|
|
function redirectInterestStream(address to) external;
|
2020-08-20 12:32:20 +00:00
|
|
|
|
|
|
|
/**
|
2020-08-21 13:38:47 +00:00
|
|
|
* @dev redirects the interest generated by from to a target address.
|
2020-08-20 12:32:20 +00:00
|
|
|
* when the interest is redirected, the user balance is added to
|
|
|
|
* the recepient redirected balance. The caller needs to have allowance on
|
|
|
|
* the interest redirection to be able to execute the function.
|
2020-08-21 13:38:47 +00:00
|
|
|
* @param from the address of the user whom interest is being redirected
|
|
|
|
* @param to the address to which the interest will be redirected
|
2020-08-20 12:32:20 +00:00
|
|
|
**/
|
2020-08-21 13:38:47 +00:00
|
|
|
function redirectInterestStreamOf(address from, address to) external;
|
2020-08-20 12:32:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev gives allowance to an address to execute the interest redirection
|
|
|
|
* on behalf of the caller.
|
2020-08-21 13:38:47 +00:00
|
|
|
* @param to the address to which the interest will be redirected. Pass address(0) to reset
|
2020-08-20 12:32:20 +00:00
|
|
|
* the allowance.
|
|
|
|
**/
|
2020-08-21 13:38:47 +00:00
|
|
|
function allowInterestRedirectionTo(address to) external;
|
2020-08-20 12:32:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev burns the aTokens and sends the equivalent amount of underlying to the target.
|
|
|
|
* only lending pools can call this function
|
2020-08-21 13:38:47 +00:00
|
|
|
* @param amount the amount being burned
|
2020-08-20 12:32:20 +00:00
|
|
|
**/
|
|
|
|
function burn(
|
2020-08-21 13:38:47 +00:00
|
|
|
address user,
|
|
|
|
address underlyingTarget,
|
|
|
|
uint256 amount
|
2020-08-20 12:32:20 +00:00
|
|
|
) external;
|
|
|
|
|
|
|
|
/**
|
2020-08-21 13:38:47 +00:00
|
|
|
* @dev mints aTokens to user
|
2020-08-20 12:32:20 +00:00
|
|
|
* only lending pools can call this function
|
2020-08-21 13:38:47 +00:00
|
|
|
* @param user the address receiving the minted tokens
|
|
|
|
* @param amount the amount of tokens to mint
|
2020-08-20 12:32:20 +00:00
|
|
|
*/
|
2020-08-21 13:38:47 +00:00
|
|
|
function mint(address user, uint256 amount) external;
|
2020-08-20 12:32:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev transfers tokens in the event of a borrow being liquidated, in case the liquidators reclaims the aToken
|
|
|
|
* only lending pools can call this function
|
2020-08-21 13:38:47 +00:00
|
|
|
* @param from the address from which transfer the aTokens
|
|
|
|
* @param to the destination address
|
|
|
|
* @param value the amount to transfer
|
2020-08-20 12:32:20 +00:00
|
|
|
**/
|
|
|
|
function transferOnLiquidation(
|
2020-08-21 13:38:47 +00:00
|
|
|
address from,
|
|
|
|
address to,
|
|
|
|
uint256 value
|
2020-08-20 12:32:20 +00:00
|
|
|
) external;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev returns the principal balance of the user. The principal balance is the last
|
|
|
|
* updated stored balance, which does not consider the perpetually accruing interest.
|
2020-08-21 13:38:47 +00:00
|
|
|
* @param user the address of the user
|
2020-08-20 12:32:20 +00:00
|
|
|
* @return the principal balance of the user
|
|
|
|
**/
|
2020-08-21 13:38:47 +00:00
|
|
|
function principalBalanceOf(address user) external view returns (uint256);
|
2020-08-20 12:32:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev Used to validate transfers before actually executing them.
|
2020-08-21 13:38:47 +00:00
|
|
|
* @param user address of the user to check
|
|
|
|
* @param amount the amount to check
|
|
|
|
* @return true if the user can transfer amount, false otherwise
|
2020-08-20 12:32:20 +00:00
|
|
|
**/
|
2020-08-21 13:38:47 +00:00
|
|
|
function isTransferAllowed(address user, uint256 amount) external view returns (bool);
|
2020-08-20 12:32:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev returns the last index of the user, used to calculate the balance of the user
|
2020-08-21 13:38:47 +00:00
|
|
|
* @param user address of the user
|
2020-08-20 12:32:20 +00:00
|
|
|
* @return the last user index
|
|
|
|
**/
|
2020-08-21 13:38:47 +00:00
|
|
|
function getUserIndex(address user) external view returns (uint256);
|
2020-08-20 12:32:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev returns the address to which the interest is redirected
|
2020-08-21 13:38:47 +00:00
|
|
|
* @param user address of the user
|
2020-08-20 12:32:20 +00:00
|
|
|
* @return 0 if there is no redirection, an address otherwise
|
|
|
|
**/
|
2020-08-21 13:38:47 +00:00
|
|
|
function getInterestRedirectionAddress(address user) external view returns (address);
|
2020-08-20 12:32:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev returns the redirected balance of the user. The redirected balance is the balance
|
|
|
|
* redirected by other accounts to the user, that is accrueing interest for him.
|
2020-08-21 13:38:47 +00:00
|
|
|
* @param user address of the user
|
2020-08-20 12:32:20 +00:00
|
|
|
* @return the total redirected balance
|
|
|
|
**/
|
2020-08-21 13:38:47 +00:00
|
|
|
function getRedirectedBalance(address user) external view returns (uint256);
|
2020-08-20 12:32:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev transfers the underlying asset to the target. Used by the lendingpool to transfer
|
|
|
|
* assets in borrow(), redeem() and flashLoan()
|
2020-08-21 13:38:47 +00:00
|
|
|
* @param target the target of the transfer
|
|
|
|
* @param amount the amount to transfer
|
2020-08-20 12:32:20 +00:00
|
|
|
* @return the amount transferred
|
|
|
|
**/
|
|
|
|
|
2020-08-21 13:38:47 +00:00
|
|
|
function transferUnderlyingTo(address target, uint256 amount) external returns (uint256);
|
2020-08-20 12:32:20 +00:00
|
|
|
}
|