mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Merge branch 'fix/172' into 'master'
Resolve "Add reserveFactor to the migration scripts" Closes #172 See merge request aave-tech/protocol-v2!195
This commit is contained in:
commit
872eb3ff94
|
@ -34,6 +34,7 @@ contract ATokensAndRatesHelper is Ownable {
|
|||
address[] calldata tokens,
|
||||
string[] calldata symbols,
|
||||
uint256[6][] calldata rates,
|
||||
address treasuryAddress,
|
||||
address incentivesController
|
||||
) external onlyOwner {
|
||||
require(tokens.length == symbols.length, 't Arrays not same length');
|
||||
|
@ -44,7 +45,7 @@ contract ATokensAndRatesHelper is Ownable {
|
|||
new AToken(
|
||||
LendingPool(pool),
|
||||
tokens[i],
|
||||
address(0),
|
||||
treasuryAddress,
|
||||
StringLib.concat('Aave interest bearing ', symbols[i]),
|
||||
StringLib.concat('a', symbols[i]),
|
||||
incentivesController
|
||||
|
|
|
@ -75,6 +75,13 @@ export const getEmergencyAdmin = async (
|
|||
return addressList[addressIndex];
|
||||
};
|
||||
|
||||
export const getTreasuryAddress = async (
|
||||
config: ICommonConfiguration
|
||||
): Promise<tEthereumAddress> => {
|
||||
const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name;
|
||||
return getParamPerNetwork(config.ReserveFactorTreasuryAddress, <eEthereumNetwork>currentNetwork);
|
||||
};
|
||||
|
||||
export const getATokenDomainSeparatorPerNetwork = (
|
||||
network: eEthereumNetwork,
|
||||
config: ICommonConfiguration
|
||||
|
|
|
@ -318,7 +318,8 @@ export const deployVariableDebtToken = async (
|
|||
);
|
||||
|
||||
export const deployGenericAToken = async (
|
||||
[poolAddress, underlyingAssetAddress, name, symbol, incentivesController]: [
|
||||
[poolAddress, underlyingAssetAddress, treasuryAddress, name, symbol,incentivesController]: [
|
||||
tEthereumAddress,
|
||||
tEthereumAddress,
|
||||
tEthereumAddress,
|
||||
string,
|
||||
|
@ -330,11 +331,12 @@ export const deployGenericAToken = async (
|
|||
const args: [
|
||||
tEthereumAddress,
|
||||
tEthereumAddress,
|
||||
string,
|
||||
string,
|
||||
tEthereumAddress,
|
||||
string,
|
||||
string,
|
||||
tEthereumAddress
|
||||
] = [poolAddress, underlyingAssetAddress, ZERO_ADDRESS, name, symbol, incentivesController];
|
||||
|
||||
] = [poolAddress, underlyingAssetAddress, treasuryAddress, name, symbol, incentivesController];
|
||||
return withSaveAndVerify(
|
||||
await new ATokenFactory(await getFirstSigner()).deploy(...args),
|
||||
eContractid.AToken,
|
||||
|
@ -344,7 +346,8 @@ export const deployGenericAToken = async (
|
|||
};
|
||||
|
||||
export const deployDelegationAwareAToken = async (
|
||||
[poolAddress, underlyingAssetAddress, name, symbol, incentivesController]: [
|
||||
[poolAddress, underlyingAssetAddress, treasuryAddress, name, symbol, incentivesController]: [
|
||||
tEthereumAddress,
|
||||
tEthereumAddress,
|
||||
tEthereumAddress,
|
||||
string,
|
||||
|
@ -356,11 +359,12 @@ export const deployDelegationAwareAToken = async (
|
|||
const args: [
|
||||
tEthereumAddress,
|
||||
tEthereumAddress,
|
||||
string,
|
||||
string,
|
||||
tEthereumAddress,
|
||||
string,
|
||||
string,
|
||||
tEthereumAddress
|
||||
] = [poolAddress, underlyingAssetAddress, ZERO_ADDRESS, name, symbol, incentivesController];
|
||||
] = [poolAddress, underlyingAssetAddress, treasuryAddress, name, symbol, incentivesController];
|
||||
|
||||
return withSaveAndVerify(
|
||||
await new DelegationAwareATokenFactory(await getFirstSigner()).deploy(...args),
|
||||
eContractid.DelegationAwareAToken,
|
||||
|
|
|
@ -32,9 +32,11 @@ export const initReservesByHelper = async (
|
|||
reservesParams: iMultiPoolsAssets<IReserveParams>,
|
||||
tokenAddresses: { [symbol: string]: tEthereumAddress },
|
||||
admin: tEthereumAddress,
|
||||
treasuryAddress: tEthereumAddress,
|
||||
incentivesController: tEthereumAddress,
|
||||
verify: boolean
|
||||
) => {
|
||||
|
||||
const stableAndVariableDeployer = await getStableAndVariableTokensHelper();
|
||||
const atokenAndRatesDeployer = await getATokensAndRatesHelper();
|
||||
|
||||
|
@ -121,18 +123,24 @@ export const initReservesByHelper = async (
|
|||
|
||||
// Deploy stable and variable deployers and save implementations
|
||||
const tx1 = await waitForTx(
|
||||
await stableAndVariableDeployer.initDeployment(tokens, symbols, incentivesController)
|
||||
await stableAndVariableDeployer.initDeployment(
|
||||
tokens,
|
||||
symbols,
|
||||
incentivesController
|
||||
)
|
||||
);
|
||||
tx1.events?.forEach((event, index) => {
|
||||
rawInsertContractAddressInDb(`stableDebt${symbols[index]}`, event?.args?.stableToken);
|
||||
rawInsertContractAddressInDb(`variableDebt${symbols[index]}`, event?.args?.variableToken);
|
||||
});
|
||||
|
||||
// Deploy atokens and rate strategies and save implementations
|
||||
const tx2 = await waitForTx(
|
||||
await atokenAndRatesDeployer.initDeployment(
|
||||
tokens,
|
||||
symbols,
|
||||
strategyRates,
|
||||
treasuryAddress,
|
||||
incentivesController
|
||||
)
|
||||
);
|
||||
|
@ -162,7 +170,7 @@ export const initReservesByHelper = async (
|
|||
) as [string, IReserveParams][];
|
||||
|
||||
for (let [symbol, params] of delegatedAwareReserves) {
|
||||
console.log(` - Deploy ${symbol} delegation await aToken, debts tokens, and strategy`);
|
||||
console.log(` - Deploy ${symbol} delegation aware aToken, debts tokens, and strategy`);
|
||||
const {
|
||||
optimalUtilizationRate,
|
||||
baseVariableBorrowRate,
|
||||
|
@ -176,6 +184,7 @@ export const initReservesByHelper = async (
|
|||
[
|
||||
poolAddress,
|
||||
tokenAddresses[symbol],
|
||||
treasuryAddress,
|
||||
`Aave interest bearing ${symbol}`,
|
||||
`a${symbol}`,
|
||||
ZERO_ADDRESS,
|
||||
|
|
|
@ -364,6 +364,7 @@ export interface ICommonConfiguration {
|
|||
ReservesConfig: iMultiPoolsAssets<IReserveParams>;
|
||||
ATokenDomainSeparator: iParamsPerNetwork<string>;
|
||||
WETH: iParamsPerNetwork<tEthereumAddress>;
|
||||
ReserveFactorTreasuryAddress: iParamsPerNetwork<tEthereumAddress>;
|
||||
}
|
||||
|
||||
export interface IAaveConfiguration extends ICommonConfiguration {
|
||||
|
|
|
@ -305,4 +305,13 @@ export const CommonsConfig: ICommonConfiguration = {
|
|||
[eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||
[eEthereumNetwork.tenderlyMain]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||
},
|
||||
ReserveFactorTreasuryAddress: {
|
||||
[eEthereumNetwork.coverage]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
||||
[eEthereumNetwork.hardhat]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
||||
[eEthereumNetwork.buidlerevm]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
||||
[eEthereumNetwork.kovan]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
||||
[eEthereumNetwork.ropsten]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
||||
[eEthereumNetwork.main]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
||||
[eEthereumNetwork.tenderlyMain]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
|
||||
},
|
||||
};
|
||||
|
|
|
@ -9,6 +9,7 @@ import {
|
|||
import {
|
||||
ConfigNames,
|
||||
getReservesConfigByPool,
|
||||
getTreasuryAddress,
|
||||
getWethAddress,
|
||||
loadPoolConfig,
|
||||
} from '../../helpers/configuration';
|
||||
|
@ -50,10 +51,13 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
|
|||
|
||||
const admin = await addressesProvider.getPoolAdmin();
|
||||
|
||||
const treasuryAddress = await getTreasuryAddress(poolConfig);
|
||||
|
||||
await initReservesByHelper(
|
||||
reservesParams,
|
||||
protoPoolReservesAddresses,
|
||||
admin,
|
||||
treasuryAddress,
|
||||
ZERO_ADDRESS,
|
||||
verify
|
||||
);
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
deployAaveProtocolDataProvider,
|
||||
deployWETHGateway,
|
||||
} from '../../helpers/contracts-deployments';
|
||||
import { loadPoolConfig, ConfigNames, getWethAddress } from '../../helpers/configuration';
|
||||
import { loadPoolConfig, ConfigNames, getWethAddress, getTreasuryAddress } from '../../helpers/configuration';
|
||||
import { eEthereumNetwork, ICommonConfiguration } from '../../helpers/types';
|
||||
import { waitForTx } from '../../helpers/misc-utils';
|
||||
import {
|
||||
|
@ -42,7 +42,9 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
|||
throw 'Reserve assets is undefined. Check ReserveAssets configuration at config directory';
|
||||
}
|
||||
|
||||
await initReservesByHelper(ReservesConfig, reserveAssets, admin, ZERO_ADDRESS, verify);
|
||||
const treasuryAddress = await getTreasuryAddress(poolConfig);
|
||||
|
||||
await initReservesByHelper(ReservesConfig, reserveAssets, admin, treasuryAddress, ZERO_ADDRESS, verify);
|
||||
await enableReservesToBorrowByHelper(ReservesConfig, reserveAssets, testHelpers, admin);
|
||||
await enableReservesAsCollateralByHelper(ReservesConfig, reserveAssets, testHelpers, admin);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import {
|
|||
import { Signer } from 'ethers';
|
||||
import { TokenContractId, eContractid, tEthereumAddress, AavePools } from '../helpers/types';
|
||||
import { MintableERC20 } from '../types/MintableERC20';
|
||||
import { getReservesConfigByPool } from '../helpers/configuration';
|
||||
import { ConfigNames, getReservesConfigByPool, getTreasuryAddress, loadPoolConfig } from '../helpers/configuration';
|
||||
import { initializeMakeSuite } from './helpers/make-suite';
|
||||
|
||||
import {
|
||||
|
@ -209,7 +209,12 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
|||
const admin = await deployer.getAddress();
|
||||
|
||||
console.log('Initialize configuration');
|
||||
await initReservesByHelper(reservesParams, allReservesAddresses, admin, ZERO_ADDRESS);
|
||||
|
||||
const config = loadPoolConfig(ConfigNames.Aave);
|
||||
|
||||
const treasuryAddress = await getTreasuryAddress(config);
|
||||
|
||||
await initReservesByHelper(reservesParams, allReservesAddresses, admin, treasuryAddress, ZERO_ADDRESS, false);
|
||||
await enableReservesToBorrowByHelper(reservesParams, allReservesAddresses, testHelpers, admin);
|
||||
await enableReservesAsCollateralByHelper(
|
||||
reservesParams,
|
||||
|
|
|
@ -33,7 +33,7 @@ makeSuite('AToken: underlying delegation', (testEnv: TestEnv) => {
|
|||
delegationERC20 = await deployMintableDelegationERC20(['DEL', 'DEL', '18']);
|
||||
|
||||
delegationAToken = await deployDelegationAwareAToken(
|
||||
[pool.address, delegationERC20.address, 'aDEL', 'aDEL', ZERO_ADDRESS],
|
||||
[pool.address, delegationERC20.address, ZERO_ADDRESS, 'aDEL', 'aDEL', ZERO_ADDRESS],
|
||||
false
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user