// Contract: CoFiXUpdate
// Target function: function addCofiMinter() public onlyOwner
pragma solidity ^0.8.4;

contract CoFiXUpdate {
    // COFI Token地址
    address constant COFI_TOKEN_ADDRESS = 0x1a23a6BfBAdB59fa563008c0fB7cf96dfCF34Ea1;
    // USDT Token地址
    address constant USDT_TOKEN_ADDRESS = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
    // HBTC Token地址
    address constant HBTC_TOKEN_ADDRESS = 0x0316EB71485b0Ab14103307bf65a021042c6d380;

    // 1.0合约地址
    // 工厂合约地址
    address constant COFIXV1FACTORY_ADDRESS = 0x66C64ecC3A6014733325a8f2EBEE46B4CA3ED550;
    // lp挖矿合约地址
    address constant COFIXV1VAULTFORLP_ADDRESS = 0x6903b1C17A5A0A9484c7346E5c0956027A713fCF;
    // cn挖矿合约地址
    address constant COFIXV1VAULTFORCNODE_ADDRESS = 0x7eDa8251aC08E7898E986DbeC4Ba97B421d545DD;
    // 交易挖矿合约地址
    address constant COFIXV1VAULTFORTRADER_ADDRESS = 0xE6183d3094a9e360B123Ec1330afAE76A74d1cbF;
    // 分红合约地址
    address constant COFISTAKINGREWARDS_ADDRESS = 0x0061c52768378b84306b2665f098c3e0b2C03308;
    // 对接nest3.6的controller
    address constant COFIXV1NEWCONTROLLER_ADDRESS = 0xB99DB9674e03A2cB07c3D7d92406aE1a3BBB9f56;

    // 2.0地址
    // 2.0lp挖矿合约地址
    address constant COFIXV2VAULTFORLP_ADDRESS = 0x618B7b93b07Bf78D04B2e8FB2B1C3B48049F8ED5;
    // 2.0cn挖矿合约地址
    address constant COFIXV2VAULTFORCNODE_ADDRESS = 0x3881292cE52AeD0EdAFF1AC7A40DA12AB2453B84;
    // 2.0交易挖矿合约地址
    address constant COFIXV2VAULTFORTRADER_ADDRESS = 0xb29A8d980E1408E487B9968f5E4f7fD7a9B0CaC5;
    // 2.0DAO合约地址
    address constant COFIXV2DAO_ADDRESS = 0x278f5d08bEa1989BEfcC09A20ad60fB39702D556;

    // 1.0多签合约地址
    address governance = 0xF51d8FdF98286e1EA846c79f1526ECC95b93AbB8;
    // 操作合约的管理员
    address _owner;
    
    constructor() public {
        _owner = msg.sender;
    }

    function doit() public onlyOwner {
        // 1.设置1.0USDT和HBTCLP不挖矿，手续费转到LP池
        setMiningZero();
        // 2.设置cofix1.0挖矿效率为0
        setVaultMiningNum();
        // 3.删除COFI Token可挖矿权限-1.0挖矿合约
        removeCofiMinter();
        // 4.添加COFI Token可挖矿权限-2.0挖矿合约
        addCofiMinter();
        // 5.转移DAO资产
        turnOutETH();
        // 6.重置管理员地址
        resetGovernance();
    }

    // Cofix1.0设置新的controller
    function setCofixV1Controller() public onlyOwner {
        ICoFiXFactory cofixFactory = ICoFiXFactory(COFIXV1FACTORY_ADDRESS);
        // Cofix1.0设置新的controller
        cofixFactory.setController(COFIXV1NEWCONTROLLER_ADDRESS);
        require(cofixFactory.controller() == COFIXV1NEWCONTROLLER_ADDRESS, "setCofixV1Controller:!COFIXV1NEWCONTROLLER_ADDRESS");
    }
    
    // 设置1.0USDT和HBTCLP不挖矿，手续费转到LP池
    function setMiningZero() public onlyOwner {
        ICoFiXFactory cofixFactory = ICoFiXFactory(COFIXV1FACTORY_ADDRESS);
        // USDT和HBTCLP不挖矿，手续费转到LP池
        cofixFactory.setTradeMiningStatus(USDT_TOKEN_ADDRESS, false);
        cofixFactory.setTradeMiningStatus(HBTC_TOKEN_ADDRESS, false);
        cofixFactory.setFeeVaultForLP(USDT_TOKEN_ADDRESS, address(0x0));
        cofixFactory.setFeeVaultForLP(HBTC_TOKEN_ADDRESS, address(0x0));
        require(cofixFactory.getTradeMiningStatus(USDT_TOKEN_ADDRESS) == false, "getTradeMiningStatus:!USDT_TOKEN_ADDRESS");
        require(cofixFactory.getTradeMiningStatus(HBTC_TOKEN_ADDRESS) == false, "getTradeMiningStatus:!HBTC_TOKEN_ADDRESS");
        require(cofixFactory.getFeeVaultForLP(USDT_TOKEN_ADDRESS) == address(0x0), "getFeeVaultForLP:!USDT_PAIR_ADDRESS");
        require(cofixFactory.getFeeVaultForLP(HBTC_TOKEN_ADDRESS) == address(0x0), "getFeeVaultForLP:!HBTC_PAIR_ADDRESS");
    }