mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Began work on implementing light deployment scripts
This commit is contained in:
parent
b4d72bfc37
commit
517d51f900
|
@ -300,7 +300,7 @@ export const deployStableDebtToken = async (
|
||||||
verify: boolean
|
verify: boolean
|
||||||
) =>
|
) =>
|
||||||
withSaveAndVerify(
|
withSaveAndVerify(
|
||||||
await new StableDebtTokenFactory(await getFirstSigner()).deploy(...args),
|
await new StableDebtTokenFactory(await getFirstSigner()).deploy(),
|
||||||
eContractid.StableDebtToken,
|
eContractid.StableDebtToken,
|
||||||
args,
|
args,
|
||||||
verify
|
verify
|
||||||
|
@ -311,7 +311,7 @@ export const deployVariableDebtToken = async (
|
||||||
verify: boolean
|
verify: boolean
|
||||||
) =>
|
) =>
|
||||||
withSaveAndVerify(
|
withSaveAndVerify(
|
||||||
await new VariableDebtTokenFactory(await getFirstSigner()).deploy(...args),
|
await new VariableDebtTokenFactory(await getFirstSigner()).deploy(),
|
||||||
eContractid.VariableDebtToken,
|
eContractid.VariableDebtToken,
|
||||||
args,
|
args,
|
||||||
verify
|
verify
|
||||||
|
@ -338,7 +338,7 @@ export const deployGenericAToken = async (
|
||||||
|
|
||||||
] = [poolAddress, underlyingAssetAddress, treasuryAddress, name, symbol, incentivesController];
|
] = [poolAddress, underlyingAssetAddress, treasuryAddress, name, symbol, incentivesController];
|
||||||
return withSaveAndVerify(
|
return withSaveAndVerify(
|
||||||
await new ATokenFactory(await getFirstSigner()).deploy(...args),
|
await new ATokenFactory(await getFirstSigner()).deploy(),
|
||||||
eContractid.AToken,
|
eContractid.AToken,
|
||||||
args,
|
args,
|
||||||
verify
|
verify
|
||||||
|
@ -366,7 +366,7 @@ export const deployDelegationAwareAToken = async (
|
||||||
] = [poolAddress, underlyingAssetAddress, treasuryAddress, name, symbol, incentivesController];
|
] = [poolAddress, underlyingAssetAddress, treasuryAddress, name, symbol, incentivesController];
|
||||||
|
|
||||||
return withSaveAndVerify(
|
return withSaveAndVerify(
|
||||||
await new DelegationAwareATokenFactory(await getFirstSigner()).deploy(...args),
|
await new DelegationAwareATokenFactory(await getFirstSigner()).deploy(),
|
||||||
eContractid.DelegationAwareAToken,
|
eContractid.DelegationAwareAToken,
|
||||||
args,
|
args,
|
||||||
verify
|
verify
|
||||||
|
@ -451,7 +451,7 @@ export const deployMockStableDebtToken = async (
|
||||||
verify?: boolean
|
verify?: boolean
|
||||||
) =>
|
) =>
|
||||||
withSaveAndVerify(
|
withSaveAndVerify(
|
||||||
await new MockStableDebtTokenFactory(await getFirstSigner()).deploy(...args),
|
await new MockStableDebtTokenFactory(await getFirstSigner()).deploy(),
|
||||||
eContractid.MockStableDebtToken,
|
eContractid.MockStableDebtToken,
|
||||||
args,
|
args,
|
||||||
verify
|
verify
|
||||||
|
@ -470,7 +470,7 @@ export const deployMockVariableDebtToken = async (
|
||||||
verify?: boolean
|
verify?: boolean
|
||||||
) =>
|
) =>
|
||||||
withSaveAndVerify(
|
withSaveAndVerify(
|
||||||
await new MockVariableDebtTokenFactory(await getFirstSigner()).deploy(...args),
|
await new MockVariableDebtTokenFactory(await getFirstSigner()).deploy(),
|
||||||
eContractid.MockVariableDebtToken,
|
eContractid.MockVariableDebtToken,
|
||||||
args,
|
args,
|
||||||
verify
|
verify
|
||||||
|
@ -481,7 +481,7 @@ export const deployMockAToken = async (
|
||||||
verify?: boolean
|
verify?: boolean
|
||||||
) =>
|
) =>
|
||||||
withSaveAndVerify(
|
withSaveAndVerify(
|
||||||
await new MockATokenFactory(await getFirstSigner()).deploy(...args),
|
await new MockATokenFactory(await getFirstSigner()).deploy(),
|
||||||
eContractid.MockAToken,
|
eContractid.MockAToken,
|
||||||
args,
|
args,
|
||||||
verify
|
verify
|
||||||
|
|
|
@ -95,7 +95,19 @@ export const initReservesByHelper = async (
|
||||||
BigNumberish
|
BigNumberish
|
||||||
][] = [];
|
][] = [];
|
||||||
const reservesDecimals: string[] = [];
|
const reservesDecimals: string[] = [];
|
||||||
|
// TEST
|
||||||
|
const inputParams: {
|
||||||
|
asset: string,
|
||||||
|
rates: [
|
||||||
|
BigNumberish,
|
||||||
|
BigNumberish,
|
||||||
|
BigNumberish,
|
||||||
|
BigNumberish,
|
||||||
|
BigNumberish,
|
||||||
|
BigNumberish
|
||||||
|
]
|
||||||
|
}[] = [];
|
||||||
|
// TEST
|
||||||
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
|
||||||
|
@ -130,12 +142,26 @@ export const initReservesByHelper = async (
|
||||||
stableRateSlope2,
|
stableRateSlope2,
|
||||||
]);
|
]);
|
||||||
reservesDecimals.push(reserveDecimals);
|
reservesDecimals.push(reserveDecimals);
|
||||||
|
|
||||||
|
// TEST
|
||||||
|
inputParams.push({
|
||||||
|
asset: tokenAddress,
|
||||||
|
rates: [
|
||||||
|
optimalUtilizationRate,
|
||||||
|
baseVariableBorrowRate,
|
||||||
|
variableRateSlope1,
|
||||||
|
variableRateSlope2,
|
||||||
|
stableRateSlope1,
|
||||||
|
stableRateSlope2
|
||||||
|
]
|
||||||
|
});
|
||||||
|
// TEST
|
||||||
}
|
}
|
||||||
|
|
||||||
// tx1 and tx2 gas is accounted for later.
|
// tx1 and tx2 gas is accounted for later.
|
||||||
// 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);
|
||||||
|
@ -144,13 +170,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);
|
||||||
|
@ -317,6 +337,16 @@ export const configureReservesByHelper = async (
|
||||||
const liquidationBonuses: string[] = [];
|
const liquidationBonuses: string[] = [];
|
||||||
const reserveFactors: string[] = [];
|
const reserveFactors: string[] = [];
|
||||||
const stableRatesEnabled: boolean[] = [];
|
const stableRatesEnabled: boolean[] = [];
|
||||||
|
// TEST
|
||||||
|
const inputParams : {
|
||||||
|
asset: string;
|
||||||
|
baseLTV: BigNumberish;
|
||||||
|
liquidationThreshold: BigNumberish;
|
||||||
|
liquidationBonus: BigNumberish;
|
||||||
|
reserveFactor: BigNumberish;
|
||||||
|
stableBorrowingEnabled: boolean;
|
||||||
|
}[] = [];
|
||||||
|
// TEST
|
||||||
|
|
||||||
for (const [
|
for (const [
|
||||||
assetSymbol,
|
assetSymbol,
|
||||||
|
@ -345,6 +375,18 @@ export const configureReservesByHelper = async (
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Push data
|
// Push data
|
||||||
|
|
||||||
|
// TEST
|
||||||
|
inputParams.push({
|
||||||
|
asset: tokenAddress,
|
||||||
|
baseLTV: baseLTVAsCollateral,
|
||||||
|
liquidationThreshold: liquidationThreshold,
|
||||||
|
liquidationBonus: liquidationBonus,
|
||||||
|
reserveFactor: reserveFactor,
|
||||||
|
stableBorrowingEnabled: stableBorrowRateEnabled
|
||||||
|
});
|
||||||
|
// TEST
|
||||||
|
|
||||||
tokens.push(tokenAddress);
|
tokens.push(tokenAddress);
|
||||||
symbols.push(assetSymbol);
|
symbols.push(assetSymbol);
|
||||||
baseLTVA.push(baseLTVAsCollateral);
|
baseLTVA.push(baseLTVAsCollateral);
|
||||||
|
@ -368,25 +410,28 @@ export const configureReservesByHelper = async (
|
||||||
const chunkedReserveFactors = chunk(reserveFactors, enableChunks);
|
const chunkedReserveFactors = chunk(reserveFactors, enableChunks);
|
||||||
const chunkedStableRatesEnabled = chunk(stableRatesEnabled, enableChunks);
|
const chunkedStableRatesEnabled = chunk(stableRatesEnabled, enableChunks);
|
||||||
|
|
||||||
|
// TEST
|
||||||
|
const chunkedInputParams = chunk(inputParams, enableChunks);
|
||||||
|
// TEST
|
||||||
|
|
||||||
|
|
||||||
console.log(`- Configure reserves in ${chunkedTokens.length} txs`);
|
console.log(`- Configure reserves in ${chunkedTokens.length} txs`);
|
||||||
for (let chunkIndex = 0; chunkIndex < chunkedTokens.length; chunkIndex++) {
|
for (let chunkIndex = 0; chunkIndex < chunkedTokens.length; chunkIndex++) {
|
||||||
addGas(await atokenAndRatesDeployer.estimateGas.configureReserves(
|
// addGas(await atokenAndRatesDeployer.estimateGas.configureReserves(
|
||||||
chunkedTokens[chunkIndex],
|
// chunkedTokens[chunkIndex],
|
||||||
chunkedBase[chunkIndex],
|
// chunkedBase[chunkIndex],
|
||||||
chunkedliquidationThresholds[chunkIndex],
|
// chunkedliquidationThresholds[chunkIndex],
|
||||||
chunkedliquidationBonuses[chunkIndex],
|
// chunkedliquidationBonuses[chunkIndex],
|
||||||
chunkedReserveFactors[chunkIndex],
|
// chunkedReserveFactors[chunkIndex],
|
||||||
chunkedStableRatesEnabled[chunkIndex],
|
// chunkedStableRatesEnabled[chunkIndex],
|
||||||
{ gasLimit: 12000000 }
|
// { gasLimit: 12000000 }
|
||||||
));
|
// ));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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 }
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -77,7 +77,7 @@ export const strategyUSDT: IReserveParams = {
|
||||||
variableRateSlope2: new BigNumber(0.75).multipliedBy(oneRay).toFixed(),
|
variableRateSlope2: new BigNumber(0.75).multipliedBy(oneRay).toFixed(),
|
||||||
stableRateSlope1: new BigNumber(0.02).multipliedBy(oneRay).toFixed(),
|
stableRateSlope1: new BigNumber(0.02).multipliedBy(oneRay).toFixed(),
|
||||||
stableRateSlope2: new BigNumber(0.60).multipliedBy(oneRay).toFixed(),
|
stableRateSlope2: new BigNumber(0.60).multipliedBy(oneRay).toFixed(),
|
||||||
baseLTVAsCollateral: '8000',
|
baseLTVAsCollateral: '-1',
|
||||||
liquidationThreshold: '8500',
|
liquidationThreshold: '8500',
|
||||||
liquidationBonus: '10500',
|
liquidationBonus: '10500',
|
||||||
borrowingEnabled: true,
|
borrowingEnabled: true,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user