mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Fix conflicts and renamings
This commit is contained in:
commit
ffc81df4ee
|
@ -4,7 +4,7 @@ import {usePlugin} from '@nomiclabs/buidler/config';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import {accounts} from './test-wallets.js';
|
import {accounts} from './test-wallets.js';
|
||||||
import {eEthereumNetwork} from './helpers/types';
|
import {eEthereumNetwork} from './helpers/types';
|
||||||
import {BUIDLEREVM_CHAINID, COVERAGE_CHAINID} from './helpers/constants';
|
import {BUIDLEREVM_CHAINID, COVERAGE_CHAINID} from './helpers/buidler-constants';
|
||||||
|
|
||||||
usePlugin('@nomiclabs/buidler-ethers');
|
usePlugin('@nomiclabs/buidler-ethers');
|
||||||
usePlugin('buidler-typechain');
|
usePlugin('buidler-typechain');
|
||||||
|
@ -14,17 +14,16 @@ usePlugin('@nomiclabs/buidler-etherscan');
|
||||||
//usePlugin('buidler-gas-reporter');
|
//usePlugin('buidler-gas-reporter');
|
||||||
|
|
||||||
const SKIP_LOAD = process.env.SKIP_LOAD === 'true';
|
const SKIP_LOAD = process.env.SKIP_LOAD === 'true';
|
||||||
|
const DEFAULT_BLOCK_GAS_LIMIT = 12500000;
|
||||||
const DEFAULT_BLOCK_GAS_LIMIT = 10000000;
|
const DEFAULT_GAS_PRICE = 1;
|
||||||
const DEFAULT_GAS_PRICE = 10;
|
|
||||||
const HARDFORK = 'istanbul';
|
const HARDFORK = 'istanbul';
|
||||||
const INFURA_KEY = '';
|
const INFURA_KEY = process.env.INFURA_KEY || '';
|
||||||
const ETHERSCAN_KEY = '';
|
const ETHERSCAN_KEY = process.env.ETHERSCAN_KEY || '';
|
||||||
const MNEMONIC_PATH = "m/44'/60'/0'/0";
|
const MNEMONIC_PATH = "m/44'/60'/0'/0";
|
||||||
const MNEMONICS: {[network: string]: string} = {
|
const MNEMONICS: {[network: string]: string} = {
|
||||||
[eEthereumNetwork.kovan]: '',
|
[eEthereumNetwork.kovan]: process.env.MNEMONIC || '',
|
||||||
[eEthereumNetwork.ropsten]: '',
|
[eEthereumNetwork.ropsten]: process.env.MNEMONIC || '',
|
||||||
[eEthereumNetwork.main]: '',
|
[eEthereumNetwork.main]: process.env.MNEMONIC || '',
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prevent to load scripts before compilation and typechain
|
// Prevent to load scripts before compilation and typechain
|
||||||
|
@ -64,7 +63,6 @@ const buidlerConfig: any = {
|
||||||
target: 'ethers-v4',
|
target: 'ethers-v4',
|
||||||
},
|
},
|
||||||
etherscan: {
|
etherscan: {
|
||||||
url: 'https://api-kovan.etherscan.io/api',
|
|
||||||
apiKey: ETHERSCAN_KEY,
|
apiKey: ETHERSCAN_KEY,
|
||||||
},
|
},
|
||||||
defaultNetwork: 'buidlerevm',
|
defaultNetwork: 'buidlerevm',
|
||||||
|
|
|
@ -119,14 +119,14 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
// ----------------
|
// ----------------
|
||||||
|
|
||||||
// If lendingPoolManagerAddress is set, will take priority over lendingPoolManagerAddressIndex
|
// If lendingPoolManagerAddress is set, will take priority over lendingPoolManagerAddressIndex
|
||||||
LendingPoolManagerAddress: {
|
AaveAdmin: {
|
||||||
[eEthereumNetwork.coverage]: undefined,
|
[eEthereumNetwork.coverage]: undefined,
|
||||||
[eEthereumNetwork.buidlerevm]: undefined,
|
[eEthereumNetwork.buidlerevm]: undefined,
|
||||||
[eEthereumNetwork.kovan]: undefined,
|
[eEthereumNetwork.kovan]: undefined,
|
||||||
[eEthereumNetwork.ropsten]: undefined,
|
[eEthereumNetwork.ropsten]: undefined,
|
||||||
[eEthereumNetwork.main]: undefined,
|
[eEthereumNetwork.main]: undefined,
|
||||||
},
|
},
|
||||||
LendingPoolManagerAddressIndex: 0,
|
AaveAdminIndex: 0,
|
||||||
ProviderRegistry: {
|
ProviderRegistry: {
|
||||||
[eEthereumNetwork.kovan]: '',
|
[eEthereumNetwork.kovan]: '',
|
||||||
[eEthereumNetwork.ropsten]: '',
|
[eEthereumNetwork.ropsten]: '',
|
||||||
|
|
|
@ -21,8 +21,8 @@ contract LendingPoolAddressesProvider is Ownable, ILendingPoolAddressesProvider
|
||||||
bytes32 private constant LENDING_POOL = 'LENDING_POOL';
|
bytes32 private constant LENDING_POOL = 'LENDING_POOL';
|
||||||
bytes32 private constant LENDING_POOL_CORE = 'LENDING_POOL_CORE';
|
bytes32 private constant LENDING_POOL_CORE = 'LENDING_POOL_CORE';
|
||||||
bytes32 private constant LENDING_POOL_CONFIGURATOR = 'LENDING_POOL_CONFIGURATOR';
|
bytes32 private constant LENDING_POOL_CONFIGURATOR = 'LENDING_POOL_CONFIGURATOR';
|
||||||
bytes32 private constant LENDING_POOL_MANAGER = 'LENDING_POOL_MANAGER';
|
bytes32 private constant AAVE_ADMIN = 'AAVE_ADMIN';
|
||||||
bytes32 private constant LENDING_POOL_LIQUIDATION_MANAGER = 'LIQUIDATION_MANAGER';
|
bytes32 private constant LENDING_POOL_COLLATERAL_MANAGER = 'COLLATERAL_MANAGER';
|
||||||
bytes32 private constant LENDING_POOL_FLASHLOAN_PROVIDER = 'FLASHLOAN_PROVIDER';
|
bytes32 private constant LENDING_POOL_FLASHLOAN_PROVIDER = 'FLASHLOAN_PROVIDER';
|
||||||
bytes32 private constant DATA_PROVIDER = 'DATA_PROVIDER';
|
bytes32 private constant DATA_PROVIDER = 'DATA_PROVIDER';
|
||||||
bytes32 private constant ETHEREUM_ADDRESS = 'ETHEREUM_ADDRESS';
|
bytes32 private constant ETHEREUM_ADDRESS = 'ETHEREUM_ADDRESS';
|
||||||
|
@ -65,23 +65,23 @@ contract LendingPoolAddressesProvider is Ownable, ILendingPoolAddressesProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev returns the address of the LendingPoolLiquidationManager. Since the manager is used
|
* @dev returns the address of the LendingPoolCollateralManager. Since the manager is used
|
||||||
* through delegateCall within the LendingPool contract, the proxy contract pattern does not work properly hence
|
* through delegateCall within the LendingPool contract, the proxy contract pattern does not work properly hence
|
||||||
* the addresses are changed directly.
|
* the addresses are changed directly.
|
||||||
* @return the address of the Lending pool liquidation manager
|
* @return the address of the Lending pool collateral manager
|
||||||
**/
|
**/
|
||||||
|
|
||||||
function getLendingPoolLiquidationManager() external override view returns (address) {
|
function getLendingPoolCollateralManager() external override view returns (address) {
|
||||||
return _addresses[LENDING_POOL_LIQUIDATION_MANAGER];
|
return _addresses[LENDING_POOL_COLLATERAL_MANAGER];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev updates the address of the Lending pool liquidation manager
|
* @dev updates the address of the Lending pool collateral manager
|
||||||
* @param manager the new lending pool liquidation manager address
|
* @param manager the new lending pool collateral manager address
|
||||||
**/
|
**/
|
||||||
function setLendingPoolLiquidationManager(address manager) external override onlyOwner {
|
function setLendingPoolCollateralManager(address manager) external override onlyOwner {
|
||||||
_addresses[LENDING_POOL_LIQUIDATION_MANAGER] = manager;
|
_addresses[LENDING_POOL_COLLATERAL_MANAGER] = manager;
|
||||||
emit LendingPoolLiquidationManagerUpdated(manager);
|
emit LendingPoolCollateralManagerUpdated(manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,13 +89,13 @@ contract LendingPoolAddressesProvider is Ownable, ILendingPoolAddressesProvider
|
||||||
* hence the upgradable proxy pattern is not used
|
* hence the upgradable proxy pattern is not used
|
||||||
**/
|
**/
|
||||||
|
|
||||||
function getLendingPoolManager() external override view returns (address) {
|
function getAaveAdmin() external override view returns (address) {
|
||||||
return _addresses[LENDING_POOL_MANAGER];
|
return _addresses[AAVE_ADMIN];
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLendingPoolManager(address lendingPoolManager) external override onlyOwner {
|
function setAaveAdmin(address aaveAdmin) external override onlyOwner {
|
||||||
_addresses[LENDING_POOL_MANAGER] = lendingPoolManager;
|
_addresses[AAVE_ADMIN] = aaveAdmin;
|
||||||
emit LendingPoolManagerUpdated(lendingPoolManager);
|
emit AaveAdminUpdated(aaveAdmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPriceOracle() external override view returns (address) {
|
function getPriceOracle() external override view returns (address) {
|
||||||
|
|
11
contracts/interfaces/IAaveIncentivesController.sol
Normal file
11
contracts/interfaces/IAaveIncentivesController.sol
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
// SPDX-License-Identifier: agpl-3.0
|
||||||
|
pragma solidity 0.6.8;
|
||||||
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
|
interface IAaveIncentivesController {
|
||||||
|
function handleAction(
|
||||||
|
address user,
|
||||||
|
uint256 userBalance,
|
||||||
|
uint256 totalSupply
|
||||||
|
) external;
|
||||||
|
}
|
|
@ -111,7 +111,7 @@ interface ILendingPool {
|
||||||
);
|
);
|
||||||
/**
|
/**
|
||||||
* @dev these events are not emitted directly by the LendingPool
|
* @dev these events are not emitted directly by the LendingPool
|
||||||
* but they are declared here as the LendingPoolLiquidationManager
|
* but they are declared here as the LendingPoolCollateralManager
|
||||||
* is executed using a delegateCall().
|
* is executed using a delegateCall().
|
||||||
* This allows to have the events in the generated ABI for LendingPool.
|
* This allows to have the events in the generated ABI for LendingPool.
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -9,9 +9,9 @@ pragma solidity ^0.6.8;
|
||||||
interface ILendingPoolAddressesProvider {
|
interface ILendingPoolAddressesProvider {
|
||||||
//events
|
//events
|
||||||
event LendingPoolUpdated(address indexed newAddress);
|
event LendingPoolUpdated(address indexed newAddress);
|
||||||
event LendingPoolManagerUpdated(address indexed newAddress);
|
event AaveAdminUpdated(address indexed newAddress);
|
||||||
event LendingPoolConfiguratorUpdated(address indexed newAddress);
|
event LendingPoolConfiguratorUpdated(address indexed newAddress);
|
||||||
event LendingPoolLiquidationManagerUpdated(address indexed newAddress);
|
event LendingPoolCollateralManagerUpdated(address indexed newAddress);
|
||||||
event EthereumAddressUpdated(address indexed newAddress);
|
event EthereumAddressUpdated(address indexed newAddress);
|
||||||
event PriceOracleUpdated(address indexed newAddress);
|
event PriceOracleUpdated(address indexed newAddress);
|
||||||
event LendingRateOracleUpdated(address indexed newAddress);
|
event LendingRateOracleUpdated(address indexed newAddress);
|
||||||
|
@ -26,13 +26,13 @@ interface ILendingPoolAddressesProvider {
|
||||||
|
|
||||||
function setLendingPoolConfiguratorImpl(address configurator) external;
|
function setLendingPoolConfiguratorImpl(address configurator) external;
|
||||||
|
|
||||||
function getLendingPoolLiquidationManager() external view returns (address);
|
function getLendingPoolCollateralManager() external view returns (address);
|
||||||
|
|
||||||
function setLendingPoolLiquidationManager(address manager) external;
|
function setLendingPoolCollateralManager(address manager) external;
|
||||||
|
|
||||||
function getLendingPoolManager() external view returns (address);
|
function getAaveAdmin() external view returns (address);
|
||||||
|
|
||||||
function setLendingPoolManager(address lendingPoolManager) external;
|
function setAaveAdmin(address aaveAdmin) external;
|
||||||
|
|
||||||
function getPriceOracle() external view returns (address);
|
function getPriceOracle() external view returns (address);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import {IStableDebtToken} from '../tokenization/interfaces/IStableDebtToken.sol'
|
||||||
import {IVariableDebtToken} from '../tokenization/interfaces/IVariableDebtToken.sol';
|
import {IVariableDebtToken} from '../tokenization/interfaces/IVariableDebtToken.sol';
|
||||||
import {IFlashLoanReceiver} from '../flashloan/interfaces/IFlashLoanReceiver.sol';
|
import {IFlashLoanReceiver} from '../flashloan/interfaces/IFlashLoanReceiver.sol';
|
||||||
import {ISwapAdapter} from '../interfaces/ISwapAdapter.sol';
|
import {ISwapAdapter} from '../interfaces/ISwapAdapter.sol';
|
||||||
import {LendingPoolLiquidationManager} from './LendingPoolLiquidationManager.sol';
|
import {LendingPoolCollateralManager} from './LendingPoolCollateralManager.sol';
|
||||||
import {IPriceOracleGetter} from '../interfaces/IPriceOracleGetter.sol';
|
import {IPriceOracleGetter} from '../interfaces/IPriceOracleGetter.sol';
|
||||||
import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol';
|
import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol';
|
||||||
import {ILendingPool} from '../interfaces/ILendingPool.sol';
|
import {ILendingPool} from '../interfaces/ILendingPool.sol';
|
||||||
|
@ -451,10 +451,10 @@ contract LendingPool is VersionedInitializable, ILendingPool {
|
||||||
bool receiveAToken
|
bool receiveAToken
|
||||||
) external override {
|
) external override {
|
||||||
whenNotPaused();
|
whenNotPaused();
|
||||||
address liquidationManager = _addressesProvider.getLendingPoolLiquidationManager();
|
address collateralManager = _addressesProvider.getLendingPoolCollateralManager();
|
||||||
|
|
||||||
//solium-disable-next-line
|
//solium-disable-next-line
|
||||||
(bool success, bytes memory result) = liquidationManager.delegatecall(
|
(bool success, bytes memory result) = collateralManager.delegatecall(
|
||||||
abi.encodeWithSignature(
|
abi.encodeWithSignature(
|
||||||
'liquidationCall(address,address,address,uint256,bool)',
|
'liquidationCall(address,address,address,uint256,bool)',
|
||||||
collateral,
|
collateral,
|
||||||
|
@ -511,10 +511,10 @@ contract LendingPool is VersionedInitializable, ILendingPool {
|
||||||
require(!_flashLiquidationLocked, Errors.REENTRANCY_NOT_ALLOWED);
|
require(!_flashLiquidationLocked, Errors.REENTRANCY_NOT_ALLOWED);
|
||||||
_flashLiquidationLocked = true;
|
_flashLiquidationLocked = true;
|
||||||
|
|
||||||
address liquidationManager = _addressesProvider.getLendingPoolLiquidationManager();
|
address collateralManager = _addressesProvider.getLendingPoolCollateralManager();
|
||||||
|
|
||||||
//solium-disable-next-line
|
//solium-disable-next-line
|
||||||
(bool success, bytes memory result) = liquidationManager.delegatecall(
|
(bool success, bytes memory result) = collateralManager.delegatecall(
|
||||||
abi.encodeWithSignature(
|
abi.encodeWithSignature(
|
||||||
'repayWithCollateral(address,address,address,uint256,address,bytes)',
|
'repayWithCollateral(address,address,address,uint256,address,bytes)',
|
||||||
collateral,
|
collateral,
|
||||||
|
@ -618,10 +618,10 @@ contract LendingPool is VersionedInitializable, ILendingPool {
|
||||||
bytes calldata params
|
bytes calldata params
|
||||||
) external override {
|
) external override {
|
||||||
whenNotPaused();
|
whenNotPaused();
|
||||||
address liquidationManager = _addressesProvider.getLendingPoolLiquidationManager();
|
address collateralManager = _addressesProvider.getLendingPoolCollateralManager();
|
||||||
|
|
||||||
//solium-disable-next-line
|
//solium-disable-next-line
|
||||||
(bool success, bytes memory result) = liquidationManager.delegatecall(
|
(bool success, bytes memory result) = collateralManager.delegatecall(
|
||||||
abi.encodeWithSignature(
|
abi.encodeWithSignature(
|
||||||
'swapLiquidity(address,address,address,uint256,bytes)',
|
'swapLiquidity(address,address,address,uint256,bytes)',
|
||||||
receiverAddress,
|
receiverAddress,
|
||||||
|
|
|
@ -24,12 +24,13 @@ import {Errors} from '../libraries/helpers/Errors.sol';
|
||||||
import {ValidationLogic} from '../libraries/logic/ValidationLogic.sol';
|
import {ValidationLogic} from '../libraries/logic/ValidationLogic.sol';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title LendingPoolLiquidationManager contract
|
* @title LendingPoolCollateralManager contract
|
||||||
* @author Aave
|
* @author Aave
|
||||||
* @notice Implements the liquidation function.
|
* @notice Implements actions involving management of collateral in the protocol.
|
||||||
* @dev LendingPoolLiquidationManager inherits Pausable from OpenZeppelin to have the same storage layout as LendingPool
|
* @notice this contract will be ran always through delegatecall
|
||||||
|
* @dev LendingPoolCollateralManager inherits VersionedInitializable from OpenZeppelin to have the same storage layout as LendingPool
|
||||||
**/
|
**/
|
||||||
contract LendingPoolLiquidationManager is VersionedInitializable {
|
contract LendingPoolCollateralManager is VersionedInitializable {
|
||||||
using SafeERC20 for IERC20;
|
using SafeERC20 for IERC20;
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
using WadRayMath for uint256;
|
using WadRayMath for uint256;
|
||||||
|
@ -185,7 +186,7 @@ contract LendingPoolLiquidationManager is VersionedInitializable {
|
||||||
vars.userVariableDebt
|
vars.userVariableDebt
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Errors.LiquidationErrors(vars.errorCode) != Errors.LiquidationErrors.NO_ERROR) {
|
if (Errors.CollateralManagerErrors(vars.errorCode) != Errors.CollateralManagerErrors.NO_ERROR) {
|
||||||
return (vars.errorCode, vars.errorMsg);
|
return (vars.errorCode, vars.errorMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +229,7 @@ contract LendingPoolLiquidationManager is VersionedInitializable {
|
||||||
);
|
);
|
||||||
if (currentAvailableCollateral < vars.maxCollateralToLiquidate) {
|
if (currentAvailableCollateral < vars.maxCollateralToLiquidate) {
|
||||||
return (
|
return (
|
||||||
uint256(Errors.LiquidationErrors.NOT_ENOUGH_LIQUIDITY),
|
uint256(Errors.CollateralManagerErrors.NOT_ENOUGH_LIQUIDITY),
|
||||||
Errors.NOT_ENOUGH_LIQUIDITY_TO_LIQUIDATE
|
Errors.NOT_ENOUGH_LIQUIDITY_TO_LIQUIDATE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -300,7 +301,7 @@ contract LendingPoolLiquidationManager is VersionedInitializable {
|
||||||
receiveAToken
|
receiveAToken
|
||||||
);
|
);
|
||||||
|
|
||||||
return (uint256(Errors.LiquidationErrors.NO_ERROR), Errors.NO_ERRORS);
|
return (uint256(Errors.CollateralManagerErrors.NO_ERROR), Errors.NO_ERRORS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -349,7 +350,7 @@ contract LendingPoolLiquidationManager is VersionedInitializable {
|
||||||
vars.userVariableDebt
|
vars.userVariableDebt
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Errors.LiquidationErrors(vars.errorCode) != Errors.LiquidationErrors.NO_ERROR) {
|
if (Errors.CollateralManagerErrors(vars.errorCode) != Errors.CollateralManagerErrors.NO_ERROR) {
|
||||||
return (vars.errorCode, vars.errorMsg);
|
return (vars.errorCode, vars.errorMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,7 +446,7 @@ contract LendingPoolLiquidationManager is VersionedInitializable {
|
||||||
vars.maxCollateralToLiquidate
|
vars.maxCollateralToLiquidate
|
||||||
);
|
);
|
||||||
|
|
||||||
return (uint256(Errors.LiquidationErrors.NO_ERROR), Errors.NO_ERRORS);
|
return (uint256(Errors.CollateralManagerErrors.NO_ERROR), Errors.NO_ERRORS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -476,7 +477,7 @@ contract LendingPoolLiquidationManager is VersionedInitializable {
|
||||||
toAsset
|
toAsset
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Errors.LiquidationErrors(vars.errorCode) != Errors.LiquidationErrors.NO_ERROR) {
|
if (Errors.CollateralManagerErrors(vars.errorCode) != Errors.CollateralManagerErrors.NO_ERROR) {
|
||||||
return (vars.errorCode, vars.errorMsg);
|
return (vars.errorCode, vars.errorMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,6 +515,11 @@ contract LendingPoolLiquidationManager is VersionedInitializable {
|
||||||
address(vars.toReserveAToken),
|
address(vars.toReserveAToken),
|
||||||
vars.amountToReceive
|
vars.amountToReceive
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (vars.toReserveAToken.balanceOf(msg.sender) == 0) {
|
||||||
|
usersConfig[msg.sender].setUsingAsCollateral(toReserve.id, true);
|
||||||
|
}
|
||||||
|
|
||||||
vars.toReserveAToken.mint(msg.sender, vars.amountToReceive, toReserve.liquidityIndex);
|
vars.toReserveAToken.mint(msg.sender, vars.amountToReceive, toReserve.liquidityIndex);
|
||||||
toReserve.updateInterestRates(
|
toReserve.updateInterestRates(
|
||||||
toAsset,
|
toAsset,
|
||||||
|
@ -533,12 +539,12 @@ contract LendingPoolLiquidationManager is VersionedInitializable {
|
||||||
|
|
||||||
if (vars.healthFactor < GenericLogic.HEALTH_FACTOR_LIQUIDATION_THRESHOLD) {
|
if (vars.healthFactor < GenericLogic.HEALTH_FACTOR_LIQUIDATION_THRESHOLD) {
|
||||||
return (
|
return (
|
||||||
uint256(Errors.LiquidationErrors.HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD),
|
uint256(Errors.CollateralManagerErrors.HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD),
|
||||||
Errors.HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD
|
Errors.HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (uint256(Errors.LiquidationErrors.NO_ERROR), Errors.NO_ERRORS);
|
return (uint256(Errors.CollateralManagerErrors.NO_ERROR), Errors.NO_ERRORS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -176,11 +176,8 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
/**
|
/**
|
||||||
* @dev only the lending pool manager can call functions affected by this modifier
|
* @dev only the lending pool manager can call functions affected by this modifier
|
||||||
**/
|
**/
|
||||||
modifier onlyLendingPoolManager {
|
modifier onlyAaveAdmin {
|
||||||
require(
|
require(addressesProvider.getAaveAdmin() == msg.sender, Errors.CALLER_NOT_AAVE_ADMIN);
|
||||||
addressesProvider.getLendingPoolManager() == msg.sender,
|
|
||||||
Errors.CALLER_NOT_LENDING_POOL_MANAGER
|
|
||||||
);
|
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +208,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
address variableDebtTokenImpl,
|
address variableDebtTokenImpl,
|
||||||
uint8 underlyingAssetDecimals,
|
uint8 underlyingAssetDecimals,
|
||||||
address interestRateStrategyAddress
|
address interestRateStrategyAddress
|
||||||
) public onlyLendingPoolManager {
|
) public onlyAaveAdmin {
|
||||||
address aTokenProxyAddress = _initTokenWithProxy(aTokenImpl, underlyingAssetDecimals);
|
address aTokenProxyAddress = _initTokenWithProxy(aTokenImpl, underlyingAssetDecimals);
|
||||||
|
|
||||||
address stableDebtTokenProxyAddress = _initTokenWithProxy(
|
address stableDebtTokenProxyAddress = _initTokenWithProxy(
|
||||||
|
@ -255,7 +252,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
* @param asset the address of the reserve to be updated
|
* @param asset the address of the reserve to be updated
|
||||||
* @param implementation the address of the new aToken implementation
|
* @param implementation the address of the new aToken implementation
|
||||||
**/
|
**/
|
||||||
function updateAToken(address asset, address implementation) external onlyLendingPoolManager {
|
function updateAToken(address asset, address implementation) external onlyAaveAdmin {
|
||||||
(address aTokenAddress, , ) = pool.getReserveTokensAddresses(asset);
|
(address aTokenAddress, , ) = pool.getReserveTokensAddresses(asset);
|
||||||
|
|
||||||
_upgradeTokenImplementation(asset, aTokenAddress, implementation);
|
_upgradeTokenImplementation(asset, aTokenAddress, implementation);
|
||||||
|
@ -268,10 +265,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
* @param asset the address of the reserve to be updated
|
* @param asset the address of the reserve to be updated
|
||||||
* @param implementation the address of the new aToken implementation
|
* @param implementation the address of the new aToken implementation
|
||||||
**/
|
**/
|
||||||
function updateStableDebtToken(address asset, address implementation)
|
function updateStableDebtToken(address asset, address implementation) external onlyAaveAdmin {
|
||||||
external
|
|
||||||
onlyLendingPoolManager
|
|
||||||
{
|
|
||||||
(, address stableDebtToken, ) = pool.getReserveTokensAddresses(asset);
|
(, address stableDebtToken, ) = pool.getReserveTokensAddresses(asset);
|
||||||
|
|
||||||
_upgradeTokenImplementation(asset, stableDebtToken, implementation);
|
_upgradeTokenImplementation(asset, stableDebtToken, implementation);
|
||||||
|
@ -284,10 +278,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
* @param asset the address of the reserve to be updated
|
* @param asset the address of the reserve to be updated
|
||||||
* @param implementation the address of the new aToken implementation
|
* @param implementation the address of the new aToken implementation
|
||||||
**/
|
**/
|
||||||
function updateVariableDebtToken(address asset, address implementation)
|
function updateVariableDebtToken(address asset, address implementation) external onlyAaveAdmin {
|
||||||
external
|
|
||||||
onlyLendingPoolManager
|
|
||||||
{
|
|
||||||
(, , address variableDebtToken) = pool.getReserveTokensAddresses(asset);
|
(, , address variableDebtToken) = pool.getReserveTokensAddresses(asset);
|
||||||
|
|
||||||
_upgradeTokenImplementation(asset, variableDebtToken, implementation);
|
_upgradeTokenImplementation(asset, variableDebtToken, implementation);
|
||||||
|
@ -302,7 +293,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
**/
|
**/
|
||||||
function enableBorrowingOnReserve(address asset, bool stableBorrowRateEnabled)
|
function enableBorrowingOnReserve(address asset, bool stableBorrowRateEnabled)
|
||||||
external
|
external
|
||||||
onlyLendingPoolManager
|
onlyAaveAdmin
|
||||||
{
|
{
|
||||||
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
||||||
|
|
||||||
|
@ -318,7 +309,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
* @dev disables borrowing on a reserve
|
* @dev disables borrowing on a reserve
|
||||||
* @param asset the address of the reserve
|
* @param asset the address of the reserve
|
||||||
**/
|
**/
|
||||||
function disableBorrowingOnReserve(address asset) external onlyLendingPoolManager {
|
function disableBorrowingOnReserve(address asset) external onlyAaveAdmin {
|
||||||
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
||||||
|
|
||||||
currentConfig.setBorrowingEnabled(false);
|
currentConfig.setBorrowingEnabled(false);
|
||||||
|
@ -339,7 +330,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
uint256 ltv,
|
uint256 ltv,
|
||||||
uint256 liquidationThreshold,
|
uint256 liquidationThreshold,
|
||||||
uint256 liquidationBonus
|
uint256 liquidationBonus
|
||||||
) external onlyLendingPoolManager {
|
) external onlyAaveAdmin {
|
||||||
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
||||||
|
|
||||||
currentConfig.setLtv(ltv);
|
currentConfig.setLtv(ltv);
|
||||||
|
@ -355,7 +346,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
* @dev disables a reserve as collateral
|
* @dev disables a reserve as collateral
|
||||||
* @param asset the address of the reserve
|
* @param asset the address of the reserve
|
||||||
**/
|
**/
|
||||||
function disableReserveAsCollateral(address asset) external onlyLendingPoolManager {
|
function disableReserveAsCollateral(address asset) external onlyAaveAdmin {
|
||||||
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
||||||
|
|
||||||
currentConfig.setLtv(0);
|
currentConfig.setLtv(0);
|
||||||
|
@ -369,7 +360,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
* @dev enable stable rate borrowing on a reserve
|
* @dev enable stable rate borrowing on a reserve
|
||||||
* @param asset the address of the reserve
|
* @param asset the address of the reserve
|
||||||
**/
|
**/
|
||||||
function enableReserveStableRate(address asset) external onlyLendingPoolManager {
|
function enableReserveStableRate(address asset) external onlyAaveAdmin {
|
||||||
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
||||||
|
|
||||||
currentConfig.setStableRateBorrowingEnabled(true);
|
currentConfig.setStableRateBorrowingEnabled(true);
|
||||||
|
@ -383,7 +374,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
* @dev disable stable rate borrowing on a reserve
|
* @dev disable stable rate borrowing on a reserve
|
||||||
* @param asset the address of the reserve
|
* @param asset the address of the reserve
|
||||||
**/
|
**/
|
||||||
function disableReserveStableRate(address asset) external onlyLendingPoolManager {
|
function disableReserveStableRate(address asset) external onlyAaveAdmin {
|
||||||
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
||||||
|
|
||||||
currentConfig.setStableRateBorrowingEnabled(false);
|
currentConfig.setStableRateBorrowingEnabled(false);
|
||||||
|
@ -397,7 +388,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
* @dev activates a reserve
|
* @dev activates a reserve
|
||||||
* @param asset the address of the reserve
|
* @param asset the address of the reserve
|
||||||
**/
|
**/
|
||||||
function activateReserve(address asset) external onlyLendingPoolManager {
|
function activateReserve(address asset) external onlyAaveAdmin {
|
||||||
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
||||||
|
|
||||||
currentConfig.setActive(true);
|
currentConfig.setActive(true);
|
||||||
|
@ -411,7 +402,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
* @dev deactivates a reserve
|
* @dev deactivates a reserve
|
||||||
* @param asset the address of the reserve
|
* @param asset the address of the reserve
|
||||||
**/
|
**/
|
||||||
function deactivateReserve(address asset) external onlyLendingPoolManager {
|
function deactivateReserve(address asset) external onlyAaveAdmin {
|
||||||
(
|
(
|
||||||
uint256 availableLiquidity,
|
uint256 availableLiquidity,
|
||||||
uint256 totalBorrowsStable,
|
uint256 totalBorrowsStable,
|
||||||
|
@ -442,7 +433,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
* @dev freezes a reserve. A freezed reserve doesn't accept any new deposit, borrow or rate swap, but can accept repayments, liquidations, rate rebalances and redeems
|
* @dev freezes a reserve. A freezed reserve doesn't accept any new deposit, borrow or rate swap, but can accept repayments, liquidations, rate rebalances and redeems
|
||||||
* @param asset the address of the reserve
|
* @param asset the address of the reserve
|
||||||
**/
|
**/
|
||||||
function freezeReserve(address asset) external onlyLendingPoolManager {
|
function freezeReserve(address asset) external onlyAaveAdmin {
|
||||||
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
||||||
|
|
||||||
currentConfig.setFrozen(true);
|
currentConfig.setFrozen(true);
|
||||||
|
@ -456,7 +447,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
* @dev unfreezes a reserve
|
* @dev unfreezes a reserve
|
||||||
* @param asset the address of the reserve
|
* @param asset the address of the reserve
|
||||||
**/
|
**/
|
||||||
function unfreezeReserve(address asset) external onlyLendingPoolManager {
|
function unfreezeReserve(address asset) external onlyAaveAdmin {
|
||||||
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
||||||
|
|
||||||
currentConfig.setFrozen(false);
|
currentConfig.setFrozen(false);
|
||||||
|
@ -471,7 +462,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
* @param asset the address of the reserve
|
* @param asset the address of the reserve
|
||||||
* @param ltv the new value for the loan to value
|
* @param ltv the new value for the loan to value
|
||||||
**/
|
**/
|
||||||
function setLtv(address asset, uint256 ltv) external onlyLendingPoolManager {
|
function setLtv(address asset, uint256 ltv) external onlyAaveAdmin {
|
||||||
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
||||||
|
|
||||||
currentConfig.setLtv(ltv);
|
currentConfig.setLtv(ltv);
|
||||||
|
@ -486,10 +477,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
* @param asset the address of the reserve
|
* @param asset the address of the reserve
|
||||||
* @param threshold the new value for the liquidation threshold
|
* @param threshold the new value for the liquidation threshold
|
||||||
**/
|
**/
|
||||||
function setLiquidationThreshold(address asset, uint256 threshold)
|
function setLiquidationThreshold(address asset, uint256 threshold) external onlyAaveAdmin {
|
||||||
external
|
|
||||||
onlyLendingPoolManager
|
|
||||||
{
|
|
||||||
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
||||||
|
|
||||||
currentConfig.setLiquidationThreshold(threshold);
|
currentConfig.setLiquidationThreshold(threshold);
|
||||||
|
@ -504,7 +492,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
* @param asset the address of the reserve
|
* @param asset the address of the reserve
|
||||||
* @param bonus the new value for the liquidation bonus
|
* @param bonus the new value for the liquidation bonus
|
||||||
**/
|
**/
|
||||||
function setLiquidationBonus(address asset, uint256 bonus) external onlyLendingPoolManager {
|
function setLiquidationBonus(address asset, uint256 bonus) external onlyAaveAdmin {
|
||||||
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
||||||
|
|
||||||
currentConfig.setLiquidationBonus(bonus);
|
currentConfig.setLiquidationBonus(bonus);
|
||||||
|
@ -519,7 +507,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
* @param asset the address of the reserve
|
* @param asset the address of the reserve
|
||||||
* @param decimals the new number of decimals
|
* @param decimals the new number of decimals
|
||||||
**/
|
**/
|
||||||
function setReserveDecimals(address asset, uint256 decimals) external onlyLendingPoolManager {
|
function setReserveDecimals(address asset, uint256 decimals) external onlyAaveAdmin {
|
||||||
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
|
||||||
|
|
||||||
currentConfig.setDecimals(decimals);
|
currentConfig.setDecimals(decimals);
|
||||||
|
@ -536,7 +524,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
**/
|
**/
|
||||||
function setReserveInterestRateStrategyAddress(address asset, address rateStrategyAddress)
|
function setReserveInterestRateStrategyAddress(address asset, address rateStrategyAddress)
|
||||||
external
|
external
|
||||||
onlyLendingPoolManager
|
onlyAaveAdmin
|
||||||
{
|
{
|
||||||
pool.setReserveInterestRateStrategyAddress(asset, rateStrategyAddress);
|
pool.setReserveInterestRateStrategyAddress(asset, rateStrategyAddress);
|
||||||
emit ReserveInterestRateStrategyChanged(asset, rateStrategyAddress);
|
emit ReserveInterestRateStrategyChanged(asset, rateStrategyAddress);
|
||||||
|
@ -587,7 +575,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
* @dev pauses or unpauses LendingPool actions
|
* @dev pauses or unpauses LendingPool actions
|
||||||
* @param val the boolean value to set the current pause state of LendingPool
|
* @param val the boolean value to set the current pause state of LendingPool
|
||||||
**/
|
**/
|
||||||
function setPoolPause(bool val) external onlyLendingPoolManager {
|
function setPoolPause(bool val) external onlyAaveAdmin {
|
||||||
pool.setPause(val);
|
pool.setPause(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,13 +59,13 @@ library Errors {
|
||||||
string public constant STABLE_BORROW_RATE_OVERFLOW = '51'; // Stable borrow rate overflows uint128
|
string public constant STABLE_BORROW_RATE_OVERFLOW = '51'; // Stable borrow rate overflows uint128
|
||||||
|
|
||||||
//require error messages - LendingPoolConfiguration
|
//require error messages - LendingPoolConfiguration
|
||||||
string public constant CALLER_NOT_LENDING_POOL_MANAGER = '35'; // 'The caller must be a lending pool manager'
|
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'
|
||||||
|
|
||||||
//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'
|
||||||
|
|
||||||
//return error messages - LendingPoolLiquidationManager
|
//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'
|
||||||
string public constant COLLATERAL_CANNOT_BE_LIQUIDATED = '39'; // 'The collateral chosen cannot be liquidated'
|
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 SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER = '40'; // 'User did not borrow the specified currency'
|
||||||
|
@ -79,7 +79,7 @@ library Errors {
|
||||||
|
|
||||||
// pausable error message
|
// pausable error message
|
||||||
string public constant IS_PAUSED = '58'; // 'Pool is paused'
|
string public constant IS_PAUSED = '58'; // 'Pool is paused'
|
||||||
enum LiquidationErrors {
|
enum CollateralManagerErrors {
|
||||||
NO_ERROR,
|
NO_ERROR,
|
||||||
NO_COLLATERAL_AVAILABLE,
|
NO_COLLATERAL_AVAILABLE,
|
||||||
COLLATERAL_CANNOT_BE_LIQUIDATED,
|
COLLATERAL_CANNOT_BE_LIQUIDATED,
|
||||||
|
@ -88,6 +88,7 @@ library Errors {
|
||||||
NOT_ENOUGH_LIQUIDITY,
|
NOT_ENOUGH_LIQUIDITY,
|
||||||
NO_ACTIVE_RESERVE,
|
NO_ACTIVE_RESERVE,
|
||||||
HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD,
|
HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD,
|
||||||
INVALID_EQUAL_ASSETS_TO_SWAP
|
INVALID_EQUAL_ASSETS_TO_SWAP,
|
||||||
|
NO_UNFREEZED_RESERVE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -351,12 +351,12 @@ library ValidationLogic {
|
||||||
if (
|
if (
|
||||||
!collateralReserve.configuration.getActive() || !principalReserve.configuration.getActive()
|
!collateralReserve.configuration.getActive() || !principalReserve.configuration.getActive()
|
||||||
) {
|
) {
|
||||||
return (uint256(Errors.LiquidationErrors.NO_ACTIVE_RESERVE), Errors.NO_ACTIVE_RESERVE);
|
return (uint256(Errors.CollateralManagerErrors.NO_ACTIVE_RESERVE), Errors.NO_ACTIVE_RESERVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userHealthFactor >= GenericLogic.HEALTH_FACTOR_LIQUIDATION_THRESHOLD) {
|
if (userHealthFactor >= GenericLogic.HEALTH_FACTOR_LIQUIDATION_THRESHOLD) {
|
||||||
return (
|
return (
|
||||||
uint256(Errors.LiquidationErrors.HEALTH_FACTOR_ABOVE_THRESHOLD),
|
uint256(Errors.CollateralManagerErrors.HEALTH_FACTOR_ABOVE_THRESHOLD),
|
||||||
Errors.HEALTH_FACTOR_NOT_BELOW_THRESHOLD
|
Errors.HEALTH_FACTOR_NOT_BELOW_THRESHOLD
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -367,19 +367,19 @@ library ValidationLogic {
|
||||||
//if collateral isn't enabled as collateral by user, it cannot be liquidated
|
//if collateral isn't enabled as collateral by user, it cannot be liquidated
|
||||||
if (!isCollateralEnabled) {
|
if (!isCollateralEnabled) {
|
||||||
return (
|
return (
|
||||||
uint256(Errors.LiquidationErrors.COLLATERAL_CANNOT_BE_LIQUIDATED),
|
uint256(Errors.CollateralManagerErrors.COLLATERAL_CANNOT_BE_LIQUIDATED),
|
||||||
Errors.COLLATERAL_CANNOT_BE_LIQUIDATED
|
Errors.COLLATERAL_CANNOT_BE_LIQUIDATED
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userStableDebt == 0 && userVariableDebt == 0) {
|
if (userStableDebt == 0 && userVariableDebt == 0) {
|
||||||
return (
|
return (
|
||||||
uint256(Errors.LiquidationErrors.CURRRENCY_NOT_BORROWED),
|
uint256(Errors.CollateralManagerErrors.CURRRENCY_NOT_BORROWED),
|
||||||
Errors.SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER
|
Errors.SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (uint256(Errors.LiquidationErrors.NO_ERROR), Errors.NO_ERRORS);
|
return (uint256(Errors.CollateralManagerErrors.NO_ERROR), Errors.NO_ERRORS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -404,14 +404,14 @@ library ValidationLogic {
|
||||||
if (
|
if (
|
||||||
!collateralReserve.configuration.getActive() || !principalReserve.configuration.getActive()
|
!collateralReserve.configuration.getActive() || !principalReserve.configuration.getActive()
|
||||||
) {
|
) {
|
||||||
return (uint256(Errors.LiquidationErrors.NO_ACTIVE_RESERVE), Errors.NO_ACTIVE_RESERVE);
|
return (uint256(Errors.CollateralManagerErrors.NO_ACTIVE_RESERVE), Errors.NO_ACTIVE_RESERVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
msg.sender != user && userHealthFactor >= GenericLogic.HEALTH_FACTOR_LIQUIDATION_THRESHOLD
|
msg.sender != user && userHealthFactor >= GenericLogic.HEALTH_FACTOR_LIQUIDATION_THRESHOLD
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
uint256(Errors.LiquidationErrors.HEALTH_FACTOR_ABOVE_THRESHOLD),
|
uint256(Errors.CollateralManagerErrors.HEALTH_FACTOR_ABOVE_THRESHOLD),
|
||||||
Errors.HEALTH_FACTOR_NOT_BELOW_THRESHOLD
|
Errors.HEALTH_FACTOR_NOT_BELOW_THRESHOLD
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -423,7 +423,7 @@ library ValidationLogic {
|
||||||
//if collateral isn't enabled as collateral by user, it cannot be liquidated
|
//if collateral isn't enabled as collateral by user, it cannot be liquidated
|
||||||
if (!isCollateralEnabled) {
|
if (!isCollateralEnabled) {
|
||||||
return (
|
return (
|
||||||
uint256(Errors.LiquidationErrors.COLLATERAL_CANNOT_BE_LIQUIDATED),
|
uint256(Errors.CollateralManagerErrors.COLLATERAL_CANNOT_BE_LIQUIDATED),
|
||||||
Errors.COLLATERAL_CANNOT_BE_LIQUIDATED
|
Errors.COLLATERAL_CANNOT_BE_LIQUIDATED
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -431,12 +431,12 @@ library ValidationLogic {
|
||||||
|
|
||||||
if (userStableDebt == 0 && userVariableDebt == 0) {
|
if (userStableDebt == 0 && userVariableDebt == 0) {
|
||||||
return (
|
return (
|
||||||
uint256(Errors.LiquidationErrors.CURRRENCY_NOT_BORROWED),
|
uint256(Errors.CollateralManagerErrors.CURRRENCY_NOT_BORROWED),
|
||||||
Errors.SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER
|
Errors.SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (uint256(Errors.LiquidationErrors.NO_ERROR), Errors.NO_ERRORS);
|
return (uint256(Errors.CollateralManagerErrors.NO_ERROR), Errors.NO_ERRORS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -452,17 +452,24 @@ library ValidationLogic {
|
||||||
address fromAsset,
|
address fromAsset,
|
||||||
address toAsset
|
address toAsset
|
||||||
) internal view returns (uint256, string memory) {
|
) internal view returns (uint256, string memory) {
|
||||||
if (!fromReserve.configuration.getActive() || !toReserve.configuration.getActive()) {
|
|
||||||
return (uint256(Errors.LiquidationErrors.NO_ACTIVE_RESERVE), Errors.NO_ACTIVE_RESERVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fromAsset == toAsset) {
|
if (fromAsset == toAsset) {
|
||||||
return (
|
return (
|
||||||
uint256(Errors.LiquidationErrors.INVALID_EQUAL_ASSETS_TO_SWAP),
|
uint256(Errors.CollateralManagerErrors.INVALID_EQUAL_ASSETS_TO_SWAP),
|
||||||
Errors.INVALID_EQUAL_ASSETS_TO_SWAP
|
Errors.INVALID_EQUAL_ASSETS_TO_SWAP
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (uint256(Errors.LiquidationErrors.NO_ERROR), Errors.NO_ERRORS);
|
(bool isToActive, bool isToFreezed, , ) = toReserve.configuration.getFlags();
|
||||||
|
if (!fromReserve.configuration.getActive() || !isToActive) {
|
||||||
|
return (uint256(Errors.CollateralManagerErrors.NO_ACTIVE_RESERVE), Errors.NO_ACTIVE_RESERVE);
|
||||||
|
}
|
||||||
|
if (isToFreezed) {
|
||||||
|
return (
|
||||||
|
uint256(Errors.CollateralManagerErrors.NO_UNFREEZED_RESERVE),
|
||||||
|
Errors.NO_UNFREEZED_RESERVE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (uint256(Errors.CollateralManagerErrors.NO_ERROR), Errors.NO_ERRORS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,9 @@ contract MockAToken is AToken {
|
||||||
LendingPool _pool,
|
LendingPool _pool,
|
||||||
address _underlyingAssetAddress,
|
address _underlyingAssetAddress,
|
||||||
string memory _tokenName,
|
string memory _tokenName,
|
||||||
string memory _tokenSymbol
|
string memory _tokenSymbol,
|
||||||
) public AToken(_pool, _underlyingAssetAddress, _tokenName, _tokenSymbol) {}
|
address incentivesController
|
||||||
|
) public AToken(_pool, _underlyingAssetAddress, _tokenName, _tokenSymbol, incentivesController) {}
|
||||||
|
|
||||||
function getRevision() internal override pure returns (uint256) {
|
function getRevision() internal override pure returns (uint256) {
|
||||||
return 0x2;
|
return 0x2;
|
||||||
|
|
|
@ -9,8 +9,12 @@ contract MockStableDebtToken is StableDebtToken {
|
||||||
address _pool,
|
address _pool,
|
||||||
address _underlyingAssetAddress,
|
address _underlyingAssetAddress,
|
||||||
string memory _tokenName,
|
string memory _tokenName,
|
||||||
string memory _tokenSymbol
|
string memory _tokenSymbol,
|
||||||
) public StableDebtToken(_pool, _underlyingAssetAddress, _tokenName, _tokenSymbol) {}
|
address incentivesController
|
||||||
|
)
|
||||||
|
public
|
||||||
|
StableDebtToken(_pool, _underlyingAssetAddress, _tokenName, _tokenSymbol, incentivesController)
|
||||||
|
{}
|
||||||
|
|
||||||
function getRevision() internal override pure returns (uint256) {
|
function getRevision() internal override pure returns (uint256) {
|
||||||
return 0x2;
|
return 0x2;
|
||||||
|
|
|
@ -9,8 +9,18 @@ contract MockVariableDebtToken is VariableDebtToken {
|
||||||
address _pool,
|
address _pool,
|
||||||
address _underlyingAssetAddress,
|
address _underlyingAssetAddress,
|
||||||
string memory _tokenName,
|
string memory _tokenName,
|
||||||
string memory _tokenSymbol
|
string memory _tokenSymbol,
|
||||||
) public VariableDebtToken(_pool, _underlyingAssetAddress, _tokenName, _tokenSymbol) {}
|
address incentivesController
|
||||||
|
)
|
||||||
|
public
|
||||||
|
VariableDebtToken(
|
||||||
|
_pool,
|
||||||
|
_underlyingAssetAddress,
|
||||||
|
_tokenName,
|
||||||
|
_tokenSymbol,
|
||||||
|
incentivesController
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
function getRevision() internal override pure returns (uint256) {
|
function getRevision() internal override pure returns (uint256) {
|
||||||
return 0x2;
|
return 0x2;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// SPDX-License-Identifier: agpl-3.0
|
// SPDX-License-Identifier: agpl-3.0
|
||||||
pragma solidity ^0.6.8;
|
pragma solidity ^0.6.8;
|
||||||
|
|
||||||
import {ERC20} from './ERC20.sol';
|
import {IncentivizedERC20} from './IncentivizedERC20.sol';
|
||||||
import {LendingPool} from '../lendingpool/LendingPool.sol';
|
import {LendingPool} from '../lendingpool/LendingPool.sol';
|
||||||
import {WadRayMath} from '../libraries/math/WadRayMath.sol';
|
import {WadRayMath} from '../libraries/math/WadRayMath.sol';
|
||||||
import {Errors} from '../libraries/helpers/Errors.sol';
|
import {Errors} from '../libraries/helpers/Errors.sol';
|
||||||
|
@ -18,9 +18,9 @@ import {SafeERC20} from '../misc/SafeERC20.sol';
|
||||||
* @dev Implementation of the interest bearing token for the DLP protocol.
|
* @dev Implementation of the interest bearing token for the DLP protocol.
|
||||||
* @author Aave
|
* @author Aave
|
||||||
*/
|
*/
|
||||||
contract AToken is VersionedInitializable, ERC20, IAToken {
|
contract AToken is VersionedInitializable, IncentivizedERC20, IAToken {
|
||||||
using WadRayMath for uint256;
|
using WadRayMath for uint256;
|
||||||
using SafeERC20 for ERC20;
|
using SafeERC20 for IncentivizedERC20;
|
||||||
|
|
||||||
uint256 public constant UINT_MAX_VALUE = uint256(-1);
|
uint256 public constant UINT_MAX_VALUE = uint256(-1);
|
||||||
address public immutable UNDERLYING_ASSET_ADDRESS;
|
address public immutable UNDERLYING_ASSET_ADDRESS;
|
||||||
|
@ -49,8 +49,9 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
|
||||||
LendingPool pool,
|
LendingPool pool,
|
||||||
address underlyingAssetAddress,
|
address underlyingAssetAddress,
|
||||||
string memory tokenName,
|
string memory tokenName,
|
||||||
string memory tokenSymbol
|
string memory tokenSymbol,
|
||||||
) public ERC20(tokenName, tokenSymbol, 18) {
|
address incentivesController
|
||||||
|
) public IncentivizedERC20(tokenName, tokenSymbol, 18, incentivesController) {
|
||||||
POOL = pool;
|
POOL = pool;
|
||||||
UNDERLYING_ASSET_ADDRESS = underlyingAssetAddress;
|
UNDERLYING_ASSET_ADDRESS = underlyingAssetAddress;
|
||||||
}
|
}
|
||||||
|
@ -106,7 +107,7 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
|
||||||
_burn(user, scaledAmount);
|
_burn(user, scaledAmount);
|
||||||
|
|
||||||
//transfers the underlying to the target
|
//transfers the underlying to the target
|
||||||
ERC20(UNDERLYING_ASSET_ADDRESS).safeTransfer(receiverOfUnderlying, amount);
|
IncentivizedERC20(UNDERLYING_ASSET_ADDRESS).safeTransfer(receiverOfUnderlying, amount);
|
||||||
|
|
||||||
//transfer event to track balances
|
//transfer event to track balances
|
||||||
emit Transfer(user, address(0), amount);
|
emit Transfer(user, address(0), amount);
|
||||||
|
@ -158,7 +159,12 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
|
||||||
* @param user the user for which the balance is being calculated
|
* @param user the user for which the balance is being calculated
|
||||||
* @return the total balance of the user
|
* @return the total balance of the user
|
||||||
**/
|
**/
|
||||||
function balanceOf(address user) public override(ERC20, IERC20) view returns (uint256) {
|
function balanceOf(address user)
|
||||||
|
public
|
||||||
|
override(IncentivizedERC20, IERC20)
|
||||||
|
view
|
||||||
|
returns (uint256)
|
||||||
|
{
|
||||||
return super.balanceOf(user).rayMul(POOL.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS));
|
return super.balanceOf(user).rayMul(POOL.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,13 +178,28 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
|
||||||
return super.balanceOf(user);
|
return super.balanceOf(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev returns the principal balance of the user and principal total supply.
|
||||||
|
* @param user the address of the user
|
||||||
|
* @return the principal balance of the user
|
||||||
|
* @return the principal total supply
|
||||||
|
**/
|
||||||
|
function getScaledUserBalanceAndSupply(address user)
|
||||||
|
external
|
||||||
|
override
|
||||||
|
view
|
||||||
|
returns (uint256, uint256)
|
||||||
|
{
|
||||||
|
return (super.balanceOf(user), super.totalSupply());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev calculates the total supply of the specific aToken
|
* @dev calculates the total supply of the specific aToken
|
||||||
* since the balance of every single user increases over time, the total supply
|
* since the balance of every single user increases over time, the total supply
|
||||||
* does that too.
|
* does that too.
|
||||||
* @return the current total supply
|
* @return the current total supply
|
||||||
**/
|
**/
|
||||||
function totalSupply() public override(ERC20, IERC20) view returns (uint256) {
|
function totalSupply() public override(IncentivizedERC20, IERC20) view returns (uint256) {
|
||||||
uint256 currentSupplyScaled = super.totalSupply();
|
uint256 currentSupplyScaled = super.totalSupply();
|
||||||
|
|
||||||
if (currentSupplyScaled == 0) {
|
if (currentSupplyScaled == 0) {
|
||||||
|
@ -211,7 +232,7 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
|
||||||
onlyLendingPool
|
onlyLendingPool
|
||||||
returns (uint256)
|
returns (uint256)
|
||||||
{
|
{
|
||||||
ERC20(UNDERLYING_ASSET_ADDRESS).safeTransfer(target, amount);
|
IncentivizedERC20(UNDERLYING_ASSET_ADDRESS).safeTransfer(target, amount);
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,16 +5,20 @@ import {Context} from '../misc/Context.sol';
|
||||||
import {IERC20} from '../interfaces/IERC20.sol';
|
import {IERC20} from '../interfaces/IERC20.sol';
|
||||||
import {IERC20Detailed} from '../interfaces/IERC20Detailed.sol';
|
import {IERC20Detailed} from '../interfaces/IERC20Detailed.sol';
|
||||||
import {SafeMath} from '../libraries/math/SafeMath.sol';
|
import {SafeMath} from '../libraries/math/SafeMath.sol';
|
||||||
|
import {IAaveIncentivesController} from '../interfaces/IAaveIncentivesController.sol';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title ERC20
|
* @title ERC20
|
||||||
* @notice Basic ERC20 implementation
|
* @notice Basic ERC20 implementation
|
||||||
* @author Aave, inspired by the Openzeppelin ERC20 implementation
|
* @author Aave, inspired by the Openzeppelin ERC20 implementation
|
||||||
**/
|
**/
|
||||||
contract ERC20 is Context, IERC20, IERC20Detailed {
|
contract IncentivizedERC20 is Context, IERC20, IERC20Detailed {
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
|
|
||||||
|
IAaveIncentivesController internal immutable _incentivesController;
|
||||||
|
|
||||||
mapping(address => uint256) internal _balances;
|
mapping(address => uint256) internal _balances;
|
||||||
|
|
||||||
mapping(address => mapping(address => uint256)) private _allowances;
|
mapping(address => mapping(address => uint256)) private _allowances;
|
||||||
uint256 internal _totalSupply;
|
uint256 internal _totalSupply;
|
||||||
string private _name;
|
string private _name;
|
||||||
|
@ -24,11 +28,13 @@ contract ERC20 is Context, IERC20, IERC20Detailed {
|
||||||
constructor(
|
constructor(
|
||||||
string memory name,
|
string memory name,
|
||||||
string memory symbol,
|
string memory symbol,
|
||||||
uint8 decimals
|
uint8 decimals,
|
||||||
|
address incentivesController
|
||||||
) public {
|
) public {
|
||||||
_name = name;
|
_name = name;
|
||||||
_symbol = symbol;
|
_symbol = symbol;
|
||||||
_decimals = decimals;
|
_decimals = decimals;
|
||||||
|
_incentivesController = IAaveIncentivesController(incentivesController);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -169,8 +175,18 @@ contract ERC20 is Context, IERC20, IERC20Detailed {
|
||||||
|
|
||||||
_beforeTokenTransfer(sender, recipient, amount);
|
_beforeTokenTransfer(sender, recipient, amount);
|
||||||
|
|
||||||
_balances[sender] = _balances[sender].sub(amount, 'ERC20: transfer amount exceeds balance');
|
uint256 oldSenderBalance = _balances[sender];
|
||||||
|
_balances[sender] = oldSenderBalance.sub(amount, 'ERC20: transfer amount exceeds balance');
|
||||||
|
uint256 oldRecipientBalance = _balances[recipient];
|
||||||
_balances[recipient] = _balances[recipient].add(amount);
|
_balances[recipient] = _balances[recipient].add(amount);
|
||||||
|
|
||||||
|
if (address(_incentivesController) != address(0)) {
|
||||||
|
uint256 totalSupply = _totalSupply;
|
||||||
|
_incentivesController.handleAction(sender, totalSupply, oldSenderBalance);
|
||||||
|
if (sender != recipient) {
|
||||||
|
_incentivesController.handleAction(recipient, totalSupply, oldRecipientBalance);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _mint(address account, uint256 amount) internal virtual {
|
function _mint(address account, uint256 amount) internal virtual {
|
||||||
|
@ -178,8 +194,15 @@ contract ERC20 is Context, IERC20, IERC20Detailed {
|
||||||
|
|
||||||
_beforeTokenTransfer(address(0), account, amount);
|
_beforeTokenTransfer(address(0), account, amount);
|
||||||
|
|
||||||
_totalSupply = _totalSupply.add(amount);
|
uint256 oldTotalSupply = _totalSupply;
|
||||||
_balances[account] = _balances[account].add(amount);
|
_totalSupply = oldTotalSupply.add(amount);
|
||||||
|
|
||||||
|
uint256 oldAccountBalance = _balances[account];
|
||||||
|
_balances[account] = oldAccountBalance.add(amount);
|
||||||
|
|
||||||
|
if (address(_incentivesController) != address(0)) {
|
||||||
|
_incentivesController.handleAction(account, oldTotalSupply, oldAccountBalance);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _burn(address account, uint256 amount) internal virtual {
|
function _burn(address account, uint256 amount) internal virtual {
|
||||||
|
@ -187,8 +210,15 @@ contract ERC20 is Context, IERC20, IERC20Detailed {
|
||||||
|
|
||||||
_beforeTokenTransfer(account, address(0), amount);
|
_beforeTokenTransfer(account, address(0), amount);
|
||||||
|
|
||||||
_balances[account] = _balances[account].sub(amount, 'ERC20: burn amount exceeds balance');
|
uint256 oldTotalSupply = _totalSupply;
|
||||||
_totalSupply = _totalSupply.sub(amount);
|
_totalSupply = oldTotalSupply.sub(amount);
|
||||||
|
|
||||||
|
uint256 oldAccountBalance = _balances[account];
|
||||||
|
_balances[account] = oldAccountBalance.sub(amount, 'ERC20: burn amount exceeds balance');
|
||||||
|
|
||||||
|
if (address(_incentivesController) != address(0)) {
|
||||||
|
_incentivesController.handleAction(account, oldTotalSupply, oldAccountBalance);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _approve(
|
function _approve(
|
|
@ -26,8 +26,9 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
|
||||||
address pool,
|
address pool,
|
||||||
address underlyingAsset,
|
address underlyingAsset,
|
||||||
string memory name,
|
string memory name,
|
||||||
string memory symbol
|
string memory symbol,
|
||||||
) public DebtTokenBase(pool, underlyingAsset, name, symbol) {}
|
address incentivesController
|
||||||
|
) public DebtTokenBase(pool, underlyingAsset, name, symbol, incentivesController) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev gets the revision of the stable debt token implementation
|
* @dev gets the revision of the stable debt token implementation
|
||||||
|
|
|
@ -22,8 +22,9 @@ contract VariableDebtToken is DebtTokenBase, IVariableDebtToken {
|
||||||
address pool,
|
address pool,
|
||||||
address underlyingAsset,
|
address underlyingAsset,
|
||||||
string memory name,
|
string memory name,
|
||||||
string memory symbol
|
string memory symbol,
|
||||||
) public DebtTokenBase(pool, underlyingAsset, name, symbol) {}
|
address incentivesController
|
||||||
|
) public DebtTokenBase(pool, underlyingAsset, name, symbol, incentivesController) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev gets the revision of the stable debt token implementation
|
* @dev gets the revision of the stable debt token implementation
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {ILendingPool} from '../../interfaces/ILendingPool.sol';
|
||||||
import {
|
import {
|
||||||
VersionedInitializable
|
VersionedInitializable
|
||||||
} from '../../libraries/openzeppelin-upgradeability/VersionedInitializable.sol';
|
} from '../../libraries/openzeppelin-upgradeability/VersionedInitializable.sol';
|
||||||
import {ERC20} from '../ERC20.sol';
|
import {IncentivizedERC20} from '../IncentivizedERC20.sol';
|
||||||
import {Errors} from '../../libraries/helpers/Errors.sol';
|
import {Errors} from '../../libraries/helpers/Errors.sol';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,7 +17,7 @@ import {Errors} from '../../libraries/helpers/Errors.sol';
|
||||||
* @author Aave
|
* @author Aave
|
||||||
*/
|
*/
|
||||||
|
|
||||||
abstract contract DebtTokenBase is ERC20, VersionedInitializable {
|
abstract contract DebtTokenBase is IncentivizedERC20, VersionedInitializable {
|
||||||
address internal immutable UNDERLYING_ASSET;
|
address internal immutable UNDERLYING_ASSET;
|
||||||
ILendingPool internal immutable POOL;
|
ILendingPool internal immutable POOL;
|
||||||
mapping(address => uint256) internal _usersData;
|
mapping(address => uint256) internal _usersData;
|
||||||
|
@ -38,8 +38,9 @@ abstract contract DebtTokenBase is ERC20, VersionedInitializable {
|
||||||
address pool,
|
address pool,
|
||||||
address underlyingAssetAddress,
|
address underlyingAssetAddress,
|
||||||
string memory name,
|
string memory name,
|
||||||
string memory symbol
|
string memory symbol,
|
||||||
) public ERC20(name, symbol, 18) {
|
address incentivesController
|
||||||
|
) public IncentivizedERC20(name, symbol, 18, incentivesController) {
|
||||||
POOL = ILendingPool(pool);
|
POOL = ILendingPool(pool);
|
||||||
UNDERLYING_ASSET = underlyingAssetAddress;
|
UNDERLYING_ASSET = underlyingAssetAddress;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,14 @@ interface IAToken is IERC20 {
|
||||||
**/
|
**/
|
||||||
function scaledBalanceOf(address user) external view returns (uint256);
|
function scaledBalanceOf(address user) external view returns (uint256);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev returns the principal balance of the user and principal total supply.
|
||||||
|
* @param user the address of the user
|
||||||
|
* @return the principal balance of the user
|
||||||
|
* @return the principal total supply
|
||||||
|
**/
|
||||||
|
function getScaledUserBalanceAndSupply(address user) external view returns (uint256, uint256);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Used to validate transfers before actually executing them.
|
* @dev Used to validate transfers before actually executing them.
|
||||||
* @param user address of the user to check
|
* @param user address of the user to check
|
||||||
|
|
|
@ -11,22 +11,30 @@
|
||||||
},
|
},
|
||||||
"LendingPoolAddressesProvider": {
|
"LendingPoolAddressesProvider": {
|
||||||
"buidlerevm": {
|
"buidlerevm": {
|
||||||
"address": "0xa4bcDF64Cdd5451b6ac3743B414124A6299B65FF",
|
"address": "0x7c2C195CD6D34B8F845992d380aADB2730bB9C6F",
|
||||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||||
},
|
},
|
||||||
"localhost": {
|
"localhost": {
|
||||||
"address": "0xAfC307938C1c0035942c141c31524504c89Aaa8B",
|
"address": "0xAfC307938C1c0035942c141c31524504c89Aaa8B",
|
||||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||||
|
},
|
||||||
|
"kovan": {
|
||||||
|
"address": "0x20e080B395341B3b617E893c281c7E999C942276",
|
||||||
|
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"LendingPoolAddressesProviderRegistry": {
|
"LendingPoolAddressesProviderRegistry": {
|
||||||
"buidlerevm": {
|
"buidlerevm": {
|
||||||
"address": "0x5A0773Ff307Bf7C71a832dBB5312237fD3437f9F",
|
"address": "0x0078371BDeDE8aAc7DeBfFf451B74c5EDB385Af7",
|
||||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||||
},
|
},
|
||||||
"localhost": {
|
"localhost": {
|
||||||
"address": "0x73DE1e0ab6A5C221258703bc546E0CAAcCc6EC87",
|
"address": "0x73DE1e0ab6A5C221258703bc546E0CAAcCc6EC87",
|
||||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||||
|
},
|
||||||
|
"kovan": {
|
||||||
|
"address": "0x00219a2958f758122106Bb8A801AFc1B70897663",
|
||||||
|
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"FeeProvider": {
|
"FeeProvider": {
|
||||||
|
@ -50,10 +58,13 @@
|
||||||
},
|
},
|
||||||
"LendingPoolConfigurator": {
|
"LendingPoolConfigurator": {
|
||||||
"buidlerevm": {
|
"buidlerevm": {
|
||||||
"address": "0x6642B57e4265BAD868C17Fc1d1F4F88DBBA04Aa8"
|
"address": "0x1b88b3E43526cB076931AD76cB2eC0CC93382FAc"
|
||||||
},
|
},
|
||||||
"localhost": {
|
"localhost": {
|
||||||
"address": "0x65e0Cd5B8904A02f2e00BC6f58bf881998D54BDe"
|
"address": "0x65e0Cd5B8904A02f2e00BC6f58bf881998D54BDe"
|
||||||
|
},
|
||||||
|
"kovan": {
|
||||||
|
"address": "0x50C9d3aD9399c1EEf6DDeadF8e57fF69994F552e"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"LendingPoolDataProvider": {
|
"LendingPoolDataProvider": {
|
||||||
|
@ -63,10 +74,13 @@
|
||||||
},
|
},
|
||||||
"LendingPool": {
|
"LendingPool": {
|
||||||
"buidlerevm": {
|
"buidlerevm": {
|
||||||
"address": "0xD9273d497eDBC967F39d419461CfcF382a0A822e"
|
"address": "0xdA71454D2a71D63116cd67099e4a0fdd3a8Dfb47"
|
||||||
},
|
},
|
||||||
"localhost": {
|
"localhost": {
|
||||||
"address": "0x5d12dDe3286D94E0d85F9D3B01B7099cfA0aBCf1"
|
"address": "0x5d12dDe3286D94E0d85F9D3B01B7099cfA0aBCf1"
|
||||||
|
},
|
||||||
|
"kovan": {
|
||||||
|
"address": "0x6d1e69bB0578699dd955Eefbf23aAC65c0DA5cE7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"PriceOracle": {
|
"PriceOracle": {
|
||||||
|
@ -97,6 +111,10 @@
|
||||||
"localhost": {
|
"localhost": {
|
||||||
"address": "0xE30c3983E51bC9d6baE3E9437710a1459e21e81F",
|
"address": "0xE30c3983E51bC9d6baE3E9437710a1459e21e81F",
|
||||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||||
|
},
|
||||||
|
"kovan": {
|
||||||
|
"address": "0x18a107d4fa249Efefd4DAf9A76EEE3b6366701AA",
|
||||||
|
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"LendingRateOracle": {
|
"LendingRateOracle": {
|
||||||
|
@ -107,6 +125,10 @@
|
||||||
"localhost": {
|
"localhost": {
|
||||||
"address": "0xDf69898e844197a24C658CcF9fD53dF15948dc8b",
|
"address": "0xDf69898e844197a24C658CcF9fD53dF15948dc8b",
|
||||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||||
|
},
|
||||||
|
"kovan": {
|
||||||
|
"address": "0xac6Eb7B1083D39eC695a3898C2f782E7c7C64973",
|
||||||
|
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"DefaultReserveInterestRateStrategy": {
|
"DefaultReserveInterestRateStrategy": {
|
||||||
|
|
3
helpers/buidler-constants.ts
Normal file
3
helpers/buidler-constants.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export const TEST_SNAPSHOT_ID = '0x1';
|
||||||
|
export const BUIDLEREVM_CHAINID = 31337;
|
||||||
|
export const COVERAGE_CHAINID = 1337;
|
|
@ -63,19 +63,16 @@ export const getFeeDistributionParamsCommon = (
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getGenesisLendingPoolManagerAddress = async (config: ICommonConfiguration) => {
|
export const getGenesisAaveAdmin = async (config: ICommonConfiguration) => {
|
||||||
const currentNetwork = BRE.network.name;
|
const currentNetwork = BRE.network.name;
|
||||||
const targetAddress = getParamPerNetwork(
|
const targetAddress = getParamPerNetwork(config.AaveAdmin, <eEthereumNetwork>currentNetwork);
|
||||||
config.LendingPoolManagerAddress,
|
|
||||||
<eEthereumNetwork>currentNetwork
|
|
||||||
);
|
|
||||||
if (targetAddress) {
|
if (targetAddress) {
|
||||||
return targetAddress;
|
return targetAddress;
|
||||||
}
|
}
|
||||||
const addressList = await Promise.all(
|
const addressList = await Promise.all(
|
||||||
(await BRE.ethers.getSigners()).map((signer) => signer.getAddress())
|
(await BRE.ethers.getSigners()).map((signer) => signer.getAddress())
|
||||||
);
|
);
|
||||||
const addressIndex = config.LendingPoolManagerAddressIndex;
|
const addressIndex = config.AaveAdminIndex;
|
||||||
return addressList[addressIndex];
|
return addressList[addressIndex];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
|
|
||||||
export const BUIDLEREVM_CHAINID = 31337;
|
// ----------------
|
||||||
export const COVERAGE_CHAINID = 1337;
|
// MATH
|
||||||
export const TEST_SNAPSHOT_ID = '0x1';
|
// ----------------
|
||||||
|
|
||||||
export const WAD = Math.pow(10, 18).toString();
|
export const WAD = Math.pow(10, 18).toString();
|
||||||
export const HALF_WAD = new BigNumber(WAD).multipliedBy(0.5).toString();
|
export const HALF_WAD = new BigNumber(WAD).multipliedBy(0.5).toString();
|
||||||
|
|
|
@ -27,7 +27,7 @@ import {PriceOracle} from '../types/PriceOracle';
|
||||||
import {MockAggregator} from '../types/MockAggregator';
|
import {MockAggregator} from '../types/MockAggregator';
|
||||||
import {LendingRateOracle} from '../types/LendingRateOracle';
|
import {LendingRateOracle} from '../types/LendingRateOracle';
|
||||||
import {DefaultReserveInterestRateStrategy} from '../types/DefaultReserveInterestRateStrategy';
|
import {DefaultReserveInterestRateStrategy} from '../types/DefaultReserveInterestRateStrategy';
|
||||||
import {LendingPoolLiquidationManager} from '../types/LendingPoolLiquidationManager';
|
import {LendingPoolCollateralManager} from '../types/LendingPoolCollateralManager';
|
||||||
import {InitializableAdminUpgradeabilityProxy} from '../types/InitializableAdminUpgradeabilityProxy';
|
import {InitializableAdminUpgradeabilityProxy} from '../types/InitializableAdminUpgradeabilityProxy';
|
||||||
import {MockFlashLoanReceiver} from '../types/MockFlashLoanReceiver';
|
import {MockFlashLoanReceiver} from '../types/MockFlashLoanReceiver';
|
||||||
import {WalletBalanceProvider} from '../types/WalletBalanceProvider';
|
import {WalletBalanceProvider} from '../types/WalletBalanceProvider';
|
||||||
|
@ -49,6 +49,7 @@ export type MockTokenMap = {[symbol: string]: MintableERC20};
|
||||||
import {MockSwapAdapter} from '../types/MockSwapAdapter';
|
import {MockSwapAdapter} from '../types/MockSwapAdapter';
|
||||||
import {signTypedData_v4, TypedData} from 'eth-sig-util';
|
import {signTypedData_v4, TypedData} from 'eth-sig-util';
|
||||||
import {fromRpcSig, ECDSASignature} from 'ethereumjs-util';
|
import {fromRpcSig, ECDSASignature} from 'ethereumjs-util';
|
||||||
|
import {SignerWithAddress} from '../test/helpers/make-suite';
|
||||||
|
|
||||||
export const registerContractInJsonDb = async (contractId: string, contractInstance: Contract) => {
|
export const registerContractInJsonDb = async (contractId: string, contractInstance: Contract) => {
|
||||||
const currentNetwork = BRE.network.name;
|
const currentNetwork = BRE.network.name;
|
||||||
|
@ -218,6 +219,14 @@ export const deployPriceOracle = async (verify?: boolean) => {
|
||||||
return instance;
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const deployLendingRateOracle = async (verify?: boolean) => {
|
||||||
|
const instance = await deployContract<LendingRateOracle>(eContractid.LendingRateOracle, []);
|
||||||
|
if (verify) {
|
||||||
|
await verifyContract(eContractid.LendingRateOracle, instance.address, []);
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
};
|
||||||
|
|
||||||
export const deployMockAggregator = async (price: tStringTokenSmallUnits, verify?: boolean) => {
|
export const deployMockAggregator = async (price: tStringTokenSmallUnits, verify?: boolean) => {
|
||||||
const args = [price];
|
const args = [price];
|
||||||
const instance = await deployContract<MockAggregator>(eContractid.MockAggregator, args);
|
const instance = await deployContract<MockAggregator>(eContractid.MockAggregator, args);
|
||||||
|
@ -254,24 +263,21 @@ export const getChainlingProxyPriceProvider = async (address?: tEthereumAddress)
|
||||||
.address
|
.address
|
||||||
);
|
);
|
||||||
|
|
||||||
export const deployLendingRateOracle = async (verify?: boolean) => {
|
export const deployLendingPoolCollateralManager = async (verify?: boolean) => {
|
||||||
const instance = await deployContract<LendingRateOracle>(eContractid.LendingRateOracle, []);
|
const collateralManagerArtifact = await readArtifact(
|
||||||
if (verify) {
|
|
||||||
await verifyContract(eContractid.LendingRateOracle, instance.address, []);
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const deployLendingPoolLiquidationManager = async (verify?: boolean) => {
|
|
||||||
const liquidationManagerArtifact = await readArtifact(
|
|
||||||
BRE.config.paths.artifacts,
|
BRE.config.paths.artifacts,
|
||||||
eContractid.LendingPoolLiquidationManager
|
eContractid.LendingPoolCollateralManager
|
||||||
);
|
);
|
||||||
|
|
||||||
const factory = await linkLibrariesToArtifact(liquidationManagerArtifact);
|
const factory = await linkLibrariesToArtifact(collateralManagerArtifact);
|
||||||
|
const args: string[] = [];
|
||||||
|
const collateralManager = await factory.deploy(args);
|
||||||
|
const instance = (await collateralManager.deployed()) as LendingPoolCollateralManager;
|
||||||
|
|
||||||
const liquidationManager = await factory.deploy();
|
if (verify) {
|
||||||
return (await liquidationManager.deployed()) as LendingPoolLiquidationManager;
|
await verifyContract(eContractid.LendingPoolCollateralManager, instance.address, args);
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deployInitializableAdminUpgradeabilityProxy = async (verify?: boolean) => {
|
export const deployInitializableAdminUpgradeabilityProxy = async (verify?: boolean) => {
|
||||||
|
@ -365,16 +371,17 @@ export const deployDefaultReserveInterestRateStrategy = async (
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deployStableDebtToken = async (
|
export const deployStableDebtToken = async (
|
||||||
[name, symbol, underlyingAsset, poolAddress]: [
|
[name, symbol, underlyingAsset, poolAddress, incentivesController]: [
|
||||||
string,
|
string,
|
||||||
string,
|
string,
|
||||||
tEthereumAddress,
|
tEthereumAddress,
|
||||||
|
tEthereumAddress,
|
||||||
tEthereumAddress
|
tEthereumAddress
|
||||||
],
|
],
|
||||||
verify: boolean
|
verify: boolean
|
||||||
) => {
|
) => {
|
||||||
const id = eContractid.StableDebtToken;
|
const id = eContractid.StableDebtToken;
|
||||||
const args = [poolAddress, underlyingAsset, name, symbol];
|
const args = [poolAddress, underlyingAsset, name, symbol, incentivesController];
|
||||||
const instance = await deployContract<StableDebtToken>(id, args);
|
const instance = await deployContract<StableDebtToken>(id, args);
|
||||||
|
|
||||||
if (verify) {
|
if (verify) {
|
||||||
|
@ -384,16 +391,17 @@ export const deployStableDebtToken = async (
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deployVariableDebtToken = async (
|
export const deployVariableDebtToken = async (
|
||||||
[name, symbol, underlyingAsset, poolAddress]: [
|
[name, symbol, underlyingAsset, poolAddress, incentivesController]: [
|
||||||
string,
|
string,
|
||||||
string,
|
string,
|
||||||
tEthereumAddress,
|
tEthereumAddress,
|
||||||
|
tEthereumAddress,
|
||||||
tEthereumAddress
|
tEthereumAddress
|
||||||
],
|
],
|
||||||
verify: boolean
|
verify: boolean
|
||||||
) => {
|
) => {
|
||||||
const id = eContractid.VariableDebtToken;
|
const id = eContractid.VariableDebtToken;
|
||||||
const args = [poolAddress, underlyingAsset, name, symbol];
|
const args = [poolAddress, underlyingAsset, name, symbol, incentivesController];
|
||||||
const instance = await deployContract<VariableDebtToken>(id, args);
|
const instance = await deployContract<VariableDebtToken>(id, args);
|
||||||
|
|
||||||
if (verify) {
|
if (verify) {
|
||||||
|
@ -403,16 +411,17 @@ export const deployVariableDebtToken = async (
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deployGenericAToken = async (
|
export const deployGenericAToken = async (
|
||||||
[poolAddress, underlyingAssetAddress, name, symbol]: [
|
[poolAddress, underlyingAssetAddress, name, symbol, incentivesController]: [
|
||||||
tEthereumAddress,
|
tEthereumAddress,
|
||||||
tEthereumAddress,
|
tEthereumAddress,
|
||||||
string,
|
string,
|
||||||
string
|
string,
|
||||||
|
tEthereumAddress
|
||||||
],
|
],
|
||||||
verify: boolean
|
verify: boolean
|
||||||
) => {
|
) => {
|
||||||
const id = eContractid.AToken;
|
const id = eContractid.AToken;
|
||||||
const args = [poolAddress, underlyingAssetAddress, name, symbol];
|
const args = [poolAddress, underlyingAssetAddress, name, symbol, incentivesController];
|
||||||
const instance = await deployContract<AToken>(id, args);
|
const instance = await deployContract<AToken>(id, args);
|
||||||
|
|
||||||
if (verify) {
|
if (verify) {
|
||||||
|
@ -724,6 +733,7 @@ export const initReserves = async (
|
||||||
lendingPool: LendingPool,
|
lendingPool: LendingPool,
|
||||||
lendingPoolConfigurator: LendingPoolConfigurator,
|
lendingPoolConfigurator: LendingPoolConfigurator,
|
||||||
aavePool: AavePools,
|
aavePool: AavePools,
|
||||||
|
incentivesController: tEthereumAddress,
|
||||||
verify: boolean
|
verify: boolean
|
||||||
) => {
|
) => {
|
||||||
if (aavePool !== AavePools.proto && aavePool !== AavePools.secondary) {
|
if (aavePool !== AavePools.proto && aavePool !== AavePools.secondary) {
|
||||||
|
@ -765,6 +775,7 @@ export const initReserves = async (
|
||||||
stableRateSlope2,
|
stableRateSlope2,
|
||||||
},
|
},
|
||||||
] = (Object.entries(reservesParams) as [string, IReserveParams][])[reserveParamIndex];
|
] = (Object.entries(reservesParams) as [string, IReserveParams][])[reserveParamIndex];
|
||||||
|
console.log('deploy def reserve');
|
||||||
const rateStrategyContract = await deployDefaultReserveInterestRateStrategy(
|
const rateStrategyContract = await deployDefaultReserveInterestRateStrategy(
|
||||||
[
|
[
|
||||||
lendingPoolAddressesProvider.address,
|
lendingPoolAddressesProvider.address,
|
||||||
|
@ -777,32 +788,38 @@ export const initReserves = async (
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log('deploy stable deb totken ', assetSymbol);
|
||||||
const stableDebtToken = await deployStableDebtToken(
|
const stableDebtToken = await deployStableDebtToken(
|
||||||
[
|
[
|
||||||
`Aave stable debt bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
`Aave stable debt bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
||||||
`stableDebt${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
`stableDebt${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
||||||
tokenAddress,
|
tokenAddress,
|
||||||
lendingPool.address,
|
lendingPool.address,
|
||||||
|
incentivesController,
|
||||||
],
|
],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log('deploy var deb totken ', assetSymbol);
|
||||||
const variableDebtToken = await deployVariableDebtToken(
|
const variableDebtToken = await deployVariableDebtToken(
|
||||||
[
|
[
|
||||||
`Aave variable debt bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
`Aave variable debt bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
||||||
`variableDebt${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
`variableDebt${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
||||||
tokenAddress,
|
tokenAddress,
|
||||||
lendingPool.address,
|
lendingPool.address,
|
||||||
|
incentivesController,
|
||||||
],
|
],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log('deploy a token ', assetSymbol);
|
||||||
const aToken = await deployGenericAToken(
|
const aToken = await deployGenericAToken(
|
||||||
[
|
[
|
||||||
lendingPool.address,
|
lendingPool.address,
|
||||||
tokenAddress,
|
tokenAddress,
|
||||||
`Aave interest bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
`Aave interest bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
||||||
`a${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
`a${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
||||||
|
incentivesController,
|
||||||
],
|
],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
@ -815,6 +832,7 @@ export const initReserves = async (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('init reserve currency ', assetSymbol);
|
||||||
await lendingPoolConfigurator.initReserve(
|
await lendingPoolConfigurator.initReserve(
|
||||||
tokenAddress,
|
tokenAddress,
|
||||||
aToken.address,
|
aToken.address,
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import {exit} from 'process';
|
import {exit} from 'process';
|
||||||
|
import fs from 'fs';
|
||||||
|
import {file} from 'tmp-promise';
|
||||||
import {BRE} from './misc-utils';
|
import {BRE} from './misc-utils';
|
||||||
|
|
||||||
export const SUPPORTED_ETHERSCAN_NETWORKS = ['main', 'ropsten', 'kovan'];
|
export const SUPPORTED_ETHERSCAN_NETWORKS = ['main', 'ropsten', 'kovan'];
|
||||||
|
@ -31,9 +33,6 @@ export const verifyContract = async (
|
||||||
if (!process.env.ETHERSCAN_KEY) {
|
if (!process.env.ETHERSCAN_KEY) {
|
||||||
throw Error('Missing process.env.ETHERSCAN_KEY.');
|
throw Error('Missing process.env.ETHERSCAN_KEY.');
|
||||||
}
|
}
|
||||||
if (!process.env.ETHERSCAN_NETWORK) {
|
|
||||||
throw Error('Missing process.env.ETHERSCAN_NETWORK');
|
|
||||||
}
|
|
||||||
if (!SUPPORTED_ETHERSCAN_NETWORKS.includes(currentNetwork)) {
|
if (!SUPPORTED_ETHERSCAN_NETWORKS.includes(currentNetwork)) {
|
||||||
throw Error(
|
throw Error(
|
||||||
`Current network ${currentNetwork} not supported. Please change to one of the next networks: ${SUPPORTED_ETHERSCAN_NETWORKS.toString()}`
|
`Current network ${currentNetwork} not supported. Please change to one of the next networks: ${SUPPORTED_ETHERSCAN_NETWORKS.toString()}`
|
||||||
|
@ -41,20 +40,26 @@ export const verifyContract = async (
|
||||||
}
|
}
|
||||||
const etherscanPath = await getEtherscanPath(contractName);
|
const etherscanPath = await getEtherscanPath(contractName);
|
||||||
|
|
||||||
const params = {
|
|
||||||
contractName: etherscanPath,
|
|
||||||
address: address,
|
|
||||||
constructorArguments,
|
|
||||||
libraries,
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log(
|
console.log(
|
||||||
'[ETHERSCAN][WARNING] Delaying Etherscan verification due their API can not find newly deployed contracts'
|
'[ETHERSCAN][WARNING] Delaying Etherscan verification due their API can not find newly deployed contracts'
|
||||||
);
|
);
|
||||||
const msDelay = 3000;
|
const msDelay = 3000;
|
||||||
const times = 30;
|
const times = 60;
|
||||||
await runTaskWithRetry('verify-contract', params, times, msDelay);
|
// Write a temporal file to host complex parameters for buidler-etherscan https://github.com/nomiclabs/buidler/tree/development/packages/buidler-etherscan#complex-arguments
|
||||||
|
const {fd, path, cleanup} = await file({
|
||||||
|
prefix: 'verify-params-',
|
||||||
|
postfix: '.js',
|
||||||
|
});
|
||||||
|
fs.writeSync(fd, `module.exports = ${JSON.stringify([...constructorArguments])};`);
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
contractName: etherscanPath,
|
||||||
|
address: address,
|
||||||
|
libraries,
|
||||||
|
constructorArgs: path,
|
||||||
|
};
|
||||||
|
await runTaskWithRetry('verify', params, times, msDelay, cleanup);
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,7 +67,8 @@ export const runTaskWithRetry = async (
|
||||||
task: string,
|
task: string,
|
||||||
params: any,
|
params: any,
|
||||||
times: number,
|
times: number,
|
||||||
msDelay: number
|
msDelay: number,
|
||||||
|
cleanup: () => void
|
||||||
) => {
|
) => {
|
||||||
let counter = times;
|
let counter = times;
|
||||||
await delay(msDelay);
|
await delay(msDelay);
|
||||||
|
@ -70,14 +76,16 @@ export const runTaskWithRetry = async (
|
||||||
try {
|
try {
|
||||||
if (times) {
|
if (times) {
|
||||||
await BRE.run(task, params);
|
await BRE.run(task, params);
|
||||||
|
cleanup();
|
||||||
} else {
|
} else {
|
||||||
|
cleanup();
|
||||||
console.error('[ERROR] Errors after all the retries, check the logs for more information.');
|
console.error('[ERROR] Errors after all the retries, check the logs for more information.');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
counter--;
|
counter--;
|
||||||
console.info(`[INFO] Retrying attemps: ${counter}.`);
|
console.info(`[INFO] Retrying attemps: ${counter}.`);
|
||||||
console.error('[ERROR]', error.message);
|
console.error('[ERROR]', error.message);
|
||||||
await runTaskWithRetry(task, params, counter, msDelay);
|
await runTaskWithRetry(task, params, counter, msDelay, cleanup);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -87,10 +95,6 @@ export const checkVerification = () => {
|
||||||
console.error('Missing process.env.ETHERSCAN_KEY.');
|
console.error('Missing process.env.ETHERSCAN_KEY.');
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
if (!process.env.ETHERSCAN_NETWORK) {
|
|
||||||
console.error('Missing process.env.ETHERSCAN_NETWORK');
|
|
||||||
exit(4);
|
|
||||||
}
|
|
||||||
if (!SUPPORTED_ETHERSCAN_NETWORKS.includes(currentNetwork)) {
|
if (!SUPPORTED_ETHERSCAN_NETWORKS.includes(currentNetwork)) {
|
||||||
console.error(
|
console.error(
|
||||||
`Current network ${currentNetwork} not supported. Please change to one of the next networks: ${SUPPORTED_ETHERSCAN_NETWORKS.toString()}`
|
`Current network ${currentNetwork} not supported. Please change to one of the next networks: ${SUPPORTED_ETHERSCAN_NETWORKS.toString()}`
|
||||||
|
|
|
@ -31,6 +31,7 @@ export const setInitialMarketRatesInRatesOracle = async (
|
||||||
assetAddressIndex
|
assetAddressIndex
|
||||||
];
|
];
|
||||||
await lendingRateOracleInstance.setMarketBorrowRate(assetAddress, borrowRate);
|
await lendingRateOracleInstance.setMarketBorrowRate(assetAddress, borrowRate);
|
||||||
|
console.log('added Market Borrow Rate for: ', assetSymbol);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ export enum eContractid {
|
||||||
LendingRateOracle = 'LendingRateOracle',
|
LendingRateOracle = 'LendingRateOracle',
|
||||||
ChainlinkProxyPriceProvider = 'ChainlinkProxyPriceProvider',
|
ChainlinkProxyPriceProvider = 'ChainlinkProxyPriceProvider',
|
||||||
DefaultReserveInterestRateStrategy = 'DefaultReserveInterestRateStrategy',
|
DefaultReserveInterestRateStrategy = 'DefaultReserveInterestRateStrategy',
|
||||||
LendingPoolLiquidationManager = 'LendingPoolLiquidationManager',
|
LendingPoolCollateralManager = 'LendingPoolCollateralManager',
|
||||||
InitializableAdminUpgradeabilityProxy = 'InitializableAdminUpgradeabilityProxy',
|
InitializableAdminUpgradeabilityProxy = 'InitializableAdminUpgradeabilityProxy',
|
||||||
MockFlashLoanReceiver = 'MockFlashLoanReceiver',
|
MockFlashLoanReceiver = 'MockFlashLoanReceiver',
|
||||||
MockSwapAdapter = 'MockSwapAdapter',
|
MockSwapAdapter = 'MockSwapAdapter',
|
||||||
|
@ -80,6 +80,7 @@ export enum ProtocolErrors {
|
||||||
NO_VARIABLE_RATE_LOAN_IN_RESERVE = '18', // 'User does not have a variable 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'
|
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'
|
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
|
// require error messages - LendingPool
|
||||||
NOT_ENOUGH_STABLE_BORROW_BALANCE = '21', // 'User does not have any stable rate loan for this reserve'
|
NOT_ENOUGH_STABLE_BORROW_BALANCE = '21', // 'User does not have any stable rate loan for this reserve'
|
||||||
|
@ -99,13 +100,13 @@ export enum ProtocolErrors {
|
||||||
RESERVE_ALREADY_INITIALIZED = '34', // 'Reserve has already been initialized'
|
RESERVE_ALREADY_INITIALIZED = '34', // 'Reserve has already been initialized'
|
||||||
|
|
||||||
//require error messages - LendingPoolConfiguration
|
//require error messages - LendingPoolConfiguration
|
||||||
CALLER_NOT_LENDING_POOL_MANAGER = '35', // 'The caller must be a lending pool manager'
|
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'
|
RESERVE_LIQUIDITY_NOT_0 = '36', // 'The liquidity of the reserve needs to be 0'
|
||||||
|
|
||||||
//require error messages - LendingPoolAddressesProviderRegistry
|
//require error messages - LendingPoolAddressesProviderRegistry
|
||||||
PROVIDER_NOT_REGISTERED = '37', // 'Provider is not registered'
|
PROVIDER_NOT_REGISTERED = '37', // 'Provider is not registered'
|
||||||
|
|
||||||
//return error messages - LendingPoolLiquidationManager
|
//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'
|
||||||
COLLATERAL_CANNOT_BE_LIQUIDATED = '39', // 'The collateral chosen cannot be liquidated'
|
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'
|
SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER = '40', // 'User did not borrow the specified currency'
|
||||||
|
@ -337,8 +338,8 @@ export interface ICommonConfiguration {
|
||||||
ChainlinkProxyPriceProvider: iParamsPerNetwork<tEthereumAddress>;
|
ChainlinkProxyPriceProvider: iParamsPerNetwork<tEthereumAddress>;
|
||||||
FallbackOracle: iParamsPerNetwork<tEthereumAddress>;
|
FallbackOracle: iParamsPerNetwork<tEthereumAddress>;
|
||||||
ChainlinkAggregator: iParamsPerNetwork<ITokenAddress>;
|
ChainlinkAggregator: iParamsPerNetwork<ITokenAddress>;
|
||||||
LendingPoolManagerAddress: iParamsPerNetwork<tEthereumAddress | undefined>;
|
AaveAdmin: iParamsPerNetwork<tEthereumAddress | undefined>;
|
||||||
LendingPoolManagerAddressIndex: number;
|
AaveAdminIndex: number;
|
||||||
ReserveAssets: iParamsPerNetwork<SymbolMap<tEthereumAddress>>;
|
ReserveAssets: iParamsPerNetwork<SymbolMap<tEthereumAddress>>;
|
||||||
ReservesConfig: iMultiPoolsAssets<IReserveParams>;
|
ReservesConfig: iMultiPoolsAssets<IReserveParams>;
|
||||||
ATokenDomainSeparator: iParamsPerNetwork<string>;
|
ATokenDomainSeparator: iParamsPerNetwork<string>;
|
||||||
|
|
4157
package-lock.json
generated
4157
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
17
package.json
17
package.json
|
@ -14,7 +14,7 @@
|
||||||
"test": "buidler test",
|
"test": "buidler test",
|
||||||
"test-scenarios": "buidler test test/__setup.spec.ts test/scenario.spec.ts",
|
"test-scenarios": "buidler test test/__setup.spec.ts test/scenario.spec.ts",
|
||||||
"aave:evm:dev:migration": "buidler aave:dev",
|
"aave:evm:dev:migration": "buidler aave:dev",
|
||||||
"aave:evm:full:migration": "buidler aave:full --verify",
|
"aave:evm:full:migration": "buidler aave:full",
|
||||||
"aave:kovan:dev:migration": "npm run buidler:kovan -- aave:dev --verify",
|
"aave:kovan:dev:migration": "npm run buidler:kovan -- aave:dev --verify",
|
||||||
"aave:kovan:full:migration": "npm run buidler:kovan -- aave:full --verify",
|
"aave:kovan:full:migration": "npm run buidler:kovan -- aave:full --verify",
|
||||||
"aave:ropsten:dev:migration": "npm run buidler:ropsten -- aave:dev --verify",
|
"aave:ropsten:dev:migration": "npm run buidler:ropsten -- aave:dev --verify",
|
||||||
|
@ -44,9 +44,9 @@
|
||||||
"ci:clean": "rm -rf ./artifacts ./cache ./types"
|
"ci:clean": "rm -rf ./artifacts ./cache ./types"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nomiclabs/buidler": "1.4.4",
|
"@nomiclabs/buidler": "^1.4.7",
|
||||||
"@nomiclabs/buidler-ethers": "2.0.0",
|
"@nomiclabs/buidler-ethers": "2.0.0",
|
||||||
"@nomiclabs/buidler-etherscan": "1.3.3",
|
"@nomiclabs/buidler-etherscan": "^2.1.0",
|
||||||
"@nomiclabs/buidler-waffle": "2.0.0",
|
"@nomiclabs/buidler-waffle": "2.0.0",
|
||||||
"@openzeppelin/contracts": "3.1.0",
|
"@openzeppelin/contracts": "3.1.0",
|
||||||
"@typechain/ethers-v4": "1.0.0",
|
"@typechain/ethers-v4": "1.0.0",
|
||||||
|
@ -64,7 +64,9 @@
|
||||||
"chai": "4.2.0",
|
"chai": "4.2.0",
|
||||||
"chai-bignumber": "3.0.0",
|
"chai-bignumber": "3.0.0",
|
||||||
"chai-bn": "^0.2.1",
|
"chai-bn": "^0.2.1",
|
||||||
|
"eth-sig-util": "2.5.3",
|
||||||
"ethereum-waffle": "3.0.2",
|
"ethereum-waffle": "3.0.2",
|
||||||
|
"ethereumjs-util": "7.0.2",
|
||||||
"ethers": "5.0.8",
|
"ethers": "5.0.8",
|
||||||
"husky": "^4.2.5",
|
"husky": "^4.2.5",
|
||||||
"lowdb": "1.0.0",
|
"lowdb": "1.0.0",
|
||||||
|
@ -78,9 +80,7 @@
|
||||||
"tslint-config-prettier": "^1.18.0",
|
"tslint-config-prettier": "^1.18.0",
|
||||||
"tslint-plugin-prettier": "^2.3.0",
|
"tslint-plugin-prettier": "^2.3.0",
|
||||||
"typechain": "2.0.0",
|
"typechain": "2.0.0",
|
||||||
"typescript": "3.9.3",
|
"typescript": "3.9.3"
|
||||||
"eth-sig-util": "2.5.3",
|
|
||||||
"ethereumjs-util": "7.0.2"
|
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
|
@ -102,5 +102,8 @@
|
||||||
"email": "andrey@aave.com"
|
"email": "andrey@aave.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"license": "AGPLv3"
|
"license": "AGPLv3",
|
||||||
|
"dependencies": {
|
||||||
|
"tmp-promise": "^3.0.2"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,10 @@ task(
|
||||||
.setAction(async ({verify}, localBRE) => {
|
.setAction(async ({verify}, localBRE) => {
|
||||||
await localBRE.run('set-bre');
|
await localBRE.run('set-bre');
|
||||||
|
|
||||||
const lendingPoolManager = await (await localBRE.ethers.getSigners())[0].getAddress();
|
const admin = await (await localBRE.ethers.getSigners())[0].getAddress();
|
||||||
|
|
||||||
const addressesProvider = await deployLendingPoolAddressesProvider(verify);
|
const addressesProvider = await deployLendingPoolAddressesProvider(verify);
|
||||||
await waitForTx(await addressesProvider.setLendingPoolManager(lendingPoolManager));
|
await waitForTx(await addressesProvider.setAaveAdmin(admin));
|
||||||
|
|
||||||
const addressesProviderRegistry = await deployLendingPoolAddressesProviderRegistry(verify);
|
const addressesProviderRegistry = await deployLendingPoolAddressesProviderRegistry(verify);
|
||||||
await waitForTx(
|
await waitForTx(
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {task} from '@nomiclabs/buidler/config';
|
||||||
import {
|
import {
|
||||||
getLendingPoolAddressesProvider,
|
getLendingPoolAddressesProvider,
|
||||||
initReserves,
|
initReserves,
|
||||||
deployLendingPoolLiquidationManager,
|
deployLendingPoolCollateralManager,
|
||||||
insertContractAddressInDb,
|
insertContractAddressInDb,
|
||||||
deployMockFlashLoanReceiver,
|
deployMockFlashLoanReceiver,
|
||||||
deployWalletBalancerProvider,
|
deployWalletBalancerProvider,
|
||||||
|
@ -17,6 +17,7 @@ import {tEthereumAddress, AavePools, eContractid} from '../../helpers/types';
|
||||||
import {waitForTx, filterMapBy} from '../../helpers/misc-utils';
|
import {waitForTx, filterMapBy} from '../../helpers/misc-utils';
|
||||||
import {enableReservesToBorrow, enableReservesAsCollateral} from '../../helpers/init-helpers';
|
import {enableReservesToBorrow, enableReservesAsCollateral} from '../../helpers/init-helpers';
|
||||||
import {getAllTokenAddresses} from '../../helpers/mock-helpers';
|
import {getAllTokenAddresses} from '../../helpers/mock-helpers';
|
||||||
|
import {ZERO_ADDRESS} from '../../helpers/constants';
|
||||||
|
|
||||||
task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
|
task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
.addOptionalParam('verify', 'Verify contracts at Etherscan')
|
.addOptionalParam('verify', 'Verify contracts at Etherscan')
|
||||||
|
@ -43,6 +44,7 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
lendingPoolProxy,
|
lendingPoolProxy,
|
||||||
lendingPoolConfiguratorProxy,
|
lendingPoolConfiguratorProxy,
|
||||||
AavePools.proto,
|
AavePools.proto,
|
||||||
|
ZERO_ADDRESS,
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
await enableReservesToBorrow(
|
await enableReservesToBorrow(
|
||||||
|
@ -58,9 +60,9 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
lendingPoolConfiguratorProxy
|
lendingPoolConfiguratorProxy
|
||||||
);
|
);
|
||||||
|
|
||||||
const liquidationManager = await deployLendingPoolLiquidationManager(verify);
|
const collateralManager = await deployLendingPoolCollateralManager(verify);
|
||||||
await waitForTx(
|
await waitForTx(
|
||||||
await addressesProvider.setLendingPoolLiquidationManager(liquidationManager.address)
|
await addressesProvider.setLendingPoolCollateralManager(collateralManager.address)
|
||||||
);
|
);
|
||||||
|
|
||||||
const mockFlashLoanReceiver = await deployMockFlashLoanReceiver(
|
const mockFlashLoanReceiver = await deployMockFlashLoanReceiver(
|
||||||
|
|
|
@ -6,18 +6,14 @@ import {
|
||||||
getLendingPoolAddressesProviderRegistry,
|
getLendingPoolAddressesProviderRegistry,
|
||||||
} from '../../helpers/contracts-helpers';
|
} from '../../helpers/contracts-helpers';
|
||||||
import {waitForTx} from '../../helpers/misc-utils';
|
import {waitForTx} from '../../helpers/misc-utils';
|
||||||
import {
|
import {ConfigNames, loadPoolConfig, getGenesisAaveAdmin} from '../../helpers/configuration';
|
||||||
ConfigNames,
|
|
||||||
loadPoolConfig,
|
|
||||||
getGenesisLendingPoolManagerAddress,
|
|
||||||
} from '../../helpers/configuration';
|
|
||||||
import {eEthereumNetwork} from '../../helpers/types';
|
import {eEthereumNetwork} from '../../helpers/types';
|
||||||
|
|
||||||
task(
|
task(
|
||||||
'full:deploy-address-provider',
|
'full:deploy-address-provider',
|
||||||
'Deploy address provider, registry and fee provider for dev enviroment'
|
'Deploy address provider, registry and fee provider for dev enviroment'
|
||||||
)
|
)
|
||||||
.addOptionalParam('verify', 'Verify contracts at Etherscan')
|
.addFlag('verify', 'Verify contracts at Etherscan')
|
||||||
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
||||||
.setAction(async ({verify, pool}, localBRE) => {
|
.setAction(async ({verify, pool}, localBRE) => {
|
||||||
await localBRE.run('set-bre');
|
await localBRE.run('set-bre');
|
||||||
|
@ -28,11 +24,7 @@ task(
|
||||||
const providerRegistryAddress = getParamPerNetwork(poolConfig.ProviderRegistry, network);
|
const providerRegistryAddress = getParamPerNetwork(poolConfig.ProviderRegistry, network);
|
||||||
// Deploy address provider and set genesis manager
|
// Deploy address provider and set genesis manager
|
||||||
const addressesProvider = await deployLendingPoolAddressesProvider(verify);
|
const addressesProvider = await deployLendingPoolAddressesProvider(verify);
|
||||||
await waitForTx(
|
await waitForTx(await addressesProvider.setAaveAdmin(await getGenesisAaveAdmin(poolConfig)));
|
||||||
await addressesProvider.setLendingPoolManager(
|
|
||||||
await getGenesisLendingPoolManagerAddress(poolConfig)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// If no provider registry is set, deploy lending pool address provider registry and register the address provider
|
// If no provider registry is set, deploy lending pool address provider registry and register the address provider
|
||||||
const addressesProviderRegistry = !providerRegistryAddress
|
const addressesProviderRegistry = !providerRegistryAddress
|
||||||
|
|
|
@ -11,7 +11,7 @@ import {eContractid} from '../../helpers/types';
|
||||||
import {waitForTx} from '../../helpers/misc-utils';
|
import {waitForTx} from '../../helpers/misc-utils';
|
||||||
|
|
||||||
task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
|
task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
|
||||||
.addOptionalParam('verify', 'Verify contracts at Etherscan')
|
.addFlag('verify', 'Verify contracts at Etherscan')
|
||||||
.setAction(async ({verify}, localBRE) => {
|
.setAction(async ({verify}, localBRE) => {
|
||||||
await localBRE.run('set-bre');
|
await localBRE.run('set-bre');
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,13 @@ import {setInitialMarketRatesInRatesOracle} from '../../helpers/oracles-helpers'
|
||||||
import {ICommonConfiguration, eEthereumNetwork, SymbolMap} from '../../helpers/types';
|
import {ICommonConfiguration, eEthereumNetwork, SymbolMap} from '../../helpers/types';
|
||||||
import {waitForTx, filterMapBy} from '../../helpers/misc-utils';
|
import {waitForTx, filterMapBy} from '../../helpers/misc-utils';
|
||||||
import {ConfigNames, loadPoolConfig} from '../../helpers/configuration';
|
import {ConfigNames, loadPoolConfig} from '../../helpers/configuration';
|
||||||
|
import {exit} from 'process';
|
||||||
|
|
||||||
task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
|
task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
|
||||||
.addOptionalParam('verify', 'Verify contracts at Etherscan')
|
.addFlag('verify', 'Verify contracts at Etherscan')
|
||||||
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
||||||
.setAction(async ({verify, pool}, localBRE) => {
|
.setAction(async ({verify, pool}, localBRE) => {
|
||||||
|
try {
|
||||||
await localBRE.run('set-bre');
|
await localBRE.run('set-bre');
|
||||||
const network = <eEthereumNetwork>localBRE.network.name;
|
const network = <eEthereumNetwork>localBRE.network.name;
|
||||||
const poolConfig = loadPoolConfig(pool);
|
const poolConfig = loadPoolConfig(pool);
|
||||||
|
@ -43,8 +45,13 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
|
||||||
};
|
};
|
||||||
const [tokens, aggregators] = getPairsTokenAggregator(tokensToWatch, chainlinkAggregators);
|
const [tokens, aggregators] = getPairsTokenAggregator(tokensToWatch, chainlinkAggregators);
|
||||||
|
|
||||||
await deployChainlinkProxyPriceProvider([tokens, aggregators, fallbackOracle], verify);
|
const chainlinkProviderPriceProvider = await deployChainlinkProxyPriceProvider(
|
||||||
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle));
|
[tokens, aggregators, fallbackOracle],
|
||||||
|
verify
|
||||||
|
);
|
||||||
|
await waitForTx(
|
||||||
|
await addressesProvider.setPriceOracle(chainlinkProviderPriceProvider.address)
|
||||||
|
);
|
||||||
|
|
||||||
const lendingRateOracle = await deployLendingRateOracle(verify);
|
const lendingRateOracle = await deployLendingRateOracle(verify);
|
||||||
await waitForTx(await addressesProvider.setLendingRateOracle(lendingRateOracle.address));
|
await waitForTx(await addressesProvider.setLendingRateOracle(lendingRateOracle.address));
|
||||||
|
@ -55,4 +62,8 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
|
||||||
tokensAddressesWithoutUsd,
|
tokensAddressesWithoutUsd,
|
||||||
lendingRateOracle
|
lendingRateOracle
|
||||||
);
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {task} from '@nomiclabs/buidler/config';
|
||||||
import {
|
import {
|
||||||
getLendingPoolAddressesProvider,
|
getLendingPoolAddressesProvider,
|
||||||
initReserves,
|
initReserves,
|
||||||
deployLendingPoolLiquidationManager,
|
deployLendingPoolCollateralManager,
|
||||||
insertContractAddressInDb,
|
insertContractAddressInDb,
|
||||||
deployWalletBalancerProvider,
|
deployWalletBalancerProvider,
|
||||||
deployAaveProtocolTestHelpers,
|
deployAaveProtocolTestHelpers,
|
||||||
|
@ -15,12 +15,16 @@ import {loadPoolConfig, ConfigNames} from '../../helpers/configuration';
|
||||||
import {AavePools, eContractid, eEthereumNetwork, ICommonConfiguration} from '../../helpers/types';
|
import {AavePools, eContractid, eEthereumNetwork, ICommonConfiguration} from '../../helpers/types';
|
||||||
import {waitForTx} from '../../helpers/misc-utils';
|
import {waitForTx} from '../../helpers/misc-utils';
|
||||||
import {enableReservesToBorrow, enableReservesAsCollateral} from '../../helpers/init-helpers';
|
import {enableReservesToBorrow, enableReservesAsCollateral} from '../../helpers/init-helpers';
|
||||||
|
import {ZERO_ADDRESS} from '../../helpers/constants';
|
||||||
|
import {exit} from 'process';
|
||||||
|
|
||||||
task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
.addOptionalParam('verify', 'Verify contracts at Etherscan')
|
.addFlag('verify', 'Verify contracts at Etherscan')
|
||||||
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
||||||
.setAction(async ({verify, pool}, localBRE) => {
|
.setAction(async ({verify, pool}, localBRE) => {
|
||||||
|
try {
|
||||||
await localBRE.run('set-bre');
|
await localBRE.run('set-bre');
|
||||||
|
console.log('init');
|
||||||
const network = <eEthereumNetwork>localBRE.network.name;
|
const network = <eEthereumNetwork>localBRE.network.name;
|
||||||
const poolConfig = loadPoolConfig(pool);
|
const poolConfig = loadPoolConfig(pool);
|
||||||
const {ReserveAssets, ReservesConfig} = poolConfig as ICommonConfiguration;
|
const {ReserveAssets, ReservesConfig} = poolConfig as ICommonConfiguration;
|
||||||
|
@ -31,6 +35,7 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
|
|
||||||
const addressesProvider = await getLendingPoolAddressesProvider();
|
const addressesProvider = await getLendingPoolAddressesProvider();
|
||||||
|
|
||||||
|
console.log('init reserves');
|
||||||
await initReserves(
|
await initReserves(
|
||||||
ReservesConfig,
|
ReservesConfig,
|
||||||
reserveAssets,
|
reserveAssets,
|
||||||
|
@ -38,14 +43,17 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
lendingPoolProxy,
|
lendingPoolProxy,
|
||||||
lendingPoolConfiguratorProxy,
|
lendingPoolConfiguratorProxy,
|
||||||
AavePools.proto,
|
AavePools.proto,
|
||||||
|
ZERO_ADDRESS,
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
console.log('enable reserves');
|
||||||
await enableReservesToBorrow(
|
await enableReservesToBorrow(
|
||||||
ReservesConfig,
|
ReservesConfig,
|
||||||
reserveAssets,
|
reserveAssets,
|
||||||
lendingPoolProxy,
|
lendingPoolProxy,
|
||||||
lendingPoolConfiguratorProxy
|
lendingPoolConfiguratorProxy
|
||||||
);
|
);
|
||||||
|
console.log('enable reserves as collateral');
|
||||||
await enableReservesAsCollateral(
|
await enableReservesAsCollateral(
|
||||||
ReservesConfig,
|
ReservesConfig,
|
||||||
reserveAssets,
|
reserveAssets,
|
||||||
|
@ -53,14 +61,16 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
lendingPoolConfiguratorProxy
|
lendingPoolConfiguratorProxy
|
||||||
);
|
);
|
||||||
|
|
||||||
const liquidationManager = await deployLendingPoolLiquidationManager(verify);
|
console.log('deploy coll manager');
|
||||||
|
const collateralManager = await deployLendingPoolCollateralManager(verify);
|
||||||
await waitForTx(
|
await waitForTx(
|
||||||
await addressesProvider.setLendingPoolLiquidationManager(liquidationManager.address)
|
await addressesProvider.setLendingPoolCollateralManager(collateralManager.address)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log('deploy bal provicer');
|
||||||
await deployWalletBalancerProvider(addressesProvider.address, verify);
|
await deployWalletBalancerProvider(addressesProvider.address, verify);
|
||||||
|
} catch (err) {
|
||||||
const testHelpers = await deployAaveProtocolTestHelpers(addressesProvider.address, verify);
|
console.error(err);
|
||||||
|
exit(1);
|
||||||
await insertContractAddressInDb(eContractid.AaveProtocolTestHelpers, testHelpers.address);
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,8 +9,7 @@ import {
|
||||||
deployPriceOracle,
|
deployPriceOracle,
|
||||||
getLendingPoolConfiguratorProxy,
|
getLendingPoolConfiguratorProxy,
|
||||||
deployChainlinkProxyPriceProvider,
|
deployChainlinkProxyPriceProvider,
|
||||||
deployLendingRateOracle,
|
deployLendingPoolCollateralManager,
|
||||||
deployLendingPoolLiquidationManager,
|
|
||||||
deployMockFlashLoanReceiver,
|
deployMockFlashLoanReceiver,
|
||||||
deployWalletBalancerProvider,
|
deployWalletBalancerProvider,
|
||||||
getLendingPool,
|
getLendingPool,
|
||||||
|
@ -21,6 +20,7 @@ import {
|
||||||
getPairsTokenAggregator,
|
getPairsTokenAggregator,
|
||||||
initReserves,
|
initReserves,
|
||||||
deployMockSwapAdapter,
|
deployMockSwapAdapter,
|
||||||
|
deployLendingRateOracle,
|
||||||
} from '../helpers/contracts-helpers';
|
} from '../helpers/contracts-helpers';
|
||||||
import {Signer} from 'ethers';
|
import {Signer} from 'ethers';
|
||||||
import {TokenContractId, eContractid, tEthereumAddress, AavePools} from '../helpers/types';
|
import {TokenContractId, eContractid, tEthereumAddress, AavePools} from '../helpers/types';
|
||||||
|
@ -36,6 +36,7 @@ import {
|
||||||
import {waitForTx} from '../helpers/misc-utils';
|
import {waitForTx} from '../helpers/misc-utils';
|
||||||
import {enableReservesToBorrow, enableReservesAsCollateral} from '../helpers/init-helpers';
|
import {enableReservesToBorrow, enableReservesAsCollateral} from '../helpers/init-helpers';
|
||||||
import {AaveConfig} from '../config/aave';
|
import {AaveConfig} from '../config/aave';
|
||||||
|
import {ZERO_ADDRESS} from '../helpers/constants';
|
||||||
|
|
||||||
const MOCK_USD_PRICE_IN_WEI = AaveConfig.ProtocolGlobalParams.MockUsdPriceInWei;
|
const MOCK_USD_PRICE_IN_WEI = AaveConfig.ProtocolGlobalParams.MockUsdPriceInWei;
|
||||||
const ALL_ASSETS_INITIAL_PRICES = AaveConfig.Mocks.AllAssetsInitialPrices;
|
const ALL_ASSETS_INITIAL_PRICES = AaveConfig.Mocks.AllAssetsInitialPrices;
|
||||||
|
@ -75,12 +76,12 @@ const deployAllMockTokens = async (deployer: Signer) => {
|
||||||
|
|
||||||
const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
console.time('setup');
|
console.time('setup');
|
||||||
const lendingPoolManager = await deployer.getAddress();
|
const aaveAdmin = await deployer.getAddress();
|
||||||
|
|
||||||
const mockTokens = await deployAllMockTokens(deployer);
|
const mockTokens = await deployAllMockTokens(deployer);
|
||||||
|
|
||||||
const addressesProvider = await deployLendingPoolAddressesProvider();
|
const addressesProvider = await deployLendingPoolAddressesProvider();
|
||||||
await waitForTx(await addressesProvider.setLendingPoolManager(lendingPoolManager));
|
await waitForTx(await addressesProvider.setAaveAdmin(aaveAdmin));
|
||||||
|
|
||||||
const addressesProviderRegistry = await deployLendingPoolAddressesProviderRegistry();
|
const addressesProviderRegistry = await deployLendingPoolAddressesProviderRegistry();
|
||||||
await waitForTx(
|
await waitForTx(
|
||||||
|
@ -208,6 +209,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
lendingPoolProxy,
|
lendingPoolProxy,
|
||||||
lendingPoolConfiguratorProxy,
|
lendingPoolConfiguratorProxy,
|
||||||
AavePools.proto,
|
AavePools.proto,
|
||||||
|
ZERO_ADDRESS,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
await enableReservesToBorrow(
|
await enableReservesToBorrow(
|
||||||
|
@ -223,9 +225,9 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
lendingPoolConfiguratorProxy
|
lendingPoolConfiguratorProxy
|
||||||
);
|
);
|
||||||
|
|
||||||
const liquidationManager = await deployLendingPoolLiquidationManager();
|
const collateralManager = await deployLendingPoolCollateralManager();
|
||||||
await waitForTx(
|
await waitForTx(
|
||||||
await addressesProvider.setLendingPoolLiquidationManager(liquidationManager.address)
|
await addressesProvider.setLendingPoolCollateralManager(collateralManager.address)
|
||||||
);
|
);
|
||||||
|
|
||||||
const mockFlashLoanReceiver = await deployMockFlashLoanReceiver(addressesProvider.address);
|
const mockFlashLoanReceiver = await deployMockFlashLoanReceiver(addressesProvider.address);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import {MAX_UINT_AMOUNT, ZERO_ADDRESS, BUIDLEREVM_CHAINID} from '../helpers/constants';
|
import {MAX_UINT_AMOUNT, ZERO_ADDRESS} from '../helpers/constants';
|
||||||
|
import {BUIDLEREVM_CHAINID} from '../helpers/buidler-constants';
|
||||||
import {buildPermitParams, getSignatureFromTypedData} from '../helpers/contracts-helpers';
|
import {buildPermitParams, getSignatureFromTypedData} from '../helpers/contracts-helpers';
|
||||||
import {expect} from 'chai';
|
import {expect} from 'chai';
|
||||||
import {ethers} from 'ethers';
|
import {ethers} from 'ethers';
|
||||||
|
|
|
@ -13,12 +13,63 @@ const {expect} = require('chai');
|
||||||
|
|
||||||
makeSuite('LendingPool SwapDeposit function', (testEnv: TestEnv) => {
|
makeSuite('LendingPool SwapDeposit function', (testEnv: TestEnv) => {
|
||||||
let _mockSwapAdapter = {} as MockSwapAdapter;
|
let _mockSwapAdapter = {} as MockSwapAdapter;
|
||||||
const {HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD} = ProtocolErrors;
|
const {
|
||||||
|
HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD,
|
||||||
|
NO_UNFREEZED_RESERVE,
|
||||||
|
NO_ACTIVE_RESERVE,
|
||||||
|
INVALID_EQUAL_ASSETS_TO_SWAP,
|
||||||
|
} = ProtocolErrors;
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
_mockSwapAdapter = await getMockSwapAdapter();
|
_mockSwapAdapter = await getMockSwapAdapter();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Should not allow to swap if from equal to', async () => {
|
||||||
|
const {pool, weth} = testEnv;
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
pool.swapLiquidity(
|
||||||
|
_mockSwapAdapter.address,
|
||||||
|
weth.address,
|
||||||
|
weth.address,
|
||||||
|
'1'.toString(),
|
||||||
|
'0x10'
|
||||||
|
)
|
||||||
|
).to.be.revertedWith(INVALID_EQUAL_ASSETS_TO_SWAP);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should not allow to swap if from or to reserves are not active', async () => {
|
||||||
|
const {pool, weth, dai, configurator} = testEnv;
|
||||||
|
|
||||||
|
await configurator.deactivateReserve(weth.address);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
pool.swapLiquidity(
|
||||||
|
_mockSwapAdapter.address,
|
||||||
|
weth.address,
|
||||||
|
dai.address,
|
||||||
|
'1'.toString(),
|
||||||
|
'0x10'
|
||||||
|
)
|
||||||
|
).to.be.revertedWith(NO_ACTIVE_RESERVE);
|
||||||
|
await configurator.activateReserve(weth.address);
|
||||||
|
|
||||||
|
await configurator.deactivateReserve(dai.address);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
pool.swapLiquidity(
|
||||||
|
_mockSwapAdapter.address,
|
||||||
|
weth.address,
|
||||||
|
dai.address,
|
||||||
|
'1'.toString(),
|
||||||
|
'0x10'
|
||||||
|
)
|
||||||
|
).to.be.revertedWith(NO_ACTIVE_RESERVE);
|
||||||
|
|
||||||
|
//cleanup state
|
||||||
|
await configurator.activateReserve(dai.address);
|
||||||
|
});
|
||||||
|
|
||||||
it('Deposits WETH into the reserve', async () => {
|
it('Deposits WETH into the reserve', async () => {
|
||||||
const {pool, weth, users} = testEnv;
|
const {pool, weth, users} = testEnv;
|
||||||
const amountToDeposit = ethers.utils.parseEther('1');
|
const amountToDeposit = ethers.utils.parseEther('1');
|
||||||
|
@ -32,6 +83,7 @@ makeSuite('LendingPool SwapDeposit function', (testEnv: TestEnv) => {
|
||||||
.deposit(weth.address, amountToDeposit, await signer.getAddress(), '0');
|
.deposit(weth.address, amountToDeposit, await signer.getAddress(), '0');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('User tries to swap more then he can, revert expected', async () => {
|
it('User tries to swap more then he can, revert expected', async () => {
|
||||||
const {pool, weth, dai} = testEnv;
|
const {pool, weth, dai} = testEnv;
|
||||||
await expect(
|
await expect(
|
||||||
|
@ -45,19 +97,6 @@ makeSuite('LendingPool SwapDeposit function', (testEnv: TestEnv) => {
|
||||||
).to.be.revertedWith('55');
|
).to.be.revertedWith('55');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('User tries to swap asset on equal asset, revert expected', async () => {
|
|
||||||
const {pool, weth} = testEnv;
|
|
||||||
await expect(
|
|
||||||
pool.swapLiquidity(
|
|
||||||
_mockSwapAdapter.address,
|
|
||||||
weth.address,
|
|
||||||
weth.address,
|
|
||||||
ethers.utils.parseEther('0.1'),
|
|
||||||
'0x10'
|
|
||||||
)
|
|
||||||
).to.be.revertedWith('56');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('User tries to swap more then available on the reserve', async () => {
|
it('User tries to swap more then available on the reserve', async () => {
|
||||||
const {pool, weth, dai, users, aEth, deployer} = testEnv;
|
const {pool, weth, dai, users, aEth, deployer} = testEnv;
|
||||||
|
|
||||||
|
@ -134,6 +173,9 @@ makeSuite('LendingPool SwapDeposit function', (testEnv: TestEnv) => {
|
||||||
reserveBalanceDAIBefore.add(amountToReturn).toString(),
|
reserveBalanceDAIBefore.add(amountToReturn).toString(),
|
||||||
'was received incorrect amount if reserve funds'
|
'was received incorrect amount if reserve funds'
|
||||||
);
|
);
|
||||||
|
expect(
|
||||||
|
(await pool.getUserReserveData(dai.address, userAddress)).usageAsCollateralEnabled
|
||||||
|
).to.be.equal(true, 'usage as collateral was not enabled on destination reserve for the user');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('User tries to drop HF below one', async () => {
|
it('User tries to drop HF below one', async () => {
|
||||||
|
@ -151,7 +193,7 @@ makeSuite('LendingPool SwapDeposit function', (testEnv: TestEnv) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should set usage as collateral to false if no leftovers after swap', async () => {
|
it('Should set usage as collateral to false if no leftovers after swap', async () => {
|
||||||
const {pool, weth, dai, aEth, users} = testEnv;
|
const {pool, weth, dai, users} = testEnv;
|
||||||
const userAddress = await pool.signer.getAddress();
|
const userAddress = await pool.signer.getAddress();
|
||||||
|
|
||||||
// add more liquidity to allow user 0 to swap everything he has
|
// add more liquidity to allow user 0 to swap everything he has
|
||||||
|
@ -195,4 +237,22 @@ makeSuite('LendingPool SwapDeposit function', (testEnv: TestEnv) => {
|
||||||
'usageAsCollateralEnabled are not set to false'
|
'usageAsCollateralEnabled are not set to false'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it('Should not allow to swap if to reserve are freezed', async () => {
|
||||||
|
const {pool, weth, dai, configurator} = testEnv;
|
||||||
|
|
||||||
|
await configurator.freezeReserve(dai.address);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
pool.swapLiquidity(
|
||||||
|
_mockSwapAdapter.address,
|
||||||
|
weth.address,
|
||||||
|
dai.address,
|
||||||
|
'1'.toString(),
|
||||||
|
'0x10'
|
||||||
|
)
|
||||||
|
).to.be.revertedWith(NO_UNFREEZED_RESERVE);
|
||||||
|
|
||||||
|
//cleanup state
|
||||||
|
await configurator.unfreezeReserve(dai.address);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,7 +10,7 @@ const APPROVAL_AMOUNT_LENDING_POOL =
|
||||||
const {expect} = require('chai');
|
const {expect} = require('chai');
|
||||||
|
|
||||||
makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
||||||
const {CALLER_NOT_LENDING_POOL_MANAGER, RESERVE_LIQUIDITY_NOT_0} = ProtocolErrors;
|
const {CALLER_NOT_AAVE_ADMIN, RESERVE_LIQUIDITY_NOT_0} = ProtocolErrors;
|
||||||
|
|
||||||
it('Deactivates the ETH reserve', async () => {
|
it('Deactivates the ETH reserve', async () => {
|
||||||
const {configurator, pool, weth} = testEnv;
|
const {configurator, pool, weth} = testEnv;
|
||||||
|
@ -27,20 +27,20 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
||||||
expect(isActive).to.be.equal(true);
|
expect(isActive).to.be.equal(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Check the onlyLendingPoolManager on deactivateReserve ', async () => {
|
it('Check the onlyAaveAdmin on deactivateReserve ', async () => {
|
||||||
const {configurator, users, weth} = testEnv;
|
const {configurator, users, weth} = testEnv;
|
||||||
await expect(
|
await expect(
|
||||||
configurator.connect(users[2].signer).deactivateReserve(weth.address),
|
configurator.connect(users[2].signer).deactivateReserve(weth.address),
|
||||||
CALLER_NOT_LENDING_POOL_MANAGER
|
CALLER_NOT_AAVE_ADMIN
|
||||||
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Check the onlyLendingPoolManager on activateReserve ', async () => {
|
it('Check the onlyAaveAdmin on activateReserve ', async () => {
|
||||||
const {configurator, users, weth} = testEnv;
|
const {configurator, users, weth} = testEnv;
|
||||||
await expect(
|
await expect(
|
||||||
configurator.connect(users[2].signer).activateReserve(weth.address),
|
configurator.connect(users[2].signer).activateReserve(weth.address),
|
||||||
CALLER_NOT_LENDING_POOL_MANAGER
|
CALLER_NOT_AAVE_ADMIN
|
||||||
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Freezes the ETH reserve', async () => {
|
it('Freezes the ETH reserve', async () => {
|
||||||
|
@ -58,20 +58,20 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
||||||
expect(isFreezed).to.be.equal(false);
|
expect(isFreezed).to.be.equal(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Check the onlyLendingPoolManager on freezeReserve ', async () => {
|
it('Check the onlyAaveAdmin on freezeReserve ', async () => {
|
||||||
const {configurator, users, weth} = testEnv;
|
const {configurator, users, weth} = testEnv;
|
||||||
await expect(
|
await expect(
|
||||||
configurator.connect(users[2].signer).freezeReserve(weth.address),
|
configurator.connect(users[2].signer).freezeReserve(weth.address),
|
||||||
CALLER_NOT_LENDING_POOL_MANAGER
|
CALLER_NOT_AAVE_ADMIN
|
||||||
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Check the onlyLendingPoolManager on unfreezeReserve ', async () => {
|
it('Check the onlyAaveAdmin on unfreezeReserve ', async () => {
|
||||||
const {configurator, users, weth} = testEnv;
|
const {configurator, users, weth} = testEnv;
|
||||||
await expect(
|
await expect(
|
||||||
configurator.connect(users[2].signer).unfreezeReserve(weth.address),
|
configurator.connect(users[2].signer).unfreezeReserve(weth.address),
|
||||||
CALLER_NOT_LENDING_POOL_MANAGER
|
CALLER_NOT_AAVE_ADMIN
|
||||||
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Deactivates the ETH reserve for borrowing', async () => {
|
it('Deactivates the ETH reserve for borrowing', async () => {
|
||||||
|
@ -90,20 +90,20 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
||||||
expect(variableBorrowIndex.toString()).to.be.equal(RAY);
|
expect(variableBorrowIndex.toString()).to.be.equal(RAY);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Check the onlyLendingPoolManager on disableBorrowingOnReserve ', async () => {
|
it('Check the onlyAaveAdmin on disableBorrowingOnReserve ', async () => {
|
||||||
const {configurator, users, weth} = testEnv;
|
const {configurator, users, weth} = testEnv;
|
||||||
await expect(
|
await expect(
|
||||||
configurator.connect(users[2].signer).disableBorrowingOnReserve(weth.address),
|
configurator.connect(users[2].signer).disableBorrowingOnReserve(weth.address),
|
||||||
CALLER_NOT_LENDING_POOL_MANAGER
|
CALLER_NOT_AAVE_ADMIN
|
||||||
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Check the onlyLendingPoolManager on enableBorrowingOnReserve ', async () => {
|
it('Check the onlyAaveAdmin on enableBorrowingOnReserve ', async () => {
|
||||||
const {configurator, users, weth} = testEnv;
|
const {configurator, users, weth} = testEnv;
|
||||||
await expect(
|
await expect(
|
||||||
configurator.connect(users[2].signer).enableBorrowingOnReserve(weth.address, true),
|
configurator.connect(users[2].signer).enableBorrowingOnReserve(weth.address, true),
|
||||||
CALLER_NOT_LENDING_POOL_MANAGER
|
CALLER_NOT_AAVE_ADMIN
|
||||||
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Deactivates the ETH reserve as collateral', async () => {
|
it('Deactivates the ETH reserve as collateral', async () => {
|
||||||
|
@ -121,22 +121,22 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
||||||
expect(usageAsCollateralEnabled).to.be.equal(true);
|
expect(usageAsCollateralEnabled).to.be.equal(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Check the onlyLendingPoolManager on disableReserveAsCollateral ', async () => {
|
it('Check the onlyAaveAdmin on disableReserveAsCollateral ', async () => {
|
||||||
const {configurator, users, weth} = testEnv;
|
const {configurator, users, weth} = testEnv;
|
||||||
await expect(
|
await expect(
|
||||||
configurator.connect(users[2].signer).disableReserveAsCollateral(weth.address),
|
configurator.connect(users[2].signer).disableReserveAsCollateral(weth.address),
|
||||||
CALLER_NOT_LENDING_POOL_MANAGER
|
CALLER_NOT_AAVE_ADMIN
|
||||||
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Check the onlyLendingPoolManager on enableReserveAsCollateral ', async () => {
|
it('Check the onlyAaveAdmin on enableReserveAsCollateral ', async () => {
|
||||||
const {configurator, users, weth} = testEnv;
|
const {configurator, users, weth} = testEnv;
|
||||||
await expect(
|
await expect(
|
||||||
configurator
|
configurator
|
||||||
.connect(users[2].signer)
|
.connect(users[2].signer)
|
||||||
.enableReserveAsCollateral(weth.address, '75', '80', '105'),
|
.enableReserveAsCollateral(weth.address, '75', '80', '105'),
|
||||||
CALLER_NOT_LENDING_POOL_MANAGER
|
CALLER_NOT_AAVE_ADMIN
|
||||||
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Disable stable borrow rate on the ETH reserve', async () => {
|
it('Disable stable borrow rate on the ETH reserve', async () => {
|
||||||
|
@ -153,20 +153,20 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
||||||
expect(stableBorrowRateEnabled).to.be.equal(true);
|
expect(stableBorrowRateEnabled).to.be.equal(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Check the onlyLendingPoolManager on disableReserveStableRate', async () => {
|
it('Check the onlyAaveAdmin on disableReserveStableRate', async () => {
|
||||||
const {configurator, users, weth} = testEnv;
|
const {configurator, users, weth} = testEnv;
|
||||||
await expect(
|
await expect(
|
||||||
configurator.connect(users[2].signer).disableReserveStableRate(weth.address),
|
configurator.connect(users[2].signer).disableReserveStableRate(weth.address),
|
||||||
CALLER_NOT_LENDING_POOL_MANAGER
|
CALLER_NOT_AAVE_ADMIN
|
||||||
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Check the onlyLendingPoolManager on enableReserveStableRate', async () => {
|
it('Check the onlyAaveAdmin on enableReserveStableRate', async () => {
|
||||||
const {configurator, users, weth} = testEnv;
|
const {configurator, users, weth} = testEnv;
|
||||||
await expect(
|
await expect(
|
||||||
configurator.connect(users[2].signer).enableReserveStableRate(weth.address),
|
configurator.connect(users[2].signer).enableReserveStableRate(weth.address),
|
||||||
CALLER_NOT_LENDING_POOL_MANAGER
|
CALLER_NOT_AAVE_ADMIN
|
||||||
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Changes LTV of the reserve', async () => {
|
it('Changes LTV of the reserve', async () => {
|
||||||
|
@ -176,12 +176,12 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
||||||
expect(ltv.toString()).to.be.bignumber.equal('60', 'Invalid LTV');
|
expect(ltv.toString()).to.be.bignumber.equal('60', 'Invalid LTV');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Check the onlyLendingPoolManager on setLtv', async () => {
|
it('Check the onlyAaveAdmin on setLtv', async () => {
|
||||||
const {configurator, users, weth} = testEnv;
|
const {configurator, users, weth} = testEnv;
|
||||||
await expect(
|
await expect(
|
||||||
configurator.connect(users[2].signer).setLtv(weth.address, '75'),
|
configurator.connect(users[2].signer).setLtv(weth.address, '75'),
|
||||||
CALLER_NOT_LENDING_POOL_MANAGER
|
CALLER_NOT_AAVE_ADMIN
|
||||||
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Changes liquidation threshold of the reserve', async () => {
|
it('Changes liquidation threshold of the reserve', async () => {
|
||||||
|
@ -194,12 +194,12 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Check the onlyLendingPoolManager on setLiquidationThreshold', async () => {
|
it('Check the onlyAaveAdmin on setLiquidationThreshold', async () => {
|
||||||
const {configurator, users, weth} = testEnv;
|
const {configurator, users, weth} = testEnv;
|
||||||
await expect(
|
await expect(
|
||||||
configurator.connect(users[2].signer).setLiquidationThreshold(weth.address, '80'),
|
configurator.connect(users[2].signer).setLiquidationThreshold(weth.address, '80'),
|
||||||
CALLER_NOT_LENDING_POOL_MANAGER
|
CALLER_NOT_AAVE_ADMIN
|
||||||
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Changes liquidation bonus of the reserve', async () => {
|
it('Changes liquidation bonus of the reserve', async () => {
|
||||||
|
@ -212,28 +212,28 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Check the onlyLendingPoolManager on setLiquidationBonus', async () => {
|
it('Check the onlyAaveAdmin on setLiquidationBonus', async () => {
|
||||||
const {configurator, users, weth} = testEnv;
|
const {configurator, users, weth} = testEnv;
|
||||||
await expect(
|
await expect(
|
||||||
configurator.connect(users[2].signer).setLiquidationBonus(weth.address, '80'),
|
configurator.connect(users[2].signer).setLiquidationBonus(weth.address, '80'),
|
||||||
CALLER_NOT_LENDING_POOL_MANAGER
|
CALLER_NOT_AAVE_ADMIN
|
||||||
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Check the onlyLendingPoolManager on setReserveDecimals', async () => {
|
it('Check the onlyAaveAdmin on setReserveDecimals', async () => {
|
||||||
const {configurator, users, weth} = testEnv;
|
const {configurator, users, weth} = testEnv;
|
||||||
await expect(
|
await expect(
|
||||||
configurator.connect(users[2].signer).setReserveDecimals(weth.address, '80'),
|
configurator.connect(users[2].signer).setReserveDecimals(weth.address, '80'),
|
||||||
CALLER_NOT_LENDING_POOL_MANAGER
|
CALLER_NOT_AAVE_ADMIN
|
||||||
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Check the onlyLendingPoolManager on setLiquidationBonus', async () => {
|
it('Check the onlyAaveAdmin on setLiquidationBonus', async () => {
|
||||||
const {configurator, users, weth} = testEnv;
|
const {configurator, users, weth} = testEnv;
|
||||||
await expect(
|
await expect(
|
||||||
configurator.connect(users[2].signer).setLiquidationBonus(weth.address, '80'),
|
configurator.connect(users[2].signer).setLiquidationBonus(weth.address, '80'),
|
||||||
CALLER_NOT_LENDING_POOL_MANAGER
|
CALLER_NOT_AAVE_ADMIN
|
||||||
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Reverts when trying to disable the DAI reserve with liquidity on it', async () => {
|
it('Reverts when trying to disable the DAI reserve with liquidity on it', async () => {
|
||||||
|
|
|
@ -14,8 +14,8 @@ makeSuite('LendingPoolAddressesProvider', (testEnv: TestEnv) => {
|
||||||
for (const contractFunction of [
|
for (const contractFunction of [
|
||||||
addressesProvider.setLendingPoolImpl,
|
addressesProvider.setLendingPoolImpl,
|
||||||
addressesProvider.setLendingPoolConfiguratorImpl,
|
addressesProvider.setLendingPoolConfiguratorImpl,
|
||||||
addressesProvider.setLendingPoolLiquidationManager,
|
addressesProvider.setLendingPoolCollateralManager,
|
||||||
addressesProvider.setLendingPoolManager,
|
addressesProvider.setAaveAdmin,
|
||||||
addressesProvider.setPriceOracle,
|
addressesProvider.setPriceOracle,
|
||||||
addressesProvider.setLendingRateOracle,
|
addressesProvider.setLendingRateOracle,
|
||||||
]) {
|
]) {
|
||||||
|
|
|
@ -10,9 +10,10 @@ import {
|
||||||
import {MockAToken} from '../types/MockAToken';
|
import {MockAToken} from '../types/MockAToken';
|
||||||
import {MockStableDebtToken} from '../types/MockStableDebtToken';
|
import {MockStableDebtToken} from '../types/MockStableDebtToken';
|
||||||
import {MockVariableDebtToken} from '../types/MockVariableDebtToken';
|
import {MockVariableDebtToken} from '../types/MockVariableDebtToken';
|
||||||
|
import {ZERO_ADDRESS} from '../helpers/constants';
|
||||||
|
|
||||||
makeSuite('Upgradeability', (testEnv: TestEnv) => {
|
makeSuite('Upgradeability', (testEnv: TestEnv) => {
|
||||||
const {CALLER_NOT_LENDING_POOL_MANAGER} = ProtocolErrors;
|
const {CALLER_NOT_AAVE_ADMIN} = ProtocolErrors;
|
||||||
let newATokenAddress: string;
|
let newATokenAddress: string;
|
||||||
let newStableTokenAddress: string;
|
let newStableTokenAddress: string;
|
||||||
let newVariableTokenAddress: string;
|
let newVariableTokenAddress: string;
|
||||||
|
@ -24,16 +25,29 @@ makeSuite('Upgradeability', (testEnv: TestEnv) => {
|
||||||
dai.address,
|
dai.address,
|
||||||
'Aave Interest bearing DAI updated',
|
'Aave Interest bearing DAI updated',
|
||||||
'aDAI',
|
'aDAI',
|
||||||
|
ZERO_ADDRESS,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const stableDebtTokenInstance = await deployContract<MockStableDebtToken>(
|
const stableDebtTokenInstance = await deployContract<MockStableDebtToken>(
|
||||||
eContractid.MockStableDebtToken,
|
eContractid.MockStableDebtToken,
|
||||||
[pool.address, dai.address, 'Aave stable debt bearing DAI updated', 'stableDebtDAI']
|
[
|
||||||
|
pool.address,
|
||||||
|
dai.address,
|
||||||
|
'Aave stable debt bearing DAI updated',
|
||||||
|
'stableDebtDAI',
|
||||||
|
ZERO_ADDRESS,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
const variableDebtTokenInstance = await deployContract<MockVariableDebtToken>(
|
const variableDebtTokenInstance = await deployContract<MockVariableDebtToken>(
|
||||||
eContractid.MockVariableDebtToken,
|
eContractid.MockVariableDebtToken,
|
||||||
[pool.address, dai.address, 'Aave variable debt bearing DAI updated', 'variableDebtDAI']
|
[
|
||||||
|
pool.address,
|
||||||
|
dai.address,
|
||||||
|
'Aave variable debt bearing DAI updated',
|
||||||
|
'variableDebtDAI',
|
||||||
|
ZERO_ADDRESS,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
newATokenAddress = aTokenInstance.address;
|
newATokenAddress = aTokenInstance.address;
|
||||||
|
@ -46,7 +60,7 @@ makeSuite('Upgradeability', (testEnv: TestEnv) => {
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
configurator.connect(users[1].signer).updateAToken(dai.address, newATokenAddress)
|
configurator.connect(users[1].signer).updateAToken(dai.address, newATokenAddress)
|
||||||
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Upgrades the DAI Atoken implementation ', async () => {
|
it('Upgrades the DAI Atoken implementation ', async () => {
|
||||||
|
@ -68,7 +82,7 @@ makeSuite('Upgradeability', (testEnv: TestEnv) => {
|
||||||
configurator
|
configurator
|
||||||
.connect(users[1].signer)
|
.connect(users[1].signer)
|
||||||
.updateStableDebtToken(dai.address, newStableTokenAddress)
|
.updateStableDebtToken(dai.address, newStableTokenAddress)
|
||||||
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Upgrades the DAI stable debt token implementation ', async () => {
|
it('Upgrades the DAI stable debt token implementation ', async () => {
|
||||||
|
@ -97,7 +111,7 @@ makeSuite('Upgradeability', (testEnv: TestEnv) => {
|
||||||
configurator
|
configurator
|
||||||
.connect(users[1].signer)
|
.connect(users[1].signer)
|
||||||
.updateVariableDebtToken(dai.address, newVariableTokenAddress)
|
.updateVariableDebtToken(dai.address, newVariableTokenAddress)
|
||||||
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Upgrades the DAI variable debt token implementation ', async () => {
|
it('Upgrades the DAI variable debt token implementation ', async () => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user