2023-05-21 15:51:14 -04:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
pragma solidity ^0.6.12;
|
|
|
|
pragma experimental ABIEncoderV2;
|
|
|
|
|
|
|
|
import { LoopbackProxy } from "../v1/LoopbackProxy.sol";
|
|
|
|
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
|
|
|
|
|
|
import { GovernancePatchUpgrade } from "./GovernancePatchUpgrade.sol";
|
|
|
|
import { TornadoStakingRewards } from "./TornadoStakingRewards.sol";
|
2023-05-21 21:44:30 -04:00
|
|
|
import { RelayerRegistry } from "./RelayerRegistry.sol";
|
2023-05-21 15:51:14 -04:00
|
|
|
|
2023-05-21 21:44:30 -04:00
|
|
|
interface Proxy {
|
|
|
|
function upgradeTo(address newImplementation) external;
|
|
|
|
}
|
|
|
|
|
2023-05-23 17:41:03 -04:00
|
|
|
/**
|
|
|
|
* @notice Proposal which should patch governance against the metamorphic contract replacement vulnerability.
|
|
|
|
*/
|
2023-05-21 21:44:30 -04:00
|
|
|
contract PatchProposal {
|
2023-05-24 19:59:14 -04:00
|
|
|
// Address of the staking proxy
|
|
|
|
address public constant stakingProxyAddress = 0x2FC93484614a34f26F7970CBB94615bA109BB4bf;
|
|
|
|
|
|
|
|
// Address of the registry proxy
|
|
|
|
address public constant registryProxyAddress = 0x58E8dCC13BE9780fC42E8723D8EaD4CF46943dF2;
|
2023-05-21 15:51:14 -04:00
|
|
|
|
2023-05-24 19:59:14 -04:00
|
|
|
// Address of the gas compensation vault
|
|
|
|
address public constant gasCompensationVaultAddress = 0xFA4C1f3f7D5dd7c12a9Adb82Cd7dDA542E3d59ef;
|
2023-05-21 21:44:30 -04:00
|
|
|
|
2023-05-24 19:59:14 -04:00
|
|
|
// Address of the user vault (not replaced)
|
|
|
|
address public constant userVaultAddress = 0x2F50508a8a3D323B91336FA3eA6ae50E55f32185;
|
|
|
|
|
|
|
|
// Address of the governance proxy
|
|
|
|
address payable public constant governanceProxyAddress = 0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce;
|
|
|
|
|
|
|
|
// Torn token
|
2023-05-21 15:51:14 -04:00
|
|
|
IERC20 public constant TORN = IERC20(0x77777FeDdddFfC19Ff86DB637967013e6C6A116C);
|
|
|
|
|
2023-05-24 19:59:14 -04:00
|
|
|
// These are the contracts we deployed
|
|
|
|
address public immutable deployedStakingContractAddress;
|
|
|
|
address public immutable deployedRelayerRegistryImplementationAddress;
|
2023-05-21 15:51:14 -04:00
|
|
|
|
2023-05-24 19:59:14 -04:00
|
|
|
constructor(address _deployedStakingContractAddress, address _deployedRelayerRegistryImplementationAddress)
|
|
|
|
public
|
|
|
|
{
|
|
|
|
deployedStakingContractAddress = _deployedStakingContractAddress;
|
|
|
|
deployedRelayerRegistryImplementationAddress = _deployedRelayerRegistryImplementationAddress;
|
2023-05-21 15:51:14 -04:00
|
|
|
}
|
|
|
|
|
2023-05-23 17:41:03 -04:00
|
|
|
/// @notice Function to execute the proposal.
|
2023-05-21 15:51:14 -04:00
|
|
|
function executeProposal() external {
|
|
|
|
// Get the old staking contract
|
2023-05-24 19:59:14 -04:00
|
|
|
TornadoStakingRewards oldStaking = TornadoStakingRewards(stakingProxyAddress);
|
2023-05-21 15:51:14 -04:00
|
|
|
|
2023-05-21 21:44:30 -04:00
|
|
|
// Get the small amount of TORN left
|
2023-05-21 15:51:14 -04:00
|
|
|
oldStaking.withdrawTorn(TORN.balanceOf(address(oldStaking)));
|
|
|
|
|
|
|
|
// And create a new staking contract
|
2023-05-24 19:59:14 -04:00
|
|
|
TornadoStakingRewards newStaking = TornadoStakingRewards(deployedStakingContractAddress);
|
2023-05-21 21:44:30 -04:00
|
|
|
|
|
|
|
// Upgrade the registry proxy
|
2023-05-24 19:59:14 -04:00
|
|
|
Proxy(registryProxyAddress).upgradeTo(deployedRelayerRegistryImplementationAddress);
|
2023-05-21 15:51:14 -04:00
|
|
|
|
|
|
|
// Now upgrade the governance to the latest stuff
|
2023-05-24 19:59:14 -04:00
|
|
|
LoopbackProxy(governanceProxyAddress).upgradeTo(
|
|
|
|
address(new GovernancePatchUpgrade(address(newStaking), gasCompensationVaultAddress, userVaultAddress))
|
|
|
|
);
|
2023-05-21 15:51:14 -04:00
|
|
|
}
|
|
|
|
}
|