github.com/klaytn/klaytn@v1.12.1/contracts/kip103/ITreasuryRebalance.sol (about) 1 // SPDX-License-Identifier: GPL-3.0 2 3 pragma solidity ^0.8.0; 4 5 /** 6 * @dev External interface of TreasuryRebalance 7 */ 8 interface ITreasuryRebalance { 9 /** 10 * @dev Emitted when the contract is deployed 11 * `rebalanceBlockNumber` is the target block number of the execution the rebalance in Core 12 * `deployedBlockNumber` is the current block number when its deployed 13 */ 14 event ContractDeployed( 15 Status status, 16 uint256 rebalanceBlockNumber, 17 uint256 deployedBlockNumber 18 ); 19 20 /** 21 * @dev Emitted when a Retired is registered 22 */ 23 event RetiredRegistered(address retired); 24 25 /** 26 * @dev Emitted when a Retired is removed 27 */ 28 event RetiredRemoved(address retired); 29 30 /** 31 * @dev Emitted when a Newbie is registered 32 */ 33 event NewbieRegistered(address newbie, uint256 fundAllocation); 34 35 /** 36 * @dev Emitted when a Newbie is removed 37 */ 38 event NewbieRemoved(address newbie); 39 40 /** 41 * @dev Emitted when a admin approves the retired address. 42 */ 43 event Approved(address retired, address approver, uint256 approversCount); 44 45 /** 46 * @dev Emitted when the contract status changes 47 */ 48 event StatusChanged(Status status); 49 50 /** 51 * @dev Emitted when the contract is finalized 52 * memo - is the result of the treasury fund rebalancing 53 */ 54 event Finalized(string memo, Status status); 55 56 // Status of the contract 57 enum Status { 58 Initialized, 59 Registered, 60 Approved, 61 Finalized 62 } 63 64 /** 65 * Retired struct to store retired address and their approver addresses 66 */ 67 struct Retired { 68 address retired; 69 address[] approvers; 70 } 71 72 /** 73 * Newbie struct to newbie receiver address and their fund allocation 74 */ 75 struct Newbie { 76 address newbie; 77 uint256 amount; 78 } 79 80 // State variables 81 function status() external view returns (Status); // current status of the contract 82 83 function rebalanceBlockNumber() external view returns (uint256); // the target block number of the execution of rebalancing 84 85 function memo() external view returns (string memory); // result of the treasury fund rebalance 86 87 /** 88 * @dev to get retired details by retiredAddress 89 */ 90 function getRetired( 91 address retiredAddress 92 ) external view returns (address, address[] memory); 93 94 /** 95 * @dev to get newbie details by newbieAddress 96 */ 97 function getNewbie( 98 address newbieAddress 99 ) external view returns (address, uint256); 100 101 /** 102 * @dev returns the sum of retirees balances 103 */ 104 function sumOfRetiredBalance() 105 external 106 view 107 returns (uint256 retireesBalance); 108 109 /** 110 * @dev returns the sum of newbie funds 111 */ 112 function getTreasuryAmount() external view returns (uint256 treasuryAmount); 113 114 /** 115 * @dev returns the length of retirees list 116 */ 117 function getRetiredCount() external view returns (uint256); 118 119 /** 120 * @dev returns the length of newbies list 121 */ 122 function getNewbieCount() external view returns (uint256); 123 124 /** 125 * @dev verify all retirees are approved by admin 126 */ 127 function checkRetiredsApproved() external view; 128 129 // State changing functions 130 /** 131 * @dev registers retired details 132 * Can only be called by the current owner at Initialized state 133 */ 134 function registerRetired(address retiredAddress) external; 135 136 /** 137 * @dev remove the retired details from the array 138 * Can only be called by the current owner at Initialized state 139 */ 140 function removeRetired(address retiredAddress) external; 141 142 /** 143 * @dev registers newbie address and its fund distribution 144 * Can only be called by the current owner at Initialized state 145 */ 146 function registerNewbie(address newbieAddress, uint256 amount) external; 147 148 /** 149 * @dev remove the newbie details from the array 150 * Can only be called by the current owner at Initialized state 151 */ 152 function removeNewbie(address newbieAddress) external; 153 154 /** 155 * @dev approves a retiredAddress,the address can be a EOA or a contract address. 156 * - If the retiredAddress is a EOA, the caller should be the EOA address 157 * - If the retiredAddress is a Contract, the caller should be one of the contract `admin` 158 */ 159 function approve(address retiredAddress) external; 160 161 /** 162 * @dev sets the status to Registered, 163 * After this stage, registrations will be restricted. 164 * Can only be called by the current owner at Initialized state 165 */ 166 function finalizeRegistration() external; 167 168 /** 169 * @dev sets the status to Approved, 170 * Can only be called by the current owner at Registered state 171 */ 172 function finalizeApproval() external; 173 174 /** 175 * @dev sets the status of the contract to Finalize. Once finalized the storage data 176 * of the contract cannot be modified 177 * Can only be called by the current owner at Approved state after the execution of rebalance in the core 178 * - memo format: { "retirees": [ { "retired": "0xaddr", "balance": 0xamount }, 179 * { "retired": "0xaddr", "balance": 0xamount }, ... ], 180 * "newbies": [ { "newbie": "0xaddr", "fundAllocated": 0xamount }, 181 * { "newbie": "0xaddr", "fundAllocated": 0xamount }, ... ], 182 * "burnt": 0xamount, "success": true/false } 183 */ 184 function finalizeContract(string memory memo) external; 185 186 /** 187 * @dev resets all storage values to empty objects except targetBlockNumber 188 */ 189 function reset() external; 190 }