mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Merge branch 'feat/166-market-id' into 'master'
- Added marketId and setter on LendingPoolAddressesProvider Closes #166 See merge request aave-tech/protocol-v2!189
This commit is contained in:
commit
b7bae0cb67
|
@ -9,6 +9,7 @@ pragma solidity 0.6.12;
|
||||||
* @author Aave
|
* @author Aave
|
||||||
**/
|
**/
|
||||||
interface ILendingPoolAddressesProvider {
|
interface ILendingPoolAddressesProvider {
|
||||||
|
event MarketIdSet(string newMarketId);
|
||||||
event LendingPoolUpdated(address indexed newAddress);
|
event LendingPoolUpdated(address indexed newAddress);
|
||||||
event ConfigurationAdminUpdated(address indexed newAddress);
|
event ConfigurationAdminUpdated(address indexed newAddress);
|
||||||
event EmergencyAdminUpdated(address indexed newAddress);
|
event EmergencyAdminUpdated(address indexed newAddress);
|
||||||
|
@ -19,6 +20,8 @@ interface ILendingPoolAddressesProvider {
|
||||||
event ProxyCreated(bytes32 id, address indexed newAddress);
|
event ProxyCreated(bytes32 id, address indexed newAddress);
|
||||||
event AddressSet(bytes32 id, address indexed newAddress, bool hasProxy);
|
event AddressSet(bytes32 id, address indexed newAddress, bool hasProxy);
|
||||||
|
|
||||||
|
function setMarketId(string calldata marketId) external;
|
||||||
|
|
||||||
function setAddress(bytes32 id, address newAddress) external;
|
function setAddress(bytes32 id, address newAddress) external;
|
||||||
|
|
||||||
function setAddressAsProxy(bytes32 id, address impl) external;
|
function setAddressAsProxy(bytes32 id, address impl) external;
|
||||||
|
|
|
@ -17,6 +17,7 @@ import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddres
|
||||||
* @author Aave
|
* @author Aave
|
||||||
**/
|
**/
|
||||||
contract LendingPoolAddressesProvider is Ownable, ILendingPoolAddressesProvider {
|
contract LendingPoolAddressesProvider is Ownable, ILendingPoolAddressesProvider {
|
||||||
|
string private _marketId;
|
||||||
mapping(bytes32 => address) private _addresses;
|
mapping(bytes32 => address) private _addresses;
|
||||||
|
|
||||||
bytes32 private constant LENDING_POOL = 'LENDING_POOL';
|
bytes32 private constant LENDING_POOL = 'LENDING_POOL';
|
||||||
|
@ -27,6 +28,18 @@ contract LendingPoolAddressesProvider is Ownable, ILendingPoolAddressesProvider
|
||||||
bytes32 private constant PRICE_ORACLE = 'PRICE_ORACLE';
|
bytes32 private constant PRICE_ORACLE = 'PRICE_ORACLE';
|
||||||
bytes32 private constant LENDING_RATE_ORACLE = 'LENDING_RATE_ORACLE';
|
bytes32 private constant LENDING_RATE_ORACLE = 'LENDING_RATE_ORACLE';
|
||||||
|
|
||||||
|
constructor(string memory marketId) public {
|
||||||
|
_setMarketId(marketId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Allows to set the market which this LendingPoolAddressesProvider represents
|
||||||
|
* @param marketId The market id
|
||||||
|
*/
|
||||||
|
function setMarketId(string memory marketId) external override onlyOwner {
|
||||||
|
_setMarketId(marketId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev General function to update the implementation of a proxy registered with
|
* @dev General function to update the implementation of a proxy registered with
|
||||||
* certain `id`. If there is no proxy registered, it will instantiate one and
|
* certain `id`. If there is no proxy registered, it will instantiate one and
|
||||||
|
@ -186,4 +199,9 @@ contract LendingPoolAddressesProvider is Ownable, ILendingPoolAddressesProvider
|
||||||
proxy.upgradeToAndCall(newAddress, params);
|
proxy.upgradeToAndCall(newAddress, params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _setMarketId(string memory marketId) internal {
|
||||||
|
_marketId = marketId;
|
||||||
|
emit MarketIdSet(marketId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,11 +65,11 @@ const readArtifact = async (id: string) => {
|
||||||
}
|
}
|
||||||
return (DRE as HardhatRuntimeEnvironment).artifacts.readArtifact(id);
|
return (DRE as HardhatRuntimeEnvironment).artifacts.readArtifact(id);
|
||||||
};
|
};
|
||||||
export const deployLendingPoolAddressesProvider = async (verify?: boolean) =>
|
export const deployLendingPoolAddressesProvider = async (marketId: string, verify?: boolean) =>
|
||||||
withSaveAndVerify(
|
withSaveAndVerify(
|
||||||
await new LendingPoolAddressesProviderFactory(await getFirstSigner()).deploy(),
|
await new LendingPoolAddressesProviderFactory(await getFirstSigner()).deploy(marketId),
|
||||||
eContractid.LendingPoolAddressesProvider,
|
eContractid.LendingPoolAddressesProvider,
|
||||||
[],
|
[marketId],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -345,7 +345,7 @@ export interface ILendingRate {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ICommonConfiguration {
|
export interface ICommonConfiguration {
|
||||||
ConfigName: string;
|
MarketId: string;
|
||||||
ProviderId: number;
|
ProviderId: number;
|
||||||
ProtocolGlobalParams: IProtocolGlobalConfig;
|
ProtocolGlobalParams: IProtocolGlobalConfig;
|
||||||
Mocks: IMocksConfig;
|
Mocks: IMocksConfig;
|
||||||
|
|
|
@ -30,7 +30,7 @@ const MOCK_CHAINLINK_AGGREGATORS_PRICES = {
|
||||||
// ----------------
|
// ----------------
|
||||||
|
|
||||||
export const CommonsConfig: ICommonConfiguration = {
|
export const CommonsConfig: ICommonConfiguration = {
|
||||||
ConfigName: 'Commons',
|
MarketId: 'Commons',
|
||||||
ProviderId: 0,
|
ProviderId: 0,
|
||||||
ProtocolGlobalParams: {
|
ProtocolGlobalParams: {
|
||||||
TokenDistributorPercentageBase: '10000',
|
TokenDistributorPercentageBase: '10000',
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {oneRay, ZERO_ADDRESS} from '../../helpers/constants';
|
import { oneRay, ZERO_ADDRESS } from '../../helpers/constants';
|
||||||
import {IAaveConfiguration, EthereumNetwork, eEthereumNetwork} from '../../helpers/types';
|
import { IAaveConfiguration, EthereumNetwork, eEthereumNetwork } from '../../helpers/types';
|
||||||
|
|
||||||
import {CommonsConfig} from './commons';
|
import { CommonsConfig } from './commons';
|
||||||
import {
|
import {
|
||||||
stablecoinStrategyBUSD,
|
stablecoinStrategyBUSD,
|
||||||
stablecoinStrategyDAI,
|
stablecoinStrategyDAI,
|
||||||
|
@ -29,7 +29,7 @@ import {
|
||||||
|
|
||||||
export const AaveConfig: IAaveConfiguration = {
|
export const AaveConfig: IAaveConfiguration = {
|
||||||
...CommonsConfig,
|
...CommonsConfig,
|
||||||
ConfigName: 'Aave',
|
MarketId: 'Aave genesis market',
|
||||||
ProviderId: 1,
|
ProviderId: 1,
|
||||||
ReservesConfig: {
|
ReservesConfig: {
|
||||||
AAVE: strategyAAVE,
|
AAVE: strategyAAVE,
|
||||||
|
|
|
@ -1,21 +1,22 @@
|
||||||
import {task} from 'hardhat/config';
|
import { task } from 'hardhat/config';
|
||||||
import {
|
import {
|
||||||
deployLendingPoolAddressesProvider,
|
deployLendingPoolAddressesProvider,
|
||||||
deployLendingPoolAddressesProviderRegistry,
|
deployLendingPoolAddressesProviderRegistry,
|
||||||
} from '../../helpers/contracts-deployments';
|
} from '../../helpers/contracts-deployments';
|
||||||
import {waitForTx} from '../../helpers/misc-utils';
|
import { waitForTx } from '../../helpers/misc-utils';
|
||||||
|
import { AaveConfig } from '../../markets/aave';
|
||||||
|
|
||||||
task(
|
task(
|
||||||
'dev:deploy-address-provider',
|
'dev:deploy-address-provider',
|
||||||
'Deploy address provider, registry and fee provider for dev enviroment'
|
'Deploy address provider, registry and fee provider for dev enviroment'
|
||||||
)
|
)
|
||||||
.addFlag('verify', 'Verify contracts at Etherscan')
|
.addFlag('verify', 'Verify contracts at Etherscan')
|
||||||
.setAction(async ({verify}, localBRE) => {
|
.setAction(async ({ verify }, localBRE) => {
|
||||||
await localBRE.run('set-DRE');
|
await localBRE.run('set-DRE');
|
||||||
|
|
||||||
const admin = 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(AaveConfig.MarketId, verify);
|
||||||
await waitForTx(await addressesProvider.setPoolAdmin(admin));
|
await waitForTx(await addressesProvider.setPoolAdmin(admin));
|
||||||
|
|
||||||
const addressesProviderRegistry = await deployLendingPoolAddressesProviderRegistry(verify);
|
const addressesProviderRegistry = await deployLendingPoolAddressesProviderRegistry(verify);
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import {task} from 'hardhat/config';
|
import { task } from 'hardhat/config';
|
||||||
import {getParamPerNetwork} from '../../helpers/contracts-helpers';
|
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
|
||||||
import {
|
import {
|
||||||
deployLendingPoolAddressesProvider,
|
deployLendingPoolAddressesProvider,
|
||||||
deployLendingPoolAddressesProviderRegistry,
|
deployLendingPoolAddressesProviderRegistry,
|
||||||
} from '../../helpers/contracts-deployments';
|
} from '../../helpers/contracts-deployments';
|
||||||
import {notFalsyOrZeroAddress, waitForTx} from '../../helpers/misc-utils';
|
import { notFalsyOrZeroAddress, waitForTx } from '../../helpers/misc-utils';
|
||||||
import {
|
import {
|
||||||
ConfigNames,
|
ConfigNames,
|
||||||
loadPoolConfig,
|
loadPoolConfig,
|
||||||
getGenesisPoolAdmin,
|
getGenesisPoolAdmin,
|
||||||
getEmergencyAdmin,
|
getEmergencyAdmin,
|
||||||
} from '../../helpers/configuration';
|
} from '../../helpers/configuration';
|
||||||
import {eEthereumNetwork} from '../../helpers/types';
|
import { eEthereumNetwork } from '../../helpers/types';
|
||||||
import {getLendingPoolAddressesProviderRegistry} from '../../helpers/contracts-getters';
|
import { getLendingPoolAddressesProviderRegistry } from '../../helpers/contracts-getters';
|
||||||
|
|
||||||
task(
|
task(
|
||||||
'full:deploy-address-provider',
|
'full:deploy-address-provider',
|
||||||
|
@ -20,16 +20,16 @@ task(
|
||||||
)
|
)
|
||||||
.addFlag('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}, DRE) => {
|
.setAction(async ({ verify, pool }, DRE) => {
|
||||||
await DRE.run('set-DRE');
|
await DRE.run('set-DRE');
|
||||||
|
|
||||||
const network = <eEthereumNetwork>DRE.network.name;
|
const network = <eEthereumNetwork>DRE.network.name;
|
||||||
const poolConfig = loadPoolConfig(pool);
|
const poolConfig = loadPoolConfig(pool);
|
||||||
const {ProviderId} = poolConfig;
|
const { ProviderId, MarketId } = poolConfig;
|
||||||
|
|
||||||
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(MarketId, verify);
|
||||||
|
|
||||||
await waitForTx(await addressesProvider.setPoolAdmin(await getGenesisPoolAdmin(poolConfig)));
|
await waitForTx(await addressesProvider.setPoolAdmin(await getGenesisPoolAdmin(poolConfig)));
|
||||||
await waitForTx(await addressesProvider.setEmergencyAdmin(await getEmergencyAdmin(poolConfig)));
|
await waitForTx(await addressesProvider.setEmergencyAdmin(await getEmergencyAdmin(poolConfig)));
|
||||||
|
|
|
@ -91,7 +91,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
|
|
||||||
const mockTokens = await deployAllMockTokens(deployer);
|
const mockTokens = await deployAllMockTokens(deployer);
|
||||||
|
|
||||||
const addressesProvider = await deployLendingPoolAddressesProvider();
|
const addressesProvider = await deployLendingPoolAddressesProvider(AaveConfig.MarketId);
|
||||||
await waitForTx(await addressesProvider.setPoolAdmin(aaveAdmin));
|
await waitForTx(await addressesProvider.setPoolAdmin(aaveAdmin));
|
||||||
|
|
||||||
//setting users[1] as emergency admin, which is in position 2 in the DRE addresses list
|
//setting users[1] as emergency admin, which is in position 2 in the DRE addresses list
|
||||||
|
|
|
@ -18,6 +18,7 @@ makeSuite('LendingPoolAddressesProvider', (testEnv: TestEnv) => {
|
||||||
await addressesProvider.transferOwnership(users[1].address);
|
await addressesProvider.transferOwnership(users[1].address);
|
||||||
|
|
||||||
for (const contractFunction of [
|
for (const contractFunction of [
|
||||||
|
addressesProvider.setMarketId,
|
||||||
addressesProvider.setLendingPoolImpl,
|
addressesProvider.setLendingPoolImpl,
|
||||||
addressesProvider.setLendingPoolConfiguratorImpl,
|
addressesProvider.setLendingPoolConfiguratorImpl,
|
||||||
addressesProvider.setLendingPoolCollateralManager,
|
addressesProvider.setLendingPoolCollateralManager,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user