From f739843927549f36c43c54d946d5dfbd9c61a021 Mon Sep 17 00:00:00 2001 From: Jesus Lanchas Date: Tue, 10 Sep 2024 20:39:58 +0200 Subject: [PATCH] fix: restore deployment script to configure some price feeds on hardhat --- deploy/3-configure-feeds.ts | 47 ++++++++++++++++++++++++++ helpers/deploymentConfig.ts | 66 +++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 deploy/3-configure-feeds.ts 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..3f5b9885 100644 --- a/helpers/deploymentConfig.ts +++ b/helpers/deploymentConfig.ts @@ -200,6 +200,10 @@ export const ADDRESSES: PreconfiguredAddresses = { }; export const chainlinkFeed: Config = { + hardhat: { + BNX: "0xf51492DeD1308Da8195C3bfcCF4a7c70fDbF9daE", + BTCB: "0x5741306c21795FdCBb9b265Ea0255F499DFe515C", + }, bscmainnet: { USDC: "0x51597f405303C4377E36123cBc172b13269EA163", USDT: "0xb97ad0e74fa7d920791e90258a6e2085088b4320", @@ -321,6 +325,68 @@ export const pythID: Config = { }; export const assets: Assets = { + hardhat: [ + { + token: "BNX", + address: "", + oracle: "chainlink", + price: "159990000000000000000", + }, + { + token: "BTCB", + address: "", + oracle: "chainlink", + 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",