93 lines
3.1 KiB
Solidity
93 lines
3.1 KiB
Solidity
|
// SPDX-License-Identifier: MIT
|
||
|
|
||
|
pragma solidity ^0.6.12;
|
||
|
pragma experimental ABIEncoderV2;
|
||
|
|
||
|
import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
|
||
|
import { LoopbackProxy } from "../v1/LoopbackProxy.sol";
|
||
|
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||
|
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
|
||
|
|
||
|
import { GovernancePatchUpgrade } from "./GovernancePatchUpgrade.sol";
|
||
|
import { TornadoStakingRewards } from "./TornadoStakingRewards.sol";
|
||
|
import { RelayerRegistry } from "./RelayerRegistry.sol";
|
||
|
|
||
|
interface Proxy {
|
||
|
function upgradeTo(address newImplementation) external;
|
||
|
}
|
||
|
|
||
|
// We will have to do this because of the contract size limit
|
||
|
|
||
|
contract ProposalContractFactory {
|
||
|
function createStakingRewards(
|
||
|
address governance,
|
||
|
address torn,
|
||
|
address registry
|
||
|
) external returns (address) {
|
||
|
return address(new TornadoStakingRewards(governance, torn, registry));
|
||
|
}
|
||
|
|
||
|
function createRegistryContract(
|
||
|
address torn,
|
||
|
address governance,
|
||
|
address ens,
|
||
|
address staking,
|
||
|
address feeManager
|
||
|
) external returns (address) {
|
||
|
return address(new RelayerRegistry(torn, governance, ens, staking, feeManager));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
contract PatchProposal {
|
||
|
using SafeMath for uint256;
|
||
|
using Address for address;
|
||
|
|
||
|
address public constant feeManagerAddress = 0x5f6c97C6AD7bdd0AE7E0Dd4ca33A4ED3fDabD4D7;
|
||
|
address public constant ensAddress = 0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e;
|
||
|
address public immutable registry = 0x58E8dCC13BE9780fC42E8723D8EaD4CF46943dF2;
|
||
|
|
||
|
IERC20 public constant TORN = IERC20(0x77777FeDdddFfC19Ff86DB637967013e6C6A116C);
|
||
|
|
||
|
ProposalContractFactory public immutable proposalContractFactory;
|
||
|
|
||
|
constructor(address _proposalContractFactory) public {
|
||
|
proposalContractFactory = ProposalContractFactory(_proposalContractFactory);
|
||
|
}
|
||
|
|
||
|
// Aight lets do this sirs
|
||
|
function executeProposal() external {
|
||
|
// address(this) has to be governance
|
||
|
address payable governance = payable(address(this));
|
||
|
|
||
|
// Get the two contracts gov depends on
|
||
|
address gasComp = address(GovernancePatchUpgrade(governance).gasCompensationVault());
|
||
|
address vault = address(GovernancePatchUpgrade(governance).userVault());
|
||
|
|
||
|
// Get the old staking contract
|
||
|
TornadoStakingRewards oldStaking = TornadoStakingRewards(address(GovernancePatchUpgrade(governance).Staking()));
|
||
|
|
||
|
// Get the small amount of TORN left
|
||
|
oldStaking.withdrawTorn(TORN.balanceOf(address(oldStaking)));
|
||
|
|
||
|
// And create a new staking contract
|
||
|
TornadoStakingRewards newStaking = TornadoStakingRewards(
|
||
|
proposalContractFactory.createStakingRewards(address(governance), address(TORN), registry)
|
||
|
);
|
||
|
|
||
|
// And a new registry
|
||
|
address newRegistryAddress = proposalContractFactory.createRegistryContract(
|
||
|
address(TORN),
|
||
|
address(governance),
|
||
|
ensAddress,
|
||
|
address(newStaking),
|
||
|
feeManagerAddress
|
||
|
);
|
||
|
|
||
|
// Upgrade the registry proxy
|
||
|
Proxy(registry).upgradeTo(newRegistryAddress);
|
||
|
|
||
|
// Now upgrade the governance to the latest stuff
|
||
|
LoopbackProxy(payable(governance)).upgradeTo(address(new GovernancePatchUpgrade(address(newStaking), gasComp, vault)));
|
||
|
}
|
||
|
}
|