generated from PaulRBerg/hardhat-template
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: restore deployment script to configure some price feeds on hardhat
- Loading branch information
Showing
2 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters