mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
fixed PVE001, PVE009(1)
This commit is contained in:
parent
3575d58ff4
commit
19756cdbe8
|
@ -54,6 +54,8 @@ contract LendingPoolAddressesProviderRegistry is Ownable, ILendingPoolAddressesP
|
||||||
* @param provider the pool address to be registered
|
* @param provider the pool address to be registered
|
||||||
**/
|
**/
|
||||||
function registerAddressesProvider(address provider, uint256 id) external override onlyOwner {
|
function registerAddressesProvider(address provider, uint256 id) external override onlyOwner {
|
||||||
|
require(id != 0, Errors.INVALID_ADDRESSES_PROVIDER_ID);
|
||||||
|
|
||||||
_addressesProviders[provider] = id;
|
_addressesProviders[provider] = id;
|
||||||
_addToAddressesProvidersList(provider);
|
_addToAddressesProvidersList(provider);
|
||||||
emit AddressesProviderRegistered(provider);
|
emit AddressesProviderRegistered(provider);
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol';
|
import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol';
|
||||||
import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddressesProvider.sol';
|
import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddressesProvider.sol';
|
||||||
import {ILendingPool} from '../interfaces/ILendingPool.sol';
|
import {ILendingPool} from '../interfaces/ILendingPool.sol';
|
||||||
|
import {ITokenConfiguration} from '../tokenization/interfaces/ITokenConfiguration.sol';
|
||||||
import {IERC20Detailed} from '../dependencies/openzeppelin/contracts/IERC20Detailed.sol';
|
import {IERC20Detailed} from '../dependencies/openzeppelin/contracts/IERC20Detailed.sol';
|
||||||
import {Errors} from '../libraries/helpers/Errors.sol';
|
import {Errors} from '../libraries/helpers/Errors.sol';
|
||||||
import {ReserveLogic} from '../libraries/logic/ReserveLogic.sol';
|
import {ReserveLogic} from '../libraries/logic/ReserveLogic.sol';
|
||||||
|
@ -200,7 +201,6 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev initializes a reserve
|
* @dev initializes a reserve
|
||||||
* @param asset the address of the reserve to be initialized
|
|
||||||
* @param aTokenImpl the address of the aToken contract implementation
|
* @param aTokenImpl the address of the aToken contract implementation
|
||||||
* @param stableDebtTokenImpl the address of the stable debt token contract
|
* @param stableDebtTokenImpl the address of the stable debt token contract
|
||||||
* @param variableDebtTokenImpl the address of the variable debt token contract
|
* @param variableDebtTokenImpl the address of the variable debt token contract
|
||||||
|
@ -208,13 +208,35 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
* @param interestRateStrategyAddress the address of the interest rate strategy contract for this reserve
|
* @param interestRateStrategyAddress the address of the interest rate strategy contract for this reserve
|
||||||
**/
|
**/
|
||||||
function initReserve(
|
function initReserve(
|
||||||
address asset,
|
|
||||||
address aTokenImpl,
|
address aTokenImpl,
|
||||||
address stableDebtTokenImpl,
|
address stableDebtTokenImpl,
|
||||||
address variableDebtTokenImpl,
|
address variableDebtTokenImpl,
|
||||||
uint8 underlyingAssetDecimals,
|
uint8 underlyingAssetDecimals,
|
||||||
address interestRateStrategyAddress
|
address interestRateStrategyAddress
|
||||||
) public onlyAaveAdmin {
|
) public onlyAaveAdmin {
|
||||||
|
address asset = ITokenConfiguration(aTokenImpl).UNDERLYING_ASSET_ADDRESS();
|
||||||
|
|
||||||
|
require(
|
||||||
|
address(pool) == ITokenConfiguration(aTokenImpl).POOL(),
|
||||||
|
Errors.INVALID_ATOKEN_POOL_ADDRESS
|
||||||
|
);
|
||||||
|
require(
|
||||||
|
address(pool) == ITokenConfiguration(stableDebtTokenImpl).POOL(),
|
||||||
|
Errors.INVALID_STABLE_DEBT_TOKEN_POOL_ADDRESS
|
||||||
|
);
|
||||||
|
require(
|
||||||
|
address(pool) == ITokenConfiguration(variableDebtTokenImpl).POOL(),
|
||||||
|
Errors.INVALID_VARIABLE_DEBT_TOKEN_POOL_ADDRESS
|
||||||
|
);
|
||||||
|
require(
|
||||||
|
asset == ITokenConfiguration(stableDebtTokenImpl).UNDERLYING_ASSET_ADDRESS(),
|
||||||
|
Errors.INVALID_STABLE_DEBT_TOKEN_UNDERLYING_ADDRESS
|
||||||
|
);
|
||||||
|
require(
|
||||||
|
asset == ITokenConfiguration(variableDebtTokenImpl).UNDERLYING_ASSET_ADDRESS(),
|
||||||
|
Errors.INVALID_VARIABLE_DEBT_TOKEN_UNDERLYING_ADDRESS
|
||||||
|
);
|
||||||
|
|
||||||
address aTokenProxyAddress = _initTokenWithProxy(aTokenImpl, underlyingAssetDecimals);
|
address aTokenProxyAddress = _initTokenWithProxy(aTokenImpl, underlyingAssetDecimals);
|
||||||
|
|
||||||
address stableDebtTokenProxyAddress = _initTokenWithProxy(
|
address stableDebtTokenProxyAddress = _initTokenWithProxy(
|
||||||
|
|
|
@ -50,8 +50,8 @@ library Errors {
|
||||||
string public constant CALLER_MUST_BE_LENDING_POOL = '28'; // 'The caller of this function must be a lending pool'
|
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 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 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_MINT_AMOUNT = '61'; //invalid amount to mint
|
||||||
string public constant INVALID_BURN_AMOUNT = '54'; //invalid amount to burn
|
string public constant INVALID_BURN_AMOUNT = '62'; //invalid amount to burn
|
||||||
|
|
||||||
// require error messages - ReserveLogic
|
// require error messages - ReserveLogic
|
||||||
string public constant RESERVE_ALREADY_INITIALIZED = '34'; // 'Reserve has already been initialized'
|
string public constant RESERVE_ALREADY_INITIALIZED = '34'; // 'Reserve has already been initialized'
|
||||||
|
@ -64,9 +64,15 @@ library Errors {
|
||||||
//require error messages - LendingPoolConfiguration
|
//require error messages - LendingPoolConfiguration
|
||||||
string public constant CALLER_NOT_AAVE_ADMIN = '35'; // 'The caller must be the aave admin'
|
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'
|
string public constant RESERVE_LIQUIDITY_NOT_0 = '36'; // 'The liquidity of the reserve needs to be 0'
|
||||||
|
string public constant INVALID_ATOKEN_POOL_ADDRESS = '63'; // the lending pool in the aToken implementation is not configured correctly
|
||||||
|
string public constant INVALID_STABLE_DEBT_TOKEN_POOL_ADDRESS = '64'; // the lending pool in the stable debt token implementation is not configured correctly
|
||||||
|
string public constant INVALID_VARIABLE_DEBT_TOKEN_POOL_ADDRESS = '65'; // the lending pool in the variable debt token implementation is not configured correctly
|
||||||
|
string public constant INVALID_STABLE_DEBT_TOKEN_UNDERLYING_ADDRESS = '66'; // the underlying asset in the stable debt token implementation is not configured correctly
|
||||||
|
string public constant INVALID_VARIABLE_DEBT_TOKEN_UNDERLYING_ADDRESS = '67'; // the underlying asset in the variable debt token implementation is not configured correctly
|
||||||
|
|
||||||
//require error messages - LendingPoolAddressesProviderRegistry
|
//require error messages - LendingPoolAddressesProviderRegistry
|
||||||
string public constant PROVIDER_NOT_REGISTERED = '37'; // 'Provider is not registered'
|
string public constant PROVIDER_NOT_REGISTERED = '37'; // 'Provider is not registered'
|
||||||
|
string public constant INVALID_ADDRESSES_PROVIDER_ID = '68'; // the addresses provider id needs to be greater than 0
|
||||||
|
|
||||||
//return error messages - LendingPoolCollateralManager
|
//return error messages - LendingPoolCollateralManager
|
||||||
string public constant HEALTH_FACTOR_NOT_BELOW_THRESHOLD = '38'; // 'Health factor is not below the threshold'
|
string public constant HEALTH_FACTOR_NOT_BELOW_THRESHOLD = '38'; // 'Health factor is not below the threshold'
|
||||||
|
|
13
contracts/tokenization/interfaces/ITokenConfiguration.sol
Normal file
13
contracts/tokenization/interfaces/ITokenConfiguration.sol
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
pragma solidity ^0.6;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title ITokenConfiguration
|
||||||
|
* @author Aave
|
||||||
|
* @dev common interface between aTokens and debt tokens to fetch the
|
||||||
|
* token configuration
|
||||||
|
**/
|
||||||
|
interface ITokenConfiguration {
|
||||||
|
function UNDERLYING_ASSET_ADDRESS() external view returns (address);
|
||||||
|
|
||||||
|
function POOL() external view returns (address);
|
||||||
|
}
|
|
@ -857,7 +857,6 @@ export const initReserves = async (
|
||||||
|
|
||||||
console.log('init reserve currency ', assetSymbol);
|
console.log('init reserve currency ', assetSymbol);
|
||||||
await lendingPoolConfigurator.initReserve(
|
await lendingPoolConfigurator.initReserve(
|
||||||
tokenAddress,
|
|
||||||
aToken.address,
|
aToken.address,
|
||||||
stableDebtToken.address,
|
stableDebtToken.address,
|
||||||
variableDebtToken.address,
|
variableDebtToken.address,
|
||||||
|
|
|
@ -106,6 +106,7 @@ export enum ProtocolErrors {
|
||||||
|
|
||||||
//require error messages - LendingPoolAddressesProviderRegistry
|
//require error messages - LendingPoolAddressesProviderRegistry
|
||||||
PROVIDER_NOT_REGISTERED = '37', // 'Provider is not registered'
|
PROVIDER_NOT_REGISTERED = '37', // 'Provider is not registered'
|
||||||
|
INVALID_ADDRESSES_PROVIDER_ID = '68',
|
||||||
|
|
||||||
//return error messages - LendingPoolCollateralManager
|
//return error messages - LendingPoolCollateralManager
|
||||||
HEALTH_FACTOR_NOT_BELOW_THRESHOLD = '38', // 'Health factor is not below the threshold'
|
HEALTH_FACTOR_NOT_BELOW_THRESHOLD = '38', // 'Health factor is not below the threshold'
|
||||||
|
|
|
@ -18,6 +18,15 @@ makeSuite('AddressesProviderRegistry', (testEnv: TestEnv) => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('tries to register an addresses provider with id 0', async () => {
|
||||||
|
const {users, registry} = testEnv;
|
||||||
|
const {INVALID_ADDRESSES_PROVIDER_ID} = ProtocolErrors;
|
||||||
|
|
||||||
|
await expect(registry.registerAddressesProvider(users[2].address, '0')).to.be.revertedWith(
|
||||||
|
INVALID_ADDRESSES_PROVIDER_ID
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('Registers a new mock addresses provider', async () => {
|
it('Registers a new mock addresses provider', async () => {
|
||||||
const {users, registry} = testEnv;
|
const {users, registry} = testEnv;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user