mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Reorg errors library, sorted by error number, added prefix to each constant and a prefix glossary.
This commit is contained in:
parent
20da932c11
commit
57ffc9c613
contracts
configuration
lendingpool
libraries
tokenization
helpers
test
addresses-provider-registry.spec.tsatoken-modifiers.spec.tsatoken-transfer.spec.tscollateral-swap.spec.tsconfigurator.spec.tsflash-liquidation-with-collateral.spec.tsflashloan.spec.tsliquidation-atoken.spec.tspausable-functions.spec.tsrepay-with-collateral.spec.tsstable-token.spec.tsupgradeability.spec.tsvariable-debt-token.spec.ts
|
@ -64,7 +64,7 @@ contract LendingPoolAddressesProviderRegistry is Ownable, ILendingPoolAddressesP
|
|||
* @param provider the pool address to be unregistered
|
||||
**/
|
||||
function unregisterAddressesProvider(address provider) external override onlyOwner {
|
||||
require(_addressesProviders[provider] > 0, Errors.PROVIDER_NOT_REGISTERED);
|
||||
require(_addressesProviders[provider] > 0, Errors.LPAPR_PROVIDER_NOT_REGISTERED);
|
||||
_addressesProviders[provider] = 0;
|
||||
emit AddressesProviderUnregistered(provider);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
function _onlyLendingPoolConfigurator() internal view {
|
||||
require(
|
||||
_addressesProvider.getLendingPoolConfigurator() == msg.sender,
|
||||
Errors.CALLER_NOT_LENDING_POOL_CONFIGURATOR
|
||||
Errors.LP_CALLER_NOT_LENDING_POOL_CONFIGURATOR
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
* - The contract must not be paused.
|
||||
*/
|
||||
function _whenNotPaused() internal view {
|
||||
require(!_paused, Errors.IS_PAUSED);
|
||||
require(!_paused, Errors.P_IS_PAUSED);
|
||||
}
|
||||
|
||||
function getRevision() internal override pure returns (uint256) {
|
||||
|
@ -226,7 +226,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
_borrowAllowance[debtToken][onBehalfOf][msg
|
||||
.sender] = _borrowAllowance[debtToken][onBehalfOf][msg.sender].sub(
|
||||
amount,
|
||||
Errors.BORROW_ALLOWANCE_ARE_NOT_ENOUGH
|
||||
Errors.LP_BORROW_ALLOWANCE_ARE_NOT_ENOUGH
|
||||
);
|
||||
}
|
||||
_executeBorrow(
|
||||
|
@ -400,7 +400,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
usageRatio >= REBALANCE_UP_USAGE_RATIO_THRESHOLD &&
|
||||
currentLiquidityRate <=
|
||||
maxVariableBorrowRate.percentMul(REBALANCE_UP_LIQUIDITY_RATE_THRESHOLD),
|
||||
Errors.INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET
|
||||
Errors.LP_INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET
|
||||
);
|
||||
|
||||
reserve.updateState();
|
||||
|
@ -475,7 +475,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
receiveAToken
|
||||
)
|
||||
);
|
||||
require(success, Errors.LIQUIDATION_CALL_FAILED);
|
||||
require(success, Errors.LP_LIQUIDATION_CALL_FAILED);
|
||||
|
||||
(uint256 returnCode, string memory returnMessage) = abi.decode(result, (uint256, string));
|
||||
|
||||
|
@ -506,7 +506,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
bytes calldata params
|
||||
) external override {
|
||||
_whenNotPaused();
|
||||
require(!_flashLiquidationLocked, Errors.REENTRANCY_NOT_ALLOWED);
|
||||
require(!_flashLiquidationLocked, Errors.LP_REENTRANCY_NOT_ALLOWED);
|
||||
_flashLiquidationLocked = true;
|
||||
|
||||
address collateralManager = _addressesProvider.getLendingPoolCollateralManager();
|
||||
|
@ -523,7 +523,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
params
|
||||
)
|
||||
);
|
||||
require(success, Errors.FAILED_REPAY_WITH_COLLATERAL);
|
||||
require(success, Errors.LP_FAILED_REPAY_WITH_COLLATERAL);
|
||||
|
||||
(uint256 returnCode, string memory returnMessage) = abi.decode(result, (uint256, string));
|
||||
|
||||
|
@ -581,7 +581,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
//execute action of the receiver
|
||||
require(
|
||||
vars.receiver.executeOperation(asset, amount, vars.premium, params),
|
||||
Errors.INVALID_FLASH_LOAN_EXECUTOR_RETURN
|
||||
Errors.LP_INVALID_FLASH_LOAN_EXECUTOR_RETURN
|
||||
);
|
||||
|
||||
vars.amountPlusPremium = amount.add(vars.premium);
|
||||
|
@ -641,7 +641,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
params
|
||||
)
|
||||
);
|
||||
require(success, Errors.FAILED_COLLATERAL_SWAP);
|
||||
require(success, Errors.LP_FAILED_COLLATERAL_SWAP);
|
||||
|
||||
(uint256 returnCode, string memory returnMessage) = abi.decode(result, (uint256, string));
|
||||
|
||||
|
@ -958,7 +958,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
* @dev adds a reserve to the array of the _reserves address
|
||||
**/
|
||||
function _addReserveToList(address asset) internal {
|
||||
require(_reservesCount < MAX_NUMBER_RESERVES, Errors.NO_MORE_RESERVES_ALLOWED);
|
||||
require(_reservesCount < MAX_NUMBER_RESERVES, Errors.LP_NO_MORE_RESERVES_ALLOWED);
|
||||
|
||||
bool reserveAlreadyAdded = _reserves[asset].id != 0 || _reservesList[0] == asset;
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ contract LendingPoolCollateralManager is VersionedInitializable, LendingPoolStor
|
|||
if (currentAvailableCollateral < vars.maxCollateralToLiquidate) {
|
||||
return (
|
||||
uint256(Errors.CollateralManagerErrors.NOT_ENOUGH_LIQUIDITY),
|
||||
Errors.NOT_ENOUGH_LIQUIDITY_TO_LIQUIDATE
|
||||
Errors.LPCM_NOT_ENOUGH_LIQUIDITY_TO_LIQUIDATE
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ contract LendingPoolCollateralManager is VersionedInitializable, LendingPoolStor
|
|||
receiveAToken
|
||||
);
|
||||
|
||||
return (uint256(Errors.CollateralManagerErrors.NO_ERROR), Errors.NO_ERRORS);
|
||||
return (uint256(Errors.CollateralManagerErrors.NO_ERROR), Errors.LPCM_NO_ERRORS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -450,7 +450,7 @@ contract LendingPoolCollateralManager is VersionedInitializable, LendingPoolStor
|
|||
vars.maxCollateralToLiquidate
|
||||
);
|
||||
|
||||
return (uint256(Errors.CollateralManagerErrors.NO_ERROR), Errors.NO_ERRORS);
|
||||
return (uint256(Errors.CollateralManagerErrors.NO_ERROR), Errors.LPCM_NO_ERRORS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -544,11 +544,11 @@ contract LendingPoolCollateralManager is VersionedInitializable, LendingPoolStor
|
|||
if (vars.healthFactor < GenericLogic.HEALTH_FACTOR_LIQUIDATION_THRESHOLD) {
|
||||
return (
|
||||
uint256(Errors.CollateralManagerErrors.HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD),
|
||||
Errors.HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD
|
||||
Errors.VL_HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD
|
||||
);
|
||||
}
|
||||
|
||||
return (uint256(Errors.CollateralManagerErrors.NO_ERROR), Errors.NO_ERRORS);
|
||||
return (uint256(Errors.CollateralManagerErrors.NO_ERROR), Errors.LPCM_NO_ERRORS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -184,7 +184,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
|||
* @dev only the lending pool manager can call functions affected by this modifier
|
||||
**/
|
||||
modifier onlyAaveAdmin {
|
||||
require(addressesProvider.getAaveAdmin() == msg.sender, Errors.CALLER_NOT_AAVE_ADMIN);
|
||||
require(addressesProvider.getAaveAdmin() == msg.sender, Errors.LPC_CALLER_NOT_AAVE_ADMIN);
|
||||
_;
|
||||
}
|
||||
|
||||
|
@ -424,7 +424,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
|||
) = pool.getReserveData(asset);
|
||||
require(
|
||||
availableLiquidity == 0 && totalStableDebt == 0 && totalVariableDebt == 0,
|
||||
Errors.RESERVE_LIQUIDITY_NOT_0
|
||||
Errors.LPC_RESERVE_LIQUIDITY_NOT_0
|
||||
);
|
||||
|
||||
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
||||
|
|
|
@ -5,83 +5,76 @@ pragma solidity ^0.6.8;
|
|||
* @title Errors library
|
||||
* @author Aave
|
||||
* @notice Implements error messages.
|
||||
* @dev Error messages prefix glossary:
|
||||
* - VL = ValidationLogic
|
||||
* - MATH = Math libraries
|
||||
* - AT = aToken or DebtTokens
|
||||
* - LP = LendingPool
|
||||
* - LPAPR = LendingPoolAddressesProviderRegistry
|
||||
* - LPC = LendingPoolConfiguration
|
||||
* - RL = ReserveLogic
|
||||
* - LPCM = LendingPoolCollateralManager
|
||||
* - P = Pausable
|
||||
*/
|
||||
library Errors {
|
||||
// require error messages - ValidationLogic
|
||||
string public constant AMOUNT_NOT_GREATER_THAN_0 = '1'; // 'Amount must be greater than 0'
|
||||
string public constant NO_ACTIVE_RESERVE = '2'; // 'Action requires an active reserve'
|
||||
string public constant NO_UNFREEZED_RESERVE = '3'; // 'Action requires an unfreezed reserve'
|
||||
string public constant CURRENT_AVAILABLE_LIQUIDITY_NOT_ENOUGH = '4'; // 'The current liquidity is not enough'
|
||||
string public constant NOT_ENOUGH_AVAILABLE_USER_BALANCE = '5'; // 'User cannot withdraw more than the available balance'
|
||||
string public constant TRANSFER_NOT_ALLOWED = '6'; // 'Transfer cannot be allowed.'
|
||||
string public constant BORROWING_NOT_ENABLED = '7'; // 'Borrowing is not enabled'
|
||||
string public constant INVALID_INTEREST_RATE_MODE_SELECTED = '8'; // 'Invalid interest rate mode selected'
|
||||
string public constant COLLATERAL_BALANCE_IS_0 = '9'; // 'The collateral balance is 0'
|
||||
string public constant HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD = '10'; // 'Health factor is lesser than the liquidation threshold'
|
||||
string public constant COLLATERAL_CANNOT_COVER_NEW_BORROW = '11'; // 'There is not enough collateral to cover a new borrow'
|
||||
string public constant STABLE_BORROWING_NOT_ENABLED = '12'; // stable borrowing not enabled
|
||||
string public constant CALLATERAL_SAME_AS_BORROWING_CURRENCY = '13'; // collateral is (mostly) the same currency that is being borrowed
|
||||
string public constant AMOUNT_BIGGER_THAN_MAX_LOAN_SIZE_STABLE = '14'; // 'The requested amount is greater than the max loan size in stable rate mode
|
||||
string public constant NO_DEBT_OF_SELECTED_TYPE = '15'; // 'for repayment of stable debt, the user needs to have stable debt, otherwise, he needs to have variable debt'
|
||||
string public constant NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF = '16'; // 'To repay on behalf of an user an explicit amount to repay is needed'
|
||||
string public constant NO_STABLE_RATE_LOAN_IN_RESERVE = '17'; // 'User does not have a stable rate loan in progress on this reserve'
|
||||
string public constant NO_VARIABLE_RATE_LOAN_IN_RESERVE = '18'; // 'User does not have a variable rate loan in progress on this reserve'
|
||||
string public constant UNDERLYING_BALANCE_NOT_GREATER_THAN_0 = '19'; // 'The underlying balance needs to be greater than 0'
|
||||
string public constant DEPOSIT_ALREADY_IN_USE = '20'; // 'User deposit is already being used as collateral'
|
||||
|
||||
// require error messages - LendingPool
|
||||
string public constant NOT_ENOUGH_STABLE_BORROW_BALANCE = '21'; // 'User does not have any stable rate loan for this reserve'
|
||||
string public constant INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET = '22'; // 'Interest rate rebalance conditions were not met'
|
||||
string public constant LIQUIDATION_CALL_FAILED = '23'; // 'Liquidation call failed'
|
||||
string public constant NOT_ENOUGH_LIQUIDITY_TO_BORROW = '24'; // 'There is not enough liquidity available to borrow'
|
||||
string public constant REQUESTED_AMOUNT_TOO_SMALL = '25'; // 'The requested amount is too small for a FlashLoan.'
|
||||
string public constant INCONSISTENT_PROTOCOL_ACTUAL_BALANCE = '26'; // 'The actual balance of the protocol is inconsistent'
|
||||
string public constant CALLER_NOT_LENDING_POOL_CONFIGURATOR = '27'; // 'The actual balance of the protocol is inconsistent'
|
||||
string public constant INVALID_FLASHLOAN_MODE = '43'; //Invalid flashloan mode selected
|
||||
string public constant BORROW_ALLOWANCE_ARE_NOT_ENOUGH = '54'; // User borrows on behalf, but allowance are too small
|
||||
string public constant REENTRANCY_NOT_ALLOWED = '57';
|
||||
string public constant FAILED_REPAY_WITH_COLLATERAL = '53';
|
||||
string public constant FAILED_COLLATERAL_SWAP = '55';
|
||||
string public constant INVALID_EQUAL_ASSETS_TO_SWAP = '56';
|
||||
string public constant NO_MORE_RESERVES_ALLOWED = '59';
|
||||
string public constant INVALID_FLASH_LOAN_EXECUTOR_RETURN = '60';
|
||||
|
||||
// require error messages - aToken - DebtTokens
|
||||
string public constant CALLER_MUST_BE_LENDING_POOL = '28'; // 'The caller of this function must be a lending pool'
|
||||
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 INVALID_MINT_AMOUNT = '53'; //invalid amount to mint
|
||||
string public constant INVALID_BURN_AMOUNT = '54'; //invalid amount to burn
|
||||
|
||||
// require error messages - ReserveLogic
|
||||
string public constant RESERVE_ALREADY_INITIALIZED = '34'; // 'Reserve has already been initialized'
|
||||
string public constant LIQUIDITY_INDEX_OVERFLOW = '47'; // Liquidity index overflows uint128
|
||||
string public constant VARIABLE_BORROW_INDEX_OVERFLOW = '48'; // Variable borrow index overflows uint128
|
||||
string public constant LIQUIDITY_RATE_OVERFLOW = '49'; // Liquidity rate overflows uint128
|
||||
string public constant VARIABLE_BORROW_RATE_OVERFLOW = '50'; // Variable borrow rate overflows uint128
|
||||
string public constant STABLE_BORROW_RATE_OVERFLOW = '51'; // Stable borrow rate overflows uint128
|
||||
|
||||
//require error messages - LendingPoolConfiguration
|
||||
string public constant CALLER_NOT_AAVE_ADMIN = '35'; // 'The caller must be the aave admin'
|
||||
string public constant RESERVE_LIQUIDITY_NOT_0 = '36'; // 'The liquidity of the reserve needs to be 0'
|
||||
|
||||
//require error messages - LendingPoolAddressesProviderRegistry
|
||||
string public constant PROVIDER_NOT_REGISTERED = '37'; // 'Provider is not registered'
|
||||
|
||||
//return error messages - LendingPoolCollateralManager
|
||||
string public constant HEALTH_FACTOR_NOT_BELOW_THRESHOLD = '38'; // 'Health factor is not below the threshold'
|
||||
string public constant COLLATERAL_CANNOT_BE_LIQUIDATED = '39'; // 'The collateral chosen cannot be liquidated'
|
||||
string public constant SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER = '40'; // 'User did not borrow the specified currency'
|
||||
string public constant NOT_ENOUGH_LIQUIDITY_TO_LIQUIDATE = '41'; // "There isn't enough liquidity available to liquidate"
|
||||
string public constant NO_ERRORS = '42'; // 'No errors'
|
||||
|
||||
//require error messages - Math libraries
|
||||
string public constant MULTIPLICATION_OVERFLOW = '44';
|
||||
string public constant ADDITION_OVERFLOW = '45';
|
||||
string public constant DIVISION_BY_ZERO = '46';
|
||||
|
||||
// pausable error message
|
||||
string public constant IS_PAUSED = '58'; // 'Pool is paused'
|
||||
string public constant VL_AMOUNT_NOT_GREATER_THAN_0 = '1'; // 'Amount must be greater than 0'
|
||||
string public constant VL_NO_ACTIVE_RESERVE = '2'; // 'Action requires an active reserve'
|
||||
string public constant VL_NO_UNFREEZED_RESERVE = '3'; // 'Action requires an unfreezed reserve'
|
||||
string public constant VL_CURRENT_AVAILABLE_LIQUIDITY_NOT_ENOUGH = '4'; // 'The current liquidity is not enough'
|
||||
string public constant VL_NOT_ENOUGH_AVAILABLE_USER_BALANCE = '5'; // 'User cannot withdraw more than the available balance'
|
||||
string public constant VL_TRANSFER_NOT_ALLOWED = '6'; // 'Transfer cannot be allowed.'
|
||||
string public constant VL_BORROWING_NOT_ENABLED = '7'; // 'Borrowing is not enabled'
|
||||
string public constant VL_INVALID_INTEREST_RATE_MODE_SELECTED = '8'; // 'Invalid interest rate mode selected'
|
||||
string public constant VL_COLLATERAL_BALANCE_IS_0 = '9'; // 'The collateral balance is 0'
|
||||
string public constant VL_HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD = '10'; // 'Health factor is lesser than the liquidation threshold'
|
||||
string public constant VL_COLLATERAL_CANNOT_COVER_NEW_BORROW = '11'; // 'There is not enough collateral to cover a new borrow'
|
||||
string public constant VL_STABLE_BORROWING_NOT_ENABLED = '12'; // stable borrowing not enabled
|
||||
string public constant VL_CALLATERAL_SAME_AS_BORROWING_CURRENCY = '13'; // collateral is (mostly) the same currency that is being borrowed
|
||||
string public constant VL_AMOUNT_BIGGER_THAN_MAX_LOAN_SIZE_STABLE = '14'; // 'The requested amount is greater than the max loan size in stable rate mode
|
||||
string public constant VL_NO_DEBT_OF_SELECTED_TYPE = '15'; // 'for repayment of stable debt, the user needs to have stable debt, otherwise, he needs to have variable debt'
|
||||
string public constant VL_NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF = '16'; // 'To repay on behalf of an user an explicit amount to repay is needed'
|
||||
string public constant VL_NO_STABLE_RATE_LOAN_IN_RESERVE = '17'; // 'User does not have a stable rate loan in progress on this reserve'
|
||||
string public constant VL_NO_VARIABLE_RATE_LOAN_IN_RESERVE = '18'; // 'User does not have a variable rate loan in progress on this reserve'
|
||||
string public constant VL_UNDERLYING_BALANCE_NOT_GREATER_THAN_0 = '19'; // 'The underlying balance needs to be greater than 0'
|
||||
string public constant VL_DEPOSIT_ALREADY_IN_USE = '20'; // 'User deposit is already being used as collateral'
|
||||
string public constant LP_NOT_ENOUGH_STABLE_BORROW_BALANCE = '21'; // 'User does not have any stable rate loan for this reserve'
|
||||
string public constant LP_INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET = '22'; // 'Interest rate rebalance conditions were not met'
|
||||
string public constant LP_LIQUIDATION_CALL_FAILED = '23'; // 'Liquidation call failed'
|
||||
string public constant LP_NOT_ENOUGH_LIQUIDITY_TO_BORROW = '24'; // 'There is not enough liquidity available to borrow'
|
||||
string public constant LP_REQUESTED_AMOUNT_TOO_SMALL = '25'; // 'The requested amount is too small for a FlashLoan.'
|
||||
string public constant LP_INCONSISTENT_PROTOCOL_ACTUAL_BALANCE = '26'; // 'The actual balance of the protocol is inconsistent'
|
||||
string public constant LP_CALLER_NOT_LENDING_POOL_CONFIGURATOR = '27'; // 'The actual balance of the protocol is inconsistent'
|
||||
string public constant AT_CALLER_MUST_BE_LENDING_POOL = '28'; // 'The caller of this function must be a lending pool'
|
||||
string public constant AT_CANNOT_GIVE_ALLOWANCE_TO_HIMSELF = '30'; // 'User cannot give allowance to himself'
|
||||
string public constant AT_TRANSFER_AMOUNT_NOT_GT_0 = '31'; // 'Transferred amount needs to be greater than zero'
|
||||
string public constant RL_RESERVE_ALREADY_INITIALIZED = '34'; // 'Reserve has already been initialized'
|
||||
string public constant LPC_CALLER_NOT_AAVE_ADMIN = '35'; // 'The caller must be the aave admin'
|
||||
string public constant LPC_RESERVE_LIQUIDITY_NOT_0 = '36'; // 'The liquidity of the reserve needs to be 0'
|
||||
string public constant LPAPR_PROVIDER_NOT_REGISTERED = '37'; // 'Provider is not registered'
|
||||
string public constant LPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD = '38'; // 'Health factor is not below the threshold'
|
||||
string public constant LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED = '39'; // 'The collateral chosen cannot be liquidated'
|
||||
string public constant LPCM_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER = '40'; // 'User did not borrow the specified currency'
|
||||
string public constant LPCM_NOT_ENOUGH_LIQUIDITY_TO_LIQUIDATE = '41'; // "There isn't enough liquidity available to liquidate"
|
||||
string public constant LPCM_NO_ERRORS = '42'; // 'No errors'
|
||||
string public constant LP_INVALID_FLASHLOAN_MODE = '43'; //Invalid flashloan mode selected
|
||||
string public constant MATH_MULTIPLICATION_OVERFLOW = '44';
|
||||
string public constant MATH_ADDITION_OVERFLOW = '45';
|
||||
string public constant MATH_DIVISION_BY_ZERO = '46';
|
||||
string public constant RL_LIQUIDITY_INDEX_OVERFLOW = '47'; // Liquidity index overflows uint128
|
||||
string public constant RL_VARIABLE_BORROW_INDEX_OVERFLOW = '48'; // Variable borrow index overflows uint128
|
||||
string public constant RL_LIQUIDITY_RATE_OVERFLOW = '49'; // Liquidity rate overflows uint128
|
||||
string public constant RL_VARIABLE_BORROW_RATE_OVERFLOW = '50'; // Variable borrow rate overflows uint128
|
||||
string public constant RL_STABLE_BORROW_RATE_OVERFLOW = '51'; // Stable borrow rate overflows uint128
|
||||
string public constant AT_INVALID_MINT_AMOUNT = '53'; //invalid amount to mint
|
||||
string public constant LP_FAILED_REPAY_WITH_COLLATERAL = '53';
|
||||
string public constant AT_INVALID_BURN_AMOUNT = '54'; //invalid amount to burn
|
||||
string public constant LP_BORROW_ALLOWANCE_ARE_NOT_ENOUGH = '54'; // User borrows on behalf, but allowance are too small
|
||||
string public constant LP_FAILED_COLLATERAL_SWAP = '55';
|
||||
string public constant LP_INVALID_EQUAL_ASSETS_TO_SWAP = '56';
|
||||
string public constant LP_REENTRANCY_NOT_ALLOWED = '57';
|
||||
string public constant P_IS_PAUSED = '58'; // 'Pool is paused'
|
||||
string public constant LP_NO_MORE_RESERVES_ALLOWED = '59';
|
||||
string public constant LP_INVALID_FLASH_LOAN_EXECUTOR_RETURN = '60';
|
||||
enum CollateralManagerErrors {
|
||||
NO_ERROR,
|
||||
NO_COLLATERAL_AVAILABLE,
|
||||
|
|
|
@ -134,7 +134,7 @@ library ReserveLogic {
|
|||
require(
|
||||
ReserveLogic.InterestRateMode.STABLE == ReserveLogic.InterestRateMode(interestRateMode) ||
|
||||
ReserveLogic.InterestRateMode.VARIABLE == ReserveLogic.InterestRateMode(interestRateMode),
|
||||
Errors.INVALID_INTEREST_RATE_MODE_SELECTED
|
||||
Errors.VL_INVALID_INTEREST_RATE_MODE_SELECTED
|
||||
);
|
||||
return
|
||||
ReserveLogic.InterestRateMode.STABLE == ReserveLogic.InterestRateMode(interestRateMode)
|
||||
|
@ -185,7 +185,7 @@ library ReserveLogic {
|
|||
uint256 result = amountToLiquidityRatio.add(WadRayMath.ray());
|
||||
|
||||
result = result.rayMul(reserve.liquidityIndex);
|
||||
require(result < (1 << 128), Errors.LIQUIDITY_INDEX_OVERFLOW);
|
||||
require(result < (1 << 128), Errors.RL_LIQUIDITY_INDEX_OVERFLOW);
|
||||
|
||||
reserve.liquidityIndex = uint128(result);
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ library ReserveLogic {
|
|||
address variableDebtTokenAddress,
|
||||
address interestRateStrategyAddress
|
||||
) external {
|
||||
require(reserve.aTokenAddress == address(0), Errors.RESERVE_ALREADY_INITIALIZED);
|
||||
require(reserve.aTokenAddress == address(0), Errors.RL_RESERVE_ALREADY_INITIALIZED);
|
||||
if (reserve.liquidityIndex == 0) {
|
||||
//if the reserve has not been initialized yet
|
||||
reserve.liquidityIndex = uint128(WadRayMath.ray());
|
||||
|
@ -385,7 +385,7 @@ library ReserveLogic {
|
|||
timestamp
|
||||
);
|
||||
newLiquidityIndex = cumulatedLiquidityInterest.rayMul(liquidityIndex);
|
||||
require(newLiquidityIndex < (1 << 128), Errors.LIQUIDITY_INDEX_OVERFLOW);
|
||||
require(newLiquidityIndex < (1 << 128), Errors.RL_LIQUIDITY_INDEX_OVERFLOW);
|
||||
|
||||
reserve.liquidityIndex = uint128(newLiquidityIndex);
|
||||
|
||||
|
@ -397,7 +397,7 @@ library ReserveLogic {
|
|||
timestamp
|
||||
);
|
||||
newVariableBorrowIndex = cumulatedVariableBorrowInterest.rayMul(variableBorrowIndex);
|
||||
require(newVariableBorrowIndex < (1 << 128), Errors.VARIABLE_BORROW_INDEX_OVERFLOW);
|
||||
require(newVariableBorrowIndex < (1 << 128), Errors.RL_VARIABLE_BORROW_INDEX_OVERFLOW);
|
||||
reserve.variableBorrowIndex = uint128(newVariableBorrowIndex);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,9 +37,9 @@ library ValidationLogic {
|
|||
function validateDeposit(ReserveLogic.ReserveData storage reserve, uint256 amount) external view {
|
||||
(bool isActive, bool isFreezed, , ) = reserve.configuration.getFlags();
|
||||
|
||||
require(amount > 0, Errors.AMOUNT_NOT_GREATER_THAN_0);
|
||||
require(isActive, Errors.NO_ACTIVE_RESERVE);
|
||||
require(!isFreezed, Errors.NO_UNFREEZED_RESERVE);
|
||||
require(amount > 0, Errors.VL_AMOUNT_NOT_GREATER_THAN_0);
|
||||
require(isActive, Errors.VL_NO_ACTIVE_RESERVE);
|
||||
require(!isFreezed, Errors.VL_NO_UNFREEZED_RESERVE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,9 +58,9 @@ library ValidationLogic {
|
|||
uint256 reservesCount,
|
||||
address oracle
|
||||
) external view {
|
||||
require(amount > 0, Errors.AMOUNT_NOT_GREATER_THAN_0);
|
||||
require(amount > 0, Errors.VL_AMOUNT_NOT_GREATER_THAN_0);
|
||||
|
||||
require(amount <= userBalance, Errors.NOT_ENOUGH_AVAILABLE_USER_BALANCE);
|
||||
require(amount <= userBalance, Errors.VL_NOT_ENOUGH_AVAILABLE_USER_BALANCE);
|
||||
|
||||
require(
|
||||
GenericLogic.balanceDecreaseAllowed(
|
||||
|
@ -73,7 +73,7 @@ library ValidationLogic {
|
|||
reservesCount,
|
||||
oracle
|
||||
),
|
||||
Errors.TRANSFER_NOT_ALLOWED
|
||||
Errors.VL_TRANSFER_NOT_ALLOWED
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -134,16 +134,16 @@ library ValidationLogic {
|
|||
vars.stableRateBorrowingEnabled
|
||||
) = reserve.configuration.getFlags();
|
||||
|
||||
require(vars.isActive, Errors.NO_ACTIVE_RESERVE);
|
||||
require(!vars.isFreezed, Errors.NO_UNFREEZED_RESERVE);
|
||||
require(vars.isActive, Errors.VL_NO_ACTIVE_RESERVE);
|
||||
require(!vars.isFreezed, Errors.VL_NO_UNFREEZED_RESERVE);
|
||||
|
||||
require(vars.borrowingEnabled, Errors.BORROWING_NOT_ENABLED);
|
||||
require(vars.borrowingEnabled, Errors.VL_BORROWING_NOT_ENABLED);
|
||||
|
||||
//validate interest rate mode
|
||||
require(
|
||||
uint256(ReserveLogic.InterestRateMode.VARIABLE) == interestRateMode ||
|
||||
uint256(ReserveLogic.InterestRateMode.STABLE) == interestRateMode,
|
||||
Errors.INVALID_INTEREST_RATE_MODE_SELECTED
|
||||
Errors.VL_INVALID_INTEREST_RATE_MODE_SELECTED
|
||||
);
|
||||
|
||||
(
|
||||
|
@ -161,11 +161,11 @@ library ValidationLogic {
|
|||
oracle
|
||||
);
|
||||
|
||||
require(vars.userCollateralBalanceETH > 0, Errors.COLLATERAL_BALANCE_IS_0);
|
||||
require(vars.userCollateralBalanceETH > 0, Errors.VL_COLLATERAL_BALANCE_IS_0);
|
||||
|
||||
require(
|
||||
vars.healthFactor > GenericLogic.HEALTH_FACTOR_LIQUIDATION_THRESHOLD,
|
||||
Errors.HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD
|
||||
Errors.VL_HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD
|
||||
);
|
||||
|
||||
//add the current already borrowed amount to the amount requested to calculate the total collateral needed.
|
||||
|
@ -175,7 +175,7 @@ library ValidationLogic {
|
|||
|
||||
require(
|
||||
vars.amountOfCollateralNeededETH <= vars.userCollateralBalanceETH,
|
||||
Errors.COLLATERAL_CANNOT_COVER_NEW_BORROW
|
||||
Errors.VL_COLLATERAL_CANNOT_COVER_NEW_BORROW
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -190,20 +190,20 @@ library ValidationLogic {
|
|||
if (vars.rateMode == ReserveLogic.InterestRateMode.STABLE) {
|
||||
//check if the borrow mode is stable and if stable rate borrowing is enabled on this reserve
|
||||
|
||||
require(vars.stableRateBorrowingEnabled, Errors.STABLE_BORROWING_NOT_ENABLED);
|
||||
require(vars.stableRateBorrowingEnabled, Errors.VL_STABLE_BORROWING_NOT_ENABLED);
|
||||
|
||||
require(
|
||||
!userConfig.isUsingAsCollateral(reserve.id) ||
|
||||
reserve.configuration.getLtv() == 0 ||
|
||||
amount > IERC20(reserve.aTokenAddress).balanceOf(userAddress),
|
||||
Errors.CALLATERAL_SAME_AS_BORROWING_CURRENCY
|
||||
Errors.VL_CALLATERAL_SAME_AS_BORROWING_CURRENCY
|
||||
);
|
||||
|
||||
//calculate the max available loan size in stable rate mode as a percentage of the
|
||||
//available liquidity
|
||||
uint256 maxLoanSizeStable = vars.availableLiquidity.percentMul(maxStableLoanPercent);
|
||||
|
||||
require(amount <= maxLoanSizeStable, Errors.AMOUNT_BIGGER_THAN_MAX_LOAN_SIZE_STABLE);
|
||||
require(amount <= maxLoanSizeStable, Errors.VL_AMOUNT_BIGGER_THAN_MAX_LOAN_SIZE_STABLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,21 +225,21 @@ library ValidationLogic {
|
|||
) external view {
|
||||
bool isActive = reserve.configuration.getActive();
|
||||
|
||||
require(isActive, Errors.NO_ACTIVE_RESERVE);
|
||||
require(isActive, Errors.VL_NO_ACTIVE_RESERVE);
|
||||
|
||||
require(amountSent > 0, Errors.AMOUNT_NOT_GREATER_THAN_0);
|
||||
require(amountSent > 0, Errors.VL_AMOUNT_NOT_GREATER_THAN_0);
|
||||
|
||||
require(
|
||||
(stableDebt > 0 &&
|
||||
ReserveLogic.InterestRateMode(rateMode) == ReserveLogic.InterestRateMode.STABLE) ||
|
||||
(variableDebt > 0 &&
|
||||
ReserveLogic.InterestRateMode(rateMode) == ReserveLogic.InterestRateMode.VARIABLE),
|
||||
Errors.NO_DEBT_OF_SELECTED_TYPE
|
||||
Errors.VL_NO_DEBT_OF_SELECTED_TYPE
|
||||
);
|
||||
|
||||
require(
|
||||
amountSent != uint256(-1) || msg.sender == onBehalfOf,
|
||||
Errors.NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF
|
||||
Errors.VL_NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -260,13 +260,13 @@ library ValidationLogic {
|
|||
) external view {
|
||||
(bool isActive, bool isFreezed, , bool stableRateEnabled) = reserve.configuration.getFlags();
|
||||
|
||||
require(isActive, Errors.NO_ACTIVE_RESERVE);
|
||||
require(!isFreezed, Errors.NO_UNFREEZED_RESERVE);
|
||||
require(isActive, Errors.VL_NO_ACTIVE_RESERVE);
|
||||
require(!isFreezed, Errors.VL_NO_UNFREEZED_RESERVE);
|
||||
|
||||
if (currentRateMode == ReserveLogic.InterestRateMode.STABLE) {
|
||||
require(stableBorrowBalance > 0, Errors.NO_STABLE_RATE_LOAN_IN_RESERVE);
|
||||
require(stableBorrowBalance > 0, Errors.VL_NO_STABLE_RATE_LOAN_IN_RESERVE);
|
||||
} else if (currentRateMode == ReserveLogic.InterestRateMode.VARIABLE) {
|
||||
require(variableBorrowBalance > 0, Errors.NO_VARIABLE_RATE_LOAN_IN_RESERVE);
|
||||
require(variableBorrowBalance > 0, Errors.VL_NO_VARIABLE_RATE_LOAN_IN_RESERVE);
|
||||
/**
|
||||
* user wants to swap to stable, before swapping we need to ensure that
|
||||
* 1. stable borrow rate is enabled on the reserve
|
||||
|
@ -274,17 +274,17 @@ library ValidationLogic {
|
|||
* more collateral than he is borrowing, artificially lowering
|
||||
* the interest rate, borrowing at variable, and switching to stable
|
||||
**/
|
||||
require(stableRateEnabled, Errors.STABLE_BORROWING_NOT_ENABLED);
|
||||
require(stableRateEnabled, Errors.VL_STABLE_BORROWING_NOT_ENABLED);
|
||||
|
||||
require(
|
||||
!userConfig.isUsingAsCollateral(reserve.id) ||
|
||||
reserve.configuration.getLtv() == 0 ||
|
||||
stableBorrowBalance.add(variableBorrowBalance) >
|
||||
IERC20(reserve.aTokenAddress).balanceOf(msg.sender),
|
||||
Errors.CALLATERAL_SAME_AS_BORROWING_CURRENCY
|
||||
Errors.VL_CALLATERAL_SAME_AS_BORROWING_CURRENCY
|
||||
);
|
||||
} else {
|
||||
revert(Errors.INVALID_INTEREST_RATE_MODE_SELECTED);
|
||||
revert(Errors.VL_INVALID_INTEREST_RATE_MODE_SELECTED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,7 @@ library ValidationLogic {
|
|||
) external view {
|
||||
uint256 underlyingBalance = IERC20(reserve.aTokenAddress).balanceOf(msg.sender);
|
||||
|
||||
require(underlyingBalance > 0, Errors.UNDERLYING_BALANCE_NOT_GREATER_THAN_0);
|
||||
require(underlyingBalance > 0, Errors.VL_UNDERLYING_BALANCE_NOT_GREATER_THAN_0);
|
||||
|
||||
require(
|
||||
GenericLogic.balanceDecreaseAllowed(
|
||||
|
@ -321,7 +321,7 @@ library ValidationLogic {
|
|||
reservesCount,
|
||||
oracle
|
||||
),
|
||||
Errors.DEPOSIT_ALREADY_IN_USE
|
||||
Errors.VL_DEPOSIT_ALREADY_IN_USE
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -331,8 +331,11 @@ library ValidationLogic {
|
|||
* @param premium the premium paid on the flashloan
|
||||
**/
|
||||
function validateFlashloan(uint256 mode, uint256 premium) internal pure {
|
||||
require(premium > 0, Errors.REQUESTED_AMOUNT_TOO_SMALL);
|
||||
require(mode <= uint256(ReserveLogic.InterestRateMode.VARIABLE), Errors.INVALID_FLASHLOAN_MODE);
|
||||
require(premium > 0, Errors.LP_REQUESTED_AMOUNT_TOO_SMALL);
|
||||
require(
|
||||
mode <= uint256(ReserveLogic.InterestRateMode.VARIABLE),
|
||||
Errors.LP_INVALID_FLASHLOAN_MODE
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -355,13 +358,16 @@ library ValidationLogic {
|
|||
if (
|
||||
!collateralReserve.configuration.getActive() || !principalReserve.configuration.getActive()
|
||||
) {
|
||||
return (uint256(Errors.CollateralManagerErrors.NO_ACTIVE_RESERVE), Errors.NO_ACTIVE_RESERVE);
|
||||
return (
|
||||
uint256(Errors.CollateralManagerErrors.NO_ACTIVE_RESERVE),
|
||||
Errors.VL_NO_ACTIVE_RESERVE
|
||||
);
|
||||
}
|
||||
|
||||
if (userHealthFactor >= GenericLogic.HEALTH_FACTOR_LIQUIDATION_THRESHOLD) {
|
||||
return (
|
||||
uint256(Errors.CollateralManagerErrors.HEALTH_FACTOR_ABOVE_THRESHOLD),
|
||||
Errors.HEALTH_FACTOR_NOT_BELOW_THRESHOLD
|
||||
Errors.LPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -372,18 +378,18 @@ library ValidationLogic {
|
|||
if (!isCollateralEnabled) {
|
||||
return (
|
||||
uint256(Errors.CollateralManagerErrors.COLLATERAL_CANNOT_BE_LIQUIDATED),
|
||||
Errors.COLLATERAL_CANNOT_BE_LIQUIDATED
|
||||
Errors.LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED
|
||||
);
|
||||
}
|
||||
|
||||
if (userStableDebt == 0 && userVariableDebt == 0) {
|
||||
return (
|
||||
uint256(Errors.CollateralManagerErrors.CURRRENCY_NOT_BORROWED),
|
||||
Errors.SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER
|
||||
Errors.LPCM_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER
|
||||
);
|
||||
}
|
||||
|
||||
return (uint256(Errors.CollateralManagerErrors.NO_ERROR), Errors.NO_ERRORS);
|
||||
return (uint256(Errors.CollateralManagerErrors.NO_ERROR), Errors.LPCM_NO_ERRORS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -408,7 +414,10 @@ library ValidationLogic {
|
|||
if (
|
||||
!collateralReserve.configuration.getActive() || !principalReserve.configuration.getActive()
|
||||
) {
|
||||
return (uint256(Errors.CollateralManagerErrors.NO_ACTIVE_RESERVE), Errors.NO_ACTIVE_RESERVE);
|
||||
return (
|
||||
uint256(Errors.CollateralManagerErrors.NO_ACTIVE_RESERVE),
|
||||
Errors.VL_NO_ACTIVE_RESERVE
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
|
@ -416,7 +425,7 @@ library ValidationLogic {
|
|||
) {
|
||||
return (
|
||||
uint256(Errors.CollateralManagerErrors.HEALTH_FACTOR_ABOVE_THRESHOLD),
|
||||
Errors.HEALTH_FACTOR_NOT_BELOW_THRESHOLD
|
||||
Errors.LPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -428,7 +437,7 @@ library ValidationLogic {
|
|||
if (!isCollateralEnabled) {
|
||||
return (
|
||||
uint256(Errors.CollateralManagerErrors.COLLATERAL_CANNOT_BE_LIQUIDATED),
|
||||
Errors.COLLATERAL_CANNOT_BE_LIQUIDATED
|
||||
Errors.LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -436,11 +445,11 @@ library ValidationLogic {
|
|||
if (userStableDebt == 0 && userVariableDebt == 0) {
|
||||
return (
|
||||
uint256(Errors.CollateralManagerErrors.CURRRENCY_NOT_BORROWED),
|
||||
Errors.SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER
|
||||
Errors.LPCM_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER
|
||||
);
|
||||
}
|
||||
|
||||
return (uint256(Errors.CollateralManagerErrors.NO_ERROR), Errors.NO_ERRORS);
|
||||
return (uint256(Errors.CollateralManagerErrors.NO_ERROR), Errors.LPCM_NO_ERRORS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -459,21 +468,24 @@ library ValidationLogic {
|
|||
if (fromAsset == toAsset) {
|
||||
return (
|
||||
uint256(Errors.CollateralManagerErrors.INVALID_EQUAL_ASSETS_TO_SWAP),
|
||||
Errors.INVALID_EQUAL_ASSETS_TO_SWAP
|
||||
Errors.LP_INVALID_EQUAL_ASSETS_TO_SWAP
|
||||
);
|
||||
}
|
||||
|
||||
(bool isToActive, bool isToFreezed, , ) = toReserve.configuration.getFlags();
|
||||
if (!fromReserve.configuration.getActive() || !isToActive) {
|
||||
return (uint256(Errors.CollateralManagerErrors.NO_ACTIVE_RESERVE), Errors.NO_ACTIVE_RESERVE);
|
||||
return (
|
||||
uint256(Errors.CollateralManagerErrors.NO_ACTIVE_RESERVE),
|
||||
Errors.VL_NO_ACTIVE_RESERVE
|
||||
);
|
||||
}
|
||||
if (isToFreezed) {
|
||||
return (
|
||||
uint256(Errors.CollateralManagerErrors.NO_UNFREEZED_RESERVE),
|
||||
Errors.NO_UNFREEZED_RESERVE
|
||||
Errors.VL_NO_UNFREEZED_RESERVE
|
||||
);
|
||||
}
|
||||
|
||||
return (uint256(Errors.CollateralManagerErrors.NO_ERROR), Errors.NO_ERRORS);
|
||||
return (uint256(Errors.CollateralManagerErrors.NO_ERROR), Errors.LPCM_NO_ERRORS);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,11 +28,11 @@ library PercentageMath {
|
|||
|
||||
uint256 result = value * percentage;
|
||||
|
||||
require(result / value == percentage, Errors.MULTIPLICATION_OVERFLOW);
|
||||
require(result / value == percentage, Errors.MATH_MULTIPLICATION_OVERFLOW);
|
||||
|
||||
result += HALF_PERCENT;
|
||||
|
||||
require(result >= HALF_PERCENT, Errors.ADDITION_OVERFLOW);
|
||||
require(result >= HALF_PERCENT, Errors.MATH_ADDITION_OVERFLOW);
|
||||
|
||||
return result / PERCENTAGE_FACTOR;
|
||||
}
|
||||
|
@ -44,16 +44,16 @@ library PercentageMath {
|
|||
* @return the value divided the percentage
|
||||
**/
|
||||
function percentDiv(uint256 value, uint256 percentage) internal pure returns (uint256) {
|
||||
require(percentage != 0, Errors.DIVISION_BY_ZERO);
|
||||
require(percentage != 0, Errors.MATH_DIVISION_BY_ZERO);
|
||||
uint256 halfPercentage = percentage / 2;
|
||||
|
||||
uint256 result = value * PERCENTAGE_FACTOR;
|
||||
|
||||
require(result / PERCENTAGE_FACTOR == value, Errors.MULTIPLICATION_OVERFLOW);
|
||||
require(result / PERCENTAGE_FACTOR == value, Errors.MATH_MULTIPLICATION_OVERFLOW);
|
||||
|
||||
result += halfPercentage;
|
||||
|
||||
require(result >= halfPercentage, Errors.ADDITION_OVERFLOW);
|
||||
require(result >= halfPercentage, Errors.MATH_ADDITION_OVERFLOW);
|
||||
|
||||
return result / percentage;
|
||||
}
|
||||
|
|
|
@ -60,11 +60,11 @@ library WadRayMath {
|
|||
|
||||
uint256 result = a * b;
|
||||
|
||||
require(result / a == b, Errors.MULTIPLICATION_OVERFLOW);
|
||||
require(result / a == b, Errors.MATH_MULTIPLICATION_OVERFLOW);
|
||||
|
||||
result += halfWAD;
|
||||
|
||||
require(result >= halfWAD, Errors.ADDITION_OVERFLOW);
|
||||
require(result >= halfWAD, Errors.MATH_ADDITION_OVERFLOW);
|
||||
|
||||
return result / WAD;
|
||||
}
|
||||
|
@ -76,17 +76,17 @@ library WadRayMath {
|
|||
* @return the result of a/b, in wad
|
||||
**/
|
||||
function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||
require(b != 0, Errors.DIVISION_BY_ZERO);
|
||||
require(b != 0, Errors.MATH_DIVISION_BY_ZERO);
|
||||
|
||||
uint256 halfB = b / 2;
|
||||
|
||||
uint256 result = a * WAD;
|
||||
|
||||
require(result / WAD == a, Errors.MULTIPLICATION_OVERFLOW);
|
||||
require(result / WAD == a, Errors.MATH_MULTIPLICATION_OVERFLOW);
|
||||
|
||||
result += halfB;
|
||||
|
||||
require(result >= halfB, Errors.ADDITION_OVERFLOW);
|
||||
require(result >= halfB, Errors.MATH_ADDITION_OVERFLOW);
|
||||
|
||||
return result / b;
|
||||
}
|
||||
|
@ -104,11 +104,11 @@ library WadRayMath {
|
|||
|
||||
uint256 result = a * b;
|
||||
|
||||
require(result / a == b, Errors.MULTIPLICATION_OVERFLOW);
|
||||
require(result / a == b, Errors.MATH_MULTIPLICATION_OVERFLOW);
|
||||
|
||||
result += halfRAY;
|
||||
|
||||
require(result >= halfRAY, Errors.ADDITION_OVERFLOW);
|
||||
require(result >= halfRAY, Errors.MATH_ADDITION_OVERFLOW);
|
||||
|
||||
return result / RAY;
|
||||
}
|
||||
|
@ -120,17 +120,17 @@ library WadRayMath {
|
|||
* @return the result of a/b, in ray
|
||||
**/
|
||||
function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||
require(b != 0, Errors.DIVISION_BY_ZERO);
|
||||
require(b != 0, Errors.MATH_DIVISION_BY_ZERO);
|
||||
|
||||
uint256 halfB = b / 2;
|
||||
|
||||
uint256 result = a * RAY;
|
||||
|
||||
require(result / RAY == a, Errors.MULTIPLICATION_OVERFLOW);
|
||||
require(result / RAY == a, Errors.MATH_MULTIPLICATION_OVERFLOW);
|
||||
|
||||
result += halfB;
|
||||
|
||||
require(result >= halfB, Errors.ADDITION_OVERFLOW);
|
||||
require(result >= halfB, Errors.MATH_ADDITION_OVERFLOW);
|
||||
|
||||
return result / b;
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ library WadRayMath {
|
|||
function rayToWad(uint256 a) internal pure returns (uint256) {
|
||||
uint256 halfRatio = WAD_RAY_RATIO / 2;
|
||||
uint256 result = halfRatio + a;
|
||||
require(result >= halfRatio, Errors.ADDITION_OVERFLOW);
|
||||
require(result >= halfRatio, Errors.MATH_ADDITION_OVERFLOW);
|
||||
|
||||
return result / WAD_RAY_RATIO;
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ library WadRayMath {
|
|||
**/
|
||||
function wadToRay(uint256 a) internal pure returns (uint256) {
|
||||
uint256 result = a * WAD_RAY_RATIO;
|
||||
require(result / WAD_RAY_RATIO == a, Errors.MULTIPLICATION_OVERFLOW);
|
||||
require(result / WAD_RAY_RATIO == a, Errors.MATH_MULTIPLICATION_OVERFLOW);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ contract AToken is VersionedInitializable, IncentivizedERC20, IAToken {
|
|||
bytes32 public DOMAIN_SEPARATOR;
|
||||
|
||||
modifier onlyLendingPool {
|
||||
require(msg.sender == address(POOL), Errors.CALLER_MUST_BE_LENDING_POOL);
|
||||
require(msg.sender == address(POOL), Errors.AT_CALLER_MUST_BE_LENDING_POOL);
|
||||
_;
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ contract AToken is VersionedInitializable, IncentivizedERC20, IAToken {
|
|||
uint256 index
|
||||
) external override onlyLendingPool {
|
||||
uint256 amountScaled = amount.rayDiv(index);
|
||||
require(amountScaled != 0, Errors.INVALID_BURN_AMOUNT);
|
||||
require(amountScaled != 0, Errors.AT_INVALID_BURN_AMOUNT);
|
||||
_burn(user, amountScaled);
|
||||
|
||||
//transfers the underlying to the target
|
||||
|
@ -126,7 +126,7 @@ contract AToken is VersionedInitializable, IncentivizedERC20, IAToken {
|
|||
uint256 index
|
||||
) external override onlyLendingPool {
|
||||
uint256 amountScaled = amount.rayDiv(index);
|
||||
require(amountScaled != 0, Errors.INVALID_MINT_AMOUNT);
|
||||
require(amountScaled != 0, Errors.AT_INVALID_MINT_AMOUNT);
|
||||
_mint(user, amountScaled);
|
||||
|
||||
//transfer event to track balances
|
||||
|
@ -315,7 +315,7 @@ contract AToken is VersionedInitializable, IncentivizedERC20, IAToken {
|
|||
bool validate
|
||||
) internal {
|
||||
if (validate) {
|
||||
require(isTransferAllowed(from, amount), Errors.TRANSFER_NOT_ALLOWED);
|
||||
require(isTransferAllowed(from, amount), Errors.VL_TRANSFER_NOT_ALLOWED);
|
||||
}
|
||||
|
||||
uint256 index = POOL.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS);
|
||||
|
|
|
@ -61,7 +61,7 @@ contract VariableDebtToken is DebtTokenBase, IVariableDebtToken {
|
|||
uint256 index
|
||||
) external override onlyLendingPool {
|
||||
uint256 amountScaled = amount.rayDiv(index);
|
||||
require(amountScaled != 0, Errors.INVALID_MINT_AMOUNT);
|
||||
require(amountScaled != 0, Errors.AT_INVALID_MINT_AMOUNT);
|
||||
|
||||
_mint(user, amountScaled);
|
||||
|
||||
|
@ -80,7 +80,7 @@ contract VariableDebtToken is DebtTokenBase, IVariableDebtToken {
|
|||
uint256 index
|
||||
) external override onlyLendingPool {
|
||||
uint256 amountScaled = amount.rayDiv(index);
|
||||
require(amountScaled != 0, Errors.INVALID_BURN_AMOUNT);
|
||||
require(amountScaled != 0, Errors.AT_INVALID_BURN_AMOUNT);
|
||||
|
||||
_burn(user, amountScaled);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ abstract contract DebtTokenBase is IncentivizedERC20, VersionedInitializable {
|
|||
* @dev Only lending pool can call functions marked by this modifier
|
||||
**/
|
||||
modifier onlyLendingPool {
|
||||
require(msg.sender == address(POOL), Errors.CALLER_MUST_BE_LENDING_POOL);
|
||||
require(msg.sender == address(POOL), Errors.AT_CALLER_MUST_BE_LENDING_POOL);
|
||||
_;
|
||||
}
|
||||
|
||||
|
|
112
helpers/types.ts
112
helpers/types.ts
|
@ -58,64 +58,62 @@ export enum eContractid {
|
|||
TokenDistributor = 'TokenDistributor',
|
||||
}
|
||||
|
||||
/*
|
||||
* Error messages prefix glossary:
|
||||
* - VL = ValidationLogic
|
||||
* - MATH = Math libraries
|
||||
* - AT = aToken or DebtTokens
|
||||
* - LP = LendingPool
|
||||
* - LPAPR = LendingPoolAddressesProviderRegistry
|
||||
* - LPC = LendingPoolConfiguration
|
||||
* - RL = ReserveLogic
|
||||
* - LPCM = LendingPoolCollateralManager
|
||||
* - P = Pausable
|
||||
*/
|
||||
export enum ProtocolErrors {
|
||||
// require error messages - ValidationLogic
|
||||
AMOUNT_NOT_GREATER_THAN_0 = '1', // 'Amount must be greater than 0'
|
||||
NO_ACTIVE_RESERVE = '2', // 'Action requires an active reserve'
|
||||
NO_UNFREEZED_RESERVE = '3', // 'Action requires an unfreezed reserve'
|
||||
CURRENT_AVAILABLE_LIQUIDITY_NOT_ENOUGH = '4', // 'The current liquidity is not enough'
|
||||
NOT_ENOUGH_AVAILABLE_USER_BALANCE = '5', // 'User cannot withdraw more than the available balance'
|
||||
TRANSFER_NOT_ALLOWED = '6', // 'Transfer cannot be allowed.'
|
||||
BORROWING_NOT_ENABLED = '7', // 'Borrowing is not enabled'
|
||||
INVALID_INTEREST_RATE_MODE_SELECTED = '8', // 'Invalid interest rate mode selected'
|
||||
COLLATERAL_BALANCE_IS_0 = '9', // 'The collateral balance is 0'
|
||||
HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD = '10', // 'Health factor is lesser than the liquidation threshold'
|
||||
COLLATERAL_CANNOT_COVER_NEW_BORROW = '11', // 'There is not enough collateral to cover a new borrow'
|
||||
STABLE_BORROWING_NOT_ENABLED = '12', // stable borrowing not enabled
|
||||
CALLATERAL_SAME_AS_BORROWING_CURRENCY = '13', // collateral is (mostly) the same currency that is being borrowed
|
||||
AMOUNT_BIGGER_THAN_MAX_LOAN_SIZE_STABLE = '14', // 'The requested amount is greater than the max loan size in stable rate mode
|
||||
NO_DEBT_OF_SELECTED_TYPE = '15', // 'for repayment of stable debt, the user needs to have stable debt, otherwise, he needs to have variable debt'
|
||||
NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF = '16', // 'To repay on behalf of an user an explicit amount to repay is needed'
|
||||
NO_STABLE_RATE_LOAN_IN_RESERVE = '17', // 'User does not have a stable rate loan in progress on this reserve'
|
||||
NO_VARIABLE_RATE_LOAN_IN_RESERVE = '18', // 'User does not have a variable rate loan in progress on this reserve'
|
||||
UNDERLYING_BALANCE_NOT_GREATER_THAN_0 = '19', // 'The underlying balance needs to be greater than 0'
|
||||
DEPOSIT_ALREADY_IN_USE = '20', // 'User deposit is already being used as collateral'
|
||||
INVALID_EQUAL_ASSETS_TO_SWAP = '56', // User can't use same reserve as destination of liquidity swap
|
||||
|
||||
// require error messages - LendingPool
|
||||
NOT_ENOUGH_STABLE_BORROW_BALANCE = '21', // 'User does not have any stable rate loan for this reserve'
|
||||
INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET = '22', // 'Interest rate rebalance conditions were not met'
|
||||
LIQUIDATION_CALL_FAILED = '23', // 'Liquidation call failed'
|
||||
NOT_ENOUGH_LIQUIDITY_TO_BORROW = '24', // 'There is not enough liquidity available to borrow'
|
||||
REQUESTED_AMOUNT_TOO_SMALL = '25', // 'The requested amount is too small for a FlashLoan.'
|
||||
INCONSISTENT_PROTOCOL_ACTUAL_BALANCE = '26', // 'The actual balance of the protocol is inconsistent'
|
||||
CALLER_NOT_LENDING_POOL_CONFIGURATOR = '27', // 'The actual balance of the protocol is inconsistent'
|
||||
INVALID_FLASH_LOAN_EXECUTOR_RETURN = '60', // The flash loan received returned 0 (EOA)
|
||||
|
||||
// require error messages - aToken
|
||||
CALLER_MUST_BE_LENDING_POOL = '28', // 'The caller of this function must be a lending pool'
|
||||
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'
|
||||
|
||||
// require error messages - ReserveLogic
|
||||
RESERVE_ALREADY_INITIALIZED = '34', // 'Reserve has already been initialized'
|
||||
|
||||
//require error messages - LendingPoolConfiguration
|
||||
CALLER_NOT_AAVE_ADMIN = '35', // 'The caller must be the aave admin'
|
||||
RESERVE_LIQUIDITY_NOT_0 = '36', // 'The liquidity of the reserve needs to be 0'
|
||||
|
||||
//require error messages - LendingPoolAddressesProviderRegistry
|
||||
PROVIDER_NOT_REGISTERED = '37', // 'Provider is not registered'
|
||||
|
||||
//return error messages - LendingPoolCollateralManager
|
||||
HEALTH_FACTOR_NOT_BELOW_THRESHOLD = '38', // 'Health factor is not below the threshold'
|
||||
COLLATERAL_CANNOT_BE_LIQUIDATED = '39', // 'The collateral chosen cannot be liquidated'
|
||||
SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER = '40', // 'User did not borrow the specified currency'
|
||||
NOT_ENOUGH_LIQUIDITY_TO_LIQUIDATE = '41', // "There isn't enough liquidity available to liquidate"
|
||||
NO_ERRORS = '42', // 'No errors'
|
||||
INVALID_FLASHLOAN_MODE = '43', //Invalid flashloan mode
|
||||
|
||||
IS_PAUSED = '58', // Pool is paused
|
||||
VL_AMOUNT_NOT_GREATER_THAN_0 = '1', // 'Amount must be greater than 0'
|
||||
VL_NO_ACTIVE_RESERVE = '2', // 'Action requires an active reserve'
|
||||
VL_NO_UNFREEZED_RESERVE = '3', // 'Action requires an unfreezed reserve'
|
||||
VL_CURRENT_AVAILABLE_LIQUIDITY_NOT_ENOUGH = '4', // 'The current liquidity is not enough'
|
||||
VL_NOT_ENOUGH_AVAILABLE_USER_BALANCE = '5', // 'User cannot withdraw more than the available balance'
|
||||
VL_TRANSFER_NOT_ALLOWED = '6', // 'Transfer cannot be allowed.'
|
||||
VL_BORROWING_NOT_ENABLED = '7', // 'Borrowing is not enabled'
|
||||
VL_INVALID_INTEREST_RATE_MODE_SELECTED = '8', // 'Invalid interest rate mode selected'
|
||||
VL_COLLATERAL_BALANCE_IS_0 = '9', // 'The collateral balance is 0'
|
||||
VL_HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD = '10', // 'Health factor is lesser than the liquidation threshold'
|
||||
VL_COLLATERAL_CANNOT_COVER_NEW_BORROW = '11', // 'There is not enough collateral to cover a new borrow'
|
||||
VL_STABLE_BORROWING_NOT_ENABLED = '12', // stable borrowing not enabled
|
||||
VL_CALLATERAL_SAME_AS_BORROWING_CURRENCY = '13', // collateral is (mostly) the same currency that is being borrowed
|
||||
VL_AMOUNT_BIGGER_THAN_MAX_LOAN_SIZE_STABLE = '14', // 'The requested amount is greater than the max loan size in stable rate mode
|
||||
VL_NO_DEBT_OF_SELECTED_TYPE = '15', // 'for repayment of stable debt, the user needs to have stable debt, otherwise, he needs to have variable debt'
|
||||
VL_NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF = '16', // 'To repay on behalf of an user an explicit amount to repay is needed'
|
||||
VL_NO_STABLE_RATE_LOAN_IN_RESERVE = '17', // 'User does not have a stable rate loan in progress on this reserve'
|
||||
VL_NO_VARIABLE_RATE_LOAN_IN_RESERVE = '18', // 'User does not have a variable rate loan in progress on this reserve'
|
||||
VL_UNDERLYING_BALANCE_NOT_GREATER_THAN_0 = '19', // 'The underlying balance needs to be greater than 0'
|
||||
VL_DEPOSIT_ALREADY_IN_USE = '20', // 'User deposit is already being used as collateral'
|
||||
LP_NOT_ENOUGH_STABLE_BORROW_BALANCE = '21', // 'User does not have any stable rate loan for this reserve'
|
||||
LP_INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET = '22', // 'Interest rate rebalance conditions were not met'
|
||||
LP_LIQUIDATION_CALL_FAILED = '23', // 'Liquidation call failed'
|
||||
LP_NOT_ENOUGH_LIQUIDITY_TO_BORROW = '24', // 'There is not enough liquidity available to borrow'
|
||||
LP_REQUESTED_AMOUNT_TOO_SMALL = '25', // 'The requested amount is too small for a FlashLoan.'
|
||||
LP_INCONSISTENT_PROTOCOL_ACTUAL_BALANCE = '26', // 'The actual balance of the protocol is inconsistent'
|
||||
LP_CALLER_NOT_LENDING_POOL_CONFIGURATOR = '27', // 'The actual balance of the protocol is inconsistent'
|
||||
AT_CALLER_MUST_BE_LENDING_POOL = '28', // 'The caller of this function must be a lending pool'
|
||||
AT_CANNOT_GIVE_ALLOWANCE_TO_HIMSELF = '30', // 'User cannot give allowance to himself'
|
||||
AT_TRANSFER_AMOUNT_NOT_GT_0 = '31', // 'Transferred amount needs to be greater than zero'
|
||||
RL_RESERVE_ALREADY_INITIALIZED = '34', // 'Reserve has already been initialized'
|
||||
LPC_CALLER_NOT_AAVE_ADMIN = '35', // 'The caller must be the aave admin'
|
||||
LPC_RESERVE_LIQUIDITY_NOT_0 = '36', // 'The liquidity of the reserve needs to be 0'
|
||||
LPAPR_PROVIDER_NOT_REGISTERED = '37', // 'Provider is not registered'
|
||||
LPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD = '38', // 'Health factor is not below the threshold'
|
||||
LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED = '39', // 'The collateral chosen cannot be liquidated'
|
||||
LPCM_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER = '40', // 'User did not borrow the specified currency'
|
||||
LPCM_NOT_ENOUGH_LIQUIDITY_TO_LIQUIDATE = '41', // "There isn't enough liquidity available to liquidate"
|
||||
LPCM_NO_ERRORS = '42', // 'No errors'
|
||||
LP_INVALID_FLASHLOAN_MODE = '43', //Invalid flashloan mode
|
||||
LP_INVALID_EQUAL_ASSETS_TO_SWAP = '56', // User can't use same reserve as destination of liquidity swap
|
||||
P_IS_PAUSED = '58', // Pool is paused
|
||||
LP_INVALID_FLASH_LOAN_EXECUTOR_RETURN = '60', // The flash loan received returned 0 (EOA)
|
||||
|
||||
// old
|
||||
|
||||
|
|
|
@ -54,22 +54,22 @@ makeSuite('AddressesProviderRegistry', (testEnv: TestEnv) => {
|
|||
});
|
||||
|
||||
it('Tries to remove a unregistered addressesProvider', async () => {
|
||||
const {PROVIDER_NOT_REGISTERED} = ProtocolErrors;
|
||||
const {LPAPR_PROVIDER_NOT_REGISTERED} = ProtocolErrors;
|
||||
|
||||
const {users, registry} = testEnv;
|
||||
|
||||
await expect(registry.unregisterAddressesProvider(users[2].address)).to.be.revertedWith(
|
||||
PROVIDER_NOT_REGISTERED
|
||||
LPAPR_PROVIDER_NOT_REGISTERED
|
||||
);
|
||||
});
|
||||
|
||||
it('Tries to remove a unregistered addressesProvider', async () => {
|
||||
const {PROVIDER_NOT_REGISTERED} = ProtocolErrors;
|
||||
const {LPAPR_PROVIDER_NOT_REGISTERED} = ProtocolErrors;
|
||||
|
||||
const {users, registry} = testEnv;
|
||||
|
||||
await expect(registry.unregisterAddressesProvider(users[2].address)).to.be.revertedWith(
|
||||
PROVIDER_NOT_REGISTERED
|
||||
LPAPR_PROVIDER_NOT_REGISTERED
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -3,19 +3,19 @@ import {makeSuite, TestEnv} from './helpers/make-suite';
|
|||
import {ProtocolErrors} from '../helpers/types';
|
||||
|
||||
makeSuite('AToken: Modifiers', (testEnv: TestEnv) => {
|
||||
const {CALLER_MUST_BE_LENDING_POOL} = ProtocolErrors;
|
||||
const {AT_CALLER_MUST_BE_LENDING_POOL} = ProtocolErrors;
|
||||
|
||||
it('Tries to invoke mint not being the LendingPool', async () => {
|
||||
const {deployer, aDai} = testEnv;
|
||||
await expect(aDai.mint(deployer.address, '1', '1')).to.be.revertedWith(
|
||||
CALLER_MUST_BE_LENDING_POOL
|
||||
AT_CALLER_MUST_BE_LENDING_POOL
|
||||
);
|
||||
});
|
||||
|
||||
it('Tries to invoke burn not being the LendingPool', async () => {
|
||||
const {deployer, aDai} = testEnv;
|
||||
await expect(aDai.burn(deployer.address, deployer.address, '1', '1')).to.be.revertedWith(
|
||||
CALLER_MUST_BE_LENDING_POOL
|
||||
AT_CALLER_MUST_BE_LENDING_POOL
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -23,13 +23,13 @@ makeSuite('AToken: Modifiers', (testEnv: TestEnv) => {
|
|||
const {deployer, users, aDai} = testEnv;
|
||||
await expect(
|
||||
aDai.transferOnLiquidation(deployer.address, users[0].address, '1')
|
||||
).to.be.revertedWith(CALLER_MUST_BE_LENDING_POOL);
|
||||
).to.be.revertedWith(AT_CALLER_MUST_BE_LENDING_POOL);
|
||||
});
|
||||
|
||||
it('Tries to invoke transferUnderlyingTo not being the LendingPool', async () => {
|
||||
const {deployer, users, aDai} = testEnv;
|
||||
await expect(aDai.transferUnderlyingTo(deployer.address, '1')).to.be.revertedWith(
|
||||
CALLER_MUST_BE_LENDING_POOL
|
||||
AT_CALLER_MUST_BE_LENDING_POOL
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -15,9 +15,9 @@ makeSuite('AToken: Transfer', (testEnv: TestEnv) => {
|
|||
INVALID_FROM_BALANCE_AFTER_TRANSFER,
|
||||
INVALID_TO_BALANCE_AFTER_TRANSFER,
|
||||
// ZERO_COLLATERAL,
|
||||
COLLATERAL_BALANCE_IS_0,
|
||||
TRANSFER_NOT_ALLOWED,
|
||||
IS_PAUSED,
|
||||
VL_COLLATERAL_BALANCE_IS_0,
|
||||
VL_TRANSFER_NOT_ALLOWED,
|
||||
P_IS_PAUSED,
|
||||
} = ProtocolErrors;
|
||||
|
||||
it('User 0 deposits 1000 DAI, transfers to user 1', async () => {
|
||||
|
@ -67,8 +67,8 @@ makeSuite('AToken: Transfer', (testEnv: TestEnv) => {
|
|||
AAVE_REFERRAL,
|
||||
users[1].address
|
||||
),
|
||||
COLLATERAL_BALANCE_IS_0
|
||||
).to.be.revertedWith(COLLATERAL_BALANCE_IS_0);
|
||||
VL_COLLATERAL_BALANCE_IS_0
|
||||
).to.be.revertedWith(VL_COLLATERAL_BALANCE_IS_0);
|
||||
});
|
||||
|
||||
it('User 1 sets the DAI as collateral and borrows, tries to transfer everything back to user 0 (revert expected)', async () => {
|
||||
|
@ -89,7 +89,7 @@ makeSuite('AToken: Transfer', (testEnv: TestEnv) => {
|
|||
|
||||
await expect(
|
||||
aDai.connect(users[1].signer).transfer(users[0].address, aDAItoTransfer),
|
||||
TRANSFER_NOT_ALLOWED
|
||||
).to.be.revertedWith(TRANSFER_NOT_ALLOWED);
|
||||
VL_TRANSFER_NOT_ALLOWED
|
||||
).to.be.revertedWith(VL_TRANSFER_NOT_ALLOWED);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -14,10 +14,10 @@ const {expect} = require('chai');
|
|||
makeSuite('LendingPool SwapDeposit function', (testEnv: TestEnv) => {
|
||||
let _mockSwapAdapter = {} as MockSwapAdapter;
|
||||
const {
|
||||
HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD,
|
||||
NO_UNFREEZED_RESERVE,
|
||||
NO_ACTIVE_RESERVE,
|
||||
INVALID_EQUAL_ASSETS_TO_SWAP,
|
||||
VL_HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD,
|
||||
VL_NO_UNFREEZED_RESERVE,
|
||||
VL_NO_ACTIVE_RESERVE,
|
||||
LP_INVALID_EQUAL_ASSETS_TO_SWAP,
|
||||
} = ProtocolErrors;
|
||||
|
||||
before(async () => {
|
||||
|
@ -35,7 +35,7 @@ makeSuite('LendingPool SwapDeposit function', (testEnv: TestEnv) => {
|
|||
'1'.toString(),
|
||||
'0x10'
|
||||
)
|
||||
).to.be.revertedWith(INVALID_EQUAL_ASSETS_TO_SWAP);
|
||||
).to.be.revertedWith(LP_INVALID_EQUAL_ASSETS_TO_SWAP);
|
||||
});
|
||||
|
||||
it('Should not allow to swap if from or to reserves are not active', async () => {
|
||||
|
@ -51,7 +51,7 @@ makeSuite('LendingPool SwapDeposit function', (testEnv: TestEnv) => {
|
|||
'1'.toString(),
|
||||
'0x10'
|
||||
)
|
||||
).to.be.revertedWith(NO_ACTIVE_RESERVE);
|
||||
).to.be.revertedWith(VL_NO_ACTIVE_RESERVE);
|
||||
await configurator.activateReserve(weth.address);
|
||||
|
||||
await configurator.deactivateReserve(dai.address);
|
||||
|
@ -64,7 +64,7 @@ makeSuite('LendingPool SwapDeposit function', (testEnv: TestEnv) => {
|
|||
'1'.toString(),
|
||||
'0x10'
|
||||
)
|
||||
).to.be.revertedWith(NO_ACTIVE_RESERVE);
|
||||
).to.be.revertedWith(VL_NO_ACTIVE_RESERVE);
|
||||
|
||||
//cleanup state
|
||||
await configurator.activateReserve(dai.address);
|
||||
|
@ -189,7 +189,7 @@ makeSuite('LendingPool SwapDeposit function', (testEnv: TestEnv) => {
|
|||
|
||||
await expect(
|
||||
pool.swapLiquidity(_mockSwapAdapter.address, weth.address, dai.address, amountToSwap, '0x10')
|
||||
).to.be.revertedWith(HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD);
|
||||
).to.be.revertedWith(VL_HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD);
|
||||
});
|
||||
|
||||
it('Should set usage as collateral to false if no leftovers after swap', async () => {
|
||||
|
@ -250,7 +250,7 @@ makeSuite('LendingPool SwapDeposit function', (testEnv: TestEnv) => {
|
|||
'1'.toString(),
|
||||
'0x10'
|
||||
)
|
||||
).to.be.revertedWith(NO_UNFREEZED_RESERVE);
|
||||
).to.be.revertedWith(VL_NO_UNFREEZED_RESERVE);
|
||||
|
||||
//cleanup state
|
||||
await configurator.unfreezeReserve(dai.address);
|
||||
|
|
|
@ -10,7 +10,7 @@ const APPROVAL_AMOUNT_LENDING_POOL =
|
|||
const {expect} = require('chai');
|
||||
|
||||
makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
||||
const {CALLER_NOT_AAVE_ADMIN, RESERVE_LIQUIDITY_NOT_0} = ProtocolErrors;
|
||||
const {LPC_CALLER_NOT_AAVE_ADMIN, LPC_RESERVE_LIQUIDITY_NOT_0} = ProtocolErrors;
|
||||
|
||||
it('Deactivates the ETH reserve', async () => {
|
||||
const {configurator, pool, weth} = testEnv;
|
||||
|
@ -31,16 +31,16 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
|||
const {configurator, users, weth} = testEnv;
|
||||
await expect(
|
||||
configurator.connect(users[2].signer).deactivateReserve(weth.address),
|
||||
CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||
LPC_CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(LPC_CALLER_NOT_AAVE_ADMIN);
|
||||
});
|
||||
|
||||
it('Check the onlyAaveAdmin on activateReserve ', async () => {
|
||||
const {configurator, users, weth} = testEnv;
|
||||
await expect(
|
||||
configurator.connect(users[2].signer).activateReserve(weth.address),
|
||||
CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||
LPC_CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(LPC_CALLER_NOT_AAVE_ADMIN);
|
||||
});
|
||||
|
||||
it('Freezes the ETH reserve', async () => {
|
||||
|
@ -100,16 +100,16 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
|||
const {configurator, users, weth} = testEnv;
|
||||
await expect(
|
||||
configurator.connect(users[2].signer).freezeReserve(weth.address),
|
||||
CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||
LPC_CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(LPC_CALLER_NOT_AAVE_ADMIN);
|
||||
});
|
||||
|
||||
it('Check the onlyAaveAdmin on unfreezeReserve ', async () => {
|
||||
const {configurator, users, weth} = testEnv;
|
||||
await expect(
|
||||
configurator.connect(users[2].signer).unfreezeReserve(weth.address),
|
||||
CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||
LPC_CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(LPC_CALLER_NOT_AAVE_ADMIN);
|
||||
});
|
||||
|
||||
it('Deactivates the ETH reserve for borrowing', async () => {
|
||||
|
@ -172,16 +172,16 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
|||
const {configurator, users, weth} = testEnv;
|
||||
await expect(
|
||||
configurator.connect(users[2].signer).disableBorrowingOnReserve(weth.address),
|
||||
CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||
LPC_CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(LPC_CALLER_NOT_AAVE_ADMIN);
|
||||
});
|
||||
|
||||
it('Check the onlyAaveAdmin on enableBorrowingOnReserve ', async () => {
|
||||
const {configurator, users, weth} = testEnv;
|
||||
await expect(
|
||||
configurator.connect(users[2].signer).enableBorrowingOnReserve(weth.address, true),
|
||||
CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||
LPC_CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(LPC_CALLER_NOT_AAVE_ADMIN);
|
||||
});
|
||||
|
||||
it('Deactivates the ETH reserve as collateral', async () => {
|
||||
|
@ -241,8 +241,8 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
|||
const {configurator, users, weth} = testEnv;
|
||||
await expect(
|
||||
configurator.connect(users[2].signer).disableReserveAsCollateral(weth.address),
|
||||
CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||
LPC_CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(LPC_CALLER_NOT_AAVE_ADMIN);
|
||||
});
|
||||
|
||||
it('Check the onlyAaveAdmin on enableReserveAsCollateral ', async () => {
|
||||
|
@ -251,8 +251,8 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
|||
configurator
|
||||
.connect(users[2].signer)
|
||||
.enableReserveAsCollateral(weth.address, '75', '80', '105'),
|
||||
CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||
LPC_CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(LPC_CALLER_NOT_AAVE_ADMIN);
|
||||
});
|
||||
|
||||
it('Disable stable borrow rate on the ETH reserve', async () => {
|
||||
|
@ -311,16 +311,16 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
|||
const {configurator, users, weth} = testEnv;
|
||||
await expect(
|
||||
configurator.connect(users[2].signer).disableReserveStableRate(weth.address),
|
||||
CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||
LPC_CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(LPC_CALLER_NOT_AAVE_ADMIN);
|
||||
});
|
||||
|
||||
it('Check the onlyAaveAdmin on enableReserveStableRate', async () => {
|
||||
const {configurator, users, weth} = testEnv;
|
||||
await expect(
|
||||
configurator.connect(users[2].signer).enableReserveStableRate(weth.address),
|
||||
CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||
LPC_CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(LPC_CALLER_NOT_AAVE_ADMIN);
|
||||
});
|
||||
|
||||
it('Changes LTV of the reserve', async () => {
|
||||
|
@ -353,8 +353,8 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
|||
const {configurator, users, weth} = testEnv;
|
||||
await expect(
|
||||
configurator.connect(users[2].signer).setLtv(weth.address, '75'),
|
||||
CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||
LPC_CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(LPC_CALLER_NOT_AAVE_ADMIN);
|
||||
});
|
||||
|
||||
it('Changes the reserve factor of the reserve', async () => {
|
||||
|
@ -387,8 +387,8 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
|||
const {configurator, users, weth} = testEnv;
|
||||
await expect(
|
||||
configurator.connect(users[2].signer).setReserveFactor(weth.address, '2000'),
|
||||
CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||
LPC_CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(LPC_CALLER_NOT_AAVE_ADMIN);
|
||||
});
|
||||
|
||||
it('Changes liquidation threshold of the reserve', async () => {
|
||||
|
@ -421,8 +421,8 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
|||
const {configurator, users, weth} = testEnv;
|
||||
await expect(
|
||||
configurator.connect(users[2].signer).setLiquidationThreshold(weth.address, '80'),
|
||||
CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||
LPC_CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(LPC_CALLER_NOT_AAVE_ADMIN);
|
||||
});
|
||||
|
||||
it('Changes liquidation bonus of the reserve', async () => {
|
||||
|
@ -455,24 +455,24 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
|||
const {configurator, users, weth} = testEnv;
|
||||
await expect(
|
||||
configurator.connect(users[2].signer).setLiquidationBonus(weth.address, '80'),
|
||||
CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||
LPC_CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(LPC_CALLER_NOT_AAVE_ADMIN);
|
||||
});
|
||||
|
||||
it('Check the onlyAaveAdmin on setReserveDecimals', async () => {
|
||||
const {configurator, users, weth} = testEnv;
|
||||
await expect(
|
||||
configurator.connect(users[2].signer).setReserveDecimals(weth.address, '80'),
|
||||
CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||
LPC_CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(LPC_CALLER_NOT_AAVE_ADMIN);
|
||||
});
|
||||
|
||||
it('Check the onlyAaveAdmin on setLiquidationBonus', async () => {
|
||||
const {configurator, users, weth} = testEnv;
|
||||
await expect(
|
||||
configurator.connect(users[2].signer).setLiquidationBonus(weth.address, '80'),
|
||||
CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||
LPC_CALLER_NOT_AAVE_ADMIN
|
||||
).to.be.revertedWith(LPC_CALLER_NOT_AAVE_ADMIN);
|
||||
});
|
||||
|
||||
it('Reverts when trying to disable the DAI reserve with liquidity on it', async () => {
|
||||
|
@ -489,7 +489,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
|||
|
||||
await expect(
|
||||
configurator.deactivateReserve(dai.address),
|
||||
RESERVE_LIQUIDITY_NOT_0
|
||||
).to.be.revertedWith(RESERVE_LIQUIDITY_NOT_0);
|
||||
LPC_RESERVE_LIQUIDITY_NOT_0
|
||||
).to.be.revertedWith(LPC_RESERVE_LIQUIDITY_NOT_0);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ const {expect} = require('chai');
|
|||
const {parseUnits, parseEther} = ethers.utils;
|
||||
|
||||
makeSuite('LendingPool. repayWithCollateral() with liquidator', (testEnv: TestEnv) => {
|
||||
const {INVALID_HF, COLLATERAL_CANNOT_BE_LIQUIDATED, IS_PAUSED} = ProtocolErrors;
|
||||
const {INVALID_HF, LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED, P_IS_PAUSED} = ProtocolErrors;
|
||||
|
||||
it('User 1 provides some liquidity for others to borrow', async () => {
|
||||
const {pool, weth, dai, usdc, deployer} = testEnv;
|
||||
|
@ -898,7 +898,7 @@ makeSuite('LendingPool. repayWithCollateral() with liquidator', (testEnv: TestEn
|
|||
mockSwapAdapter.address,
|
||||
'0x'
|
||||
)
|
||||
).to.be.revertedWith(COLLATERAL_CANNOT_BE_LIQUIDATED);
|
||||
).to.be.revertedWith(LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED);
|
||||
|
||||
const repayWithCollateralTimestamp = await timeLatest();
|
||||
|
||||
|
|
|
@ -18,13 +18,13 @@ const {expect} = require('chai');
|
|||
makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => {
|
||||
let _mockFlashLoanReceiver = {} as MockFlashLoanReceiver;
|
||||
const {
|
||||
COLLATERAL_BALANCE_IS_0,
|
||||
REQUESTED_AMOUNT_TOO_SMALL,
|
||||
VL_COLLATERAL_BALANCE_IS_0,
|
||||
LP_REQUESTED_AMOUNT_TOO_SMALL,
|
||||
TRANSFER_AMOUNT_EXCEEDS_BALANCE,
|
||||
INVALID_FLASHLOAN_MODE,
|
||||
LP_INVALID_FLASHLOAN_MODE,
|
||||
SAFEERC20_LOWLEVEL_CALL,
|
||||
IS_PAUSED,
|
||||
INVALID_FLASH_LOAN_EXECUTOR_RETURN,
|
||||
P_IS_PAUSED,
|
||||
LP_INVALID_FLASH_LOAN_EXECUTOR_RETURN,
|
||||
} = ProtocolErrors;
|
||||
|
||||
before(async () => {
|
||||
|
@ -134,7 +134,7 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => {
|
|||
'0x10',
|
||||
'0'
|
||||
)
|
||||
).to.be.revertedWith(INVALID_FLASH_LOAN_EXECUTOR_RETURN);
|
||||
).to.be.revertedWith(LP_INVALID_FLASH_LOAN_EXECUTOR_RETURN);
|
||||
});
|
||||
|
||||
it('Takes a WETH flashloan with an invalid mode. (revert expected)', async () => {
|
||||
|
@ -154,7 +154,7 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => {
|
|||
'0x10',
|
||||
'0'
|
||||
)
|
||||
).to.be.revertedWith(INVALID_FLASHLOAN_MODE);
|
||||
).to.be.revertedWith(LP_INVALID_FLASHLOAN_MODE);
|
||||
});
|
||||
|
||||
it('Caller deposits 1000 DAI as collateral, Takes WETH flashloan with mode = 2, does not return the funds. A variable loan for caller is created', async () => {
|
||||
|
@ -206,7 +206,7 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => {
|
|||
'0x10',
|
||||
'0'
|
||||
)
|
||||
).to.be.revertedWith(REQUESTED_AMOUNT_TOO_SMALL);
|
||||
).to.be.revertedWith(LP_REQUESTED_AMOUNT_TOO_SMALL);
|
||||
});
|
||||
|
||||
it('tries to take a flashloan that is bigger than the available liquidity (revert expected)', async () => {
|
||||
|
@ -296,7 +296,7 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => {
|
|||
pool
|
||||
.connect(caller.signer)
|
||||
.flashLoan(_mockFlashLoanReceiver.address, usdc.address, flashloanAmount, 2, '0x10', '0')
|
||||
).to.be.revertedWith(COLLATERAL_BALANCE_IS_0);
|
||||
).to.be.revertedWith(VL_COLLATERAL_BALANCE_IS_0);
|
||||
});
|
||||
|
||||
it('Caller deposits 5 WETH as collateral, Takes a USDC flashloan with mode = 2, does not return the funds. A loan for caller is created', async () => {
|
||||
|
|
|
@ -17,11 +17,11 @@ const {expect} = chai;
|
|||
|
||||
makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) => {
|
||||
const {
|
||||
HEALTH_FACTOR_NOT_BELOW_THRESHOLD,
|
||||
LPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD,
|
||||
INVALID_HF,
|
||||
SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER,
|
||||
COLLATERAL_CANNOT_BE_LIQUIDATED,
|
||||
IS_PAUSED,
|
||||
LPCM_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER,
|
||||
LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED,
|
||||
P_IS_PAUSED,
|
||||
} = ProtocolErrors;
|
||||
|
||||
it('LIQUIDATION - Deposits WETH, borrows DAI/Check liquidation fails because health factor is above 1', async () => {
|
||||
|
@ -80,7 +80,7 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) =>
|
|||
//someone tries to liquidate user 2
|
||||
await expect(
|
||||
pool.liquidationCall(weth.address, dai.address, borrower.address, 1, true)
|
||||
).to.be.revertedWith(HEALTH_FACTOR_NOT_BELOW_THRESHOLD);
|
||||
).to.be.revertedWith(LPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD);
|
||||
});
|
||||
|
||||
it('LIQUIDATION - Drop the health factor below 1', async () => {
|
||||
|
@ -105,7 +105,7 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) =>
|
|||
//user 2 tries to borrow
|
||||
await expect(
|
||||
pool.liquidationCall(weth.address, weth.address, borrower.address, oneEther.toString(), true)
|
||||
).revertedWith(SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER);
|
||||
).revertedWith(LPCM_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER);
|
||||
});
|
||||
|
||||
it('LIQUIDATION - Tries to liquidate a different collateral than the borrower collateral', async () => {
|
||||
|
@ -114,7 +114,7 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) =>
|
|||
|
||||
await expect(
|
||||
pool.liquidationCall(dai.address, dai.address, borrower.address, oneEther.toString(), true)
|
||||
).revertedWith(COLLATERAL_CANNOT_BE_LIQUIDATED);
|
||||
).revertedWith(LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED);
|
||||
});
|
||||
|
||||
it('LIQUIDATION - Liquidates the borrow', async () => {
|
||||
|
|
|
@ -12,8 +12,8 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
let _mockFlashLoanReceiver = {} as MockFlashLoanReceiver;
|
||||
|
||||
const {
|
||||
IS_PAUSED,
|
||||
TRANSFER_NOT_ALLOWED,
|
||||
P_IS_PAUSED,
|
||||
VL_TRANSFER_NOT_ALLOWED,
|
||||
INVALID_FROM_BALANCE_AFTER_TRANSFER,
|
||||
INVALID_TO_BALANCE_AFTER_TRANSFER,
|
||||
} = ProtocolErrors;
|
||||
|
@ -44,7 +44,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
// User 0 tries the transfer to User 1
|
||||
await expect(
|
||||
aDai.connect(users[0].signer).transfer(users[1].address, amountDAItoDeposit)
|
||||
).to.revertedWith(IS_PAUSED);
|
||||
).to.revertedWith(P_IS_PAUSED);
|
||||
|
||||
const pausedFromBalance = await aDai.balanceOf(users[0].address);
|
||||
const pausedToBalance = await aDai.balanceOf(users[1].address);
|
||||
|
@ -91,7 +91,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
await configurator.setPoolPause(true);
|
||||
await expect(
|
||||
pool.connect(users[0].signer).deposit(dai.address, amountDAItoDeposit, users[0].address, '0')
|
||||
).to.revertedWith(IS_PAUSED);
|
||||
).to.revertedWith(P_IS_PAUSED);
|
||||
|
||||
// Configurator unpauses the pool
|
||||
await configurator.setPoolPause(false);
|
||||
|
@ -116,7 +116,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
// user tries to burn
|
||||
await expect(
|
||||
pool.connect(users[0].signer).withdraw(dai.address, amountDAItoDeposit)
|
||||
).to.revertedWith(IS_PAUSED);
|
||||
).to.revertedWith(P_IS_PAUSED);
|
||||
|
||||
// Configurator unpauses the pool
|
||||
await configurator.setPoolPause(false);
|
||||
|
@ -133,7 +133,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
// Try to execute liquidation
|
||||
await expect(
|
||||
pool.connect(user.signer).delegateBorrowAllowance(dai.address, toUser.address, '1', '1')
|
||||
).revertedWith(IS_PAUSED);
|
||||
).revertedWith(P_IS_PAUSED);
|
||||
|
||||
// Unpause the pool
|
||||
await configurator.setPoolPause(false);
|
||||
|
@ -149,7 +149,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
// Try to execute liquidation
|
||||
await expect(
|
||||
pool.connect(user.signer).borrow(dai.address, '1', '1', '0', user.address)
|
||||
).revertedWith(IS_PAUSED);
|
||||
).revertedWith(P_IS_PAUSED);
|
||||
|
||||
// Unpause the pool
|
||||
await configurator.setPoolPause(false);
|
||||
|
@ -165,7 +165,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
// Try to execute liquidation
|
||||
await expect(
|
||||
pool.connect(user.signer).swapLiquidity(user.address, dai.address, weth.address, '1', '0x')
|
||||
).revertedWith(IS_PAUSED);
|
||||
).revertedWith(P_IS_PAUSED);
|
||||
|
||||
// Unpause the pool
|
||||
await configurator.setPoolPause(false);
|
||||
|
@ -180,7 +180,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
|
||||
// Try to execute liquidation
|
||||
await expect(pool.connect(user.signer).repay(dai.address, '1', '1', user.address)).revertedWith(
|
||||
IS_PAUSED
|
||||
P_IS_PAUSED
|
||||
);
|
||||
|
||||
// Unpause the pool
|
||||
|
@ -207,7 +207,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
mockSwapAdapter.address,
|
||||
'0x'
|
||||
)
|
||||
).revertedWith(IS_PAUSED);
|
||||
).revertedWith(P_IS_PAUSED);
|
||||
|
||||
// Unpause the pool
|
||||
await configurator.setPoolPause(false);
|
||||
|
@ -229,7 +229,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
pool
|
||||
.connect(caller.signer)
|
||||
.flashLoan(_mockFlashLoanReceiver.address, weth.address, flashAmount, 1, '0x10', '0')
|
||||
).revertedWith(IS_PAUSED);
|
||||
).revertedWith(P_IS_PAUSED);
|
||||
|
||||
// Unpause pool
|
||||
await configurator.setPoolPause(false);
|
||||
|
@ -307,7 +307,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
// Do liquidation
|
||||
expect(
|
||||
pool.liquidationCall(weth.address, usdc.address, borrower.address, amountToLiquidate, true)
|
||||
).revertedWith(IS_PAUSED);
|
||||
).revertedWith(P_IS_PAUSED);
|
||||
|
||||
// Unpause pool
|
||||
await configurator.setPoolPause(false);
|
||||
|
@ -336,7 +336,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
// Try to repay
|
||||
await expect(
|
||||
pool.connect(user.signer).swapBorrowRateMode(usdc.address, RateMode.Stable)
|
||||
).revertedWith(IS_PAUSED);
|
||||
).revertedWith(P_IS_PAUSED);
|
||||
|
||||
// Unpause pool
|
||||
await configurator.setPoolPause(false);
|
||||
|
@ -350,7 +350,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
|
||||
await expect(
|
||||
pool.connect(user.signer).rebalanceStableBorrowRate(dai.address, user.address)
|
||||
).revertedWith(IS_PAUSED);
|
||||
).revertedWith(P_IS_PAUSED);
|
||||
|
||||
// Unpause pool
|
||||
await configurator.setPoolPause(false);
|
||||
|
@ -370,7 +370,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
|
||||
await expect(
|
||||
pool.connect(user.signer).setUserUseReserveAsCollateral(weth.address, false)
|
||||
).revertedWith(IS_PAUSED);
|
||||
).revertedWith(P_IS_PAUSED);
|
||||
|
||||
// Unpause pool
|
||||
await configurator.setPoolPause(false);
|
||||
|
|
|
@ -37,7 +37,7 @@ export const expectRepayWithCollateralEvent = (
|
|||
};
|
||||
|
||||
makeSuite('LendingPool. repayWithCollateral()', (testEnv: TestEnv) => {
|
||||
const {IS_PAUSED} = ProtocolErrors;
|
||||
const {P_IS_PAUSED} = ProtocolErrors;
|
||||
it("It's not possible to repayWithCollateral() on a non-active collateral or a non active principal", async () => {
|
||||
const {configurator, weth, pool, users, dai, mockSwapAdapter} = testEnv;
|
||||
const user = users[1];
|
||||
|
|
|
@ -5,7 +5,7 @@ import {getContract} from '../helpers/contracts-helpers';
|
|||
import {StableDebtToken} from '../types/StableDebtToken';
|
||||
|
||||
makeSuite('Stable debt token tests', (testEnv: TestEnv) => {
|
||||
const {CALLER_MUST_BE_LENDING_POOL} = ProtocolErrors;
|
||||
const {AT_CALLER_MUST_BE_LENDING_POOL} = ProtocolErrors;
|
||||
|
||||
it('Tries to invoke mint not being the LendingPool', async () => {
|
||||
const {deployer, pool, dai} = testEnv;
|
||||
|
@ -19,7 +19,7 @@ makeSuite('Stable debt token tests', (testEnv: TestEnv) => {
|
|||
);
|
||||
|
||||
await expect(stableDebtContract.mint(deployer.address, '1', '1')).to.be.revertedWith(
|
||||
CALLER_MUST_BE_LENDING_POOL
|
||||
AT_CALLER_MUST_BE_LENDING_POOL
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -35,7 +35,7 @@ makeSuite('Stable debt token tests', (testEnv: TestEnv) => {
|
|||
);
|
||||
|
||||
await expect(stableDebtContract.burn(deployer.address, '1')).to.be.revertedWith(
|
||||
CALLER_MUST_BE_LENDING_POOL
|
||||
AT_CALLER_MUST_BE_LENDING_POOL
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@ import {MockVariableDebtToken} from '../types/MockVariableDebtToken';
|
|||
import {ZERO_ADDRESS} from '../helpers/constants';
|
||||
|
||||
makeSuite('Upgradeability', (testEnv: TestEnv) => {
|
||||
const {CALLER_NOT_AAVE_ADMIN} = ProtocolErrors;
|
||||
const {LPC_CALLER_NOT_AAVE_ADMIN} = ProtocolErrors;
|
||||
let newATokenAddress: string;
|
||||
let newStableTokenAddress: string;
|
||||
let newVariableTokenAddress: string;
|
||||
|
@ -61,7 +61,7 @@ makeSuite('Upgradeability', (testEnv: TestEnv) => {
|
|||
|
||||
await expect(
|
||||
configurator.connect(users[1].signer).updateAToken(dai.address, newATokenAddress)
|
||||
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||
).to.be.revertedWith(LPC_CALLER_NOT_AAVE_ADMIN);
|
||||
});
|
||||
|
||||
it('Upgrades the DAI Atoken implementation ', async () => {
|
||||
|
@ -83,7 +83,7 @@ makeSuite('Upgradeability', (testEnv: TestEnv) => {
|
|||
configurator
|
||||
.connect(users[1].signer)
|
||||
.updateStableDebtToken(dai.address, newStableTokenAddress)
|
||||
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||
).to.be.revertedWith(LPC_CALLER_NOT_AAVE_ADMIN);
|
||||
});
|
||||
|
||||
it('Upgrades the DAI stable debt token implementation ', async () => {
|
||||
|
@ -112,7 +112,7 @@ makeSuite('Upgradeability', (testEnv: TestEnv) => {
|
|||
configurator
|
||||
.connect(users[1].signer)
|
||||
.updateVariableDebtToken(dai.address, newVariableTokenAddress)
|
||||
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||
).to.be.revertedWith(LPC_CALLER_NOT_AAVE_ADMIN);
|
||||
});
|
||||
|
||||
it('Upgrades the DAI variable debt token implementation ', async () => {
|
||||
|
|
|
@ -5,7 +5,7 @@ import {getContract} from '../helpers/contracts-helpers';
|
|||
import {VariableDebtToken} from '../types/VariableDebtToken';
|
||||
|
||||
makeSuite('Variable debt token tests', (testEnv: TestEnv) => {
|
||||
const {CALLER_MUST_BE_LENDING_POOL} = ProtocolErrors;
|
||||
const {AT_CALLER_MUST_BE_LENDING_POOL} = ProtocolErrors;
|
||||
|
||||
it('Tries to invoke mint not being the LendingPool', async () => {
|
||||
const {deployer, pool, dai} = testEnv;
|
||||
|
@ -19,7 +19,7 @@ makeSuite('Variable debt token tests', (testEnv: TestEnv) => {
|
|||
);
|
||||
|
||||
await expect(variableDebtContract.mint(deployer.address, '1', '1')).to.be.revertedWith(
|
||||
CALLER_MUST_BE_LENDING_POOL
|
||||
AT_CALLER_MUST_BE_LENDING_POOL
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -35,7 +35,7 @@ makeSuite('Variable debt token tests', (testEnv: TestEnv) => {
|
|||
);
|
||||
|
||||
await expect(variableDebtContract.burn(deployer.address, '1', '1')).to.be.revertedWith(
|
||||
CALLER_MUST_BE_LENDING_POOL
|
||||
AT_CALLER_MUST_BE_LENDING_POOL
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user