mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Added extra check to verify symbol of token implementation
This commit is contained in:
parent
e0025184a0
commit
86db408af5
|
@ -9,6 +9,7 @@ import { AaveProtocolDataProvider } from '../types/AaveProtocolDataProvider';
|
||||||
import { chunk, DRE, getDb, waitForTx } from './misc-utils';
|
import { chunk, DRE, getDb, waitForTx } from './misc-utils';
|
||||||
import {
|
import {
|
||||||
getAaveProtocolDataProvider,
|
getAaveProtocolDataProvider,
|
||||||
|
getAToken,
|
||||||
getATokensAndRatesHelper,
|
getATokensAndRatesHelper,
|
||||||
getLendingPoolAddressesProvider,
|
getLendingPoolAddressesProvider,
|
||||||
getStableAndVariableTokensHelper,
|
getStableAndVariableTokensHelper,
|
||||||
|
@ -440,10 +441,9 @@ export const initTokenReservesByHelper = async (
|
||||||
][])[reserveParamIndex];
|
][])[reserveParamIndex];
|
||||||
|
|
||||||
if (!isZeroAddress(aTokenAddress)) {
|
if (!isZeroAddress(aTokenAddress)) {
|
||||||
console.log(`Skipping ${symbol} due already initialized`);
|
console.log(`- Skipping ${symbol} due already initialized`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
console.log('Getting deployment information from', symbol);
|
|
||||||
let stableTokenImpl = await getAddressById(`stableDebt${symbol}`, network);
|
let stableTokenImpl = await getAddressById(`stableDebt${symbol}`, network);
|
||||||
let variableTokenImpl = await getAddressById(`variableDebt${symbol}`, network);
|
let variableTokenImpl = await getAddressById(`variableDebt${symbol}`, network);
|
||||||
let aTokenImplementation = await getAddressById(`a${symbol}`, network);
|
let aTokenImplementation = await getAddressById(`a${symbol}`, network);
|
||||||
|
@ -519,7 +519,15 @@ export const initTokenReservesByHelper = async (
|
||||||
);
|
);
|
||||||
strategyImpl = rates.address;
|
strategyImpl = rates.address;
|
||||||
}
|
}
|
||||||
|
const symbols = [`a${symbol}`, `variableDebt${symbol}`, `stableDebt${symbol}`];
|
||||||
|
const tokens = [aTokenImplementation, variableTokenImpl, stableTokenImpl];
|
||||||
|
for (let index = 0; index < symbols.length; index++) {
|
||||||
|
if (!(await isErc20SymbolCorrect(tokens[index], symbols[index]))) {
|
||||||
|
console.error(`${symbol} and implementation does not match: ${tokens[index]}`);
|
||||||
|
throw Error('Symbol does not match implementation.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(`- Added ${symbol} to the initialize batch`);
|
||||||
deployedStableTokens.push(stableTokenImpl);
|
deployedStableTokens.push(stableTokenImpl);
|
||||||
deployedVariableTokens.push(variableTokenImpl);
|
deployedVariableTokens.push(variableTokenImpl);
|
||||||
deployedATokens.push(aTokenImplementation);
|
deployedATokens.push(aTokenImplementation);
|
||||||
|
@ -557,3 +565,9 @@ export const initTokenReservesByHelper = async (
|
||||||
await waitForTx(await addressProvider.setPoolAdmin(admin));
|
await waitForTx(await addressProvider.setPoolAdmin(admin));
|
||||||
return gasUsage;
|
return gasUsage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isErc20SymbolCorrect = async (token: tEthereumAddress, symbol: string) => {
|
||||||
|
const erc20 = await getAToken(token); // using aToken for ERC20 interface
|
||||||
|
const erc20Symbol = await erc20.symbol();
|
||||||
|
return symbol === erc20Symbol;
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user