mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Merge branch 'master' into fix/34
This commit is contained in:
commit
d1ffac6380
|
@ -46,6 +46,8 @@ contract LendingPool is VersionedInitializable, ILendingPool {
|
|||
uint256 public constant REBALANCE_DOWN_RATE_DELTA = (1e27) / 5;
|
||||
uint256 public constant MAX_STABLE_RATE_BORROW_SIZE_PERCENT = 25;
|
||||
uint256 public constant FLASHLOAN_PREMIUM_TOTAL = 9;
|
||||
uint256 public constant UINT_MAX_VALUE = uint256(-1);
|
||||
uint256 public constant LENDINGPOOL_REVISION = 0x2;
|
||||
|
||||
ILendingPoolAddressesProvider public immutable ADDRESSES_PROVIDER;
|
||||
|
||||
|
@ -67,10 +69,6 @@ contract LendingPool is VersionedInitializable, ILendingPool {
|
|||
_;
|
||||
}
|
||||
|
||||
uint256 public constant UINT_MAX_VALUE = uint256(-1);
|
||||
|
||||
uint256 public constant LENDINGPOOL_REVISION = 0x2;
|
||||
|
||||
function getRevision() internal override pure returns (uint256) {
|
||||
return LENDINGPOOL_REVISION;
|
||||
}
|
||||
|
|
|
@ -43,11 +43,8 @@ library Errors {
|
|||
|
||||
// require error messages - aToken
|
||||
string public constant CALLER_MUST_BE_LENDING_POOL = '28'; // 'The caller of this function must be a lending pool'
|
||||
string public constant INTEREST_REDIRECTION_NOT_ALLOWED = '29'; // 'Caller is not allowed to redirect the interest of the user'
|
||||
string public constant CANNOT_GIVE_ALLOWANCE_TO_HIMSELF = '30'; // 'User cannot give allowance to himself'
|
||||
string public constant TRANSFER_AMOUNT_NOT_GT_0 = '31'; // 'Transferred amount needs to be greater than zero'
|
||||
string public constant INTEREST_ALREADY_REDIRECTED = '32'; // 'Interest is already redirected to the user'
|
||||
string public constant NO_VALID_BALANCE_FOR_REDIRECTION = '33'; // 'Interest stream can only be redirected if there is a valid balance'
|
||||
string public constant INVALID_ATOKEN_BALANCE = '52'; // balance on burning is invalid
|
||||
|
||||
// require error messages - ReserveLogic
|
||||
|
|
|
@ -23,16 +23,13 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
|
|||
using SafeERC20 for ERC20;
|
||||
|
||||
uint256 public constant UINT_MAX_VALUE = uint256(-1);
|
||||
|
||||
uint256 public constant ATOKEN_REVISION = 0x1;
|
||||
address public immutable UNDERLYING_ASSET_ADDRESS;
|
||||
address public immutable RESERVE_TREASURY_ADDRESS;
|
||||
LendingPool public immutable POOL;
|
||||
|
||||
mapping(address => uint256) private _scaledRedirectedBalances;
|
||||
|
||||
|
||||
uint256 public constant ATOKEN_REVISION = 0x1;
|
||||
|
||||
modifier onlyLendingPool {
|
||||
require(msg.sender == address(POOL), Errors.CALLER_MUST_BE_LENDING_POOL);
|
||||
_;
|
||||
|
|
|
@ -102,7 +102,7 @@ interface IAToken is IERC20 {
|
|||
* @dev transfer the amount of the underlying asset to the user
|
||||
* @param user address of the user
|
||||
* @param amount the amount to transfer
|
||||
* @return the redirected balance index
|
||||
* @return the amount transferred
|
||||
**/
|
||||
|
||||
function transferUnderlyingTo(address user, uint256 amount) external returns (uint256);
|
||||
|
|
|
@ -78,11 +78,8 @@ export enum ProtocolErrors {
|
|||
|
||||
// require error messages - aToken
|
||||
CALLER_MUST_BE_LENDING_POOL = '28', // 'The caller of this function must be a lending pool'
|
||||
INTEREST_REDIRECTION_NOT_ALLOWED = '29', // 'Caller is not allowed to redirect the interest of the user'
|
||||
CANNOT_GIVE_ALLOWANCE_TO_HIMSELF = '30', // 'User cannot give allowance to himself'
|
||||
TRANSFER_AMOUNT_NOT_GT_0 = '31', // 'Transferred amount needs to be greater than zero'
|
||||
INTEREST_ALREADY_REDIRECTED = '32', // 'Interest is already redirected to the user'
|
||||
NO_VALID_BALANCE_FOR_REDIRECTION = '33', // 'Interest stream can only be redirected if there is a valid balance'
|
||||
|
||||
// require error messages - ReserveLogic
|
||||
RESERVE_ALREADY_INITIALIZED = '34', // 'Reserve has already been initialized'
|
||||
|
@ -107,9 +104,6 @@ export enum ProtocolErrors {
|
|||
INVALID_FROM_BALANCE_AFTER_TRANSFER = 'Invalid from balance after transfer',
|
||||
INVALID_TO_BALANCE_AFTER_TRANSFER = 'Invalid from balance after transfer',
|
||||
INVALID_OWNER_REVERT_MSG = 'Ownable: caller is not the owner',
|
||||
INVALID_REDIRECTED_BALANCE_BEFORE_TRANSFER = 'Invalid redirected balance before transfer',
|
||||
INVALID_REDIRECTED_BALANCE_AFTER_TRANSFER = 'Invalid redirected balance after transfer',
|
||||
INVALID_REDIRECTION_ADDRESS = 'Invalid redirection address',
|
||||
INVALID_HF = 'Invalid health factor',
|
||||
TRANSFER_AMOUNT_EXCEEDS_BALANCE = 'ERC20: transfer amount exceeds balance',
|
||||
SAFEERC20_LOWLEVEL_CALL = 'SafeERC20: low-level call failed',
|
||||
|
|
|
@ -14,11 +14,7 @@ makeSuite('AToken: Transfer', (testEnv: TestEnv) => {
|
|||
const {
|
||||
INVALID_FROM_BALANCE_AFTER_TRANSFER,
|
||||
INVALID_TO_BALANCE_AFTER_TRANSFER,
|
||||
INVALID_REDIRECTED_BALANCE_BEFORE_TRANSFER,
|
||||
INVALID_REDIRECTED_BALANCE_AFTER_TRANSFER,
|
||||
INVALID_REDIRECTION_ADDRESS,
|
||||
// ZERO_COLLATERAL,
|
||||
TRANSFER_AMOUNT_NOT_GT_0,
|
||||
COLLATERAL_BALANCE_IS_0,
|
||||
TRANSFER_NOT_ALLOWED,
|
||||
} = ProtocolErrors;
|
||||
|
|
|
@ -933,17 +933,6 @@ const calcExpectedATokenBalance = (
|
|||
return scaledBalanceBeforeAction.rayMul(index);
|
||||
};
|
||||
|
||||
const calcExpectedRedirectedBalance = (
|
||||
expectedUserDataAfterAction: UserReserveData,
|
||||
index: BigNumber,
|
||||
redirectedBalanceBefore: BigNumber,
|
||||
amountToAdd: BigNumber,
|
||||
amountToSubstract: BigNumber
|
||||
): BigNumber => {
|
||||
return expectedUserDataAfterAction.interestRedirectionAddress !== ZERO_ADDRESS
|
||||
? redirectedBalanceBefore.plus(amountToAdd.rayDiv(index)).minus(amountToSubstract.rayDiv(index))
|
||||
: new BigNumber('0');
|
||||
};
|
||||
const calcExpectedAverageStableBorrowRate = (
|
||||
avgStableRateBefore: BigNumber,
|
||||
totalBorrowsStableBefore: BigNumber,
|
||||
|
|
Loading…
Reference in New Issue
Block a user