mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Add UNI aDelegatedToken
This commit is contained in:
parent
56d25e81cb
commit
1c26eeef87
|
@ -8,17 +8,26 @@ import {
|
||||||
} from './contracts-getters';
|
} from './contracts-getters';
|
||||||
import { rawInsertContractAddressInDb } from './contracts-helpers';
|
import { rawInsertContractAddressInDb } from './contracts-helpers';
|
||||||
import { BigNumberish } from 'ethers';
|
import { BigNumberish } from 'ethers';
|
||||||
|
import {
|
||||||
|
deployDefaultReserveInterestRateStrategy,
|
||||||
|
deployDelegationAwareAToken,
|
||||||
|
deployStableDebtToken,
|
||||||
|
deployVariableDebtToken,
|
||||||
|
} from './contracts-deployments';
|
||||||
|
import { ZERO_ADDRESS } from './constants';
|
||||||
|
|
||||||
export const initReservesByHelper = async (
|
export const initReservesByHelper = async (
|
||||||
reservesParams: iMultiPoolsAssets<IReserveParams>,
|
reservesParams: iMultiPoolsAssets<IReserveParams>,
|
||||||
tokenAddresses: { [symbol: string]: tEthereumAddress },
|
tokenAddresses: { [symbol: string]: tEthereumAddress },
|
||||||
admin: tEthereumAddress,
|
admin: tEthereumAddress,
|
||||||
incentivesController: tEthereumAddress
|
incentivesController: tEthereumAddress,
|
||||||
|
verify: boolean
|
||||||
) => {
|
) => {
|
||||||
const stableAndVariableDeployer = await getStableAndVariableTokensHelper();
|
const stableAndVariableDeployer = await getStableAndVariableTokensHelper();
|
||||||
const atokenAndRatesDeployer = await getATokensAndRatesHelper();
|
const atokenAndRatesDeployer = await getATokensAndRatesHelper();
|
||||||
|
|
||||||
const addressProvider = await getLendingPoolAddressesProvider();
|
const addressProvider = await getLendingPoolAddressesProvider();
|
||||||
|
const poolAddress = await addressProvider.getLendingPool();
|
||||||
|
|
||||||
// Set aTokenAndRatesDeployer as temporal admin
|
// Set aTokenAndRatesDeployer as temporal admin
|
||||||
await waitForTx(await addressProvider.setPoolAdmin(atokenAndRatesDeployer.address));
|
await waitForTx(await addressProvider.setPoolAdmin(atokenAndRatesDeployer.address));
|
||||||
|
@ -39,6 +48,7 @@ export const initReservesByHelper = async (
|
||||||
let deployedRates: string[] = [];
|
let deployedRates: string[] = [];
|
||||||
let reserveTokens: string[] = [];
|
let reserveTokens: string[] = [];
|
||||||
let reserveInitDecimals: string[] = [];
|
let reserveInitDecimals: string[] = [];
|
||||||
|
let reserveSymbols: string[] = [];
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`- Token deployments in ${reservesChunks.length * 2} txs instead of ${
|
`- Token deployments in ${reservesChunks.length * 2} txs instead of ${
|
||||||
|
@ -59,6 +69,10 @@ export const initReservesByHelper = async (
|
||||||
const reservesDecimals: string[] = [];
|
const reservesDecimals: string[] = [];
|
||||||
|
|
||||||
for (let [assetSymbol, { reserveDecimals }] of reservesChunk) {
|
for (let [assetSymbol, { reserveDecimals }] of reservesChunk) {
|
||||||
|
// Skip UNI due is aDelegatedToken
|
||||||
|
if (assetSymbol === 'UNI') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const assetAddressIndex = Object.keys(tokenAddresses).findIndex(
|
const assetAddressIndex = Object.keys(tokenAddresses).findIndex(
|
||||||
(value) => value === assetSymbol
|
(value) => value === assetSymbol
|
||||||
);
|
);
|
||||||
|
@ -126,6 +140,62 @@ export const initReservesByHelper = async (
|
||||||
deployedRates = [...deployedRates, ...strategies];
|
deployedRates = [...deployedRates, ...strategies];
|
||||||
reserveInitDecimals = [...reserveInitDecimals, ...reservesDecimals];
|
reserveInitDecimals = [...reserveInitDecimals, ...reservesDecimals];
|
||||||
reserveTokens = [...reserveTokens, ...tokens];
|
reserveTokens = [...reserveTokens, ...tokens];
|
||||||
|
reserveSymbols = [...reserveSymbols, ...symbols];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deploy UNI token due is delegated aToken
|
||||||
|
if (tokenAddresses.UNI) {
|
||||||
|
console.log(' - Deploy UNI delegated aToken, debts tokens, and strategy');
|
||||||
|
const {
|
||||||
|
baseVariableBorrowRate,
|
||||||
|
variableRateSlope1,
|
||||||
|
variableRateSlope2,
|
||||||
|
stableRateSlope1,
|
||||||
|
stableRateSlope2,
|
||||||
|
} = reservesParams.UNI;
|
||||||
|
const aTokenUNI = await deployDelegationAwareAToken(
|
||||||
|
[poolAddress, tokenAddresses.UNI, 'Aave interest bearing ', 'aUNI', ZERO_ADDRESS],
|
||||||
|
verify
|
||||||
|
);
|
||||||
|
const stableDebtUNI = await deployStableDebtToken(
|
||||||
|
[
|
||||||
|
poolAddress,
|
||||||
|
tokenAddresses.UNI,
|
||||||
|
'Aave stable debt bearing UNI',
|
||||||
|
'stableDebtUNI',
|
||||||
|
ZERO_ADDRESS,
|
||||||
|
],
|
||||||
|
verify
|
||||||
|
);
|
||||||
|
const variableDebtUNI = await deployVariableDebtToken(
|
||||||
|
[
|
||||||
|
poolAddress,
|
||||||
|
tokenAddresses.UNI,
|
||||||
|
'Aave variable debt bearing UNI',
|
||||||
|
'variableDebtUNI',
|
||||||
|
ZERO_ADDRESS,
|
||||||
|
],
|
||||||
|
verify
|
||||||
|
);
|
||||||
|
const ratesUNI = await deployDefaultReserveInterestRateStrategy(
|
||||||
|
[
|
||||||
|
tokenAddresses.UNI,
|
||||||
|
baseVariableBorrowRate,
|
||||||
|
variableRateSlope1,
|
||||||
|
variableRateSlope2,
|
||||||
|
stableRateSlope1,
|
||||||
|
stableRateSlope2,
|
||||||
|
],
|
||||||
|
verify
|
||||||
|
);
|
||||||
|
|
||||||
|
deployedStableTokens.push(stableDebtUNI.address);
|
||||||
|
deployedVariableTokens.push(variableDebtUNI.address);
|
||||||
|
deployedATokens.push(aTokenUNI.address);
|
||||||
|
deployedRates.push(ratesUNI.address);
|
||||||
|
reserveInitDecimals.push(reservesParams.UNI.reserveDecimals);
|
||||||
|
reserveTokens.push(tokenAddresses.UNI);
|
||||||
|
reserveSymbols.push('UNI');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deploy init reserves per chunks
|
// Deploy init reserves per chunks
|
||||||
|
@ -134,7 +204,7 @@ export const initReservesByHelper = async (
|
||||||
const chunkedAtokens = chunk(deployedATokens, initChunks);
|
const chunkedAtokens = chunk(deployedATokens, initChunks);
|
||||||
const chunkedRates = chunk(deployedRates, initChunks);
|
const chunkedRates = chunk(deployedRates, initChunks);
|
||||||
const chunkedDecimals = chunk(reserveInitDecimals, initChunks);
|
const chunkedDecimals = chunk(reserveInitDecimals, initChunks);
|
||||||
const chunkedSymbols = chunk(Object.keys(tokenAddresses), initChunks);
|
const chunkedSymbols = chunk(reserveSymbols, initChunks);
|
||||||
|
|
||||||
console.log(`- Reserves initialization in ${chunkedStableTokens.length} txs`);
|
console.log(`- Reserves initialization in ${chunkedStableTokens.length} txs`);
|
||||||
for (let chunkIndex = 0; chunkIndex < chunkedDecimals.length; chunkIndex++) {
|
for (let chunkIndex = 0; chunkIndex < chunkedDecimals.length; chunkIndex++) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {task} from 'hardhat/config';
|
import { task } from 'hardhat/config';
|
||||||
import {
|
import {
|
||||||
deployLendingPoolCollateralManager,
|
deployLendingPoolCollateralManager,
|
||||||
deployMockFlashLoanReceiver,
|
deployMockFlashLoanReceiver,
|
||||||
|
@ -13,22 +13,25 @@ import {
|
||||||
loadPoolConfig,
|
loadPoolConfig,
|
||||||
} from '../../helpers/configuration';
|
} from '../../helpers/configuration';
|
||||||
|
|
||||||
import {tEthereumAddress, AavePools, eContractid} from '../../helpers/types';
|
import { tEthereumAddress, AavePools, eContractid } from '../../helpers/types';
|
||||||
import {waitForTx, filterMapBy} from '../../helpers/misc-utils';
|
import { waitForTx, filterMapBy } from '../../helpers/misc-utils';
|
||||||
import {
|
import {
|
||||||
enableReservesToBorrowByHelper,
|
enableReservesToBorrowByHelper,
|
||||||
enableReservesAsCollateralByHelper,
|
enableReservesAsCollateralByHelper,
|
||||||
initReservesByHelper,
|
initReservesByHelper,
|
||||||
} from '../../helpers/init-helpers';
|
} from '../../helpers/init-helpers';
|
||||||
import {getAllTokenAddresses} from '../../helpers/mock-helpers';
|
import { getAllTokenAddresses } from '../../helpers/mock-helpers';
|
||||||
import {ZERO_ADDRESS} from '../../helpers/constants';
|
import { ZERO_ADDRESS } from '../../helpers/constants';
|
||||||
import {getAllMockedTokens, getLendingPoolAddressesProvider} from '../../helpers/contracts-getters';
|
import {
|
||||||
import {insertContractAddressInDb} from '../../helpers/contracts-helpers';
|
getAllMockedTokens,
|
||||||
|
getLendingPoolAddressesProvider,
|
||||||
|
} from '../../helpers/contracts-getters';
|
||||||
|
import { insertContractAddressInDb } from '../../helpers/contracts-helpers';
|
||||||
|
|
||||||
task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
|
task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
.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}, localBRE) => {
|
.setAction(async ({ verify, pool }, localBRE) => {
|
||||||
await localBRE.run('set-DRE');
|
await localBRE.run('set-DRE');
|
||||||
const poolConfig = loadPoolConfig(pool);
|
const poolConfig = loadPoolConfig(pool);
|
||||||
|
|
||||||
|
@ -37,7 +40,7 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
|
|
||||||
const addressesProvider = await getLendingPoolAddressesProvider();
|
const addressesProvider = await getLendingPoolAddressesProvider();
|
||||||
|
|
||||||
const protoPoolReservesAddresses = <{[symbol: string]: tEthereumAddress}>(
|
const protoPoolReservesAddresses = <{ [symbol: string]: tEthereumAddress }>(
|
||||||
filterMapBy(allTokenAddresses, (key: string) => !key.includes('UNI_'))
|
filterMapBy(allTokenAddresses, (key: string) => !key.includes('UNI_'))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -47,7 +50,13 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
|
|
||||||
const admin = await addressesProvider.getPoolAdmin();
|
const admin = await addressesProvider.getPoolAdmin();
|
||||||
|
|
||||||
await initReservesByHelper(reservesParams, protoPoolReservesAddresses, admin, ZERO_ADDRESS);
|
await initReservesByHelper(
|
||||||
|
reservesParams,
|
||||||
|
protoPoolReservesAddresses,
|
||||||
|
admin,
|
||||||
|
ZERO_ADDRESS,
|
||||||
|
verify
|
||||||
|
);
|
||||||
await enableReservesToBorrowByHelper(
|
await enableReservesToBorrowByHelper(
|
||||||
reservesParams,
|
reservesParams,
|
||||||
protoPoolReservesAddresses,
|
protoPoolReservesAddresses,
|
||||||
|
|
|
@ -1,32 +1,32 @@
|
||||||
import {task} from 'hardhat/config';
|
import { task } from 'hardhat/config';
|
||||||
import {getParamPerNetwork} from '../../helpers/contracts-helpers';
|
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
|
||||||
import {
|
import {
|
||||||
deployLendingPoolCollateralManager,
|
deployLendingPoolCollateralManager,
|
||||||
deployWalletBalancerProvider,
|
deployWalletBalancerProvider,
|
||||||
deployAaveProtocolDataProvider,
|
deployAaveProtocolDataProvider,
|
||||||
deployWETHGateway,
|
deployWETHGateway,
|
||||||
} from '../../helpers/contracts-deployments';
|
} from '../../helpers/contracts-deployments';
|
||||||
import {loadPoolConfig, ConfigNames, getWethAddress} from '../../helpers/configuration';
|
import { loadPoolConfig, ConfigNames, getWethAddress } from '../../helpers/configuration';
|
||||||
import {eEthereumNetwork, ICommonConfiguration} from '../../helpers/types';
|
import { eEthereumNetwork, ICommonConfiguration } from '../../helpers/types';
|
||||||
import {waitForTx} from '../../helpers/misc-utils';
|
import { waitForTx } from '../../helpers/misc-utils';
|
||||||
import {
|
import {
|
||||||
initReservesByHelper,
|
initReservesByHelper,
|
||||||
enableReservesToBorrowByHelper,
|
enableReservesToBorrowByHelper,
|
||||||
enableReservesAsCollateralByHelper,
|
enableReservesAsCollateralByHelper,
|
||||||
} from '../../helpers/init-helpers';
|
} from '../../helpers/init-helpers';
|
||||||
import {exit} from 'process';
|
import { exit } from 'process';
|
||||||
import {getLendingPoolAddressesProvider} from '../../helpers/contracts-getters';
|
import { getLendingPoolAddressesProvider } from '../../helpers/contracts-getters';
|
||||||
import {ZERO_ADDRESS} from '../../helpers/constants';
|
import { ZERO_ADDRESS } from '../../helpers/constants';
|
||||||
|
|
||||||
task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
.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}, localBRE) => {
|
.setAction(async ({ verify, pool }, localBRE) => {
|
||||||
try {
|
try {
|
||||||
await localBRE.run('set-DRE');
|
await localBRE.run('set-DRE');
|
||||||
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;
|
||||||
|
|
||||||
const reserveAssets = await getParamPerNetwork(ReserveAssets, network);
|
const reserveAssets = await getParamPerNetwork(ReserveAssets, network);
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
throw 'Reserve assets is undefined. Check ReserveAssets configuration at config directory';
|
throw 'Reserve assets is undefined. Check ReserveAssets configuration at config directory';
|
||||||
}
|
}
|
||||||
|
|
||||||
await initReservesByHelper(ReservesConfig, reserveAssets, admin, ZERO_ADDRESS);
|
await initReservesByHelper(ReservesConfig, reserveAssets, admin, ZERO_ADDRESS, verify);
|
||||||
await enableReservesToBorrowByHelper(ReservesConfig, reserveAssets, testHelpers, admin);
|
await enableReservesToBorrowByHelper(ReservesConfig, reserveAssets, testHelpers, admin);
|
||||||
await enableReservesAsCollateralByHelper(ReservesConfig, reserveAssets, testHelpers, admin);
|
await enableReservesAsCollateralByHelper(ReservesConfig, reserveAssets, testHelpers, admin);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user