Skip to content

Commit

Permalink
016 deploy script (#584)
Browse files Browse the repository at this point in the history
* 016 deploy script

* Update debug task
  • Loading branch information
Franck authored Mar 24, 2021
1 parent edb84fe commit 5ae9a22
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const {
const { proposeArgs } = require("../utils/governor");
const { getTxOpts } = require("../utils/tx");

const deployName = "015_buyback_contract";
const deployName = "016_chainlink_and_buyback";

const runDeployment = async (hre) => {
console.log(`Running ${deployName} deployment...`);
Expand All @@ -25,6 +25,24 @@ const runDeployment = async (hre) => {
const sGovernor = await ethers.provider.getSigner(governorAddr);
const sDeployer = await ethers.provider.getSigner(deployerAddr);

// Contracts
const cVaultProxy = await ethers.getContract("VaultProxy");
const cVaultCoreProxy = await ethers.getContractAt(
"VaultCore",
cVaultProxy.address
);
const cVaultAdmin = await ethers.getContractAt(
"VaultAdmin",
cVaultProxy.address
);

// Deploy a new VaultCore contract
const dVaultCore = await deployWithConfirmation("VaultCore");

// Deploy a new VaultAdmin contract
const dVaultAdmin = await deployWithConfirmation("VaultAdmin");

// Deploy the Buyback contract.
await deployWithConfirmation("Buyback");
const cBuyback = await ethers.getContract("Buyback");

Expand All @@ -36,20 +54,23 @@ const runDeployment = async (hre) => {
);
log(`Buyback transferGovernance(${governorAddr} called`);

// Deploy a new VaultCore contract
const dVaultCore = await deployWithConfirmation("VaultCore");
const cVaultProxy = await ethers.getContract("VaultProxy");
const cVaultAdmin = await ethers.getContractAt(
"VaultAdmin",
cVaultProxy.address
);
// Deploy OracleRouter
await deployWithConfirmation("OracleRouter");
const cOracleRouter = await ethers.getContract("OracleRouter");

// Proposal to:
// - Upgrade VaultCore to pick up the Buyback contract integration
// - Upgrade VaultAdmin
// - Upgrade VaultCore
// - Claim Governance on the Buyback contract
// - Set the trustee address to the Buyback contract
// - Set the price provider to the OracleRouter contract
const propDescription = "Deploy and integrate Buyback contract";
const propArgs = await proposeArgs([
{
contract: cVaultCoreProxy,
signature: "setAdminImpl(address)",
args: [dVaultAdmin.address],
},
{
contract: cVaultProxy,
signature: "upgradeTo(address)",
Expand All @@ -64,6 +85,11 @@ const runDeployment = async (hre) => {
signature: "setTrusteeAddress(address)",
args: [cBuyback.address],
},
{
contract: cVaultAdmin,
signature: "setPriceProvider(address)",
args: [cOracleRouter.address],
},
]);

if (isMainnet) {
Expand Down Expand Up @@ -110,7 +136,7 @@ const main = async (hre) => {
};

main.id = deployName;
main.dependencies = ["013_trustee"];
main.dependencies = ["015_flipper"];
main.skip = () => !(isMainnet || isRinkeby || isFork) || isSmokeTest;

module.exports = main;
52 changes: 13 additions & 39 deletions contracts/tasks/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ async function debug(taskArguments, hre) {
);
const cThreePoolStrategy = await hre.ethers.getContract("ThreePoolStrategy");

const mixOracle = await hre.ethers.getContract("MixOracle");
const chainlinkOracle = await hre.ethers.getContract("ChainlinkOracle");
const oracleRouter = await hre.ethers.getContract("OracleRouter");

const governor = await hre.ethers.getContract("Governor");

Expand All @@ -60,6 +59,7 @@ async function debug(taskArguments, hre) {
console.log(`Vault: ${cVault.address}`);
console.log(`VaultCore: ${vaultCore.address}`);
console.log(`VaultAdmin: ${vaultAdmin.address}`);
console.log(`OracleRouter: ${oracleRouter.address}`);
console.log(`AaveStrategy proxy: ${aaveProxy.address}`);
console.log(`AaveStrategy impl: ${await aaveProxy.implementation()}`);
console.log(`AaveStrategy: ${cAaveStrategy.address}`);
Expand All @@ -73,8 +73,6 @@ async function debug(taskArguments, hre) {
`ThreePoolStrategy impl: ${await threePoolStrategyProxy.implementation()}`
);
console.log(`ThreePoolStrategy: ${cThreePoolStrategy.address}`);
console.log(`MixOracle: ${mixOracle.address}`);
console.log(`ChainlinkOracle: ${chainlinkOracle.address}`);
console.log(`Governor: ${governor.address}`);
console.log(`OGNStaking proxy: ${ognStakingProxy.address}`);
console.log(
Expand Down Expand Up @@ -106,8 +104,6 @@ async function debug(taskArguments, hre) {
const aaveStrategyGovernorAddr = await aaveStrategy.governor();
const compoundStrategyGovernorAddr = await compoundStrategy.governor();
const threePoolStrategyGovernorAddr = await threePoolStrategy.governor();
const mixOracleGovernorAddr = await mixOracle.governor();
const chainlinkOracleGovernoreAddr = await chainlinkOracle.governor();

console.log("\nGovernor addresses");
console.log("====================");
Expand All @@ -116,8 +112,6 @@ async function debug(taskArguments, hre) {
console.log("AaveStrategy: ", aaveStrategyGovernorAddr);
console.log("CompoundStrategy: ", compoundStrategyGovernorAddr);
console.log("ThreePoolStrategy: ", threePoolStrategyGovernorAddr);
console.log("MixOracle: ", mixOracleGovernorAddr);
console.log("ChainlinkOracle: ", chainlinkOracleGovernoreAddr);

//
// OUSD
Expand Down Expand Up @@ -145,38 +139,16 @@ async function debug(taskArguments, hre) {
console.log(`rebasingCredits: ${rebasingCredits}`);

//
// Oracles
// Oracle
//
const maxDrift = await mixOracle.maxDrift();
const minDrift = await mixOracle.minDrift();
const ethUsdOracles0 = await mixOracle.ethUsdOracles(0);

console.log("\nMixOracle");
console.log("===========");
console.log(`maxDrift:\t\t\t${maxDrift}`);
console.log(`minDrift:\t\t\t${minDrift}`);
console.log(`ethUsdOracles[0]:\t\t${ethUsdOracles0}`);

const tokens = ["DAI", "USDT", "USDC"];
// Token -> USD oracles
for (const token of tokens) {
const l = await mixOracle.getTokenUSDOraclesLength(token);
console.log(`tokenUSDOracle[${token}].length:\t${l}`);
for (let i = 0; i < l; i++) {
const addr = await mixOracle.getTokenUSDOracle(token, i);
console.log(`tokenUSDOracle[${token}]:\t\t${addr}`);
}
}

// Token -> ETH oracles
for (const token of tokens) {
const l = await mixOracle.getTokenETHOraclesLength(token);
console.log(`tokenETHOracle[${token}].length:\t${l}`);
for (let i = 0; i < l; i++) {
const addr = await mixOracle.getTokenETHOracle(token, i);
console.log(`tokenETHOracle[${token}]:\t\t${addr}`);
}
}
console.log("\nOracle");
console.log("========");
const priceDAI = await oracleRouter.price(addresses.mainnet.DAI);
const priceUSDC = await oracleRouter.price(addresses.mainnet.USDC);
const priceUSDT = await oracleRouter.price(addresses.mainnet.USDT);
console.log(`DAI price : ${formatUnits(priceDAI, 8)} USD`);
console.log(`USDT price: ${formatUnits(priceUSDC, 8)} USD`);
console.log(`USDC price: ${formatUnits(priceUSDT, 8)} USD`);

//
// Vault
Expand All @@ -196,6 +168,7 @@ async function debug(taskArguments, hre) {
const assetCount = await vault.getAssetCount();
const strategistAddress = await vault.strategistAddr();
const trusteeAddress = await vault.trusteeAddress();
const priceProvider = await vault.priceProvider();

console.log("\nVault Settings");
console.log("================");
Expand All @@ -219,6 +192,7 @@ async function debug(taskArguments, hre) {
`maxSupplyDiff:\t\t\t ${formatUnits(maxSupplyDiff.toString(), 16)}%`
);

console.log("Price provider address:\t\t", priceProvider);
console.log("Uniswap address:\t\t", uniswapAddr);
console.log("Strategy count:\t\t\t", Number(strategyCount));
console.log("Asset count:\t\t\t", Number(assetCount));
Expand Down

0 comments on commit 5ae9a22

Please sign in to comment.