Skip to content

Commit

Permalink
Add governance proposal to transfer out Morpho tokens (#2305)
Browse files Browse the repository at this point in the history
* Add governance proposal to transfer out Morpho tokens

* prettify

* Tweaks to deploy script

* Rename deployment ID to 110
  • Loading branch information
shahthepro authored Nov 13, 2024
1 parent de0cf23 commit d71e7a9
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 24 deletions.
69 changes: 69 additions & 0 deletions contracts/deploy/mainnet/110_transfer_morpho.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const { deploymentWithGovernanceProposal } = require("../../utils/deploy");

module.exports = deploymentWithGovernanceProposal(
{
deployName: "110_transfer_morpho",
forceDeploy: false,
forceSkip: true,
skipSimulation: true,
reduceQueueTime: true,
deployerIsProposer: false,
proposalId: "",
},
async () => {
const cOUSDMorphoAaveProxy = await ethers.getContract(
"MorphoAaveStrategyProxy"
);
const cOUSDMorphoCompoundProxy = await ethers.getContract(
"MorphoCompoundStrategyProxy"
);
const cOETHMorphoAaveProxy = await ethers.getContract(
"OETHMorphoAaveStrategyProxy"
);

const cOUSDMorphoAave = await ethers.getContractAt(
"InitializableAbstractStrategy",
cOUSDMorphoAaveProxy.address
);
const cOUSDMorphoCompound = await ethers.getContractAt(
"InitializableAbstractStrategy",
cOUSDMorphoCompoundProxy.address
);
const cOETHMorphoAave = await ethers.getContractAt(
"InitializableAbstractStrategy",
cOETHMorphoAaveProxy.address
);

const morpho = await ethers.getContractAt(
"IERC20",
"0x9994e35db50125e0df82e4c2dde62496ce330999"
);

const ousdAaveBalance = await morpho.balanceOf(cOUSDMorphoAave.address);
const ousdCompBalance = await morpho.balanceOf(cOUSDMorphoCompound.address);
const oethAaveBalance = await morpho.balanceOf(cOETHMorphoAave.address);

// Governance Actions
// ----------------
return {
name: "Transfer Morpho Tokens from Strategies to the Guardian",
actions: [
{
contract: cOUSDMorphoAave,
signature: "transferToken(address,uint256)",
args: [morpho.address, ousdAaveBalance],
},
{
contract: cOUSDMorphoCompound,
signature: "transferToken(address,uint256)",
args: [morpho.address, ousdCompBalance],
},
{
contract: cOETHMorphoAave,
signature: "transferToken(address,uint256)",
args: [morpho.address, oethAaveBalance],
},
],
};
}
);
54 changes: 30 additions & 24 deletions contracts/utils/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ const executeProposalOnFork = async ({
/**
* Successfully execute the proposal whether it is in
* "Pending", "Active" or "Queued" state.
* Given a proposal Id, enqueues and executes it on OGV Governance.
* Given a proposal Id, enqueues and executes it on xOGN Governance.
* @param {Number} proposalId
* @returns {Promise<void>}
*/
Expand Down Expand Up @@ -671,7 +671,7 @@ const configureGovernanceContractDurations = async (reduceQueueTime) => {
};

/**
* In forked environment simulated that 5/8 multisig has submitted an OGV
* In forked environment simulated that 5/8 multisig has submitted an xOGN
* governance proposal
*
* @param {Array<Object>} proposalArgs
Expand Down Expand Up @@ -723,7 +723,7 @@ const submitProposalToOgvGovernance = async (
);
const proposalId = result.receipt.parsedLogs[0].args[0].toString();

log(`Submitted governance proposal to OGV governance ${proposalId}`);
log(`Submitted governance proposal to xOGN governance ${proposalId}`);
if (!isMainnet) {
await advanceBlocks(1);
}
Expand All @@ -744,7 +744,7 @@ const sanityCheckOgvGovernance = async ({
deployerIsProposer = false,
} = {}) => {
if (isMainnet) {
// only applicable when OGV governance is the governor
// only applicable when xOGN governance is the governor
if (deployerIsProposer) {
const governorSix = await getGovernorSix();
const { deployerAddr } = await getNamedAccounts();
Expand Down Expand Up @@ -1162,9 +1162,10 @@ function deploymentWithGovernanceProposal(opts, fn) {
onlyOnFork,
forceSkip,
proposalId,
deployerIsProposer = false, // The deployer issues the propose to OGV Governor
deployerIsProposer = false, // The deployer issues the propose to xOGN Governor
reduceQueueTime = false, // reduce governance queue times
executeGasLimit = null,
skipSimulation = false, // Skips simulating execution of proposal on fork
} = opts;
const runDeployment = async (hre) => {
const oracleAddresses = await getOracleAddresses(hre.deployments);
Expand Down Expand Up @@ -1217,8 +1218,8 @@ function deploymentWithGovernanceProposal(opts, fn) {
// }

if (isMainnet) {
// On Mainnet, only build the propose transaction for OGV governance
log("Building OGV governance proposal...");
// On Mainnet, only build the propose transaction for xOGN governance
log("Building xOGN governance proposal...");
if (deployerIsProposer) {
await submitProposalToOgvGovernance(
propArgs,
Expand All @@ -1230,23 +1231,28 @@ function deploymentWithGovernanceProposal(opts, fn) {
}
log("Proposal sent.");
} else if (isFork) {
// On Fork we can send the proposal then impersonate the guardian to execute it.
log("Sending the governance proposal to OGV governance");
propOpts.reduceQueueTime = reduceQueueTime;
const { proposalState, proposalId, proposalIdBn } =
await submitProposalToOgvGovernance(
propArgs,
propDescription,
propOpts
);
log("Executing the proposal");
await executeGovernanceProposalOnFork({
proposalIdBn,
proposalState,
reduceQueueTime,
executeGasLimit,
existingProposal: false,
});
if (skipSimulation) {
log("Building xOGN governance proposal...");
await submitProposalGnosisSafe(propArgs, propDescription, propOpts);
} else {
// On Fork we can send the proposal then impersonate the guardian to execute it.
log("Sending the governance proposal to xOGN governance");
propOpts.reduceQueueTime = reduceQueueTime;
const { proposalState, proposalId, proposalIdBn } =
await submitProposalToOgvGovernance(
propArgs,
propDescription,
propOpts
);
log("Executing the proposal");
await executeGovernanceProposalOnFork({
proposalIdBn,
proposalState,
reduceQueueTime,
executeGasLimit,
existingProposal: false,
});
}
log("Proposal executed.");
} else {
throw new Error(
Expand Down

0 comments on commit d71e7a9

Please sign in to comment.