mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Adapted deployments and tests
This commit is contained in:
parent
c0cb7d06a9
commit
dad66ef2d4
|
@ -11,7 +11,6 @@ import {
|
||||||
PoolConfiguration,
|
PoolConfiguration,
|
||||||
eEthereumNetwork,
|
eEthereumNetwork,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
import { MintableERC20 } from '../types/MintableERC20';
|
import { MintableERC20 } from '../types/MintableERC20';
|
||||||
import { MockContract } from 'ethereum-waffle';
|
import { MockContract } from 'ethereum-waffle';
|
||||||
import { getReservesConfigByPool } from './configuration';
|
import { getReservesConfigByPool } from './configuration';
|
||||||
|
@ -69,6 +68,7 @@ const readArtifact = async (id: string) => {
|
||||||
}
|
}
|
||||||
return (DRE as HardhatRuntimeEnvironment).artifacts.readArtifact(id);
|
return (DRE as HardhatRuntimeEnvironment).artifacts.readArtifact(id);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deployLendingPoolAddressesProvider = async (marketId: string, verify?: boolean) =>
|
export const deployLendingPoolAddressesProvider = async (marketId: string, verify?: boolean) =>
|
||||||
withSaveAndVerify(
|
withSaveAndVerify(
|
||||||
await new LendingPoolAddressesProviderFactory(await getFirstSigner()).deploy(marketId),
|
await new LendingPoolAddressesProviderFactory(await getFirstSigner()).deploy(marketId),
|
||||||
|
@ -302,78 +302,111 @@ export const deployDefaultReserveInterestRateStrategy = async (
|
||||||
export const deployStableDebtToken = async (
|
export const deployStableDebtToken = async (
|
||||||
args: [tEthereumAddress, tEthereumAddress, string, string, tEthereumAddress],
|
args: [tEthereumAddress, tEthereumAddress, string, string, tEthereumAddress],
|
||||||
verify: boolean
|
verify: boolean
|
||||||
) =>
|
) => {
|
||||||
withSaveAndVerify(
|
const instance = await withSaveAndVerify(
|
||||||
await new StableDebtTokenFactory(await getFirstSigner()).deploy(...args),
|
await new StableDebtTokenFactory(await getFirstSigner()).deploy(),
|
||||||
eContractid.StableDebtToken,
|
eContractid.StableDebtToken,
|
||||||
args,
|
[],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await instance.initialize(
|
||||||
|
args[0],
|
||||||
|
args[1],
|
||||||
|
args[2],
|
||||||
|
"18",
|
||||||
|
args[3],
|
||||||
|
args[4]
|
||||||
|
);
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export const deployVariableDebtToken = async (
|
export const deployVariableDebtToken = async (
|
||||||
args: [tEthereumAddress, tEthereumAddress, string, string, tEthereumAddress],
|
args: [tEthereumAddress, tEthereumAddress, string, string, tEthereumAddress],
|
||||||
verify: boolean
|
verify: boolean
|
||||||
) =>
|
) => {
|
||||||
withSaveAndVerify(
|
const instance = await withSaveAndVerify(
|
||||||
await new VariableDebtTokenFactory(await getFirstSigner()).deploy(...args),
|
await new VariableDebtTokenFactory(await getFirstSigner()).deploy(),
|
||||||
eContractid.VariableDebtToken,
|
eContractid.VariableDebtToken,
|
||||||
args,
|
[],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await instance.initialize(
|
||||||
|
args[0],
|
||||||
|
args[1],
|
||||||
|
args[2],
|
||||||
|
"18",
|
||||||
|
args[3],
|
||||||
|
args[4]
|
||||||
|
);
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export const deployGenericAToken = async (
|
export const deployGenericAToken = async (
|
||||||
[poolAddress, underlyingAssetAddress, treasuryAddress, name, symbol, incentivesController]: [
|
[poolAddress, underlyingAssetAddress, treasuryAddress, incentivesController, name, symbol]: [
|
||||||
|
tEthereumAddress,
|
||||||
tEthereumAddress,
|
tEthereumAddress,
|
||||||
tEthereumAddress,
|
tEthereumAddress,
|
||||||
tEthereumAddress,
|
tEthereumAddress,
|
||||||
string,
|
string,
|
||||||
string,
|
string
|
||||||
tEthereumAddress
|
|
||||||
],
|
],
|
||||||
verify: boolean
|
verify: boolean
|
||||||
) => {
|
) => {
|
||||||
const args: [
|
const instance = await withSaveAndVerify(
|
||||||
tEthereumAddress,
|
await new ATokenFactory(await getFirstSigner()).deploy(),
|
||||||
tEthereumAddress,
|
|
||||||
string,
|
|
||||||
string,
|
|
||||||
tEthereumAddress,
|
|
||||||
tEthereumAddress
|
|
||||||
] = [poolAddress, underlyingAssetAddress, treasuryAddress, name, symbol, incentivesController];
|
|
||||||
return withSaveAndVerify(
|
|
||||||
await new ATokenFactory(await getFirstSigner()).deploy(...args),
|
|
||||||
eContractid.AToken,
|
eContractid.AToken,
|
||||||
args,
|
[],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await instance.initialize(
|
||||||
|
poolAddress,
|
||||||
|
treasuryAddress,
|
||||||
|
underlyingAssetAddress,
|
||||||
|
incentivesController,
|
||||||
|
"18",
|
||||||
|
name,
|
||||||
|
symbol
|
||||||
|
);
|
||||||
|
|
||||||
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deployDelegationAwareAToken = async (
|
export const deployDelegationAwareAToken = async (
|
||||||
[poolAddress, underlyingAssetAddress, treasuryAddress, name, symbol, incentivesController]: [
|
[pool, underlyingAssetAddress, treasuryAddress, incentivesController, name, symbol]: [
|
||||||
|
tEthereumAddress,
|
||||||
tEthereumAddress,
|
tEthereumAddress,
|
||||||
tEthereumAddress,
|
tEthereumAddress,
|
||||||
tEthereumAddress,
|
tEthereumAddress,
|
||||||
string,
|
string,
|
||||||
string,
|
string
|
||||||
tEthereumAddress
|
|
||||||
],
|
],
|
||||||
verify: boolean
|
verify: boolean
|
||||||
) => {
|
) => {
|
||||||
const args: [
|
const instance = await withSaveAndVerify(
|
||||||
tEthereumAddress,
|
await new DelegationAwareATokenFactory(await getFirstSigner()).deploy(),
|
||||||
tEthereumAddress,
|
|
||||||
string,
|
|
||||||
string,
|
|
||||||
tEthereumAddress,
|
|
||||||
tEthereumAddress
|
|
||||||
] = [poolAddress, underlyingAssetAddress, treasuryAddress, name, symbol, incentivesController];
|
|
||||||
|
|
||||||
return withSaveAndVerify(
|
|
||||||
await new DelegationAwareATokenFactory(await getFirstSigner()).deploy(...args),
|
|
||||||
eContractid.DelegationAwareAToken,
|
eContractid.DelegationAwareAToken,
|
||||||
args,
|
[],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await instance.initialize(
|
||||||
|
pool,
|
||||||
|
treasuryAddress,
|
||||||
|
underlyingAssetAddress,
|
||||||
|
incentivesController,
|
||||||
|
"18",
|
||||||
|
name,
|
||||||
|
symbol
|
||||||
|
)
|
||||||
|
|
||||||
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deployAllMockTokens = async (verify?: boolean) => {
|
export const deployAllMockTokens = async (verify?: boolean) => {
|
||||||
|
@ -390,6 +423,7 @@ export const deployAllMockTokens = async (verify?: boolean) => {
|
||||||
[tokenSymbol, tokenSymbol, configData ? configData.reserveDecimals : decimals],
|
[tokenSymbol, tokenSymbol, configData ? configData.reserveDecimals : decimals],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
await registerContractInJsonDb(tokenSymbol.toUpperCase(), tokens[tokenSymbol]);
|
||||||
}
|
}
|
||||||
return tokens;
|
return tokens;
|
||||||
};
|
};
|
||||||
|
@ -449,16 +483,29 @@ export const deployWETHGateway = async (
|
||||||
);
|
);
|
||||||
|
|
||||||
export const deployMockStableDebtToken = async (
|
export const deployMockStableDebtToken = async (
|
||||||
args: [tEthereumAddress, tEthereumAddress, string, string, tEthereumAddress],
|
args: [tEthereumAddress, tEthereumAddress, tEthereumAddress, string, string],
|
||||||
verify?: boolean
|
verify?: boolean
|
||||||
) =>
|
) => {
|
||||||
withSaveAndVerify(
|
const instance = await withSaveAndVerify(
|
||||||
await new MockStableDebtTokenFactory(await getFirstSigner()).deploy(...args),
|
await new MockStableDebtTokenFactory(await getFirstSigner()).deploy(),
|
||||||
eContractid.MockStableDebtToken,
|
eContractid.MockStableDebtToken,
|
||||||
args,
|
[],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await instance.initialize(
|
||||||
|
args[0],
|
||||||
|
args[1],
|
||||||
|
args[2],
|
||||||
|
"18",
|
||||||
|
args[3],
|
||||||
|
args[4]
|
||||||
|
);
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export const deployWETHMocked = async (verify?: boolean) =>
|
export const deployWETHMocked = async (verify?: boolean) =>
|
||||||
withSaveAndVerify(
|
withSaveAndVerify(
|
||||||
await new WETH9MockedFactory(await getFirstSigner()).deploy(),
|
await new WETH9MockedFactory(await getFirstSigner()).deploy(),
|
||||||
|
@ -468,26 +515,53 @@ export const deployWETHMocked = async (verify?: boolean) =>
|
||||||
);
|
);
|
||||||
|
|
||||||
export const deployMockVariableDebtToken = async (
|
export const deployMockVariableDebtToken = async (
|
||||||
args: [tEthereumAddress, tEthereumAddress, string, string, tEthereumAddress],
|
args: [tEthereumAddress, tEthereumAddress, tEthereumAddress, string, string],
|
||||||
verify?: boolean
|
verify?: boolean
|
||||||
) =>
|
) => {
|
||||||
withSaveAndVerify(
|
const instance = await withSaveAndVerify(
|
||||||
await new MockVariableDebtTokenFactory(await getFirstSigner()).deploy(...args),
|
await new MockVariableDebtTokenFactory(await getFirstSigner()).deploy(),
|
||||||
eContractid.MockVariableDebtToken,
|
eContractid.MockVariableDebtToken,
|
||||||
args,
|
[],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await instance.initialize(
|
||||||
|
args[0],
|
||||||
|
args[1],
|
||||||
|
args[2],
|
||||||
|
"18",
|
||||||
|
args[3],
|
||||||
|
args[4]
|
||||||
|
);
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export const deployMockAToken = async (
|
export const deployMockAToken = async (
|
||||||
args: [tEthereumAddress, tEthereumAddress, tEthereumAddress, string, string, tEthereumAddress],
|
args: [tEthereumAddress, tEthereumAddress, tEthereumAddress,tEthereumAddress, string, string],
|
||||||
verify?: boolean
|
verify?: boolean
|
||||||
) =>
|
) => {
|
||||||
withSaveAndVerify(
|
const instance = await withSaveAndVerify(
|
||||||
await new MockATokenFactory(await getFirstSigner()).deploy(...args),
|
await new MockATokenFactory(await getFirstSigner()).deploy(),
|
||||||
eContractid.MockAToken,
|
eContractid.MockAToken,
|
||||||
args,
|
[],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await instance.initialize(
|
||||||
|
args[0],
|
||||||
|
args[2],
|
||||||
|
args[1],
|
||||||
|
args[3],
|
||||||
|
"18",
|
||||||
|
args[4],
|
||||||
|
args[5],
|
||||||
|
);
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export const deploySelfdestructTransferMock = async (verify?: boolean) =>
|
export const deploySelfdestructTransferMock = async (verify?: boolean) =>
|
||||||
withSaveAndVerify(
|
withSaveAndVerify(
|
||||||
|
|
|
@ -12,6 +12,7 @@ import {
|
||||||
getAToken,
|
getAToken,
|
||||||
getATokensAndRatesHelper,
|
getATokensAndRatesHelper,
|
||||||
getLendingPoolAddressesProvider,
|
getLendingPoolAddressesProvider,
|
||||||
|
getLendingPoolConfiguratorProxy,
|
||||||
getStableAndVariableTokensHelper,
|
getStableAndVariableTokensHelper,
|
||||||
} from './contracts-getters';
|
} from './contracts-getters';
|
||||||
import { rawInsertContractAddressInDb } from './contracts-helpers';
|
import { rawInsertContractAddressInDb } from './contracts-helpers';
|
||||||
|
@ -75,11 +76,30 @@ export const initReservesByHelper = async (
|
||||||
let reserveInitDecimals: string[] = [];
|
let reserveInitDecimals: string[] = [];
|
||||||
let reserveSymbols: string[] = [];
|
let reserveSymbols: string[] = [];
|
||||||
|
|
||||||
|
let initInputParams: {
|
||||||
|
aTokenImpl: string,
|
||||||
|
stableDebtTokenImpl: string,
|
||||||
|
variableDebtTokenImpl: string,
|
||||||
|
underlyingAssetDecimals: BigNumberish,
|
||||||
|
interestRateStrategyAddress: string,
|
||||||
|
underlyingAsset: string,
|
||||||
|
treasury: string,
|
||||||
|
incentivesController: string,
|
||||||
|
underlyingAssetName: string,
|
||||||
|
aTokenName: string,
|
||||||
|
aTokenSymbol: string,
|
||||||
|
variableDebtTokenName: string,
|
||||||
|
variableDebtTokenSymbol: string,
|
||||||
|
stableDebtTokenName: string,
|
||||||
|
stableDebtTokenSymbol: string,
|
||||||
|
}[] = [];
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`- Token deployments in ${reservesChunks.length * 2} txs instead of ${
|
`- Token deployments in ${reservesChunks.length * 2} txs instead of ${
|
||||||
Object.entries(reservesParams).length * 4
|
Object.entries(reservesParams).length * 4
|
||||||
} txs`
|
} txs`
|
||||||
);
|
);
|
||||||
|
|
||||||
for (let reservesChunk of reservesChunks) {
|
for (let reservesChunk of reservesChunks) {
|
||||||
// Prepare data
|
// Prepare data
|
||||||
const tokens: string[] = [];
|
const tokens: string[] = [];
|
||||||
|
@ -94,6 +114,18 @@ export const initReservesByHelper = async (
|
||||||
][] = [];
|
][] = [];
|
||||||
const reservesDecimals: string[] = [];
|
const reservesDecimals: string[] = [];
|
||||||
|
|
||||||
|
const inputParams: {
|
||||||
|
asset: string,
|
||||||
|
rates: [
|
||||||
|
BigNumberish,
|
||||||
|
BigNumberish,
|
||||||
|
BigNumberish,
|
||||||
|
BigNumberish,
|
||||||
|
BigNumberish,
|
||||||
|
BigNumberish
|
||||||
|
]
|
||||||
|
}[] = [];
|
||||||
|
|
||||||
for (let [assetSymbol, { reserveDecimals }] of reservesChunk) {
|
for (let [assetSymbol, { reserveDecimals }] of reservesChunk) {
|
||||||
const assetAddressIndex = Object.keys(tokenAddresses).findIndex(
|
const assetAddressIndex = Object.keys(tokenAddresses).findIndex(
|
||||||
(value) => value === assetSymbol
|
(value) => value === assetSymbol
|
||||||
|
@ -128,11 +160,23 @@ export const initReservesByHelper = async (
|
||||||
stableRateSlope2,
|
stableRateSlope2,
|
||||||
]);
|
]);
|
||||||
reservesDecimals.push(reserveDecimals);
|
reservesDecimals.push(reserveDecimals);
|
||||||
|
|
||||||
|
inputParams.push({
|
||||||
|
asset: tokenAddress,
|
||||||
|
rates: [
|
||||||
|
optimalUtilizationRate,
|
||||||
|
baseVariableBorrowRate,
|
||||||
|
variableRateSlope1,
|
||||||
|
variableRateSlope2,
|
||||||
|
stableRateSlope1,
|
||||||
|
stableRateSlope2
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deploy stable and variable deployers and save implementations
|
// Deploy stable and variable deployers and save implementations
|
||||||
const tx1 = await waitForTx(
|
const tx1 = await waitForTx(
|
||||||
await stableAndVariableDeployer.initDeployment(tokens, symbols, incentivesController)
|
await stableAndVariableDeployer.initDeployment(tokens, symbols)
|
||||||
);
|
);
|
||||||
tx1.events?.forEach((event, index) => {
|
tx1.events?.forEach((event, index) => {
|
||||||
rawInsertContractAddressInDb(`stableDebt${symbols[index]}`, event?.args?.stableToken);
|
rawInsertContractAddressInDb(`stableDebt${symbols[index]}`, event?.args?.stableToken);
|
||||||
|
@ -141,13 +185,7 @@ export const initReservesByHelper = async (
|
||||||
|
|
||||||
// Deploy atokens and rate strategies and save implementations
|
// Deploy atokens and rate strategies and save implementations
|
||||||
const tx2 = await waitForTx(
|
const tx2 = await waitForTx(
|
||||||
await atokenAndRatesDeployer.initDeployment(
|
await atokenAndRatesDeployer.initDeployment(inputParams)
|
||||||
tokens,
|
|
||||||
symbols,
|
|
||||||
strategyRates,
|
|
||||||
treasuryAddress,
|
|
||||||
incentivesController
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
tx2.events?.forEach((event, index) => {
|
tx2.events?.forEach((event, index) => {
|
||||||
rawInsertContractAddressInDb(`a${symbols[index]}`, event?.args?.aToken);
|
rawInsertContractAddressInDb(`a${symbols[index]}`, event?.args?.aToken);
|
||||||
|
@ -158,7 +196,7 @@ export const initReservesByHelper = async (
|
||||||
console.log(' * gasUsed: debtTokens batch', tx1.gasUsed.toString());
|
console.log(' * gasUsed: debtTokens batch', tx1.gasUsed.toString());
|
||||||
console.log(' * gasUsed: aTokens and Strategy batch', tx2.gasUsed.toString());
|
console.log(' * gasUsed: aTokens and Strategy batch', tx2.gasUsed.toString());
|
||||||
gasUsage = gasUsage.add(tx1.gasUsed).add(tx2.gasUsed);
|
gasUsage = gasUsage.add(tx1.gasUsed).add(tx2.gasUsed);
|
||||||
|
|
||||||
const stableTokens: string[] = tx1.events?.map((e) => e.args?.stableToken) || [];
|
const stableTokens: string[] = tx1.events?.map((e) => e.args?.stableToken) || [];
|
||||||
const variableTokens: string[] = tx1.events?.map((e) => e.args?.variableToken) || [];
|
const variableTokens: string[] = tx1.events?.map((e) => e.args?.variableToken) || [];
|
||||||
const aTokens: string[] = tx2.events?.map((e) => e.args?.aToken) || [];
|
const aTokens: string[] = tx2.events?.map((e) => e.args?.aToken) || [];
|
||||||
|
@ -194,9 +232,9 @@ export const initReservesByHelper = async (
|
||||||
poolAddress,
|
poolAddress,
|
||||||
tokenAddresses[symbol],
|
tokenAddresses[symbol],
|
||||||
treasuryAddress,
|
treasuryAddress,
|
||||||
|
ZERO_ADDRESS,
|
||||||
`Aave interest bearing ${symbol}`,
|
`Aave interest bearing ${symbol}`,
|
||||||
`a${symbol}`,
|
`a${symbol}`,
|
||||||
ZERO_ADDRESS,
|
|
||||||
],
|
],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
@ -204,9 +242,9 @@ export const initReservesByHelper = async (
|
||||||
[
|
[
|
||||||
poolAddress,
|
poolAddress,
|
||||||
tokenAddresses[symbol],
|
tokenAddresses[symbol],
|
||||||
|
ZERO_ADDRESS, // Incentives controller
|
||||||
`Aave stable debt bearing ${symbol}`,
|
`Aave stable debt bearing ${symbol}`,
|
||||||
`stableDebt${symbol}`,
|
`stableDebt${symbol}`
|
||||||
ZERO_ADDRESS,
|
|
||||||
],
|
],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
@ -214,9 +252,9 @@ export const initReservesByHelper = async (
|
||||||
[
|
[
|
||||||
poolAddress,
|
poolAddress,
|
||||||
tokenAddresses[symbol],
|
tokenAddresses[symbol],
|
||||||
|
ZERO_ADDRESS, // Incentives controller
|
||||||
`Aave variable debt bearing ${symbol}`,
|
`Aave variable debt bearing ${symbol}`,
|
||||||
`variableDebt${symbol}`,
|
`variableDebt${symbol}`,
|
||||||
ZERO_ADDRESS,
|
|
||||||
],
|
],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
@ -242,24 +280,37 @@ export const initReservesByHelper = async (
|
||||||
reserveSymbols.push(symbol);
|
reserveSymbols.push(symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deploy init reserves per chunks
|
for (let i = 0; i < deployedATokens.length; i ++) {
|
||||||
const chunkedStableTokens = chunk(deployedStableTokens, initChunks);
|
initInputParams.push({
|
||||||
const chunkedVariableTokens = chunk(deployedVariableTokens, initChunks);
|
aTokenImpl: deployedATokens[i],
|
||||||
const chunkedAtokens = chunk(deployedATokens, initChunks);
|
stableDebtTokenImpl: deployedStableTokens[i],
|
||||||
const chunkedRates = chunk(deployedRates, initChunks);
|
variableDebtTokenImpl: deployedVariableTokens[i],
|
||||||
const chunkedDecimals = chunk(reserveInitDecimals, initChunks);
|
underlyingAssetDecimals: reserveInitDecimals[i],
|
||||||
const chunkedSymbols = chunk(reserveSymbols, initChunks);
|
interestRateStrategyAddress: deployedRates[i],
|
||||||
|
underlyingAsset: reserveTokens[i],
|
||||||
|
treasury: treasuryAddress,
|
||||||
|
incentivesController: ZERO_ADDRESS,
|
||||||
|
underlyingAssetName: reserveSymbols[i],
|
||||||
|
aTokenName: `Aave interest bearing ${reserveSymbols[i]}`,
|
||||||
|
aTokenSymbol: `a${reserveSymbols[i]}`,
|
||||||
|
variableDebtTokenName: `Aave variable debt bearing ${reserveSymbols[i]}`,
|
||||||
|
variableDebtTokenSymbol: `variableDebt${reserveSymbols[i]}`,
|
||||||
|
stableDebtTokenName: `Aave stable debt bearing ${reserveSymbols[i]}`,
|
||||||
|
stableDebtTokenSymbol: `stableDebt${reserveSymbols[i]}`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
console.log(`- Reserves initialization in ${chunkedStableTokens.length} txs`);
|
// Deploy init reserves per chunks
|
||||||
for (let chunkIndex = 0; chunkIndex < chunkedDecimals.length; chunkIndex++) {
|
const chunkedSymbols = chunk(reserveSymbols, initChunks);
|
||||||
|
const chunkedInitInputParams = chunk(initInputParams, initChunks);
|
||||||
|
|
||||||
|
const configurator = await getLendingPoolConfiguratorProxy();
|
||||||
|
await waitForTx(await addressProvider.setPoolAdmin(admin));
|
||||||
|
|
||||||
|
console.log(`- Reserves initialization in ${chunkedInitInputParams.length} txs`);
|
||||||
|
for (let chunkIndex = 0; chunkIndex < chunkedInitInputParams.length; chunkIndex++) {
|
||||||
const tx3 = await waitForTx(
|
const tx3 = await waitForTx(
|
||||||
await atokenAndRatesDeployer.initReserve(
|
await configurator.batchInitReserve(chunkedInitInputParams[chunkIndex])
|
||||||
chunkedStableTokens[chunkIndex],
|
|
||||||
chunkedVariableTokens[chunkIndex],
|
|
||||||
chunkedAtokens[chunkIndex],
|
|
||||||
chunkedRates[chunkIndex],
|
|
||||||
chunkedDecimals[chunkIndex]
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(` - Reserve ready for: ${chunkedSymbols[chunkIndex].join(', ')}`);
|
console.log(` - Reserve ready for: ${chunkedSymbols[chunkIndex].join(', ')}`);
|
||||||
|
@ -267,6 +318,7 @@ export const initReservesByHelper = async (
|
||||||
gasUsage = gasUsage.add(tx3.gasUsed);
|
gasUsage = gasUsage.add(tx3.gasUsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set deployer back as admin
|
// Set deployer back as admin
|
||||||
await waitForTx(await addressProvider.setPoolAdmin(admin));
|
await waitForTx(await addressProvider.setPoolAdmin(admin));
|
||||||
return gasUsage;
|
return gasUsage;
|
||||||
|
@ -315,6 +367,15 @@ export const configureReservesByHelper = async (
|
||||||
const reserveFactors: string[] = [];
|
const reserveFactors: string[] = [];
|
||||||
const stableRatesEnabled: boolean[] = [];
|
const stableRatesEnabled: boolean[] = [];
|
||||||
|
|
||||||
|
const inputParams : {
|
||||||
|
asset: string;
|
||||||
|
baseLTV: BigNumberish;
|
||||||
|
liquidationThreshold: BigNumberish;
|
||||||
|
liquidationBonus: BigNumberish;
|
||||||
|
reserveFactor: BigNumberish;
|
||||||
|
stableBorrowingEnabled: boolean;
|
||||||
|
}[] = [];
|
||||||
|
|
||||||
for (const [
|
for (const [
|
||||||
assetSymbol,
|
assetSymbol,
|
||||||
{
|
{
|
||||||
|
@ -342,6 +403,16 @@ export const configureReservesByHelper = async (
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Push data
|
// Push data
|
||||||
|
|
||||||
|
inputParams.push({
|
||||||
|
asset: tokenAddress,
|
||||||
|
baseLTV: baseLTVAsCollateral,
|
||||||
|
liquidationThreshold: liquidationThreshold,
|
||||||
|
liquidationBonus: liquidationBonus,
|
||||||
|
reserveFactor: reserveFactor,
|
||||||
|
stableBorrowingEnabled: stableBorrowRateEnabled
|
||||||
|
});
|
||||||
|
|
||||||
tokens.push(tokenAddress);
|
tokens.push(tokenAddress);
|
||||||
symbols.push(assetSymbol);
|
symbols.push(assetSymbol);
|
||||||
baseLTVA.push(baseLTVAsCollateral);
|
baseLTVA.push(baseLTVAsCollateral);
|
||||||
|
@ -356,24 +427,14 @@ export const configureReservesByHelper = async (
|
||||||
|
|
||||||
// Deploy init per chunks
|
// Deploy init per chunks
|
||||||
const enableChunks = 20;
|
const enableChunks = 20;
|
||||||
const chunkedTokens = chunk(tokens, enableChunks);
|
|
||||||
const chunkedSymbols = chunk(symbols, enableChunks);
|
const chunkedSymbols = chunk(symbols, enableChunks);
|
||||||
const chunkedBase = chunk(baseLTVA, enableChunks);
|
const chunkedInputParams = chunk(inputParams, enableChunks);
|
||||||
const chunkedliquidationThresholds = chunk(liquidationThresholds, enableChunks);
|
|
||||||
const chunkedliquidationBonuses = chunk(liquidationBonuses, enableChunks);
|
|
||||||
const chunkedReserveFactors = chunk(reserveFactors, enableChunks);
|
|
||||||
const chunkedStableRatesEnabled = chunk(stableRatesEnabled, enableChunks);
|
|
||||||
|
|
||||||
console.log(`- Configure reserves in ${chunkedTokens.length} txs`);
|
console.log(`- Configure reserves in ${chunkedInputParams.length} txs`);
|
||||||
for (let chunkIndex = 0; chunkIndex < chunkedTokens.length; chunkIndex++) {
|
for (let chunkIndex = 0; chunkIndex < chunkedInputParams.length; chunkIndex++) {
|
||||||
await waitForTx(
|
await waitForTx(
|
||||||
await atokenAndRatesDeployer.configureReserves(
|
await atokenAndRatesDeployer.configureReserves(
|
||||||
chunkedTokens[chunkIndex],
|
chunkedInputParams[chunkIndex],
|
||||||
chunkedBase[chunkIndex],
|
|
||||||
chunkedliquidationThresholds[chunkIndex],
|
|
||||||
chunkedliquidationBonuses[chunkIndex],
|
|
||||||
chunkedReserveFactors[chunkIndex],
|
|
||||||
chunkedStableRatesEnabled[chunkIndex],
|
|
||||||
{ gasLimit: 12000000 }
|
{ gasLimit: 12000000 }
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -425,8 +486,28 @@ export const initTokenReservesByHelper = async (
|
||||||
let deployedVariableTokens: string[] = [];
|
let deployedVariableTokens: string[] = [];
|
||||||
let deployedATokens: string[] = [];
|
let deployedATokens: string[] = [];
|
||||||
let deployedRates: string[] = [];
|
let deployedRates: string[] = [];
|
||||||
|
let reserveTokens: string[] = [];
|
||||||
let reserveInitDecimals: string[] = [];
|
let reserveInitDecimals: string[] = [];
|
||||||
let reserveSymbols: string[] = [];
|
let reserveSymbols: string[] = [];
|
||||||
|
|
||||||
|
let initInputParams: {
|
||||||
|
aTokenImpl: string,
|
||||||
|
stableDebtTokenImpl: string,
|
||||||
|
variableDebtTokenImpl: string,
|
||||||
|
underlyingAssetDecimals: BigNumberish,
|
||||||
|
interestRateStrategyAddress: string,
|
||||||
|
underlyingAsset: string,
|
||||||
|
treasury: string,
|
||||||
|
incentivesController: string,
|
||||||
|
underlyingAssetName: string,
|
||||||
|
aTokenName: string,
|
||||||
|
aTokenSymbol: string,
|
||||||
|
variableDebtTokenName: string,
|
||||||
|
variableDebtTokenSymbol: string,
|
||||||
|
stableDebtTokenName: string,
|
||||||
|
stableDebtTokenSymbol: string,
|
||||||
|
}[] = [];
|
||||||
|
|
||||||
const network =
|
const network =
|
||||||
process.env.MAINNET_FORK === 'true'
|
process.env.MAINNET_FORK === 'true'
|
||||||
? eEthereumNetwork.main
|
? eEthereumNetwork.main
|
||||||
|
@ -454,9 +535,9 @@ export const initTokenReservesByHelper = async (
|
||||||
[
|
[
|
||||||
poolAddress,
|
poolAddress,
|
||||||
tokenAddresses[symbol],
|
tokenAddresses[symbol],
|
||||||
|
ZERO_ADDRESS, // Incentives controller
|
||||||
`Aave stable debt bearing ${symbol}`,
|
`Aave stable debt bearing ${symbol}`,
|
||||||
`stableDebt${symbol}`,
|
`stableDebt${symbol}`
|
||||||
ZERO_ADDRESS,
|
|
||||||
],
|
],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
@ -467,9 +548,9 @@ export const initTokenReservesByHelper = async (
|
||||||
[
|
[
|
||||||
poolAddress,
|
poolAddress,
|
||||||
tokenAddresses[symbol],
|
tokenAddresses[symbol],
|
||||||
|
ZERO_ADDRESS, // Incentives Controller
|
||||||
`Aave variable debt bearing ${symbol}`,
|
`Aave variable debt bearing ${symbol}`,
|
||||||
`variableDebt${symbol}`,
|
`variableDebt${symbol}`
|
||||||
ZERO_ADDRESS,
|
|
||||||
],
|
],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
@ -485,9 +566,9 @@ export const initTokenReservesByHelper = async (
|
||||||
poolAddress,
|
poolAddress,
|
||||||
tokenAddresses[symbol],
|
tokenAddresses[symbol],
|
||||||
treasuryAddress,
|
treasuryAddress,
|
||||||
`Aave interest bearing ${symbol}`,
|
|
||||||
`a${symbol}`,
|
|
||||||
ZERO_ADDRESS,
|
ZERO_ADDRESS,
|
||||||
|
`Aave interest bearing ${symbol}`,
|
||||||
|
`a${symbol}`
|
||||||
],
|
],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
@ -531,34 +612,47 @@ export const initTokenReservesByHelper = async (
|
||||||
deployedStableTokens.push(stableTokenImpl);
|
deployedStableTokens.push(stableTokenImpl);
|
||||||
deployedVariableTokens.push(variableTokenImpl);
|
deployedVariableTokens.push(variableTokenImpl);
|
||||||
deployedATokens.push(aTokenImplementation);
|
deployedATokens.push(aTokenImplementation);
|
||||||
|
reserveTokens.push();
|
||||||
deployedRates.push(strategyImpl);
|
deployedRates.push(strategyImpl);
|
||||||
reserveInitDecimals.push(decimals.toString());
|
reserveInitDecimals.push(decimals.toString());
|
||||||
reserveSymbols.push(symbol);
|
reserveSymbols.push(symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deploy init reserves per chunks
|
for (let i = 0; i < deployedATokens.length; i ++) {
|
||||||
const chunkedStableTokens = chunk(deployedStableTokens, initChunks);
|
initInputParams.push({
|
||||||
const chunkedVariableTokens = chunk(deployedVariableTokens, initChunks);
|
aTokenImpl: deployedATokens[i],
|
||||||
const chunkedAtokens = chunk(deployedATokens, initChunks);
|
stableDebtTokenImpl: deployedStableTokens[i],
|
||||||
const chunkedRates = chunk(deployedRates, initChunks);
|
variableDebtTokenImpl: deployedVariableTokens[i],
|
||||||
const chunkedDecimals = chunk(reserveInitDecimals, initChunks);
|
underlyingAssetDecimals: reserveInitDecimals[i],
|
||||||
const chunkedSymbols = chunk(reserveSymbols, initChunks);
|
interestRateStrategyAddress: deployedRates[i],
|
||||||
|
underlyingAsset: tokenAddresses[reserveSymbols[i]],
|
||||||
|
treasury: treasuryAddress,
|
||||||
|
incentivesController: ZERO_ADDRESS,
|
||||||
|
underlyingAssetName: reserveSymbols[i],
|
||||||
|
aTokenName: `Aave interest bearing ${reserveSymbols[i]}`,
|
||||||
|
aTokenSymbol: `a${reserveSymbols[i]}`,
|
||||||
|
variableDebtTokenName: `Aave variable debt bearing ${reserveSymbols[i]}`,
|
||||||
|
variableDebtTokenSymbol: `variableDebt${reserveSymbols[i]}`,
|
||||||
|
stableDebtTokenName: `Aave stable debt bearing ${reserveSymbols[i]}`,
|
||||||
|
stableDebtTokenSymbol: `stableDebt${reserveSymbols[i]}`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
console.log(`- Reserves initialization in ${chunkedStableTokens.length} txs`);
|
// Deploy init reserves per chunks
|
||||||
for (let chunkIndex = 0; chunkIndex < chunkedDecimals.length; chunkIndex++) {
|
const chunkedSymbols = chunk(reserveSymbols, initChunks);
|
||||||
|
const chunkedInitInputParams = chunk(initInputParams, initChunks);
|
||||||
|
|
||||||
|
const configurator = await getLendingPoolConfiguratorProxy();
|
||||||
|
await waitForTx(await addressProvider.setPoolAdmin(admin));
|
||||||
|
|
||||||
|
console.log(`- Reserves initialization in ${chunkedInitInputParams.length} txs`);
|
||||||
|
for (let chunkIndex = 0; chunkIndex < chunkedInitInputParams.length; chunkIndex++) {
|
||||||
const tx3 = await waitForTx(
|
const tx3 = await waitForTx(
|
||||||
await atokenAndRatesDeployer.initReserve(
|
await configurator.batchInitReserve(chunkedInitInputParams[chunkIndex])
|
||||||
chunkedStableTokens[chunkIndex],
|
|
||||||
chunkedVariableTokens[chunkIndex],
|
|
||||||
chunkedAtokens[chunkIndex],
|
|
||||||
chunkedRates[chunkIndex],
|
|
||||||
chunkedDecimals[chunkIndex]
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(` - Reserve ready for: ${chunkedSymbols[chunkIndex].join(', ')}`);
|
console.log(` - Reserve ready for: ${chunkedSymbols[chunkIndex].join(', ')}`);
|
||||||
console.log(' * gasUsed', tx3.gasUsed.toString());
|
console.log(' * gasUsed', tx3.gasUsed.toString());
|
||||||
gasUsage = gasUsage.add(tx3.gasUsed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set deployer back as admin
|
// Set deployer back as admin
|
||||||
|
|
|
@ -53,9 +53,9 @@ WRONG RESERVE ASSET SETUP:
|
||||||
poolAddress,
|
poolAddress,
|
||||||
reserveAssetAddress,
|
reserveAssetAddress,
|
||||||
treasuryAddress,
|
treasuryAddress,
|
||||||
|
ZERO_ADDRESS,
|
||||||
`Aave interest bearing ${symbol}`,
|
`Aave interest bearing ${symbol}`,
|
||||||
`a${symbol}`,
|
`a${symbol}`,
|
||||||
ZERO_ADDRESS,
|
|
||||||
],
|
],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user