mirror of
				https://github.com/Instadapp/aave-protocol-v2.git
				synced 2024-07-29 21:47:30 +00:00 
			
		
		
		
	Merge branch 'master' into feat/36-permit-atoken
This commit is contained in:
		
						commit
						c531b87703
					
				| 
						 | 
				
			
			@ -9,6 +9,7 @@ usePlugin('buidler-typechain');
 | 
			
		|||
usePlugin('solidity-coverage');
 | 
			
		||||
usePlugin('@nomiclabs/buidler-waffle');
 | 
			
		||||
usePlugin('@nomiclabs/buidler-etherscan');
 | 
			
		||||
//usePlugin('buidler-gas-reporter');
 | 
			
		||||
 | 
			
		||||
const DEFAULT_BLOCK_GAS_LIMIT = 10000000;
 | 
			
		||||
const DEFAULT_GAS_PRICE = 10;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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,12 +23,9 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
 | 
			
		|||
  using SafeERC20 for ERC20;
 | 
			
		||||
 | 
			
		||||
  uint256 public constant UINT_MAX_VALUE = uint256(-1);
 | 
			
		||||
 | 
			
		||||
  address public immutable UNDERLYING_ASSET_ADDRESS;
 | 
			
		||||
  LendingPool public immutable POOL;
 | 
			
		||||
 | 
			
		||||
  mapping(address => uint256) private _scaledRedirectedBalances;
 | 
			
		||||
 | 
			
		||||
  /// @dev owner => next valid nonce to submit with permit()
 | 
			
		||||
  mapping (address => uint256) public _nonces;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -94,7 +94,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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -79,11 +79,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'
 | 
			
		||||
| 
						 | 
				
			
			@ -108,9 +105,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