"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const hardhat_1 = __importDefault(require("hardhat"));
const deploymentConfig_1 = require("../helpers/deploymentConfig");
const func = async function ({ network, deployments, getNamedAccounts }) {
    const { deploy } = deployments;
    const { deployer } = await getNamedAccounts();
    const resilientOracle = await hardhat_1.default.ethers.getContract("ResilientOracle");
    const oraclesData = await (0, deploymentConfig_1.getOraclesData)();
    for (const asset of deploymentConfig_1.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 hardhat_1.default.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);
    }
};
exports.default = func;
func.tags = ["configure"];
func.skip = async (env) => env.network.live;
//# sourceMappingURL=3-configure-feeds.js.map