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: transfer proxy admin and PUSO ownership #223

Merged
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
26 changes: 24 additions & 2 deletions script/upgrades/MU08/MU08.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ interface IOwnableLite {

interface IProxyLite {
function _getImplementation() external view returns (address);

function _getOwner() external view returns (address);

function _transferOwnership(address) external;
}

contract MU08 is IMentoUpgrade, GovernanceScript {
Expand All @@ -39,6 +43,7 @@ contract MU08 is IMentoUpgrade, GovernanceScript {
address private cBRLProxy;
address private eXOFProxy;
address private cKESProxy;
address private PUSOProxy;

// MentoV2 contracts:
address private brokerProxy;
Expand Down Expand Up @@ -72,6 +77,7 @@ contract MU08 is IMentoUpgrade, GovernanceScript {
contracts.loadSilent("MU03-01-Create-Nonupgradeable-Contracts", "latest");
contracts.loadSilent("eXOF-00-Create-Proxies", "latest");
contracts.loadSilent("cKES-00-Create-Proxies", "latest");
contracts.loadSilent("PUSO-00-Create-Proxies", "latest");
contracts.loadSilent("MUGOV-00-Create-Factory", "latest");
}

Expand All @@ -88,6 +94,7 @@ contract MU08 is IMentoUpgrade, GovernanceScript {
cBRLProxy = address(uint160(contracts.celoRegistry("StableTokenBRL")));
eXOFProxy = address(uint160(contracts.deployed("StableTokenXOFProxy")));
cKESProxy = address(uint160(contracts.deployed("StableTokenKESProxy")));
PUSOProxy = address(uint160(contracts.deployed("StableTokenPHPProxy")));

// MentoV2 contracts:
brokerProxy = address(uint160(contracts.deployed("BrokerProxy")));
Expand Down Expand Up @@ -132,9 +139,10 @@ contract MU08 is IMentoUpgrade, GovernanceScript {
}

function proposal_transferTokenOwnership() public {
address[] memory tokenProxies = Arrays.addresses(cUSDProxy, cEURProxy, cBRLProxy, eXOFProxy, cKESProxy);
address[] memory tokenProxies = Arrays.addresses(cUSDProxy, cEURProxy, cBRLProxy, eXOFProxy, cKESProxy, PUSOProxy);
for (uint i = 0; i < tokenProxies.length; i++) {
transferOwnership(tokenProxies[i]);
transferProxyAdmin(tokenProxies[i]);
}

// All the token proxies are pointing to the same StableTokenV2 implementation (cUSD)
Expand All @@ -153,6 +161,7 @@ contract MU08 is IMentoUpgrade, GovernanceScript {
address[] memory mentoV2Proxies = Arrays.addresses(brokerProxy, biPoolManagerProxy, reserveProxy);
for (uint i = 0; i < mentoV2Proxies.length; i++) {
transferOwnership(mentoV2Proxies[i]);
transferProxyAdmin(mentoV2Proxies[i]);
address implementation = IProxyLite(mentoV2Proxies[i])._getImplementation();
transferOwnership(implementation);
}
Expand All @@ -178,7 +187,7 @@ contract MU08 is IMentoUpgrade, GovernanceScript {
);
for (uint i = 0; i < mentoV1Proxies.length; i++) {
transferOwnership(mentoV1Proxies[i]);
address implementation = IProxyLite(mentoV1Proxies[i])._getImplementation();
transferProxyAdmin(mentoV1Proxies[i]);
}
}

Expand All @@ -198,4 +207,17 @@ contract MU08 is IMentoUpgrade, GovernanceScript {
);
}
}

function transferProxyAdmin(address contractAddr) internal {
address proxyAdmin = IProxyLite(contractAddr)._getOwner();
if (proxyAdmin != timelockProxy && proxyAdmin == celoGovernance) {
transactions.push(
ICeloGovernance.Transaction({
value: 0,
destination: contractAddr,
data: abi.encodeWithSelector(IProxyLite(0)._transferOwnership.selector, timelockProxy)
})
);
}
}
}
11 changes: 10 additions & 1 deletion script/upgrades/MU08/MU08Checks.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ interface IOwnableLite {

interface IProxyLite {
function _getImplementation() external view returns (address);

function _getOwner() external view returns (address);
}

contract MU08Checks is GovernanceScript, Test {
Expand All @@ -32,6 +34,7 @@ contract MU08Checks is GovernanceScript, Test {
address private cBRLProxy;
address private eXOFProxy;
address private cKESProxy;
address private PUSOProxy;

// MentoV2 contracts:
address private brokerProxy;
Expand All @@ -58,6 +61,7 @@ contract MU08Checks is GovernanceScript, Test {
contracts.loadSilent("MU03-01-Create-Nonupgradeable-Contracts", "latest");
contracts.loadSilent("eXOF-00-Create-Proxies", "latest");
contracts.loadSilent("cKES-00-Create-Proxies", "latest");
contracts.loadSilent("PUSO-00-Create-Proxies", "latest");
contracts.loadSilent("MUGOV-00-Create-Factory", "latest");

// Celo Governance:
Expand All @@ -69,6 +73,7 @@ contract MU08Checks is GovernanceScript, Test {
cBRLProxy = address(uint160(contracts.celoRegistry("StableTokenBRL")));
eXOFProxy = address(uint160(contracts.deployed("StableTokenXOFProxy")));
cKESProxy = address(uint160(contracts.deployed("StableTokenKESProxy")));
PUSOProxy = address(uint160(contracts.deployed("StableTokenPHPProxy")));

// MentoV2 contracts:
brokerProxy = address(uint160(contracts.deployed("BrokerProxy")));
Expand Down Expand Up @@ -101,7 +106,7 @@ contract MU08Checks is GovernanceScript, Test {

function verifyTokenOwnership() public {
console.log("\n== Verifying token proxy and implementation ownership: ==");
address[] memory tokenProxies = Arrays.addresses(cUSDProxy, cEURProxy, cBRLProxy, eXOFProxy, cKESProxy);
address[] memory tokenProxies = Arrays.addresses(cUSDProxy, cEURProxy, cBRLProxy, eXOFProxy, cKESProxy, PUSOProxy);

for (uint256 i = 0; i < tokenProxies.length; i++) {
verifyProxyAndImplementationOwnership(tokenProxies[i]);
Expand Down Expand Up @@ -152,6 +157,10 @@ contract MU08Checks is GovernanceScript, Test {
require(proxyOwner == timelockProxy, "❗️❌ Proxy ownership not transferred to Mento Governance");
console.log("🟢 Proxy:[%s] ownership transferred to Mento Governance", proxy);

address proxyAdmin = IProxyLite(proxy)._getOwner();
require(proxyAdmin == timelockProxy, "❗️❌ Proxy admin ownership not transferred to Mento Governance");
console.log("🟢 Proxy:[%s] admin ownership transferred to Mento Governance", proxy);

address implementation = IProxyLite(proxy)._getImplementation();
address implementationOwner = IOwnableLite(implementation).owner();
require(implementationOwner != address(0), "❗️❌ Implementation not owned by anybody");
Expand Down
Loading