mirror of
				https://github.com/Instadapp/dsa-governance.git
				synced 2024-07-29 22:27:52 +00:00 
			
		
		
		
	added propose function on payload contract
This commit is contained in:
		
							parent
							
								
									957c158932
								
							
						
					
					
						commit
						fbea228a18
					
				| 
						 | 
				
			
			@ -1,63 +0,0 @@
 | 
			
		|||
pragma solidity ^0.7.0;
 | 
			
		||||
 | 
			
		||||
import "../SafeMath.sol";
 | 
			
		||||
 | 
			
		||||
interface IGovernorBravo {
 | 
			
		||||
    function _acceptAdmin() external;
 | 
			
		||||
    function _setVotingDelay(uint newVotingDelay) external;
 | 
			
		||||
    function _setVotingPeriod(uint newVotingPeriod) external;
 | 
			
		||||
    function _acceptAdminOnTimelock() external;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface ITimelock {
 | 
			
		||||
    function acceptAdmin() external;
 | 
			
		||||
    function setDelay(uint delay_) external;
 | 
			
		||||
    function setPendingAdmin(address pendingAdmin_) external;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface IInstaIndex {
 | 
			
		||||
    function updateMaster() external;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
contract PayloadIGP {
 | 
			
		||||
    uint256 public constant PROPOSAL_ID = 6;
 | 
			
		||||
 | 
			
		||||
    IGovernorBravo public constant GOVERNOR = IGovernorBravo(0x0204Cd037B2ec03605CFdFe482D8e257C765fA1B);
 | 
			
		||||
    ITimelock public constant OLD_TIMELOCK = ITimelock(0xC7Cb1dE2721BFC0E0DA1b9D526bCdC54eF1C0eFC);
 | 
			
		||||
    ITimelock public constant TIMELOCK = ITimelock(0xC7Cb1dE2721BFC0E0DA1b9D526bCdC54eF1C0eFC);
 | 
			
		||||
    IInstaIndex public constant INSTAINDEX = IInstaIndex(0xC7Cb1dE2721BFC0E0DA1b9D526bCdC54eF1C0eFC);
 | 
			
		||||
 | 
			
		||||
    uint256 public constant ONE_DAY_TIME_IN_SECONDS = 1 days; // 1 day in seconds. 86400s
 | 
			
		||||
    uint256 public constant ONE_DAY_TIME_IN_BLOCKS = 7_200; // 1 day in blocks. 12s per block
 | 
			
		||||
    uint256 public constant TWO_DAY_TIME_IN_BLOCKS = 14_400; // 2 day in blocks. 12s per block
 | 
			
		||||
 | 
			
		||||
    function execute() external {
 | 
			
		||||
        // Action 1: _acceptAdmin() function on governor contract
 | 
			
		||||
        GOVERNOR._acceptAdmin();
 | 
			
		||||
 | 
			
		||||
        // Action 2: acceptAdmin() function on old time contract
 | 
			
		||||
        OLD_TIMELOCK.acceptAdmin();
 | 
			
		||||
        
 | 
			
		||||
        // Action 2: updateMaster() function on DSA instaIndex
 | 
			
		||||
        INSTAINDEX.updateMaster();
 | 
			
		||||
 | 
			
		||||
        // Action 4: setDelay() on new timelock contract with 1 day
 | 
			
		||||
        TIMELOCK.setDelay(ONE_DAY_TIME_IN_SECONDS);
 | 
			
		||||
 | 
			
		||||
        // Action 5: setPendingAdmin() on new timelock contract
 | 
			
		||||
        TIMELOCK.setPendingAdmin(address(GOVERNOR));
 | 
			
		||||
 | 
			
		||||
        // Action 6: _acceptAdminOnTimelock() on governor contract
 | 
			
		||||
        GOVERNOR._acceptAdminOnTimelock();
 | 
			
		||||
 | 
			
		||||
        // Action 7: _setVotingDelay() function on governor contract with 1 days
 | 
			
		||||
        GOVERNOR._setVotingDelay(ONE_DAY_TIME_IN_BLOCKS);
 | 
			
		||||
 | 
			
		||||
        // Action 8: _setVotingPeriod() function on governor contract with 2 days
 | 
			
		||||
        GOVERNOR._setVotingPeriod(TWO_DAY_TIME_IN_BLOCKS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function verifyProposal() external {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										276
									
								
								contracts/payloads/PayloadIGP7.sol
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										276
									
								
								contracts/payloads/PayloadIGP7.sol
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,276 @@
 | 
			
		|||
pragma solidity ^0.7.0;
 | 
			
		||||
pragma experimental ABIEncoderV2;
 | 
			
		||||
 | 
			
		||||
interface IGovernorBravo {
 | 
			
		||||
    function _acceptAdmin() external;
 | 
			
		||||
    function _setVotingDelay(uint newVotingDelay) external;
 | 
			
		||||
    function _setVotingPeriod(uint newVotingPeriod) external;
 | 
			
		||||
    function _acceptAdminOnTimelock() external;
 | 
			
		||||
    function _setImplementation(address implementation_) external;
 | 
			
		||||
    function propose(address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description) external returns (uint);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface ITimelock {
 | 
			
		||||
    function acceptAdmin() external;
 | 
			
		||||
    function setDelay(uint delay_) external;
 | 
			
		||||
    function setPendingAdmin(address pendingAdmin_) external;
 | 
			
		||||
    function queueTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) external returns (bytes32);
 | 
			
		||||
    function executeTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) external payable returns (bytes memory);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface IInstaIndex {
 | 
			
		||||
    function changeMaster(address _newMaster) external;
 | 
			
		||||
    function updateMaster() external;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface ILite {
 | 
			
		||||
    function setAdmin(address newAdmin) external;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface IDSAV2 {
 | 
			
		||||
    function cast(
 | 
			
		||||
        string[] memory _targetNames,
 | 
			
		||||
        bytes[] memory _datas,
 | 
			
		||||
        address _origin
 | 
			
		||||
    )
 | 
			
		||||
    external
 | 
			
		||||
    payable 
 | 
			
		||||
    returns (bytes32);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
contract PayloadIGP {
 | 
			
		||||
    uint256 public constant PROPOSAL_ID = 7;
 | 
			
		||||
 | 
			
		||||
    IGovernorBravo public constant GOVERNOR = IGovernorBravo(0x0204Cd037B2ec03605CFdFe482D8e257C765fA1B);
 | 
			
		||||
    ITimelock public constant OLD_TIMELOCK = ITimelock(0xC7Cb1dE2721BFC0E0DA1b9D526bCdC54eF1C0eFC);
 | 
			
		||||
    ITimelock public constant TIMELOCK = ITimelock(0xC7Cb1dE2721BFC0E0DA1b9D526bCdC54eF1C0eFC);
 | 
			
		||||
 | 
			
		||||
    IInstaIndex public constant INSTAINDEX = IInstaIndex(0xC7Cb1dE2721BFC0E0DA1b9D526bCdC54eF1C0eFC);
 | 
			
		||||
    ILite public constant LITE = ILite(0xA0D3707c569ff8C87FA923d3823eC5D81c98Be78);
 | 
			
		||||
    IDSAV2 public constant TREASURY = IDSAV2(0x28849D2b63fA8D361e5fc15cB8aBB13019884d09);
 | 
			
		||||
 | 
			
		||||
    uint256 public constant ONE_DAY_TIME_IN_SECONDS = 1 days; // 1 day in seconds. 86400s
 | 
			
		||||
    uint256 public constant ONE_DAY_TIME_IN_BLOCKS = 7_200; // 1 day in blocks. 12s per block
 | 
			
		||||
    uint256 public constant TWO_DAY_TIME_IN_BLOCKS = 14_400; // 2 day in blocks. 12s per block
 | 
			
		||||
 | 
			
		||||
    string public constant description = "";
 | 
			
		||||
 | 
			
		||||
    address public constant GOVERNOR_IMPLEMENTATION_ADDRESS = address(0); // todo
 | 
			
		||||
    address public constant TEAM_MULTISIG = 0x4F6F977aCDD1177DCD81aB83074855EcB9C2D49e;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    function propose() external {
 | 
			
		||||
        uint256 totalActions = 8;
 | 
			
		||||
        address[] memory targets = new address[](totalActions);
 | 
			
		||||
        uint256[] memory values = new uint256[](totalActions);
 | 
			
		||||
        string[] memory signatures = new string[](totalActions);
 | 
			
		||||
        bytes[] memory calldatas = new bytes[](totalActions);
 | 
			
		||||
 | 
			
		||||
        // Action 1: call cast() - transfer rewards to Team Multisig, add new Timelock as auth & remove old Timelock as auth on Treasury
 | 
			
		||||
        (targets[0], values[0], signatures[0], calldatas[0]) = action1();
 | 
			
		||||
 | 
			
		||||
        // Action 2: call _setImplementation() - upgrade governor contract to new implementation
 | 
			
		||||
        (targets[1], values[1], signatures[1], calldatas[1]) = action2();
 | 
			
		||||
 | 
			
		||||
        // Action 3: call changeMaster() - change ownership of DSA to new timelock contract
 | 
			
		||||
        (targets[2], values[2], signatures[2], calldatas[2]) = action3();
 | 
			
		||||
 | 
			
		||||
        // Action 4: call setAdmin() - change ownership of Lite to new timelock contract
 | 
			
		||||
        (targets[3], values[3], signatures[3], calldatas[3]) = action4();
 | 
			
		||||
 | 
			
		||||
        // Action 5: call _setPendingAdmin() - on governor contract with new timelock address
 | 
			
		||||
        (targets[4], values[4], signatures[4], calldatas[4]) = action5();
 | 
			
		||||
 | 
			
		||||
        // Action 6: call setPendingAdmin() - on old timelock with new timelock address
 | 
			
		||||
        (targets[5], values[5], signatures[5], calldatas[5]) = action6();
 | 
			
		||||
 | 
			
		||||
        // Action 7: call queueTransaction - new timelock contract to queue below payload
 | 
			
		||||
        (targets[6], values[6], signatures[6], calldatas[6]) = action7();
 | 
			
		||||
 | 
			
		||||
        // Action 8: call executeTransaction - new timelock contract to execute below payload
 | 
			
		||||
        (targets[7], values[7], signatures[7], calldatas[7]) = action8();
 | 
			
		||||
 | 
			
		||||
        uint256 proposedId = GOVERNOR.propose(
 | 
			
		||||
            targets,
 | 
			
		||||
            values,
 | 
			
		||||
            signatures,
 | 
			
		||||
            calldatas,
 | 
			
		||||
            description
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        require(proposedId == PROPOSAL_ID, "PROPOSAL_IS_NOT_SAME");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function execute() external {
 | 
			
		||||
        // Action 1: _acceptAdmin() function on governor contract
 | 
			
		||||
        GOVERNOR._acceptAdmin();
 | 
			
		||||
 | 
			
		||||
        // Action 2: acceptAdmin() function on old time contract
 | 
			
		||||
        OLD_TIMELOCK.acceptAdmin();
 | 
			
		||||
        
 | 
			
		||||
        // Action 2: updateMaster() function on DSA instaIndex
 | 
			
		||||
        INSTAINDEX.updateMaster();
 | 
			
		||||
 | 
			
		||||
        // Action 4: setDelay() on new timelock contract with 1 day
 | 
			
		||||
        TIMELOCK.setDelay(ONE_DAY_TIME_IN_SECONDS);
 | 
			
		||||
 | 
			
		||||
        // Action 5: setPendingAdmin() on new timelock contract
 | 
			
		||||
        TIMELOCK.setPendingAdmin(address(GOVERNOR));
 | 
			
		||||
 | 
			
		||||
        // Action 6: _acceptAdminOnTimelock() on governor contract
 | 
			
		||||
        GOVERNOR._acceptAdminOnTimelock();
 | 
			
		||||
 | 
			
		||||
        // Action 7: _setVotingDelay() function on governor contract with 1 days
 | 
			
		||||
        GOVERNOR._setVotingDelay(ONE_DAY_TIME_IN_BLOCKS);
 | 
			
		||||
 | 
			
		||||
        // Action 8: _setVotingPeriod() function on governor contract with 2 days
 | 
			
		||||
        GOVERNOR._setVotingPeriod(TWO_DAY_TIME_IN_BLOCKS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function verifyProposal() external {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ///////// PROPOSAL ACTIONS - 8 Actions ///////
 | 
			
		||||
 | 
			
		||||
        /// @notice Action 1: call cast() - transfer rewards to Team Multisig, add new Timelock as auth & remove old Timelock as auth on Treasury
 | 
			
		||||
    function action1() public view returns(address target, uint256 value, string memory signature, bytes memory calldatas) {
 | 
			
		||||
        string[] memory targets = new string[](7);
 | 
			
		||||
        bytes[] memory encodedSpells = new bytes[](7);
 | 
			
		||||
 | 
			
		||||
        string memory withdrawSignature = "withdraw(address,uint256,address,uint256,uint256)";
 | 
			
		||||
 | 
			
		||||
        // Spell 1: Transfer ETH
 | 
			
		||||
        {
 | 
			
		||||
            address ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
 | 
			
		||||
            uint256 ETH_AMOUNT = 230 * 1e18;
 | 
			
		||||
            targets[0] = "BASIC-A";
 | 
			
		||||
            encodedSpells[0] = abi.encodeWithSignature(withdrawSignature, ETH_ADDRESS, ETH_AMOUNT, TEAM_MULTISIG, 0, 0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Spell 2: Transfer USDC
 | 
			
		||||
        {   
 | 
			
		||||
            address USDC_ADDRESS = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
 | 
			
		||||
            uint256 USDC_AMOUNT = 100_000 * 1e6;
 | 
			
		||||
            targets[1] = "BASIC-A";
 | 
			
		||||
            encodedSpells[1] = abi.encodeWithSignature(withdrawSignature, USDC_ADDRESS, USDC_AMOUNT, TEAM_MULTISIG, 0, 0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Spell 3: Transfer DAI
 | 
			
		||||
        {   
 | 
			
		||||
            address DAI_ADDRESS = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
 | 
			
		||||
            uint256 DAI_AMOUNT = 100_000 * 1e18;
 | 
			
		||||
            targets[2] = "BASIC-A";
 | 
			
		||||
            encodedSpells[2] = abi.encodeWithSignature(withdrawSignature, DAI_ADDRESS, DAI_AMOUNT, TEAM_MULTISIG, 0, 0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Spell 4: Transfer USDT
 | 
			
		||||
        {   
 | 
			
		||||
            address USDT_ADDRESS = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
 | 
			
		||||
            uint256 USDT_AMOUNT = 100_000 * 1e6;
 | 
			
		||||
            targets[3] = "BASIC-A";
 | 
			
		||||
            encodedSpells[3] = abi.encodeWithSignature(withdrawSignature, USDT_ADDRESS, USDT_AMOUNT, TEAM_MULTISIG, 0, 0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Spell 5: Transfer stETH
 | 
			
		||||
        {   
 | 
			
		||||
            address STETH_ADDRESS = 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84;
 | 
			
		||||
            uint256 STETH_AMOUNT = 70 * 1e18;
 | 
			
		||||
            targets[4] = "BASIC-A";
 | 
			
		||||
            encodedSpells[4] = abi.encodeWithSignature(withdrawSignature, STETH_ADDRESS, STETH_AMOUNT, TEAM_MULTISIG, 0, 0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Spell 6: Add new Timelock as auth
 | 
			
		||||
        {
 | 
			
		||||
            targets[5] = "AUTHORITY-A";
 | 
			
		||||
            encodedSpells[5] = abi.encodeWithSignature("add(address)", address(TIMELOCK));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Spell 7: Remove old Timelock as auth
 | 
			
		||||
        {
 | 
			
		||||
            targets[5] = "AUTHORITY-A";
 | 
			
		||||
            encodedSpells[5] = abi.encodeWithSignature("remove(address)", address(OLD_TIMELOCK));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        target = address(TREASURY);
 | 
			
		||||
        value = 0;
 | 
			
		||||
        signature = "cast(string[],bytes[],address)";
 | 
			
		||||
        calldatas = abi.encode(targets, encodedSpells, address(this));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @notice Action 2: call _setImplementation() - upgrade governor contract to new implementation
 | 
			
		||||
    function action2() public pure returns(address target, uint256 value, string memory signature, bytes memory calldatas) {
 | 
			
		||||
        target = address(GOVERNOR);
 | 
			
		||||
        value = 0;
 | 
			
		||||
        signature = "_setImplementation(address)";
 | 
			
		||||
        calldatas = abi.encode(GOVERNOR_IMPLEMENTATION_ADDRESS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @notice Action 3: call changeMaster() - change ownership of DSA to new timelock contract
 | 
			
		||||
    function action3() public pure returns(address target, uint256 value, string memory signature, bytes memory calldatas) {
 | 
			
		||||
        target = address(INSTAINDEX);
 | 
			
		||||
        value = 0;
 | 
			
		||||
        signature = "changeMaster(address)";
 | 
			
		||||
        calldatas = abi.encode(TIMELOCK);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @notice Action 4: call setAdmin() - change ownership of Lite to new timelock contract
 | 
			
		||||
    function action4() public pure returns(address target, uint256 value, string memory signature, bytes memory calldatas) {
 | 
			
		||||
        target = address(LITE);
 | 
			
		||||
        value = 0;
 | 
			
		||||
        signature = "setAdmin(address)";
 | 
			
		||||
        calldatas = abi.encode(TIMELOCK);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @notice Action 5: call _setPendingAdmin() - on governor contract with new timelock address
 | 
			
		||||
    function action5() public pure returns(address target, uint256 value, string memory signature, bytes memory calldatas) {
 | 
			
		||||
        target = address(GOVERNOR);
 | 
			
		||||
        value = 0;
 | 
			
		||||
        signature = "_setPendingAdmin(address)";
 | 
			
		||||
        calldatas = abi.encode(TIMELOCK);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @notice Action 6: call setPendingAdmin() - on old timelock with new timelock address
 | 
			
		||||
    function action6() public pure returns(address target, uint256 value, string memory signature, bytes memory calldatas) {
 | 
			
		||||
        target = address(OLD_TIMELOCK);
 | 
			
		||||
        value = 0;
 | 
			
		||||
        signature = "setPendingAdmin()";
 | 
			
		||||
        calldatas = abi.encode(TIMELOCK);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @notice Action 7: call queueTransaction - new timelock contract to queue below payload
 | 
			
		||||
    function action7() public view returns(address target, uint256 value, string memory signature, bytes memory calldatas) {
 | 
			
		||||
        target = address(TIMELOCK);
 | 
			
		||||
        value = 0;
 | 
			
		||||
        signature = "queueTransaction(address,uint256,string,bytes,uint256)";
 | 
			
		||||
        calldatas = abi.encode(
 | 
			
		||||
            TIMELOCK,
 | 
			
		||||
            0,
 | 
			
		||||
            "executePayload(address,string,bytes)",
 | 
			
		||||
            abi.encode(
 | 
			
		||||
                address(this),
 | 
			
		||||
                "execute()",
 | 
			
		||||
                abi.encode()
 | 
			
		||||
            ),
 | 
			
		||||
            block.timestamp
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @notice Action 8: call executeTransaction - new timelock contract to execute below payload
 | 
			
		||||
     function action8() public view returns(address target, uint256 value, string memory signature, bytes memory calldatas) {
 | 
			
		||||
        target = address(TIMELOCK);
 | 
			
		||||
        value = 0;
 | 
			
		||||
        signature = "executeTransaction(address,uint256,string,bytes,uint256)";
 | 
			
		||||
        calldatas = abi.encode(
 | 
			
		||||
            TIMELOCK,
 | 
			
		||||
            0,
 | 
			
		||||
            "executePayload(address,string,bytes)",
 | 
			
		||||
            abi.encode(
 | 
			
		||||
                address(this),
 | 
			
		||||
                "execute()",
 | 
			
		||||
                abi.encode()
 | 
			
		||||
            ),
 | 
			
		||||
            block.timestamp
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user