Skip to content

Commit

Permalink
CompensationClaims contract deployment (#498)
Browse files Browse the repository at this point in the history
* update deploy script

* ABI files

* fix deploy script

* tweak

* Add ABIs to the DApp
  • Loading branch information
Franck authored Jan 13, 2021
1 parent 2317bd2 commit 6e53f49
Show file tree
Hide file tree
Showing 5 changed files with 1,287 additions and 44 deletions.
92 changes: 50 additions & 42 deletions contracts/deploy/005_compensation_claims.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,79 @@
const { isMainnet, isFork } = require("../test/helpers.js");

const {
isMainnet,
isRinkeby,
isMainnetOrRinkebyOrFork,
} = require("../test/helpers.js");
const { log } = require("../utils/deploy");
log,
deployWithConfirmation,
withConfirmation,
executeProposal,
sendProposal,
} = require("../utils/deploy");
const { getTxOpts } = require("../utils/tx");
const { proposeArgs } = require("../utils/governor");

// Wait for 3 blocks confirmation on Mainnet/Rinkeby.
const NUM_CONFIRMATIONS = isMainnet || isRinkeby ? 3 : 0;
const deployName = "005_compensation_claims";

//
// 1. Deploy new Single Asset Staking contract
// Deploys the new OUSD CompensationClaims contract.
//
const compensationClaimsDeploy = async ({ getNamedAccounts, deployments }) => {
console.log("Running 005_compensation_claims...");
const compensationClaimsDeploy = async ({ getNamedAccounts }) => {
console.log(`Running ${deployName}...`);

const { deploy } = deployments;
const { governorAddr, deployerAddr, adjusterAddr } = await getNamedAccounts();

const sDeployer = ethers.provider.getSigner(deployerAddr);
const sGovernor = ethers.provider.getSigner(governorAddr);

//
// Deploy the contract.
//
const OUSD = await ethers.getContract("OUSDProxy");
log(`Using OUSD address ${OUSD.address}`);
log(`Using adjuster address ${adjusterAddr}`);

// Deploy the claims contract proxy.
let d = await deploy("CompensationClaims", {
args: [OUSD.address, adjusterAddr],
contract: "CompensationClaims",
from: deployerAddr,
});

await ethers.provider.waitForTransaction(
d.receipt.transactionHash,
NUM_CONFIRMATIONS
);
log("Deployed CompensationClaims", d);
await deployWithConfirmation("CompensationClaims", [
OUSD.address,
adjusterAddr,
]);

const claimsContract = await ethers.getContract("CompensationClaims");

//
// Transfer governance of the CompensationClaims contract to the governor
// - On Mainnet the governance transfer gets executed separately, via the multi-sig wallet.
// - On other networks, this migration script can claim governance by the governor.
//
let t = await claimsContract
.connect(sDeployer)
.transferGovernance(governorAddr);
await ethers.provider.waitForTransaction(t.hash, NUM_CONFIRMATIONS);

await withConfirmation(
claimsContract.connect(sDeployer).transferGovernance(governorAddr, await getTxOpts())
);
log(`CompensationClaims transferGovernance(${governorAddr} called`);

if (!isMainnetOrRinkebyOrFork) {
t = await claimsContract
.connect(sGovernor) // Claim governance with governor
.claimGovernance();
await ethers.provider.waitForTransaction(t.hash, NUM_CONFIRMATIONS);
log("Claimed governance for CompensationClaims");
}
// Generate the governance proposal.
const propDescription = "Claim ownership of CompensationClaims";
const propArgs = await proposeArgs([
{
contract: claimsContract,
signature: "claimGovernance()",
},
]);

console.log("005_compensation_claims deploy done.");
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 {
// On other networks, claim governance using the governor account.
await withConfirmation(claimsContract.connect(sGovernor).claimGovernance());
}

console.log(`${deployName} deploy done.`);
return true;
};

compensationClaimsDeploy.id = "005_compensation_claims";
compensationClaimsDeploy.id = deployName;
compensationClaimsDeploy.dependencies = ["core"];

// TODO(franck): enable Mainnet once we are ready to deploy.
compensationClaimsDeploy.skip = () => isMainnet || isRinkeby;

module.exports = compensationClaimsDeploy;
5 changes: 3 additions & 2 deletions contracts/deployments/mainnet/.migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"008_ousd_reset": 1609285987,
"009_ousd_fix": 1609736357,
"010_upgrade_single_asset_staking": 1609971639,
"011_ousd_fix": 1610148010
}
"011_ousd_fix": 1610148010,
"005_compensation_claims": 1610487584
}
Loading

0 comments on commit 6e53f49

Please sign in to comment.