Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add partial reserve multisig as other reserve addresses #235

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading