mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Added borrow rates deployment optimization and minor tweaks for deployment helpers
This commit is contained in:
parent
e17f2ec814
commit
161fb63f19
|
@ -9,8 +9,9 @@ import {AToken} from '../tokenization/AToken.sol';
|
|||
import {
|
||||
DefaultReserveInterestRateStrategy
|
||||
} from '../lendingpool/DefaultReserveInterestRateStrategy.sol';
|
||||
import {Ownable} from '../dependencies/openzeppelin/contracts/Ownable.sol';
|
||||
|
||||
contract ATokensAndRatesHelper {
|
||||
contract ATokensAndRatesHelper is Ownable {
|
||||
address payable private pool;
|
||||
address private addressesProvider;
|
||||
address private poolConfigurator;
|
||||
|
@ -35,7 +36,7 @@ contract ATokensAndRatesHelper {
|
|||
string[] calldata symbols,
|
||||
uint256[5][] calldata rates,
|
||||
address incentivesController
|
||||
) external {
|
||||
) external onlyOwner {
|
||||
require(tokens.length == symbols.length, 't Arrays not same length');
|
||||
require(rates.length == symbols.length, 'r Arrays not same length');
|
||||
|
||||
|
@ -71,7 +72,7 @@ contract ATokensAndRatesHelper {
|
|||
address[] calldata aTokens,
|
||||
address[] calldata strategies,
|
||||
uint8[] calldata reserveDecimals
|
||||
) external {
|
||||
) external onlyOwner {
|
||||
require(variables.length == stables.length);
|
||||
require(aTokens.length == stables.length);
|
||||
require(strategies.length == stables.length);
|
||||
|
@ -93,7 +94,7 @@ contract ATokensAndRatesHelper {
|
|||
uint256[] calldata baseLTVs,
|
||||
uint256[] calldata liquidationThresholds,
|
||||
uint256[] calldata liquidationBonuses
|
||||
) external {
|
||||
) external onlyOwner {
|
||||
require(baseLTVs.length == tokens.length);
|
||||
require(liquidationThresholds.length == tokens.length);
|
||||
require(liquidationBonuses.length == tokens.length);
|
||||
|
@ -110,6 +111,7 @@ contract ATokensAndRatesHelper {
|
|||
|
||||
function enableBorrowingOnReserves(address[] calldata tokens, bool[] calldata stableBorrows)
|
||||
external
|
||||
onlyOwner
|
||||
{
|
||||
require(stableBorrows.length == tokens.length);
|
||||
|
||||
|
|
|
@ -4,8 +4,10 @@ pragma experimental ABIEncoderV2;
|
|||
|
||||
import {StableDebtToken} from '../tokenization/StableDebtToken.sol';
|
||||
import {VariableDebtToken} from '../tokenization/VariableDebtToken.sol';
|
||||
import {LendingRateOracle} from '../mocks/oracle/LendingRateOracle.sol';
|
||||
import {Ownable} from '../dependencies/openzeppelin/contracts/Ownable.sol';
|
||||
|
||||
contract StableAndVariableTokensHelper {
|
||||
contract StableAndVariableTokensHelper is Ownable {
|
||||
address payable private pool;
|
||||
address private addressesProvider;
|
||||
event deployedContracts(address stableToken, address variableToken);
|
||||
|
@ -23,7 +25,7 @@ contract StableAndVariableTokensHelper {
|
|||
address[] calldata tokens,
|
||||
string[] calldata symbols,
|
||||
address incentivesController
|
||||
) external {
|
||||
) external onlyOwner {
|
||||
require(tokens.length == symbols.length, 'Arrays not same length');
|
||||
require(pool != address(0), 'Pool can not be zero address');
|
||||
for (uint256 i = 0; i < tokens.length; i++) {
|
||||
|
@ -49,4 +51,23 @@ contract StableAndVariableTokensHelper {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
function setOracleBorrowRates(
|
||||
address[] calldata assets,
|
||||
uint256[] calldata rates,
|
||||
address oracle
|
||||
) external onlyOwner {
|
||||
require(assets.length == rates.length, 'Arrays not same length');
|
||||
|
||||
for (uint256 i = 0; i < assets.length; i++) {
|
||||
// LendingRateOracle owner must be this contract
|
||||
LendingRateOracle(oracle).setMarketBorrowRate(assets[i], rates[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function setOracleOwnership(address oracle, address admin) external onlyOwner {
|
||||
require(admin != address(0), 'owner can not be zero');
|
||||
require(LendingRateOracle(oracle).owner() == address(this), 'helper is not owner');
|
||||
LendingRateOracle(oracle).transferOwnership(admin);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,8 @@
|
|||
},
|
||||
"LendingPool": {
|
||||
"buidlerevm": {
|
||||
"address": "0xD9273d497eDBC967F39d419461CfcF382a0A822e"
|
||||
"address": "0x35c1419Da7cf0Ff885B8Ef8EA9242FEF6800c99b",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x3EE716e38f21e5FC16BFDB773db24D63C637A5d8"
|
||||
|
@ -97,7 +98,7 @@
|
|||
},
|
||||
"PriceOracle": {
|
||||
"buidlerevm": {
|
||||
"address": "0x0C6c3C47A1f650809B0D1048FDf9603e09473D7E",
|
||||
"address": "0xb682dEEf4f8e298d86bFc3e21f50c675151FB974",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
|
@ -111,7 +112,7 @@
|
|||
},
|
||||
"MockAggregator": {
|
||||
"buidlerevm": {
|
||||
"address": "0xc11f8E173ee67ffA7BBdD185D2399994AAd23Ec6",
|
||||
"address": "0x3D8FFB457fedDFBc760F3F243283F52692b579B1",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
|
@ -125,7 +126,7 @@
|
|||
},
|
||||
"ChainlinkProxyPriceProvider": {
|
||||
"buidlerevm": {
|
||||
"address": "0xD662fb7FDC7526C79AA4417d2A4415416e057ec4",
|
||||
"address": "0xEC1C93A9f6a9e18E97784c76aC52053587FcDB89",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
|
@ -143,7 +144,7 @@
|
|||
},
|
||||
"LendingRateOracle": {
|
||||
"buidlerevm": {
|
||||
"address": "0xEC1C93A9f6a9e18E97784c76aC52053587FcDB89",
|
||||
"address": "0xAF6BA11790D1942625C0c2dA07da19AB63845cfF",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
|
@ -224,7 +225,7 @@
|
|||
},
|
||||
"MockFlashLoanReceiver": {
|
||||
"buidlerevm": {
|
||||
"address": "0x2530ce07D254eA185E8e0bCC37a39e2FbA3bE548"
|
||||
"address": "0xfC88832bac6AbdF216BC5A67be68E9DE94aD5ba2"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x9c91aEaD98b1354C7B0EAfb8ff539d0796c79894"
|
||||
|
@ -235,7 +236,7 @@
|
|||
},
|
||||
"WalletBalanceProvider": {
|
||||
"buidlerevm": {
|
||||
"address": "0x0Cf45557d25a4e4c0F1aC65EF6c48ae67c61a0E6",
|
||||
"address": "0x1256eBA4d0a7A38D10BaF4F61775ba491Ce7EE25",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
|
@ -575,7 +576,7 @@
|
|||
},
|
||||
"AaveProtocolTestHelpers": {
|
||||
"buidlerevm": {
|
||||
"address": "0x93472C0e03215F9c33DA240Eb16703C8244eAa8c"
|
||||
"address": "0xf4830d6b1D70C8595d3BD8A63f9ed9F636DB9ef2"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x987223924D2DD6c6efB601756850f3886ECbceF6"
|
||||
|
@ -644,7 +645,7 @@
|
|||
},
|
||||
"MockAToken": {
|
||||
"buidlerevm": {
|
||||
"address": "0x7fAeC7791277Ff512c41CA903c177B2Ed952dDAc",
|
||||
"address": "0x77B0b5636fEA30eA79BB65AeCCdb599997A849A8",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
|
@ -672,7 +673,7 @@
|
|||
},
|
||||
"MockStableDebtToken": {
|
||||
"buidlerevm": {
|
||||
"address": "0x33958cC3535Fc328369EAC2B2Bebd120D67C7fa1",
|
||||
"address": "0x78Ee8Fb9fE5abD5e347Fc94c2fb85596d1f60e3c",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
|
@ -686,7 +687,7 @@
|
|||
},
|
||||
"MockVariableDebtToken": {
|
||||
"buidlerevm": {
|
||||
"address": "0x2cBbbBE1B75Ad7848F0844215816F551f429c64f",
|
||||
"address": "0x920d847fE49E54C19047ba8bc236C45A8068Bca7",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
|
@ -710,7 +711,7 @@
|
|||
},
|
||||
"ReserveLogic": {
|
||||
"buidlerevm": {
|
||||
"address": "0xFAe0fd738dAbc8a0426F47437322b6d026A9FD95",
|
||||
"address": "0x78Ee8Fb9fE5abD5e347Fc94c2fb85596d1f60e3c",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"kovan": {
|
||||
|
@ -720,7 +721,7 @@
|
|||
},
|
||||
"GenericLogic": {
|
||||
"buidlerevm": {
|
||||
"address": "0x6082731fdAba4761277Fb31299ebC782AD3bCf24",
|
||||
"address": "0x920d847fE49E54C19047ba8bc236C45A8068Bca7",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"kovan": {
|
||||
|
@ -730,7 +731,7 @@
|
|||
},
|
||||
"ValidationLogic": {
|
||||
"buidlerevm": {
|
||||
"address": "0x8456161947DFc1fC159A0B26c025cD2b4bba0c3e",
|
||||
"address": "0xA4765Ff72A9F3CfE73089bb2c3a41B838DF71574",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"kovan": {
|
||||
|
@ -740,7 +741,7 @@
|
|||
},
|
||||
"LendingPoolCollateralManager": {
|
||||
"buidlerevm": {
|
||||
"address": "0x8BFFF31B1757da579Bb5B118489568526F7fb6D4",
|
||||
"address": "0x8D0206fEBEB380486729b64bB4cfEDC5b354a6D6",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"kovan": {
|
||||
|
@ -750,7 +751,7 @@
|
|||
},
|
||||
"StableAndVariableTokensHelper": {
|
||||
"buidlerevm": {
|
||||
"address": "0x3392c115Ff2CE1A782B4a965fF770da61e69228E",
|
||||
"address": "0x0C6c3C47A1f650809B0D1048FDf9603e09473D7E",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"kovan": {
|
||||
|
@ -760,7 +761,7 @@
|
|||
},
|
||||
"ATokensAndRatesHelper": {
|
||||
"buidlerevm": {
|
||||
"address": "0x72358bcB1b8B60Ca2f30244e50Be20C3ecaC74B2",
|
||||
"address": "0x06bA8d8af0dF898D0712DffFb0f862cC51AF45c2",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"kovan": {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import {
|
||||
AaveProtocolTestHelpersFactory,
|
||||
ATokenFactory,
|
||||
ATokensAndRatesHelperFactory,
|
||||
DefaultReserveInterestRateStrategyFactory,
|
||||
DeployATokensAndRatesFactory,
|
||||
DeployStableAndVariableTokensFactory,
|
||||
|
@ -14,6 +15,7 @@ import {
|
|||
MockFlashLoanReceiverFactory,
|
||||
PriceOracleFactory,
|
||||
ReserveLogicFactory,
|
||||
StableAndVariableTokensHelperFactory,
|
||||
StableDebtTokenFactory,
|
||||
VariableDebtTokenFactory,
|
||||
} from '../types';
|
||||
|
@ -205,7 +207,7 @@ export const getGenericLogic = async (address?: tEthereumAddress) =>
|
|||
);
|
||||
|
||||
export const getStableAndVariableTokensHelper = async (address?: tEthereumAddress) =>
|
||||
await DeployStableAndVariableTokensFactory.connect(
|
||||
await StableAndVariableTokensHelperFactory.connect(
|
||||
address ||
|
||||
(
|
||||
await getDb()
|
||||
|
@ -216,7 +218,7 @@ export const getStableAndVariableTokensHelper = async (address?: tEthereumAddres
|
|||
);
|
||||
|
||||
export const getATokensAndRatesHelper = async (address?: tEthereumAddress) =>
|
||||
await DeployATokensAndRatesFactory.connect(
|
||||
await ATokensAndRatesHelperFactory.connect(
|
||||
address ||
|
||||
(await getDb().get(`${eContractid.ATokensAndRatesHelper}.${BRE.network.name}`).value())
|
||||
.address,
|
||||
|
|
|
@ -6,35 +6,28 @@ import {
|
|||
deployStableAndVariableTokensHelper,
|
||||
} from './contracts-deployments';
|
||||
import {chunk, waitForTx} from './misc-utils';
|
||||
import {getATokensAndRatesHelper, getLendingPoolAddressesProvider} from './contracts-getters';
|
||||
import {
|
||||
getATokensAndRatesHelper,
|
||||
getLendingPoolAddressesProvider,
|
||||
getStableAndVariableTokensHelper,
|
||||
} from './contracts-getters';
|
||||
|
||||
export const initReservesByHelper = async (
|
||||
lendingPoolProxy: tEthereumAddress,
|
||||
addressesProvider: tEthereumAddress,
|
||||
lendingPoolConfigurator: tEthereumAddress,
|
||||
reservesParams: iMultiPoolsAssets<IReserveParams>,
|
||||
tokenAddresses: {[symbol: string]: tEthereumAddress},
|
||||
helpers: AaveProtocolTestHelpers,
|
||||
admin: tEthereumAddress,
|
||||
incentivesController: tEthereumAddress,
|
||||
verify?: boolean
|
||||
incentivesController: tEthereumAddress
|
||||
) => {
|
||||
const stableAndVariableDeployer = await deployStableAndVariableTokensHelper(
|
||||
[lendingPoolProxy, addressesProvider],
|
||||
verify
|
||||
);
|
||||
const atokenAndRatesDeployer = await deployATokensAndRatesHelper([
|
||||
lendingPoolProxy,
|
||||
addressesProvider,
|
||||
lendingPoolConfigurator,
|
||||
]);
|
||||
const addressProvider = await getLendingPoolAddressesProvider(addressesProvider);
|
||||
const stableAndVariableDeployer = await getStableAndVariableTokensHelper();
|
||||
const atokenAndRatesDeployer = await getATokensAndRatesHelper();
|
||||
|
||||
const addressProvider = await getLendingPoolAddressesProvider();
|
||||
|
||||
// Set aTokenAndRatesDeployer as temporal admin
|
||||
await waitForTx(await addressProvider.setAaveAdmin(atokenAndRatesDeployer.address));
|
||||
|
||||
// CHUNK CONFIGURATION
|
||||
const tokensChunks = 3;
|
||||
const tokensChunks = 4;
|
||||
const initChunks = 6;
|
||||
|
||||
// Deploy tokens and rates in chunks
|
||||
|
|
|
@ -4,7 +4,6 @@ import {
|
|||
IMarketRates,
|
||||
iAssetBase,
|
||||
iAssetAggregatorBase,
|
||||
eContractid,
|
||||
SymbolMap,
|
||||
} from './types';
|
||||
|
||||
|
@ -12,13 +11,19 @@ import {LendingRateOracle} from '../types/LendingRateOracle';
|
|||
import {PriceOracle} from '../types/PriceOracle';
|
||||
import {MockAggregator} from '../types/MockAggregator';
|
||||
import {deployMockAggregator} from './contracts-deployments';
|
||||
import {waitForTx} from './misc-utils';
|
||||
import {chunk, waitForTx} from './misc-utils';
|
||||
import {getStableAndVariableTokensHelper} from './contracts-getters';
|
||||
|
||||
export const setInitialMarketRatesInRatesOracle = async (
|
||||
export const setInitialMarketRatesInRatesOracleByHelper = async (
|
||||
marketRates: iMultiPoolsAssets<IMarketRates>,
|
||||
assetsAddresses: {[x: string]: tEthereumAddress},
|
||||
lendingRateOracleInstance: LendingRateOracle
|
||||
lendingRateOracleInstance: LendingRateOracle,
|
||||
admin: tEthereumAddress
|
||||
) => {
|
||||
const stableAndVariableTokenHelper = await getStableAndVariableTokensHelper();
|
||||
const assetAddresses: string[] = [];
|
||||
const borrowRates: string[] = [];
|
||||
const symbols: string[] = [];
|
||||
for (const [assetSymbol, {borrowRate}] of Object.entries(marketRates) as [
|
||||
string,
|
||||
IMarketRates
|
||||
|
@ -29,9 +34,36 @@ export const setInitialMarketRatesInRatesOracle = async (
|
|||
const [, assetAddress] = (Object.entries(assetsAddresses) as [string, string][])[
|
||||
assetAddressIndex
|
||||
];
|
||||
await waitForTx(await lendingRateOracleInstance.setMarketBorrowRate(assetAddress, borrowRate));
|
||||
console.log('added Market Borrow Rate for: ', assetSymbol);
|
||||
assetAddresses.push(assetAddress);
|
||||
borrowRates.push(borrowRate);
|
||||
symbols.push(assetSymbol);
|
||||
}
|
||||
// Set borrow rates per chunks
|
||||
const ratesChunks = 20;
|
||||
const chunkedTokens = chunk(assetAddresses, ratesChunks);
|
||||
const chunkedRates = chunk(borrowRates, ratesChunks);
|
||||
const chunkedSymbols = chunk(symbols, ratesChunks);
|
||||
|
||||
// Set helper as owner
|
||||
await waitForTx(
|
||||
await lendingRateOracleInstance.transferOwnership(stableAndVariableTokenHelper.address)
|
||||
);
|
||||
|
||||
console.log(`- Oracle borrow initalization in ${chunkedTokens.length} txs`);
|
||||
for (let chunkIndex = 0; chunkIndex < chunkedTokens.length; chunkIndex++) {
|
||||
const tx3 = await waitForTx(
|
||||
await stableAndVariableTokenHelper.setOracleBorrowRates(
|
||||
chunkedTokens[chunkIndex],
|
||||
chunkedRates[chunkIndex],
|
||||
lendingRateOracleInstance.address
|
||||
)
|
||||
);
|
||||
console.log(` - Setted Oracle Borrow Rates for: ${chunkedSymbols[chunkIndex].join(', ')}`);
|
||||
}
|
||||
// Set back ownership
|
||||
await waitForTx(
|
||||
await stableAndVariableTokenHelper.setOracleOwnership(lendingRateOracleInstance.address, admin)
|
||||
);
|
||||
};
|
||||
|
||||
export const setInitialAssetPricesInOracle = async (
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import {task} from '@nomiclabs/buidler/config';
|
||||
import {
|
||||
deployATokensAndRatesHelper,
|
||||
deployLendingPool,
|
||||
deployLendingPoolConfigurator,
|
||||
deployStableAndVariableTokensHelper,
|
||||
} from '../../helpers/contracts-deployments';
|
||||
import {eContractid} from '../../helpers/types';
|
||||
import {waitForTx} from '../../helpers/misc-utils';
|
||||
|
@ -43,4 +45,14 @@ task('dev:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
|
|||
eContractid.LendingPoolConfigurator,
|
||||
lendingPoolConfiguratorProxy.address
|
||||
);
|
||||
|
||||
// Deploy deployment helpers
|
||||
await deployStableAndVariableTokensHelper(
|
||||
[lendingPoolProxy.address, addressesProvider.address],
|
||||
verify
|
||||
);
|
||||
await deployATokensAndRatesHelper(
|
||||
[lendingPoolProxy.address, addressesProvider.address, lendingPoolConfiguratorProxy.address],
|
||||
verify
|
||||
);
|
||||
});
|
||||
|
|
|
@ -7,8 +7,8 @@ import {
|
|||
|
||||
import {
|
||||
setInitialAssetPricesInOracle,
|
||||
setInitialMarketRatesInRatesOracle,
|
||||
deployAllMockAggregators,
|
||||
setInitialMarketRatesInRatesOracleByHelper,
|
||||
} from '../../helpers/oracles-helpers';
|
||||
import {ICommonConfiguration, iAssetBase, TokenContractId} from '../../helpers/types';
|
||||
import {waitForTx} from '../../helpers/misc-utils';
|
||||
|
@ -42,6 +42,7 @@ task('dev:deploy-oracles', 'Deploy oracles for dev enviroment')
|
|||
return prev;
|
||||
}, defaultTokenList);
|
||||
const addressesProvider = await getLendingPoolAddressesProvider();
|
||||
const admin = await addressesProvider.getAaveAdmin();
|
||||
|
||||
const fallbackOracle = await deployPriceOracle(verify);
|
||||
await waitForTx(await fallbackOracle.setEthUsdPrice(MockUsdPriceInWei));
|
||||
|
@ -67,9 +68,10 @@ task('dev:deploy-oracles', 'Deploy oracles for dev enviroment')
|
|||
const allReservesAddresses = {
|
||||
...tokensAddressesWithoutUsd,
|
||||
};
|
||||
await setInitialMarketRatesInRatesOracle(
|
||||
await setInitialMarketRatesInRatesOracleByHelper(
|
||||
LendingRateOracleRatesCommon,
|
||||
allReservesAddresses,
|
||||
lendingRateOracle
|
||||
lendingRateOracle,
|
||||
admin
|
||||
);
|
||||
});
|
||||
|
|
|
@ -46,17 +46,7 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
|
|||
|
||||
const admin = await addressesProvider.getAaveAdmin();
|
||||
|
||||
await initReservesByHelper(
|
||||
lendingPoolProxy.address,
|
||||
addressesProvider.address,
|
||||
lendingPoolConfiguratorProxy.address,
|
||||
reservesParams,
|
||||
protoPoolReservesAddresses,
|
||||
testHelpers,
|
||||
admin,
|
||||
ZERO_ADDRESS,
|
||||
verify
|
||||
);
|
||||
await initReservesByHelper(reservesParams, protoPoolReservesAddresses, admin, ZERO_ADDRESS);
|
||||
await enableReservesToBorrowByHelper(
|
||||
reservesParams,
|
||||
protoPoolReservesAddresses,
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import {task} from '@nomiclabs/buidler/config';
|
||||
import {insertContractAddressInDb} from '../../helpers/contracts-helpers';
|
||||
import {
|
||||
deployATokensAndRatesHelper,
|
||||
deployLendingPool,
|
||||
deployLendingPoolConfigurator,
|
||||
deployStableAndVariableTokensHelper,
|
||||
} from '../../helpers/contracts-deployments';
|
||||
import {eContractid} from '../../helpers/types';
|
||||
import {waitForTx} from '../../helpers/misc-utils';
|
||||
|
@ -46,4 +48,13 @@ task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
|
|||
eContractid.LendingPoolConfigurator,
|
||||
lendingPoolConfiguratorProxy.address
|
||||
);
|
||||
// Deploy deployment helpers
|
||||
await deployStableAndVariableTokensHelper(
|
||||
[lendingPoolProxy.address, addressesProvider.address],
|
||||
verify
|
||||
);
|
||||
await deployATokensAndRatesHelper(
|
||||
[lendingPoolProxy.address, addressesProvider.address, lendingPoolConfiguratorProxy.address],
|
||||
verify
|
||||
);
|
||||
});
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
deployChainlinkProxyPriceProvider,
|
||||
deployLendingRateOracle,
|
||||
} from '../../helpers/contracts-deployments';
|
||||
import {setInitialMarketRatesInRatesOracle} from '../../helpers/oracles-helpers';
|
||||
import {setInitialMarketRatesInRatesOracleByHelper} from '../../helpers/oracles-helpers';
|
||||
import {ICommonConfiguration, eEthereumNetwork, SymbolMap} from '../../helpers/types';
|
||||
import {waitForTx, filterMapBy} from '../../helpers/misc-utils';
|
||||
import {ConfigNames, loadPoolConfig} from '../../helpers/configuration';
|
||||
|
@ -30,11 +30,11 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
|
|||
FallbackOracle,
|
||||
ChainlinkAggregator,
|
||||
} = poolConfig as ICommonConfiguration;
|
||||
|
||||
const lendingRateOracles = filterMapBy(LendingRateOracleRatesCommon, (key) =>
|
||||
ReserveSymbols.includes(key)
|
||||
);
|
||||
const addressesProvider = await getLendingPoolAddressesProvider();
|
||||
const admin = await addressesProvider.getAaveAdmin();
|
||||
|
||||
const fallbackOracle = await getParamPerNetwork(FallbackOracle, network);
|
||||
const reserveAssets = await getParamPerNetwork(ReserveAssets, network);
|
||||
|
@ -58,10 +58,11 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
|
|||
await waitForTx(await addressesProvider.setLendingRateOracle(lendingRateOracle.address));
|
||||
|
||||
const {USD, ...tokensAddressesWithoutUsd} = tokensToWatch;
|
||||
await setInitialMarketRatesInRatesOracle(
|
||||
await setInitialMarketRatesInRatesOracleByHelper(
|
||||
lendingRateOracles,
|
||||
tokensAddressesWithoutUsd,
|
||||
lendingRateOracle
|
||||
lendingRateOracle,
|
||||
admin
|
||||
);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
|
|
@ -44,17 +44,7 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
|||
throw 'Reserve assets is undefined. Check ReserveAssets configuration at config directory';
|
||||
}
|
||||
|
||||
await initReservesByHelper(
|
||||
lendingPoolProxy.address,
|
||||
addressesProvider.address,
|
||||
lendingPoolConfiguratorProxy.address,
|
||||
ReservesConfig,
|
||||
reserveAssets,
|
||||
testHelpers,
|
||||
admin,
|
||||
ZERO_ADDRESS,
|
||||
verify
|
||||
);
|
||||
await initReservesByHelper(ReservesConfig, reserveAssets, admin, ZERO_ADDRESS);
|
||||
await enableReservesToBorrowByHelper(ReservesConfig, reserveAssets, testHelpers, admin);
|
||||
await enableReservesAsCollateralByHelper(ReservesConfig, reserveAssets, testHelpers, admin);
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ import {
|
|||
deployWalletBalancerProvider,
|
||||
deployAaveProtocolTestHelpers,
|
||||
deployLendingRateOracle,
|
||||
deployStableAndVariableTokensHelper,
|
||||
deployATokensAndRatesHelper,
|
||||
} from '../helpers/contracts-deployments';
|
||||
import {Signer} from 'ethers';
|
||||
import {TokenContractId, eContractid, tEthereumAddress, AavePools} from '../helpers/types';
|
||||
|
@ -27,8 +29,8 @@ import {initializeMakeSuite} from './helpers/make-suite';
|
|||
|
||||
import {
|
||||
setInitialAssetPricesInOracle,
|
||||
setInitialMarketRatesInRatesOracle,
|
||||
deployAllMockAggregators,
|
||||
setInitialMarketRatesInRatesOracleByHelper,
|
||||
} from '../helpers/oracles-helpers';
|
||||
import {waitForTx} from '../helpers/misc-utils';
|
||||
import {
|
||||
|
@ -115,6 +117,14 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
|||
lendingPoolConfiguratorProxy.address
|
||||
);
|
||||
|
||||
// Deploy deployment helpers
|
||||
await deployStableAndVariableTokensHelper([lendingPoolProxy.address, addressesProvider.address]);
|
||||
await deployATokensAndRatesHelper([
|
||||
lendingPoolProxy.address,
|
||||
addressesProvider.address,
|
||||
lendingPoolConfiguratorProxy.address,
|
||||
]);
|
||||
|
||||
const fallbackOracle = await deployPriceOracle();
|
||||
await waitForTx(await fallbackOracle.setEthUsdPrice(MOCK_USD_PRICE_IN_WEI));
|
||||
await setInitialAssetPricesInOracle(
|
||||
|
@ -183,10 +193,11 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
|||
const allReservesAddresses = {
|
||||
...tokensAddressesWithoutUsd,
|
||||
};
|
||||
await setInitialMarketRatesInRatesOracle(
|
||||
await setInitialMarketRatesInRatesOracleByHelper(
|
||||
LENDING_RATE_ORACLE_RATES_COMMON,
|
||||
allReservesAddresses,
|
||||
lendingRateOracle
|
||||
lendingRateOracle,
|
||||
aaveAdmin
|
||||
);
|
||||
|
||||
const {
|
||||
|
@ -207,16 +218,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
|||
const admin = await deployer.getAddress();
|
||||
|
||||
console.log('Initialize configuration');
|
||||
await initReservesByHelper(
|
||||
lendingPoolProxy.address,
|
||||
addressesProvider.address,
|
||||
lendingPoolConfiguratorProxy.address,
|
||||
reservesParams,
|
||||
protoPoolReservesAddresses,
|
||||
testHelpers,
|
||||
admin,
|
||||
ZERO_ADDRESS
|
||||
);
|
||||
await initReservesByHelper(reservesParams, protoPoolReservesAddresses, admin, ZERO_ADDRESS);
|
||||
await enableReservesToBorrowByHelper(
|
||||
reservesParams,
|
||||
protoPoolReservesAddresses,
|
||||
|
@ -240,7 +242,6 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
|||
|
||||
await deployWalletBalancerProvider(addressesProvider.address);
|
||||
|
||||
console.log('END');
|
||||
console.timeEnd('setup');
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user