aave-protocol-v2/tasks/arbitrum/deploy-ChainlinkSourcesRegistry.ts
Lasse Herskind aa6ab1d4ee feat: Add config + additional tasks + delay in withSaveAndVerify
- Add configurations
- Add tasks for minor interaction
- Add a delay in `withSaveAndVerify` to handle rate limiting
2021-08-02 11:25:21 +02:00

64 lines
2.3 KiB
TypeScript

import { getArtifactFromContractOutput } from '@nomiclabs/buidler/internal/artifacts';
import { sign } from 'crypto';
import { formatEther, formatUnits, parseUnits } from 'ethers/lib/utils';
import { task } from 'hardhat/config';
import { ConfigNames, loadPoolConfig } from '../../helpers/configuration';
import { deployAllMockTokens } from '../../helpers/contracts-deployments';
import {
getAToken,
getFirstSigner,
getIErc20Detailed,
getLendingPool,
getMockedTokens,
getStableDebtToken,
getVariableDebtToken,
} from '../../helpers/contracts-getters';
import { getParamPerNetwork, withSaveAndVerify } from '../../helpers/contracts-helpers';
import { eArbitrumNetwork, eContractid, eEthereumNetwork } from '../../helpers/types';
import { ChainlinkSourcesRegistryFactory, LendingPool } from '../../types';
const deployChainlinkSourcesRegistry = async (verify: boolean) => {
return withSaveAndVerify(
await new ChainlinkSourcesRegistryFactory(await getFirstSigner()).deploy(),
'ChainlinkSourcesRegistry',
[],
verify
);
};
task(
'arbitrum:deploy:chainlink-sources-registry',
'Deploy chainlink sources registry to arbitrum'
).setAction(async ({}, localBRE) => {
await localBRE.run('set-DRE');
const conf = loadPoolConfig(ConfigNames.Arbitrum);
const network = localBRE.network.name;
let assetNames = Object.keys(conf.ReserveAssets[network]);
let assets: string[] = [];
let aggregators: string[] = [];
assetNames.forEach((assetName) => {
assets.push(conf.ReserveAssets[network][assetName]);
aggregators.push(conf.ChainlinkAggregator[network][assetName]);
});
console.log('Assets', assets, 'Aggregators', aggregators);
const signer = await getFirstSigner();
const chainlinkSourcesRegistry = await deployChainlinkSourcesRegistry(false);
console.log(`Deployed ChainlinkSourcesRegistry to: ${chainlinkSourcesRegistry.address}`);
await chainlinkSourcesRegistry.connect(signer).initialize();
await chainlinkSourcesRegistry.connect(signer).updateAggregators(assets, aggregators);
// Lookup to see if it updated
for (let i = 0; i < assets.length; i++) {
let asset = assets[i];
const aggregatorFromContract = await chainlinkSourcesRegistry.aggregatorsOfAssets(asset);
console.log(`${assetNames[i]} at ${asset} with aggregator at: ${aggregatorFromContract}`);
}
});