IAToken
Also available on Github.
IAToken.sol
IScaledBalanceToken.sol
IERC20.sol
1
// SPDX-License-Identifier: agpl-3.0
2
pragma solidity 0.6.12;
3
4
import {IERC20} from './IERC20.sol';
5
import {IScaledBalanceToken} from './IScaledBalanceToken.sol';
6
7
interface IAToken is IERC20, IScaledBalanceToken {
8
/**
9
* @dev Emitted after the mint action
10
* @param from The address performing the mint
11
* @param value The amount being
12
* @param index The new liquidity index of the reserve
13
**/
14
event Mint(address indexed from, uint256 value, uint256 index);
15
16
/**
17
* @dev Mints `amount` aTokens to `user`
18
* @param user The address receiving the minted tokens
19
* @param amount The amount of tokens getting minted
20
* @param index The new liquidity index of the reserve
21
* @return `true` if the the previous balance of the user was 0
22
*/
23
function mint(
24
address user,
25
uint256 amount,
26
uint256 index
27
) external returns (bool);
28
29
/**
30
* @dev Emitted after aTokens are burned
31
* @param from The owner of the aTokens, getting them burned
32
* @param target The address that will receive the underlying
33
* @param value The amount being burned
34
* @param index The new liquidity index of the reserve
35
**/
36
event Burn(address indexed from, address indexed target, uint256 value, uint256 index);
37
38
/**
39
* @dev Emitted during the transfer action
40
* @param from The user whose tokens are being transferred
41
* @param to The recipient
42
* @param value The amount being transferred
43
* @param index The new liquidity index of the reserve
44
**/
45
event BalanceTransfer(address indexed from, address indexed to, uint256 value, uint256 index);
46
47
/**
48
* @dev Burns aTokens from `user` and sends the equivalent amount of underlying to `receiverOfUnderlying`
49
* @param user The owner of the aTokens, getting them burned
50
* @param receiverOfUnderlying The address that will receive the underlying
51
* @param amount The amount being burned
52
* @param index The new liquidity index of the reserve
53
**/
54
function burn(
55
address user,
56
address receiverOfUnderlying,
57
uint256 amount,
58
uint256 index
59
) external;
60
61
/**
62
* @dev Mints aTokens to the reserve treasury
63
* @param amount The amount of tokens getting minted
64
* @param index The new liquidity index of the reserve
65
*/
66
function mintToTreasury(uint256 amount, uint256 index) external;
67
68
/**
69
* @dev Transfers aTokens in the event of a borrow being liquidated, in case the liquidators reclaims the aToken
70
* @param from The address getting liquidated, current owner of the aTokens
71
* @param to The recipient
72
* @param value The amount of tokens getting transferred
73
**/
74
function transferOnLiquidation(
75
address from,
76
address to,
77
uint256 value
78
) external;
79
80
/**
81
* @dev Transfers the underlying asset to `target`. Used by the LendingPool to transfer
82
* assets in borrow(), withdraw() and flashLoan()
83
* @param user The recipient of the aTokens
84
* @param amount The amount getting transferred
85
* @return The amount transferred
86
**/
87
function transferUnderlyingTo(address user, uint256 amount) external returns (uint256);
88
}
Copied!
1
// SPDX-License-Identifier: agpl-3.0
2
pragma solidity 0.6.12;
3
4
interface IScaledBalanceToken {
5
/**
6
* @dev Returns the scaled balance of the user. The scaled balance is the sum of all the
7
* updated stored balance divided by the reserve's liquidity index at the moment of the update
8
* @param user The user whose balance is calculated
9
* @return The scaled balance of the user
10
**/
11
function scaledBalanceOf(address user) external view returns (uint256);
12
13
/**
14
* @dev Returns the scaled balance of the user and the scaled total supply.
15
* @param user The address of the user
16
* @return The scaled balance of the user
17
* @return The scaled balance and the scaled total supply
18
**/
19
function getScaledUserBalanceAndSupply(address user) external view returns (uint256, uint256);
20
21
/**
22
* @dev Returns the scaled total supply of the variable debt token. Represents sum(debt/index)
23
* @return The scaled total supply
24
**/
25
function scaledTotalSupply() external view returns (uint256);
26
}
27
Copied!
1
// SPDX-License-Identifier: agpl-3.0
2
pragma solidity 0.6.8;
3
4
/**
5
* @dev Interface of the ERC20 standard as defined in the EIP.
6
*/
7
interface IERC20 {
8
/**
9
* @dev Returns the amount of tokens in existence.
10
*/
11
function totalSupply() external view returns (uint256);
12
13
/**
14
* @dev Returns the amount of tokens owned by `account`.
15
*/
16
function balanceOf(address account) external view returns (uint256);
17
18
/**
19
* @dev Moves `amount` tokens from the caller's account to `recipient`.
20
*
21
* Returns a boolean value indicating whether the operation succeeded.
22
*
23
* Emits a {Transfer} event.
24
*/
25
function transfer(address recipient, uint256 amount) external returns (bool);
26
27
/**
28
* @dev Returns the remaining number of tokens that `spender` will be
29
* allowed to spend on behalf of `owner` through {transferFrom}. This is
30
* zero by default.
31
*
32
* This value changes when {approve} or {transferFrom} are called.
33
*/
34
function allowance(address owner, address spender) external view returns (uint256);
35
36
/**
37
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
38
*
39
* Returns a boolean value indicating whether the operation succeeded.
40
*
41
* IMPORTANT: Beware that changing an allowance with this method brings the risk
42
* that someone may use both the old and the new allowance by unfortunate
43
* transaction ordering. One possible solution to mitigate this race
44
* condition is to first reduce the spender's allowance to 0 and set the
45
* desired value afterwards:
46
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
47
*
48
* Emits an {Approval} event.
49
*/
50
function approve(address spender, uint256 amount) external returns (bool);
51
52
/**
53
* @dev Moves `amount` tokens from `sender` to `recipient` using the
54
* allowance mechanism. `amount` is then deducted from the caller's
55
* allowance.
56
*
57
* Returns a boolean value indicating whether the operation succeeded.
58
*
59
* Emits a {Transfer} event.
60
*/
61
function transferFrom(
62
address sender,
63
address recipient,
64
uint256 amount
65
) external returns (bool);
66
67
/**
68
* @dev Emitted when `value` tokens are moved from one account (`from`) to
69
* another (`to`).
70
*
71
* Note that `value` may be zero.
72
*/
73
event Transfer(address indexed from, address indexed to, uint256 value);
74
75
/**
76
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
77
* a call to {approve}. `value` is the new allowance.
78
*/
79
event Approval(address indexed owner, address indexed spender, uint256 value);
80
}
81
Copied!
Last modified 10mo ago
Copy link