Skip to content

Commit

Permalink
Deploy script for OUSD and VaultCore upgrade. (#606)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielVF authored Jul 1, 2021
1 parent cbf377d commit 1ed8a5e
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
29 changes: 29 additions & 0 deletions contracts/deploy/019_resolution_and_savings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const { deploymentWithProposal } = require("../utils/deploy");

module.exports = deploymentWithProposal(
{ deployName: "019_resolution_and_savings" },
async ({ ethers, deployWithConfirmation }) => {
// Deployments
const dOUSD = await deployWithConfirmation("OUSD");
const dVaultCore = await deployWithConfirmation("VaultCore");

// Governance proposal
const cOUSDProxy = await ethers.getContract("OUSDProxy");
const cVaultProxy = await ethers.getContract("VaultProxy");
return {
name: "Upgrade OUSD resolution for new contracts, redeem gas savings",
actions: [
{
contract: cOUSDProxy,
signature: "upgradeTo(address)",
args: [dOUSD.address],
},
{
contract: cVaultProxy,
signature: "upgradeTo(address)",
args: [dVaultCore.address],
},
],
};
}
);
60 changes: 60 additions & 0 deletions contracts/utils/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,65 @@ const sendProposal = async (proposalArgs, description, opts = {}) => {
log("Done");
};

/**
* Shortcut to create a deployment for hardhat to use
* @param {Object} options for deployment
* @param {Promise<Object>} fn to deploy contracts and return needed proposals
* @returns {Object} main object used by hardhat
*/
function deploymentWithProposal(opts, fn) {
const { deployName, dependencies } = opts;
const runDeployment = async (hre) => {
const tools = {
ethers,
deployWithConfirmation,
};
const proposal = await fn(tools);

const propDescription = proposal.name;
const propArgs = await proposeArgs(proposal.actions);

if (isMainnet) {
// On Mainnet, only propose. The enqueue and execution are handled manually via multi-sig.
log("Sending proposal to governor...");
await sendProposal(propArgs, propDescription);
log("Proposal sent.");
} else if (isFork) {
// On Fork we can send the proposal then impersonate the guardian to execute it.
log("Sending and executing proposal...");
await executeProposal(propArgs, propDescription);
log("Proposal executed.");
} else {
// Hardcoding gas estimate on Rinkeby since it fails for an undetermined reason...
const gasLimit = isRinkeby ? 1000000 : null;
for (const proposal of proposals) {
const { contract, signature, args } = proposal;
log(`Sending goverance action ${signature} to ${address}`);
await withConfirmation(
contract
.connect(sGovernor)
[signature](...args, await getTxOpts(gasLimit))
);
console.log(`... ${signature} completed`);
}
}
};

const main = async (hre) => {
console.log(`Running ${deployName} deployment...`);
if (!hre) {
hre = require("hardhat");
}
await runDeployment(hre);
console.log(`${deployName} deploy done.`);
return true;
};
main.id = deployName;
main.dependencies = dependencies;
main.skip = () => !(isMainnet || isRinkeby || isFork) || isSmokeTest;
return main;
}

module.exports = {
log,
sleep,
Expand All @@ -253,4 +312,5 @@ module.exports = {
executeProposal,
executeProposalOnFork,
sendProposal,
deploymentWithProposal,
};

0 comments on commit 1ed8a5e

Please sign in to comment.