diff --git a/deploy/3-configure-feeds.ts b/deploy/3-configure-feeds.ts new file mode 100644 index 00000000..3cb9591d --- /dev/null +++ b/deploy/3-configure-feeds.ts @@ -0,0 +1,47 @@ +import hre from "hardhat"; +import { DeployFunction } from "hardhat-deploy/dist/types"; +import { HardhatRuntimeEnvironment } from "hardhat/types"; + +import { Oracles, assets, getOraclesData } from "../helpers/deploymentConfig"; + +const func: DeployFunction = async function ({ network, deployments, getNamedAccounts }: HardhatRuntimeEnvironment) { + const { deploy } = deployments; + const { deployer } = await getNamedAccounts(); + + const resilientOracle = await hre.ethers.getContract("ResilientOracle"); + + const oraclesData: Oracles = await getOraclesData(); + + for (const asset of assets[network.name]) { + const { oracle } = asset; + console.log(`Configuring ${asset.token}`); + + await deploy(`Mock${asset.token}`, { + from: deployer, + log: true, + deterministicDeployment: false, + args: [`Mock${asset.token}`, `Mock${asset.token}`, 18], + autoMine: true, + contract: "BEP20Harness", + }); + + const mock = await hre.ethers.getContract(`Mock${asset.token}`); + + console.log(`Configuring resilient oracle for ${asset.token}`); + let tx = await resilientOracle.setTokenConfig({ + asset: mock.address, + oracles: oraclesData[oracle].oracles, + enableFlagsForOracles: oraclesData[oracle].enableFlagsForOracles, + }); + + await tx.wait(1); + + console.log(`Configuring ${oracle} oracle for ${asset.token}`); + tx = await oraclesData[oracle].underlyingOracle?.setPrice(mock.address, asset.price); + await tx.wait(1); + } +}; + +export default func; +func.tags = ["configure"]; +func.skip = async env => env.network.live; diff --git a/helpers/deploymentConfig.ts b/helpers/deploymentConfig.ts index 153f4cec..93dfe19c 100644 --- a/helpers/deploymentConfig.ts +++ b/helpers/deploymentConfig.ts @@ -321,6 +321,68 @@ export const pythID: Config = { }; export const assets: Assets = { + hardhat: [ + { + token: "BNX", + address: "", + oracle: "chainlinkFixed", + price: "159990000000000000000", + }, + { + token: "BTCB", + address: "", + oracle: "chainlinkFixed", + price: "208000000000000000", + }, + { + token: "XVS", + address: "", + oracle: "chainlinkFixed", + price: "208000000000000000", + }, + { + token: "ANKR", + address: "", + oracle: "chainlinkFixed", + price: "159990000000000000000", + }, + { + token: "ankrBNB", + address: "", + oracle: "chainlinkFixed", + price: "159990000000000000000", + }, + { + token: "MBOX", + address: "", + oracle: "chainlinkFixed", + price: "159990000000000000000", + }, + { + token: "NFT", + address: "", + oracle: "chainlinkFixed", + price: "159990000000000000000", + }, + { + token: "RACA", + address: "", + oracle: "chainlinkFixed", + price: "159990000000000000000", + }, + { + token: "stkBNB", + address: "", + oracle: "chainlinkFixed", + price: "159990000000000000000", + }, + { + token: "USDD", + address: "", + oracle: "chainlinkFixed", + price: "159990000000000000000", + }, + ], bsctestnet: [ { token: "BNX",