Skip to content

Commit

Permalink
fix: deploy binance and pyth in seperate scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
web3rover committed Jul 9, 2024
1 parent 62ade25 commit b5ff1d7
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 65 deletions.
65 changes: 0 additions & 65 deletions deploy/1-deploy-oracles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,71 +94,6 @@ const func: DeployFunction = async function ({
},
});

if (!network.live) {
return;
}

const { pythOracleAddress } = ADDRESSES[network.name];

// Skip if no pythOracle address in config
if (pythOracleAddress) {
await deploy("PythOracle", {
contract: network.live ? "PythOracle" : "MockPythOracle",
from: deployer,
log: true,
deterministicDeployment: false,
args: [],
proxy: {
owner: proxyOwnerAddress,
proxyContract: "OptimizedTransparentProxy",
execute: {
methodName: "initialize",
args: network.live ? [pythOracleAddress, accessControlManagerAddress] : [pythOracleAddress],
},
},
});

const pythOracle = await hre.ethers.getContract("PythOracle");
await accessControlManager?.giveCallPermission(pythOracle.address, "setTokenConfig(TokenConfig)", deployer);
const pythOracleOwner = await pythOracle.owner();

if (pythOracleOwner === deployer) {
await pythOracle.transferOwnership(timelock);
console.log(`Ownership of PythOracle transfered from deployer to Timelock (${timelock})`);
}
}

const { sidRegistryAddress, feedRegistryAddress } = ADDRESSES[network.name];
// Skip if no sidRegistryAddress address in config
if (sidRegistryAddress) {
await deploy("BinanceOracle", {
contract: network.live ? "BinanceOracle" : "MockBinanceOracle",
from: deployer,
log: true,
deterministicDeployment: false,
args: [],
proxy: {
owner: proxyOwnerAddress,
proxyContract: "OptimizedTransparentProxy",
execute: {
methodName: "initialize",
args: network.live ? [sidRegistryAddress, accessControlManagerAddress] : [],
},
},
});
const binanceOracle = await hre.ethers.getContract("BinanceOracle");
const binanceOracleOwner = await binanceOracle.owner();

if (network.live && sidRegistryAddress === "0x0000000000000000000000000000000000000000") {
await binanceOracle.setFeedRegistryAddress(feedRegistryAddress);
}

if (binanceOracleOwner === deployer) {
await binanceOracle.transferOwnership(timelock);
console.log(`Ownership of BinanceOracle transfered from deployer to Timelock (${timelock})`);
}
}

const resilientOracle = await hre.ethers.getContract("ResilientOracle");
const chainlinkOracle = await hre.ethers.getContract(contractName);

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
51 changes: 51 additions & 0 deletions deploy/2-deploy-binance-oracle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import hre from "hardhat";
import { DeployFunction } from "hardhat-deploy/dist/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

import { ADDRESSES } from "../helpers/deploymentConfig";

const func: DeployFunction = async function ({ getNamedAccounts, deployments, network }: HardhatRuntimeEnvironment) {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();

const accessControlManagerAddress = ADDRESSES[network.name].acm;
const proxyOwnerAddress = ADDRESSES[network.name].timelock;
const timelock = ADDRESSES[network.name].timeloc;

const { sidRegistryAddress, feedRegistryAddress } = ADDRESSES[network.name];

// Skip if no sidRegistryAddress address in config
if (sidRegistryAddress) {
await deploy("BinanceOracle", {
contract: "BinanceOracle",
from: deployer,
log: true,
deterministicDeployment: false,
args: [],
proxy: {
owner: proxyOwnerAddress,
proxyContract: "OptimizedTransparentProxy",
execute: {
methodName: "initialize",
args: [sidRegistryAddress, accessControlManagerAddress],
},
},
});
const binanceOracle = await hre.ethers.getContract("BinanceOracle");
const binanceOracleOwner = await binanceOracle.owner();

if (sidRegistryAddress === "0x0000000000000000000000000000000000000000") {
await binanceOracle.setFeedRegistryAddress(feedRegistryAddress);
}

if (binanceOracleOwner === deployer) {
await binanceOracle.transferOwnership(timelock);
console.log(`Ownership of BinanceOracle transfered from deployer to Timelock (${timelock})`);
}
}
};

func.tags = ["deploy-binance-oracle"];
func.skip = async env => !env.network.live;

export default func;
45 changes: 45 additions & 0 deletions deploy/2-deploy-pyth-oracle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import hre from "hardhat";
import { DeployFunction } from "hardhat-deploy/dist/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

import { ADDRESSES } from "../helpers/deploymentConfig";

const func: DeployFunction = async function ({ getNamedAccounts, deployments, network }: HardhatRuntimeEnvironment) {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();

const accessControlManagerAddress = ADDRESSES[network.name].acm;
const proxyOwnerAddress = ADDRESSES[network.name].timelock;
const { timelock, pythOracleAddress } = ADDRESSES[network.name];

// Skip if no pythOracle address in config
if (pythOracleAddress) {
await deploy("PythOracle", {
contract: "PythOracle",
from: deployer,
log: true,
deterministicDeployment: false,
args: [],
proxy: {
owner: proxyOwnerAddress,
proxyContract: "OptimizedTransparentProxy",
execute: {
methodName: "initialize",
args: [pythOracleAddress, accessControlManagerAddress],
},
},
});

const pythOracle = await hre.ethers.getContract("PythOracle");
const pythOracleOwner = await pythOracle.owner();

if (pythOracleOwner === deployer) {
await pythOracle.transferOwnership(timelock);
console.log(`Ownership of PythOracle transfered from deployer to Timelock (${timelock})`);
}
}
};
func.tags = ["deploy-pyth-oracle"];
func.skip = async env => !env.network.live;

export default func;
File renamed without changes.

0 comments on commit b5ff1d7

Please sign in to comment.