Skip to content

Commit

Permalink
feat: add partial reserve multisig as other reserve addresses, remove…
Browse files Browse the repository at this point in the history
… current addresses (#235)
  • Loading branch information
baroooo authored Oct 29, 2024
1 parent 5b2867c commit ea17e46
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
2 changes: 1 addition & 1 deletion script/upgrades/MU08/MU08.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Transfer ownership of the MentoProtocol contracts to Mento Governance.

Proposal Summary:
This proposal transfers ownership of the MentoProtocol contracts to Mento Governance. This will allow Mento token holders to own and manage the protocol.
This proposal transfers ownership of the MentoProtocol contracts to Mento Governance. This will allow Mento token holders to own and manage the protocol. Additionally it adds Reserve Multisig as an "Other Reserve Address" of onchain Reserve contract and removes old other reserve addresses.

Contracts to Transfer Ownership:

Expand Down
38 changes: 38 additions & 0 deletions script/upgrades/MU08/MU08.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ interface IProxyLite {
function _transferOwnership(address) external;
}

interface IReserveLite {
function getOtherReserveAddresses() external returns (address[] memory);

function removeOtherReserveAddress(address, uint256) external returns (bool);

function addOtherReserveAddress(address) external returns (bool);
}

contract MU08 is IMentoUpgrade, GovernanceScript {
using Contracts for Contracts.Cache;

Expand Down Expand Up @@ -64,6 +72,9 @@ contract MU08 is IMentoUpgrade, GovernanceScript {
address private governanceFactory;
address private timelockProxy;

// Mento Reserve Multisig address:
address private reserveMultisig;

function prepare() public {
loadDeployedContracts();
setAddresses();
Expand Down Expand Up @@ -116,6 +127,9 @@ contract MU08 is IMentoUpgrade, GovernanceScript {
// MentoGovernance contracts:
governanceFactory = contracts.deployed("GovernanceFactory");
timelockProxy = IGovernanceFactory(governanceFactory).governanceTimelock();

// Mento Reserve Multisig address:
reserveMultisig = contracts.dependency("PartialReserveMultisig");
}

function run() public {
Expand All @@ -133,6 +147,7 @@ contract MU08 is IMentoUpgrade, GovernanceScript {
function buildProposal() public returns (ICeloGovernance.Transaction[] memory) {
require(transactions.length == 0, "buildProposal() should only be called once");

proposal_updateOtherReserveAddresses();
proposal_transferTokenOwnership();
proposal_transferMentoV2Ownership();
proposal_transferMentoV1Ownership();
Expand All @@ -141,6 +156,29 @@ contract MU08 is IMentoUpgrade, GovernanceScript {
return transactions;
}

function proposal_updateOtherReserveAddresses() public {
// remove anchorage addressess
address[] memory otherReserves = IReserveLite(reserveProxy).getOtherReserveAddresses();
for (uint256 i = 0; i < otherReserves.length; i++) {
transactions.push(
ICeloGovernance.Transaction({
value: 0,
destination: reserveProxy,
// we remove the first index(0) in the list for each iteration because the index changes after each removal
data: abi.encodeWithSelector(IReserveLite(0).removeOtherReserveAddress.selector, otherReserves[i], 0)
})
);
}
// add reserve multisig
transactions.push(
ICeloGovernance.Transaction({
value: 0,
destination: reserveProxy,
data: abi.encodeWithSelector(IReserveLite(0).addOtherReserveAddress.selector, reserveMultisig)
})
);
}

function proposal_transferTokenOwnership() public {
address[] memory tokenProxies = Arrays.addresses(
cUSDProxy,
Expand Down
21 changes: 21 additions & 0 deletions script/upgrades/MU08/MU08Checks.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ interface IProxyLite {
function _getOwner() external view returns (address);
}

interface IReserveLite {
function getOtherReserveAddresses() external returns (address[] memory);
}

contract MU08Checks is GovernanceScript, Test {
using Contracts for Contracts.Cache;

Expand Down Expand Up @@ -55,6 +59,9 @@ contract MU08Checks is GovernanceScript, Test {
address private governanceFactory;
address private timelockProxy;

// Mento Reserve Multisig address:
address private reserveMultisig;

function prepare() public {
// Load addresses from deployments
contracts.loadSilent("MU01-00-Create-Proxies", "latest");
Expand Down Expand Up @@ -95,18 +102,32 @@ contract MU08Checks is GovernanceScript, Test {
// MentoGovernance contracts:
governanceFactory = contracts.deployed("GovernanceFactory");
timelockProxy = IGovernanceFactory(governanceFactory).governanceTimelock();

// Mento Reserve Multisig address:
reserveMultisig = contracts.dependency("PartialReserveMultisig");
}

function run() public {
console.log("\nStarting MU08 checks:");
prepare();

verifyOtherReservesAddresses();
verifyTokenOwnership();
verifyMentoV2Ownership();
verifyMentoV1Ownership();
verifyGovernanceFactoryOwnership();
}

function verifyOtherReservesAddresses() public {
console.log("\n== Verifying other reserves addresses of onchain Reserve: ==");
address[] memory otherReserves = IReserveLite(reserveProxy).getOtherReserveAddresses();

require(otherReserves.length == 1, "❗️❌ Wrong number of other reserves addresses");
require(otherReserves[0] == reserveMultisig, "❗️❌ Other reserve address is not the Reserve Multisig");
console.log("🟢Other reserves address was added successfully: ", reserveMultisig);
console.log("🤘🏼Other reserves addresses of onchain Reserve are updated correctly.");
}

function verifyTokenOwnership() public {
console.log("\n== Verifying token proxy and implementation ownership: ==");
address[] memory tokenProxies = Arrays.addresses(
Expand Down

0 comments on commit ea17e46

Please sign in to comment.