mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
added events to mintToTreasury()
This commit is contained in:
parent
2ebe34a051
commit
9d1c13cf96
|
@ -22,7 +22,6 @@ contract AToken is VersionedInitializable, IncentivizedERC20, IAToken {
|
||||||
using WadRayMath for uint256;
|
using WadRayMath for uint256;
|
||||||
using SafeERC20 for IERC20;
|
using SafeERC20 for IERC20;
|
||||||
|
|
||||||
|
|
||||||
bytes public constant EIP712_REVISION = bytes('1');
|
bytes public constant EIP712_REVISION = bytes('1');
|
||||||
bytes32 internal constant EIP712_DOMAIN = keccak256(
|
bytes32 internal constant EIP712_DOMAIN = keccak256(
|
||||||
'EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'
|
'EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'
|
||||||
|
@ -39,9 +38,9 @@ contract AToken is VersionedInitializable, IncentivizedERC20, IAToken {
|
||||||
|
|
||||||
/// @dev owner => next valid nonce to submit with permit()
|
/// @dev owner => next valid nonce to submit with permit()
|
||||||
mapping(address => uint256) public _nonces;
|
mapping(address => uint256) public _nonces;
|
||||||
|
|
||||||
bytes32 public DOMAIN_SEPARATOR;
|
bytes32 public DOMAIN_SEPARATOR;
|
||||||
|
|
||||||
modifier onlyLendingPool {
|
modifier onlyLendingPool {
|
||||||
require(msg.sender == address(POOL), Errors.CALLER_MUST_BE_LENDING_POOL);
|
require(msg.sender == address(POOL), Errors.CALLER_MUST_BE_LENDING_POOL);
|
||||||
_;
|
_;
|
||||||
|
@ -140,7 +139,11 @@ contract AToken is VersionedInitializable, IncentivizedERC20, IAToken {
|
||||||
}
|
}
|
||||||
|
|
||||||
function mintToTreasury(uint256 amount, uint256 index) external override onlyLendingPool {
|
function mintToTreasury(uint256 amount, uint256 index) external override onlyLendingPool {
|
||||||
_mint(RESERVE_TREASURY_ADDRESS, amount.div(index));
|
_mint(RESERVE_TREASURY_ADDRESS, amount.div(index));
|
||||||
|
|
||||||
|
//transfer event to track balances
|
||||||
|
emit Transfer(address(0), RESERVE_TREASURY_ADDRESS, amount);
|
||||||
|
emit Mint(RESERVE_TREASURY_ADDRESS, amount, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -216,6 +219,14 @@ contract AToken is VersionedInitializable, IncentivizedERC20, IAToken {
|
||||||
return currentSupplyScaled.rayMul(POOL.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS));
|
return currentSupplyScaled.rayMul(POOL.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Returns the scaled total supply of the variable debt token. Represents sum(borrows/index)
|
||||||
|
* @return the scaled total supply
|
||||||
|
**/
|
||||||
|
function scaledTotalSupply() public virtual override view returns (uint256) {
|
||||||
|
return super.totalSupply();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Used to validate transfers before actually executing them.
|
* @dev Used to validate transfers before actually executing them.
|
||||||
* @param user address of the user to check
|
* @param user address of the user to check
|
||||||
|
|
|
@ -62,7 +62,7 @@ contract VariableDebtToken is DebtTokenBase, IVariableDebtToken {
|
||||||
_mint(user, amount.rayDiv(index));
|
_mint(user, amount.rayDiv(index));
|
||||||
|
|
||||||
emit Transfer(address(0), user, amount);
|
emit Transfer(address(0), user, amount);
|
||||||
emit MintDebt(user, amount, index);
|
emit Mint(user, amount, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,7 +78,7 @@ contract VariableDebtToken is DebtTokenBase, IVariableDebtToken {
|
||||||
_burn(user, amount.rayDiv(index));
|
_burn(user, amount.rayDiv(index));
|
||||||
|
|
||||||
emit Transfer(user, address(0), amount);
|
emit Transfer(user, address(0), amount);
|
||||||
emit BurnDebt(user, amount, index);
|
emit Burn(user, amount, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,4 +104,15 @@ contract VariableDebtToken is DebtTokenBase, IVariableDebtToken {
|
||||||
function scaledTotalSupply() public virtual override view returns (uint256) {
|
function scaledTotalSupply() public virtual override view returns (uint256) {
|
||||||
return super.totalSupply();
|
return super.totalSupply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev returns the principal balance of the user and principal total supply.
|
||||||
|
* @param user the address of the user
|
||||||
|
* @return the principal balance of the user
|
||||||
|
* @return the principal total supply
|
||||||
|
**/
|
||||||
|
function getScaledUserBalanceAndSupply(address user) external override view returns (uint256, uint256){
|
||||||
|
return (super.balanceOf(user), super.totalSupply());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
pragma solidity ^0.6.8;
|
pragma solidity ^0.6.8;
|
||||||
|
|
||||||
import {IERC20} from '../../interfaces/IERC20.sol';
|
import {IERC20} from '../../interfaces/IERC20.sol';
|
||||||
|
import {IScaledBalanceToken} from './IScaledBalanceToken.sol';
|
||||||
|
|
||||||
interface IAToken is IERC20 {
|
interface IAToken is IERC20, IScaledBalanceToken {
|
||||||
/**
|
/**
|
||||||
* @dev emitted after aTokens are burned
|
* @dev emitted after aTokens are burned
|
||||||
* @param from the address performing the redeem
|
* @param from the address performing the redeem
|
||||||
|
@ -16,15 +17,6 @@ interface IAToken is IERC20 {
|
||||||
uint256 value,
|
uint256 value,
|
||||||
uint256 index
|
uint256 index
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev emitted after the mint action
|
|
||||||
* @param from the address performing the mint
|
|
||||||
* @param value the amount to be minted
|
|
||||||
* @param index the last index of the reserve
|
|
||||||
**/
|
|
||||||
event Mint(address indexed from, uint256 value, uint256 index);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev emitted during the transfer action
|
* @dev emitted during the transfer action
|
||||||
* @param from the address from which the tokens are being transferred
|
* @param from the address from which the tokens are being transferred
|
||||||
|
@ -38,7 +30,6 @@ interface IAToken is IERC20 {
|
||||||
uint256 value,
|
uint256 value,
|
||||||
uint256 index
|
uint256 index
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev burns the aTokens and sends the equivalent amount of underlying to the target.
|
* @dev burns the aTokens and sends the equivalent amount of underlying to the target.
|
||||||
* only lending pools can call this function
|
* only lending pools can call this function
|
||||||
|
@ -52,15 +43,6 @@ interface IAToken is IERC20 {
|
||||||
uint256 index
|
uint256 index
|
||||||
) external;
|
) external;
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev mints aTokens to user
|
|
||||||
* only lending pools can call this function
|
|
||||||
* @param user the address receiving the minted tokens
|
|
||||||
* @param amount the amount of tokens to mint
|
|
||||||
* @param index the liquidity index
|
|
||||||
*/
|
|
||||||
function mint(address user, uint256 amount, uint256 index) external;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev mints aTokens to the reserve treasury
|
* @dev mints aTokens to the reserve treasury
|
||||||
* @param amount the amount to mint
|
* @param amount the amount to mint
|
||||||
|
@ -81,28 +63,7 @@ interface IAToken is IERC20 {
|
||||||
uint256 value
|
uint256 value
|
||||||
) external;
|
) 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.
|
|
||||||
* @param user the address of the user
|
|
||||||
* @return the principal balance of the user
|
|
||||||
**/
|
|
||||||
function scaledBalanceOf(address user) external view returns (uint256);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev returns the principal balance of the user and principal total supply.
|
|
||||||
* @param user the address of the user
|
|
||||||
* @return the principal balance of the user
|
|
||||||
* @return the principal total supply
|
|
||||||
**/
|
|
||||||
function getScaledUserBalanceAndSupply(address user) external view returns (uint256, uint256);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev Used to validate transfers before actually executing them.
|
|
||||||
* @param user address of the user to check
|
|
||||||
* @param amount the amount to check
|
|
||||||
* @return true if the user can transfer amount, false otherwise
|
|
||||||
**/
|
|
||||||
function isTransferAllowed(address user, uint256 amount) external view returns (bool);
|
function isTransferAllowed(address user, uint256 amount) external view returns (bool);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
49
contracts/tokenization/interfaces/IScaledBalanceToken.sol
Normal file
49
contracts/tokenization/interfaces/IScaledBalanceToken.sol
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
|
||||||
|
// SPDX-License-Identifier: agpl-3.0
|
||||||
|
pragma solidity ^0.6.8;
|
||||||
|
|
||||||
|
interface IScaledBalanceToken {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev emitted after the mint action
|
||||||
|
* @param from the address performing the mint
|
||||||
|
* @param value the amount to be minted
|
||||||
|
* @param index the last index of the reserve
|
||||||
|
**/
|
||||||
|
event Mint(address indexed from, uint256 value, uint256 index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev mints aTokens to user
|
||||||
|
* only lending pools can call this function
|
||||||
|
* @param user the address receiving the minted tokens
|
||||||
|
* @param amount the amount of tokens to mint
|
||||||
|
* @param index the liquidity index
|
||||||
|
*/
|
||||||
|
function mint(
|
||||||
|
address user,
|
||||||
|
uint256 amount,
|
||||||
|
uint256 index
|
||||||
|
) 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.
|
||||||
|
* @param user the address of the user
|
||||||
|
* @return the principal balance of the user
|
||||||
|
**/
|
||||||
|
function scaledBalanceOf(address user) external view returns (uint256);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev returns the principal balance of the user and principal total supply.
|
||||||
|
* @param user the address of the user
|
||||||
|
* @return the principal balance of the user
|
||||||
|
* @return the principal total supply
|
||||||
|
**/
|
||||||
|
function getScaledUserBalanceAndSupply(address user) external view returns (uint256, uint256);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Returns the scaled total supply of the variable debt token. Represents sum(borrows/index)
|
||||||
|
* @return the scaled total supply
|
||||||
|
**/
|
||||||
|
function scaledTotalSupply() external view returns (uint256);
|
||||||
|
}
|
|
@ -1,63 +1,36 @@
|
||||||
// SPDX-License-Identifier: agpl-3.0
|
// SPDX-License-Identifier: agpl-3.0
|
||||||
pragma solidity ^0.6.8;
|
pragma solidity ^0.6.8;
|
||||||
|
|
||||||
|
import {IScaledBalanceToken} from './IScaledBalanceToken.sol';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title interface IVariableDebtToken
|
* @title interface IVariableDebtToken
|
||||||
* @author Aave
|
* @author Aave
|
||||||
* @notice defines the basic interface for a variable debt token.
|
* @notice defines the basic interface for a variable debt token.
|
||||||
* @dev does not inherit from IERC20 to save in contract size
|
|
||||||
**/
|
**/
|
||||||
interface IVariableDebtToken {
|
interface IVariableDebtToken is IScaledBalanceToken {
|
||||||
/**
|
|
||||||
* @dev emitted when new variable debt is minted
|
|
||||||
* @param user the user receiving the debt
|
|
||||||
* @param amount the amount of debt being minted
|
|
||||||
* @param index the index of the user
|
|
||||||
**/
|
|
||||||
event MintDebt(
|
|
||||||
address user,
|
|
||||||
uint256 amount,
|
|
||||||
uint256 index
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev emitted when variable debt is burnt
|
* @dev emitted when variable debt is burnt
|
||||||
* @param user the user which debt has been burned
|
* @param user the user which debt has been burned
|
||||||
* @param amount the amount of debt being burned
|
* @param amount the amount of debt being burned
|
||||||
* @param index the index of the user
|
* @param index the index of the user
|
||||||
**/
|
**/
|
||||||
event BurnDebt(
|
event Burn(
|
||||||
address user,
|
address indexed user,
|
||||||
uint256 amount,
|
uint256 amount,
|
||||||
uint256 index
|
uint256 index
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev mints new variable debt
|
|
||||||
* @param user the user receiving the debt
|
|
||||||
* @param amount the amount of debt being minted
|
|
||||||
* @param index the variable debt index of the reserve
|
|
||||||
**/
|
|
||||||
function mint(address user, uint256 amount, uint256 index) external;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev burns user variable debt
|
* @dev burns user variable debt
|
||||||
* @param user the user which debt is burnt
|
* @param user the user which debt is burnt
|
||||||
* @param amount the amount of debt being burned
|
|
||||||
* @param index the variable debt index of the reserve
|
* @param index the variable debt index of the reserve
|
||||||
**/
|
**/
|
||||||
function burn(address user, uint256 amount, uint256 index) external;
|
function burn(
|
||||||
|
address user,
|
||||||
/**
|
uint256 amount,
|
||||||
* @dev returns the scaled balance of the variable debt token
|
uint256 index
|
||||||
* @param user the user
|
) external;
|
||||||
**/
|
|
||||||
function scaledBalanceOf(address user) external view returns(uint256);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev Returns the scaled total supply of the variable debt token. Represents sum(borrows/index)
|
|
||||||
* @return the scaled total supply
|
|
||||||
**/
|
|
||||||
function scaledTotalSupply() external view returns(uint256);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user