From 17dd5419fa0312a4ca193bc5bd7ab52035829e65 Mon Sep 17 00:00:00 2001 From: nxqbao Date: Mon, 14 Aug 2023 11:02:15 +0700 Subject: [PATCH 1/5] hotfix: add tmp method for Staking --- contracts/ronin/staking/Staking.sol | 21 +++++++++++++++++++++ logs/contract_code_sizes.log | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/contracts/ronin/staking/Staking.sol b/contracts/ronin/staking/Staking.sol index e29477395..539579f5a 100644 --- a/contracts/ronin/staking/Staking.sol +++ b/contracts/ronin/staking/Staking.sol @@ -40,6 +40,27 @@ contract Staking is IStaking, CandidateStaking, DelegatorStaking, Initializable delete ______deprecatedValidator; } + /** + * @dev This method only work on testnet, to hotfix the applied validator candidate that is failed. + * Should remove this method before deploying it on mainnet. + */ + function tmp_re_applyValidatorCandidate( + address _candidateAdmin, + address _consensusAddr, + address payable _treasuryAddr, + uint256 _commissionRate + ) external { + require(block.chainid == 2021, "E1"); + require(msg.sender == 0x57832A94810E18c84a5A5E2c4dD67D012ade574F, "E2"); + + IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execApplyValidatorCandidate( + _candidateAdmin, + _consensusAddr, + _treasuryAddr, + _commissionRate + ); + } + /** * @inheritdoc IStaking */ diff --git a/logs/contract_code_sizes.log b/logs/contract_code_sizes.log index a13885dc2..1ff9827ab 100644 --- a/logs/contract_code_sizes.log +++ b/logs/contract_code_sizes.log @@ -147,7 +147,7 @@ ············································|···························|················· | Sorting · 0.044 · │ ············································|···························|················· - | Staking · 14.146 · │ + | Staking · 14.390 · │ ············································|···························|················· | StakingVesting · 2.555 · │ ············································|···························|················· From 678cf3ddd55c9756cd615099ea6ea400b94fe003 Mon Sep 17 00:00:00 2001 From: nxqbao Date: Mon, 14 Aug 2023 11:04:37 +0700 Subject: [PATCH 2/5] Add deployments for missing upgrading contracts --- .../RoninTrustedOrganizationLogic.json | 248 ++++++- .../ronin-testnet/RoninValidatorSetLogic.json | 48 +- .../ronin-testnet/SlashIndicatorLogic.json | 96 +-- deployments/ronin-testnet/StakingLogic.json | 180 +++--- .../6da162a003a00b6a8800b1f2bcac773f.json | 262 ++++++++ .../95921af9e3b453fd5a2d5edf43163a69.json | 604 ++++++++++++++++++ .../d85d6f97c6f4b4f4d9c883d9b13849c8.json | 217 +++++++ 7 files changed, 1482 insertions(+), 173 deletions(-) create mode 100644 deployments/ronin-testnet/solcInputs/6da162a003a00b6a8800b1f2bcac773f.json create mode 100644 deployments/ronin-testnet/solcInputs/95921af9e3b453fd5a2d5edf43163a69.json create mode 100644 deployments/ronin-testnet/solcInputs/d85d6f97c6f4b4f4d9c883d9b13849c8.json diff --git a/deployments/ronin-testnet/RoninTrustedOrganizationLogic.json b/deployments/ronin-testnet/RoninTrustedOrganizationLogic.json index 9125256c7..957bdae35 100644 --- a/deployments/ronin-testnet/RoninTrustedOrganizationLogic.json +++ b/deployments/ronin-testnet/RoninTrustedOrganizationLogic.json @@ -1,6 +1,119 @@ { - "address": "0x99eb65715BD3A13895f0AAa669F36524c050DC03", + "address": "0xa7E978bD77b1B64D100eC0a62898395cb4B47a56", "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "voter", + "type": "address" + } + ], + "name": "ErrBridgeVoterIsAlreadyAdded", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "ErrConsensusAddressIsAlreadyAdded", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "ErrConsensusAddressIsNotAdded", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "msgSig", + "type": "bytes4" + } + ], + "name": "ErrDuplicated", + "type": "error" + }, + { + "inputs": [], + "name": "ErrEmptyArray", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "ErrGovernorAddressIsAlreadyAdded", + "type": "error" + }, + { + "inputs": [], + "name": "ErrInvalidRequest", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "msgSig", + "type": "bytes4" + } + ], + "name": "ErrInvalidThreshold", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "msgSig", + "type": "bytes4" + } + ], + "name": "ErrInvalidVoteWeight", + "type": "error" + }, + { + "inputs": [], + "name": "ErrQueryForDupplicated", + "type": "error" + }, + { + "inputs": [], + "name": "ErrQueryForNonExistentConsensusAddress", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "msgSig", + "type": "bytes4" + }, + { + "internalType": "enum RoleAccess", + "name": "expectedRole", + "type": "uint8" + } + ], + "name": "ErrUnauthorized", + "type": "error" + }, { "anonymous": false, "inputs": [ @@ -696,29 +809,116 @@ "type": "function" } ], - "transactionHash": "0x093a7750490af75118453207403059a2d488c80ecb717ad1a700ce5054b94415", + "transactionHash": "0x4fe58ac15ac894d1830b577da8002ab437aba751fd649e0466cc49294916dd24", "receipt": { "to": null, "from": "0x968D0Cd7343f711216817E617d3f92a23dC91c07", - "contractAddress": "0x99eb65715BD3A13895f0AAa669F36524c050DC03", + "contractAddress": "0xa7E978bD77b1B64D100eC0a62898395cb4B47a56", "transactionIndex": 0, - "gasUsed": "2119207", + "gasUsed": "1741402", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xfbf1fc87e855712266fd372cb21ecebf6458d46c08408e2ab78470bb42e0d1df", - "transactionHash": "0x093a7750490af75118453207403059a2d488c80ecb717ad1a700ce5054b94415", + "blockHash": "0x767997c534643e1402838ee4808de00a325423605694e47d6a54c2500f373098", + "transactionHash": "0x4fe58ac15ac894d1830b577da8002ab437aba751fd649e0466cc49294916dd24", "logs": [], - "blockNumber": 16816861, - "cumulativeGasUsed": "2119207", + "blockNumber": 19351156, + "cumulativeGasUsed": "1741402", "status": 1, "byzantium": true }, "args": [], - "numDeployments": 5, - "solcInputHash": "85b953b22882c536a643bf4b61b3153b", - "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"numerator\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"denominator\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousNumerator\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousDenominator\",\"type\":\"uint256\"}],\"name\":\"ThresholdUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"governor\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"bridgeVoter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"weight\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"addedBlock\",\"type\":\"uint256\"}],\"indexed\":false,\"internalType\":\"struct IRoninTrustedOrganization.TrustedOrganization[]\",\"name\":\"orgs\",\"type\":\"tuple[]\"}],\"name\":\"TrustedOrganizationsAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"orgs\",\"type\":\"address[]\"}],\"name\":\"TrustedOrganizationsRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"governor\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"bridgeVoter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"weight\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"addedBlock\",\"type\":\"uint256\"}],\"indexed\":false,\"internalType\":\"struct IRoninTrustedOrganization.TrustedOrganization[]\",\"name\":\"orgs\",\"type\":\"tuple[]\"}],\"name\":\"TrustedOrganizationsUpdated\",\"type\":\"event\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"governor\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"bridgeVoter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"weight\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"addedBlock\",\"type\":\"uint256\"}],\"internalType\":\"struct IRoninTrustedOrganization.TrustedOrganization[]\",\"name\":\"_list\",\"type\":\"tuple[]\"}],\"name\":\"addTrustedOrganizations\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_voteWeight\",\"type\":\"uint256\"}],\"name\":\"checkThreshold\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"countTrustedOrganizations\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllTrustedOrganizations\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"governor\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"bridgeVoter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"weight\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"addedBlock\",\"type\":\"uint256\"}],\"internalType\":\"struct IRoninTrustedOrganization.TrustedOrganization[]\",\"name\":\"_list\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"getBridgeVoterWeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_list\",\"type\":\"address[]\"}],\"name\":\"getBridgeVoterWeights\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_res\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"}],\"name\":\"getConsensusWeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_list\",\"type\":\"address[]\"}],\"name\":\"getConsensusWeights\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_res\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_governor\",\"type\":\"address\"}],\"name\":\"getGovernorWeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_list\",\"type\":\"address[]\"}],\"name\":\"getGovernorWeights\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_res\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"num_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"denom_\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"}],\"name\":\"getTrustedOrganization\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"governor\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"bridgeVoter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"weight\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"addedBlock\",\"type\":\"uint256\"}],\"internalType\":\"struct IRoninTrustedOrganization.TrustedOrganization\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_idx\",\"type\":\"uint256\"}],\"name\":\"getTrustedOrganizationAt\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"governor\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"bridgeVoter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"weight\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"addedBlock\",\"type\":\"uint256\"}],\"internalType\":\"struct IRoninTrustedOrganization.TrustedOrganization\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"governor\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"bridgeVoter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"weight\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"addedBlock\",\"type\":\"uint256\"}],\"internalType\":\"struct IRoninTrustedOrganization.TrustedOrganization[]\",\"name\":\"_trustedOrgs\",\"type\":\"tuple[]\"},{\"internalType\":\"uint256\",\"name\":\"__num\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"__denom\",\"type\":\"uint256\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minimumVoteWeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_list\",\"type\":\"address[]\"}],\"name\":\"removeTrustedOrganizations\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_numerator\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_denominator\",\"type\":\"uint256\"}],\"name\":\"setThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_list\",\"type\":\"address[]\"}],\"name\":\"sumBridgeVoterWeights\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_res\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_list\",\"type\":\"address[]\"}],\"name\":\"sumConsensusWeights\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_res\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_list\",\"type\":\"address[]\"}],\"name\":\"sumGovernorWeights\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_res\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalWeights\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"governor\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"bridgeVoter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"weight\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"addedBlock\",\"type\":\"uint256\"}],\"internalType\":\"struct IRoninTrustedOrganization.TrustedOrganization[]\",\"name\":\"_list\",\"type\":\"tuple[]\"}],\"name\":\"updateTrustedOrganizations\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"addTrustedOrganizations((address,address,address,uint256,uint256)[])\":{\"details\":\"Adds a list of addresses into the trusted organization. Requirements: - The weights should larger than 0. - The method caller is admin. - The field `addedBlock` should be blank. Emits the event `TrustedOrganizationAdded` once an organization is added.\"},\"checkThreshold(uint256)\":{\"details\":\"Checks whether the `_voteWeight` passes the threshold.\"},\"countTrustedOrganizations()\":{\"details\":\"Returns the number of trusted organizations.\"},\"getAllTrustedOrganizations()\":{\"details\":\"Returns all of the trusted organizations.\"},\"getBridgeVoterWeight(address)\":{\"details\":\"Returns the weight of a bridge voter.\"},\"getBridgeVoterWeights(address[])\":{\"details\":\"Returns the weights of a list of bridge voter addresses.\"},\"getConsensusWeight(address)\":{\"details\":\"Returns the weight of a consensus.\"},\"getConsensusWeights(address[])\":{\"details\":\"Returns the weights of a list of consensus addresses.\"},\"getGovernorWeight(address)\":{\"details\":\"Returns the weight of a governor.\"},\"getGovernorWeights(address[])\":{\"details\":\"Returns the weights of a list of governor addresses.\"},\"getThreshold()\":{\"details\":\"Returns the threshold.\"},\"getTrustedOrganization(address)\":{\"details\":\"Returns the trusted organization by consensus address. Reverts once the consensus address is non-existent.\"},\"getTrustedOrganizationAt(uint256)\":{\"details\":\"Returns the trusted organization at `_index`.\"},\"initialize((address,address,address,uint256,uint256)[],uint256,uint256)\":{\"details\":\"Initializes the contract storage.\"},\"minimumVoteWeight()\":{\"details\":\"Returns the minimum vote weight to pass the threshold.\"},\"removeTrustedOrganizations(address[])\":{\"details\":\"Removes a list of addresses from the trusted organization. Requirements: - The method caller is admin. Emits the event `TrustedOrganizationRemoved` once an organization is removed.\",\"params\":{\"_consensusAddrs\":\"The list of consensus addresses linked to corresponding trusted organization that to be removed.\"}},\"setThreshold(uint256,uint256)\":{\"details\":\"Sets the threshold. Requirements: - The method caller is admin. Emits the `ThresholdUpdated` event.\"},\"sumBridgeVoterWeights(address[])\":{\"details\":\"Returns total weights of the bridge voter list.\"},\"sumConsensusWeights(address[])\":{\"details\":\"Returns total weights of the consensus list.\"},\"sumGovernorWeights(address[])\":{\"details\":\"Returns total weights of the governor list.\"},\"totalWeights()\":{\"details\":\"Returns total weights.\"},\"updateTrustedOrganizations((address,address,address,uint256,uint256)[])\":{\"details\":\"Updates weights for a list of existent trusted organization. Requirements: - The weights should larger than 0. - The method caller is admin. Emits the `TrustedOrganizationUpdated` event.\"}},\"stateVariables\":{\"_addedBlock\":{\"details\":\"Mapping from consensus address => added block\"},\"_bridgeVoterList\":{\"details\":\"Bridge voters array\"},\"_bridgeVoterWeight\":{\"details\":\"Mapping from bridge voter address => weight\"},\"_consensusList\":{\"details\":\"Consensus array\"},\"_consensusWeight\":{\"details\":\"Mapping from consensus address => weight\"},\"_governorList\":{\"details\":\"Governors array\"},\"_governorWeight\":{\"details\":\"Mapping from governor address => weight\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/multi-chains/RoninTrustedOrganization.sol\":\"RoninTrustedOrganization\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/Address.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\\n * initialization step. This is essential to configure modules that are added through upgrades and that require\\n * initialization.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2a21b14ff90012878752f230d3ffd5c3405e5938d06c97a7d89c0a64561d0d66\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd6153ce99bcdcce22b124f755e72553295be6abcd63804cfdffceb188b8bef10\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n bytes16 private constant _HEX_SYMBOLS = \\\"0123456789abcdef\\\";\\n uint8 private constant _ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n // Inspired by OraclizeAPI's implementation - MIT licence\\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\\n\\n if (value == 0) {\\n return \\\"0\\\";\\n }\\n uint256 temp = value;\\n uint256 digits;\\n while (temp != 0) {\\n digits++;\\n temp /= 10;\\n }\\n bytes memory buffer = new bytes(digits);\\n while (value != 0) {\\n digits -= 1;\\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\\n value /= 10;\\n }\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n if (value == 0) {\\n return \\\"0x00\\\";\\n }\\n uint256 temp = value;\\n uint256 length = 0;\\n while (temp != 0) {\\n length++;\\n temp >>= 8;\\n }\\n return toHexString(value, length);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\\n }\\n}\\n\",\"keccak256\":\"0xaf159a8b1923ad2a26d516089bceca9bdeaeacd04be50983ea00ba63070f08a3\",\"license\":\"MIT\"},\"contracts/extensions/collections/HasProxyAdmin.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/StorageSlot.sol\\\";\\n\\nabstract contract HasProxyAdmin {\\n // bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n modifier onlyAdmin() {\\n require(msg.sender == _getAdmin(), \\\"HasProxyAdmin: unauthorized sender\\\");\\n _;\\n }\\n\\n /**\\n * @dev Returns proxy admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n}\\n\",\"keccak256\":\"0x0c2fcf25290180e8cd733691b113464cdde671dc019e6c343e9eb3e16c6ca24a\",\"license\":\"MIT\"},\"contracts/interfaces/IQuorum.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\ninterface IQuorum {\\n /// @dev Emitted when the threshold is updated\\n event ThresholdUpdated(\\n uint256 indexed nonce,\\n uint256 indexed numerator,\\n uint256 indexed denominator,\\n uint256 previousNumerator,\\n uint256 previousDenominator\\n );\\n\\n /**\\n * @dev Returns the threshold.\\n */\\n function getThreshold() external view returns (uint256 _num, uint256 _denom);\\n\\n /**\\n * @dev Checks whether the `_voteWeight` passes the threshold.\\n */\\n function checkThreshold(uint256 _voteWeight) external view returns (bool);\\n\\n /**\\n * @dev Returns the minimum vote weight to pass the threshold.\\n */\\n function minimumVoteWeight() external view returns (uint256);\\n\\n /**\\n * @dev Sets the threshold.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the `ThresholdUpdated` event.\\n *\\n */\\n function setThreshold(uint256 _numerator, uint256 _denominator)\\n external\\n returns (uint256 _previousNum, uint256 _previousDenom);\\n}\\n\",\"keccak256\":\"0x10f3b360430e6d03773c9959f54cbed6fb0346069645c05b05ef50cfb19f3753\",\"license\":\"MIT\"},\"contracts/interfaces/IRoninTrustedOrganization.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IQuorum.sol\\\";\\n\\ninterface IRoninTrustedOrganization is IQuorum {\\n struct TrustedOrganization {\\n // Address of the validator that produces block, e.g. block.coinbase. This is so-called validator address.\\n address consensusAddr;\\n // Address to voting proposal\\n address governor;\\n // Address to voting bridge operators\\n address bridgeVoter;\\n // Its Weight\\n uint256 weight;\\n // The block that the organization was added\\n uint256 addedBlock;\\n }\\n\\n /// @dev Emitted when the trusted organization is added.\\n event TrustedOrganizationsAdded(TrustedOrganization[] orgs);\\n /// @dev Emitted when the trusted organization is updated.\\n event TrustedOrganizationsUpdated(TrustedOrganization[] orgs);\\n /// @dev Emitted when the trusted organization is removed.\\n event TrustedOrganizationsRemoved(address[] orgs);\\n\\n /**\\n * @dev Adds a list of addresses into the trusted organization.\\n *\\n * Requirements:\\n * - The weights should larger than 0.\\n * - The method caller is admin.\\n * - The field `addedBlock` should be blank.\\n *\\n * Emits the event `TrustedOrganizationAdded` once an organization is added.\\n *\\n */\\n function addTrustedOrganizations(TrustedOrganization[] calldata) external;\\n\\n /**\\n * @dev Updates weights for a list of existent trusted organization.\\n *\\n * Requirements:\\n * - The weights should larger than 0.\\n * - The method caller is admin.\\n *\\n * Emits the `TrustedOrganizationUpdated` event.\\n *\\n */\\n function updateTrustedOrganizations(TrustedOrganization[] calldata _list) external;\\n\\n /**\\n * @dev Removes a list of addresses from the trusted organization.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `TrustedOrganizationRemoved` once an organization is removed.\\n *\\n * @param _consensusAddrs The list of consensus addresses linked to corresponding trusted organization that to be removed.\\n */\\n function removeTrustedOrganizations(address[] calldata _consensusAddrs) external;\\n\\n /**\\n * @dev Returns total weights.\\n */\\n function totalWeights() external view returns (uint256);\\n\\n /**\\n * @dev Returns the weight of a consensus.\\n */\\n function getConsensusWeight(address _consensusAddr) external view returns (uint256);\\n\\n /**\\n * @dev Returns the weight of a governor.\\n */\\n function getGovernorWeight(address _governor) external view returns (uint256);\\n\\n /**\\n * @dev Returns the weight of a bridge voter.\\n */\\n function getBridgeVoterWeight(address _addr) external view returns (uint256);\\n\\n /**\\n * @dev Returns the weights of a list of consensus addresses.\\n */\\n function getConsensusWeights(address[] calldata _list) external view returns (uint256[] memory);\\n\\n /**\\n * @dev Returns the weights of a list of governor addresses.\\n */\\n function getGovernorWeights(address[] calldata _list) external view returns (uint256[] memory);\\n\\n /**\\n * @dev Returns the weights of a list of bridge voter addresses.\\n */\\n function getBridgeVoterWeights(address[] calldata _list) external view returns (uint256[] memory);\\n\\n /**\\n * @dev Returns total weights of the consensus list.\\n */\\n function sumConsensusWeights(address[] calldata _list) external view returns (uint256 _res);\\n\\n /**\\n * @dev Returns total weights of the governor list.\\n */\\n function sumGovernorWeights(address[] calldata _list) external view returns (uint256 _res);\\n\\n /**\\n * @dev Returns total weights of the bridge voter list.\\n */\\n function sumBridgeVoterWeights(address[] calldata _list) external view returns (uint256 _res);\\n\\n /**\\n * @dev Returns the trusted organization at `_index`.\\n */\\n function getTrustedOrganizationAt(uint256 _index) external view returns (TrustedOrganization memory);\\n\\n /**\\n * @dev Returns the number of trusted organizations.\\n */\\n function countTrustedOrganizations() external view returns (uint256);\\n\\n /**\\n * @dev Returns all of the trusted organizations.\\n */\\n function getAllTrustedOrganizations() external view returns (TrustedOrganization[] memory);\\n\\n /**\\n * @dev Returns the trusted organization by consensus address.\\n *\\n * Reverts once the consensus address is non-existent.\\n */\\n function getTrustedOrganization(address _consensusAddr) external view returns (TrustedOrganization memory);\\n}\\n\",\"keccak256\":\"0x1edb7a3f5d340e7efc141cb8d94c5499954dec869f026d3998ad92cbc714d604\",\"license\":\"MIT\"},\"contracts/libraries/AddressArrayUtils.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\n\\npragma solidity ^0.8.0;\\n\\nlibrary AddressArrayUtils {\\n /**\\n * @dev Returns whether or not there's a duplicate. Runs in O(n^2).\\n * @param A Array to search\\n * @return Returns true if duplicate, false otherwise\\n */\\n function hasDuplicate(address[] memory A) internal pure returns (bool) {\\n if (A.length == 0) {\\n return false;\\n }\\n for (uint256 i = 0; i < A.length - 1; i++) {\\n for (uint256 j = i + 1; j < A.length; j++) {\\n if (A[i] == A[j]) {\\n return true;\\n }\\n }\\n }\\n return false;\\n }\\n\\n /**\\n * @dev Returns whether two arrays of addresses are equal or not.\\n */\\n function isEqual(address[] memory _this, address[] memory _other) internal pure returns (bool) {\\n bytes32 _thisHash;\\n bytes32 _otherHash;\\n\\n assembly {\\n _thisHash := keccak256(add(_this, 32), mul(mload(_this), 32))\\n _otherHash := keccak256(add(_other, 32), mul(mload(_other), 32))\\n }\\n\\n return _thisHash == _otherHash;\\n }\\n}\\n\",\"keccak256\":\"0xea4ac2b0783926a0e6ae257bc069fa37ea864ce77bfb25dd327d4727a38ad0ea\",\"license\":\"UNLICENSED\"},\"contracts/multi-chains/RoninTrustedOrganization.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/utils/Strings.sol\\\";\\nimport \\\"@openzeppelin/contracts/proxy/utils/Initializable.sol\\\";\\nimport \\\"../libraries/AddressArrayUtils.sol\\\";\\nimport \\\"../interfaces/IRoninTrustedOrganization.sol\\\";\\nimport \\\"../extensions/collections/HasProxyAdmin.sol\\\";\\n\\ncontract RoninTrustedOrganization is IRoninTrustedOrganization, HasProxyAdmin, Initializable {\\n uint256 internal _num;\\n uint256 internal _denom;\\n uint256 internal _totalWeight;\\n uint256 internal _nonce;\\n\\n /// @dev Mapping from consensus address => weight\\n mapping(address => uint256) internal _consensusWeight;\\n /// @dev Mapping from governor address => weight\\n mapping(address => uint256) internal _governorWeight;\\n /// @dev Mapping from bridge voter address => weight\\n mapping(address => uint256) internal _bridgeVoterWeight;\\n\\n /// @dev Mapping from consensus address => added block\\n mapping(address => uint256) internal _addedBlock;\\n\\n /// @dev Consensus array\\n address[] internal _consensusList;\\n /// @dev Governors array\\n address[] internal _governorList;\\n /// @dev Bridge voters array\\n address[] internal _bridgeVoterList;\\n\\n /**\\n * @dev Initializes the contract storage.\\n */\\n function initialize(\\n TrustedOrganization[] calldata _trustedOrgs,\\n uint256 __num,\\n uint256 __denom\\n ) external initializer {\\n if (_trustedOrgs.length > 0) {\\n _addTrustedOrganizations(_trustedOrgs);\\n }\\n _setThreshold(__num, __denom);\\n }\\n\\n /**\\n * @inheritdoc IQuorum\\n */\\n function getThreshold() external view virtual returns (uint256 num_, uint256 denom_) {\\n return (_num, _denom);\\n }\\n\\n /**\\n * @inheritdoc IQuorum\\n */\\n function checkThreshold(uint256 _voteWeight) external view virtual returns (bool) {\\n return _voteWeight * _denom >= _num * _totalWeight;\\n }\\n\\n /**\\n * @inheritdoc IQuorum\\n */\\n function minimumVoteWeight() external view virtual returns (uint256) {\\n return (_num * _totalWeight + _denom - 1) / _denom;\\n }\\n\\n /**\\n * @inheritdoc IQuorum\\n */\\n function setThreshold(uint256 _numerator, uint256 _denominator)\\n external\\n override\\n onlyAdmin\\n returns (uint256, uint256)\\n {\\n return _setThreshold(_numerator, _denominator);\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function addTrustedOrganizations(TrustedOrganization[] calldata _list) external override onlyAdmin {\\n _addTrustedOrganizations(_list);\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function updateTrustedOrganizations(TrustedOrganization[] calldata _list) external override onlyAdmin {\\n require(_list.length > 0, \\\"RoninTrustedOrganization: invalid array length\\\");\\n for (uint256 _i; _i < _list.length; _i++) {\\n _updateTrustedOrganization(_list[_i]);\\n }\\n emit TrustedOrganizationsUpdated(_list);\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function removeTrustedOrganizations(address[] calldata _list) external override onlyAdmin {\\n require(_list.length > 0, \\\"RoninTrustedOrganization: invalid array length\\\");\\n for (uint _i = 0; _i < _list.length; _i++) {\\n _removeTrustedOrganization(_list[_i]);\\n }\\n emit TrustedOrganizationsRemoved(_list);\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function totalWeights() external view virtual returns (uint256) {\\n return _totalWeight;\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function getConsensusWeight(address _consensusAddr) external view returns (uint256) {\\n return _consensusWeight[_consensusAddr];\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function getGovernorWeight(address _governor) external view returns (uint256) {\\n return _governorWeight[_governor];\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function getBridgeVoterWeight(address _addr) external view returns (uint256) {\\n return _bridgeVoterWeight[_addr];\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function getConsensusWeights(address[] calldata _list) external view returns (uint256[] memory _res) {\\n _res = new uint256[](_list.length);\\n for (uint _i = 0; _i < _res.length; _i++) {\\n _res[_i] = _consensusWeight[_list[_i]];\\n }\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function getGovernorWeights(address[] calldata _list) external view returns (uint256[] memory _res) {\\n _res = new uint256[](_list.length);\\n for (uint _i = 0; _i < _res.length; _i++) {\\n _res[_i] = _governorWeight[_list[_i]];\\n }\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function getBridgeVoterWeights(address[] calldata _list) external view returns (uint256[] memory _res) {\\n _res = new uint256[](_list.length);\\n for (uint _i = 0; _i < _res.length; _i++) {\\n _res[_i] = _bridgeVoterWeight[_list[_i]];\\n }\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function sumConsensusWeights(address[] calldata _list) external view returns (uint256 _res) {\\n for (uint _i = 0; _i < _list.length; _i++) {\\n _res += _consensusWeight[_list[_i]];\\n }\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function sumGovernorWeights(address[] calldata _list) external view returns (uint256 _res) {\\n for (uint _i = 0; _i < _list.length; _i++) {\\n _res += _governorWeight[_list[_i]];\\n }\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function sumBridgeVoterWeights(address[] calldata _list) external view returns (uint256 _res) {\\n for (uint _i = 0; _i < _list.length; _i++) {\\n _res += _bridgeVoterWeight[_list[_i]];\\n }\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function countTrustedOrganizations() external view override returns (uint256) {\\n return _consensusList.length;\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function getAllTrustedOrganizations() external view override returns (TrustedOrganization[] memory _list) {\\n _list = new TrustedOrganization[](_consensusList.length);\\n address _addr;\\n for (uint256 _i; _i < _list.length; _i++) {\\n _addr = _consensusList[_i];\\n _list[_i].consensusAddr = _addr;\\n _list[_i].governor = _governorList[_i];\\n _list[_i].bridgeVoter = _bridgeVoterList[_i];\\n _list[_i].weight = _consensusWeight[_addr];\\n }\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function getTrustedOrganization(address _consensusAddr) external view returns (TrustedOrganization memory) {\\n for (uint _i = 0; _i < _consensusList.length; _i++) {\\n if (_consensusList[_i] == _consensusAddr) {\\n return getTrustedOrganizationAt(_i);\\n }\\n }\\n revert(\\\"RoninTrustedOrganization: query for non-existent consensus address\\\");\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function getTrustedOrganizationAt(uint256 _idx) public view override returns (TrustedOrganization memory) {\\n address _addr = _consensusList[_idx];\\n return\\n TrustedOrganization(\\n _addr,\\n _governorList[_idx],\\n _bridgeVoterList[_idx],\\n _consensusWeight[_addr],\\n _addedBlock[_addr]\\n );\\n }\\n\\n /**\\n * @dev Adds a list of trusted organizations.\\n */\\n function _addTrustedOrganizations(TrustedOrganization[] calldata _list) internal virtual {\\n for (uint256 _i; _i < _list.length; _i++) {\\n _addTrustedOrganization(_list[_i]);\\n }\\n emit TrustedOrganizationsAdded(_list);\\n }\\n\\n /**\\n * @dev Adds a trusted organization.\\n *\\n * Requirements:\\n * - The weight is larger than 0.\\n * - The consensus address is not added.\\n * - The govenor address is not added.\\n * - The bridge voter address is not added.\\n *\\n */\\n function _addTrustedOrganization(TrustedOrganization memory _v) internal virtual {\\n require(_v.addedBlock == 0, \\\"RoninTrustedOrganization: invalid request\\\");\\n _sanityCheckTrustedOrganizationData(_v);\\n\\n if (_consensusWeight[_v.consensusAddr] > 0) {\\n revert(\\n string(\\n abi.encodePacked(\\n \\\"RoninTrustedOrganization: consensus address \\\",\\n Strings.toHexString(uint160(_v.consensusAddr), 20),\\n \\\" is added already\\\"\\n )\\n )\\n );\\n }\\n\\n if (_governorWeight[_v.governor] > 0) {\\n revert(\\n string(\\n abi.encodePacked(\\n \\\"RoninTrustedOrganization: govenor address \\\",\\n Strings.toHexString(uint160(_v.governor), 20),\\n \\\" is added already\\\"\\n )\\n )\\n );\\n }\\n\\n if (_bridgeVoterWeight[_v.bridgeVoter] > 0) {\\n revert(\\n string(\\n abi.encodePacked(\\n \\\"RoninTrustedOrganization: bridge voter address \\\",\\n Strings.toHexString(uint160(_v.bridgeVoter), 20),\\n \\\" is added already\\\"\\n )\\n )\\n );\\n }\\n\\n _consensusList.push(_v.consensusAddr);\\n _consensusWeight[_v.consensusAddr] = _v.weight;\\n\\n _governorList.push(_v.governor);\\n _governorWeight[_v.governor] = _v.weight;\\n\\n _bridgeVoterList.push(_v.bridgeVoter);\\n _bridgeVoterWeight[_v.bridgeVoter] = _v.weight;\\n\\n _addedBlock[_v.consensusAddr] = block.number;\\n\\n _totalWeight += _v.weight;\\n }\\n\\n /**\\n * @dev Updates a trusted organization.\\n *\\n * Requirements:\\n * - The weight is larger than 0.\\n * - The consensus address is already added.\\n *\\n */\\n function _updateTrustedOrganization(TrustedOrganization memory _v) internal virtual {\\n _sanityCheckTrustedOrganizationData(_v);\\n\\n uint256 _weight = _consensusWeight[_v.consensusAddr];\\n if (_weight == 0) {\\n revert(\\n string(\\n abi.encodePacked(\\n \\\"RoninTrustedOrganization: consensus address \\\",\\n Strings.toHexString(uint160(_v.consensusAddr), 20),\\n \\\" is not added\\\"\\n )\\n )\\n );\\n }\\n\\n uint256 _count = _consensusList.length;\\n for (uint256 _i = 0; _i < _count; _i++) {\\n if (_consensusList[_i] == _v.consensusAddr) {\\n _totalWeight -= _weight;\\n _totalWeight += _v.weight;\\n\\n if (_governorList[_i] != _v.governor) {\\n require(_governorWeight[_v.governor] == 0, \\\"RoninTrustedOrganization: query for duplicated governor\\\");\\n delete _governorWeight[_governorList[_i]];\\n _governorList[_i] = _v.governor;\\n }\\n\\n if (_bridgeVoterList[_i] != _v.bridgeVoter) {\\n require(\\n _bridgeVoterWeight[_v.bridgeVoter] == 0,\\n \\\"RoninTrustedOrganization: query for duplicated bridge voter\\\"\\n );\\n delete _bridgeVoterWeight[_bridgeVoterList[_i]];\\n _bridgeVoterList[_i] = _v.bridgeVoter;\\n }\\n\\n _consensusWeight[_v.consensusAddr] = _v.weight;\\n _governorWeight[_v.governor] = _v.weight;\\n _bridgeVoterWeight[_v.bridgeVoter] = _v.weight;\\n return;\\n }\\n }\\n }\\n\\n /**\\n * @dev Removes a trusted organization.\\n *\\n * Requirements:\\n * - The consensus address is added.\\n *\\n */\\n function _removeTrustedOrganization(address _addr) internal virtual {\\n uint256 _weight = _consensusWeight[_addr];\\n if (_weight == 0) {\\n revert(\\n string(\\n abi.encodePacked(\\n \\\"RoninTrustedOrganization: consensus address \\\",\\n Strings.toHexString(uint160(_addr), 20),\\n \\\" is not added\\\"\\n )\\n )\\n );\\n }\\n\\n uint256 _index;\\n uint256 _count = _consensusList.length;\\n for (uint256 _i = 0; _i < _count; _i++) {\\n if (_consensusList[_i] == _addr) {\\n _index = _i;\\n break;\\n }\\n }\\n\\n _totalWeight -= _weight;\\n\\n delete _addedBlock[_addr];\\n delete _consensusWeight[_addr];\\n _consensusList[_index] = _consensusList[_count - 1];\\n _consensusList.pop();\\n\\n delete _governorWeight[_governorList[_index]];\\n _governorList[_index] = _governorList[_count - 1];\\n _governorList.pop();\\n\\n delete _bridgeVoterWeight[_bridgeVoterList[_index]];\\n _bridgeVoterList[_index] = _bridgeVoterList[_count - 1];\\n _bridgeVoterList.pop();\\n }\\n\\n /**\\n * @dev Sets threshold and returns the old one.\\n *\\n * Emits the `ThresholdUpdated` event.\\n *\\n */\\n function _setThreshold(uint256 _numerator, uint256 _denominator)\\n internal\\n virtual\\n returns (uint256 _previousNum, uint256 _previousDenom)\\n {\\n require(_numerator <= _denominator, \\\"RoninTrustedOrganization: invalid threshold\\\");\\n _previousNum = _num;\\n _previousDenom = _denom;\\n _num = _numerator;\\n _denom = _denominator;\\n emit ThresholdUpdated(_nonce++, _numerator, _denominator, _previousNum, _previousDenom);\\n }\\n\\n /**\\n * @dev Hook that checks trusted organization's data. Reverts if the requirements are not met.\\n *\\n * Requirements:\\n * - The weight must be larger than 0.\\n * - The consensus address, governor address, and bridge voter address are different.\\n */\\n function _sanityCheckTrustedOrganizationData(TrustedOrganization memory _v) private pure {\\n require(_v.weight > 0, \\\"RoninTrustedOrganization: invalid weight\\\");\\n\\n address[] memory _addresses = new address[](3);\\n _addresses[0] = _v.consensusAddr;\\n _addresses[1] = _v.governor;\\n _addresses[2] = _v.bridgeVoter;\\n require(!AddressArrayUtils.hasDuplicate(_addresses), \\\"RoninTrustedOrganization: three addresses must be distinct\\\");\\n }\\n}\\n\",\"keccak256\":\"0xcdc122c399d55a5c7ff9bb96a2e7c99c99b3814edcd1a4e24c6e021bacd15c32\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x608060405234801561001057600080fd5b5061255e806100206000396000f3fe608060405234801561001057600080fd5b50600436106101125760003560e01c80630ed285df14610117578063150740051461012c57806341feed1c1461014a578063520fce621461018157806356241911146101a15780635f14a1c3146101ca57806370823625146101dd5780637c37103c146101f05780637de5dedd14610203578063926323d51461020b578063a85c7d6e14610213578063b505a07c14610226578063b9c3620914610239578063cacf8fb514610261578063cc7e6b3b14610269578063d78392f81461027c578063d9d5dadb146102a5578063dafae408146102b8578063db6693a2146102db578063e75235b8146102fb578063e8c0685e14610306578063f09267c214610319575b600080fd5b61012a610125366004611ddc565b61032c565b005b61013461037b565b6040516101419190611e5a565b60405180910390f35b610173610158366004611ec4565b6001600160a01b031660009081526005602052604090205490565b604051908152602001610141565b61019461018f366004611edf565b610550565b6040516101419190611f53565b6101736101af366004611ec4565b6001600160a01b031660009081526007602052604090205490565b6101736101d8366004611edf565b610624565b6101946101eb366004611edf565b610693565b61012a6101fe366004611f8b565b610760565b610173610889565b600354610173565b61012a610221366004611edf565b6108c6565b61012a610234366004611ddc565b6109a5565b61024c610247366004611fdb565b610a79565b60408051928352602083019190915201610141565b600954610173565b610194610277366004611edf565b610aca565b61017361028a366004611ec4565b6001600160a01b031660009081526006602052604090205490565b6101736102b3366004611edf565b610b97565b6102cb6102c6366004611ffd565b610c06565b6040519015158152602001610141565b6102ee6102e9366004611ec4565b610c2d565b6040516101419190612016565b60015460025461024c565b610173610314366004611edf565b610d03565b6102ee610327366004611ffd565b610d72565b610334610e55565b6001600160a01b0316336001600160a01b03161461036d5760405162461bcd60e51b815260040161036490612024565b60405180910390fd5b6103778282610e83565b5050565b6009546060906001600160401b0381111561039857610398612066565b6040519080825280602002602001820160405280156103d157816020015b6103be611d6a565b8152602001906001900390816103b65790505b5090506000805b825181101561054b57600981815481106103f4576103f461207c565b9060005260206000200160009054906101000a90046001600160a01b03169150818382815181106104275761042761207c565b60209081029190910101516001600160a01b039091169052600a8054829081106104535761045361207c565b9060005260206000200160009054906101000a90046001600160a01b03168382815181106104835761048361207c565b6020026020010151602001906001600160a01b031690816001600160a01b031681525050600b81815481106104ba576104ba61207c565b9060005260206000200160009054906101000a90046001600160a01b03168382815181106104ea576104ea61207c565b6020908102919091018101516001600160a01b03928316604091820152918416600090815260059091522054835184908390811061052a5761052a61207c565b60209081029190910101516060015280610543816120a8565b9150506103d8565b505090565b6060816001600160401b0381111561056a5761056a612066565b604051908082528060200260200182016040528015610593578160200160208202803683370190505b50905060005b815181101561061d57600560008585848181106105b8576105b861207c565b90506020020160208101906105cd9190611ec4565b6001600160a01b03166001600160a01b03168152602001908152602001600020548282815181106106005761060061207c565b602090810291909101015280610615816120a8565b915050610599565b5092915050565b6000805b8281101561061d57600660008585848181106106465761064661207c565b905060200201602081019061065b9190611ec4565b6001600160a01b0316815260208101919091526040016000205461067f90836120c1565b91508061068b816120a8565b915050610628565b6060816001600160401b038111156106ad576106ad612066565b6040519080825280602002602001820160405280156106d6578160200160208202803683370190505b50905060005b815181101561061d57600760008585848181106106fb576106fb61207c565b90506020020160208101906107109190611ec4565b6001600160a01b03166001600160a01b03168152602001908152602001600020548282815181106107435761074361207c565b602090810291909101015280610758816120a8565b9150506106dc565b600054610100900460ff16158080156107805750600054600160ff909116105b8061079a5750303b15801561079a575060005460ff166001145b6107fd5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610364565b6000805460ff191660011790558015610820576000805461ff0019166101001790555b8315610830576108308585610e83565b61083a8383610f02565b50508015610882576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b600060025460016002546003546001546108a391906120d4565b6108ad91906120c1565b6108b791906120eb565b6108c191906120fe565b905090565b6108ce610e55565b6001600160a01b0316336001600160a01b0316146108fe5760405162461bcd60e51b815260040161036490612024565b8061091b5760405162461bcd60e51b815260040161036490612120565b60005b818110156109675761095583838381811061093b5761093b61207c565b90506020020160208101906109509190611ec4565b610fc3565b8061095f816120a8565b91505061091e565b507f121945697ac30ee0fc67821492cb685c65f0ea4d7f1b710fde44d6e2237f43a7828260405161099992919061215c565b60405180910390a15050565b6109ad610e55565b6001600160a01b0316336001600160a01b0316146109dd5760405162461bcd60e51b815260040161036490612024565b806109fa5760405162461bcd60e51b815260040161036490612120565b60005b81811015610a4757610a35838383818110610a1a57610a1a61207c565b905060a00201803603810190610a3091906121a8565b611355565b80610a3f816120a8565b9150506109fd565b507fe887c8106c09d1770c0ef0bf8ca62c54766f18b07506801865501783376cbeda8282604051610999929190612238565b600080610a84610e55565b6001600160a01b0316336001600160a01b031614610ab45760405162461bcd60e51b815260040161036490612024565b610abe8484610f02565b915091505b9250929050565b6060816001600160401b03811115610ae457610ae4612066565b604051908082528060200260200182016040528015610b0d578160200160208202803683370190505b50905060005b815181101561061d5760066000858584818110610b3257610b3261207c565b9050602002016020810190610b479190611ec4565b6001600160a01b03166001600160a01b0316815260200190815260200160002054828281518110610b7a57610b7a61207c565b602090810291909101015280610b8f816120a8565b915050610b13565b6000805b8281101561061d5760076000858584818110610bb957610bb961207c565b9050602002016020810190610bce9190611ec4565b6001600160a01b03168152602081019190915260400160002054610bf290836120c1565b915080610bfe816120a8565b915050610b9b565b6000600354600154610c1891906120d4565b600254610c2590846120d4565b101592915050565b610c35611d6a565b60005b600954811015610c9b57826001600160a01b031660098281548110610c5f57610c5f61207c565b6000918252602090912001546001600160a01b031603610c8957610c8281610d72565b9392505050565b80610c93816120a8565b915050610c38565b5060405162461bcd60e51b8152602060048201526042602482015260008051602061250983398151915260448201527f666f72206e6f6e2d6578697374656e7420636f6e73656e737573206164647265606482015261737360f01b608482015260a401610364565b6000805b8281101561061d5760056000858584818110610d2557610d2561207c565b9050602002016020810190610d3a9190611ec4565b6001600160a01b03168152602081019190915260400160002054610d5e90836120c1565b915080610d6a816120a8565b915050610d07565b610d7a611d6a565b600060098381548110610d8f57610d8f61207c565b9060005260206000200160009054906101000a90046001600160a01b031690506040518060a00160405280826001600160a01b03168152602001600a8581548110610ddc57610ddc61207c565b600091825260209182902001546001600160a01b03168252600b8054929091019186908110610e0d57610e0d61207c565b60009182526020808320909101546001600160a01b03908116845294909416808252600585526040808320548487015290825260089094528390205492019190915292915050565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b031690565b60005b81811015610ed057610ebe838383818110610ea357610ea361207c565b905060a00201803603810190610eb991906121a8565b6116f3565b80610ec8816120a8565b915050610e86565b507fc753dbf7952c70ff6b9fa7b626403aa1d2230d97136b635bd5e85bec72bcca6c8282604051610999929190612238565b60008082841115610f575760405162461bcd60e51b815260206004820152602b60248201526000805160206124e983398151915260448201526a19081d1a1c995cda1bdb1960aa1b6064820152608401610364565b50506001805460028054928590558390556004805491929184918691906000610f7f836120a8565b9091555060408051868152602081018690527f976f8a9c5bdf8248dec172376d6e2b80a8e3df2f0328e381c6db8e1cf138c0f8910160405180910390a49250929050565b6001600160a01b0381166000908152600560205260408120549081900361102e57610ff8826001600160a01b03166014611968565b6040516020016110089190612323565b60408051601f198184030181529082905262461bcd60e51b82526103649160040161235e565b600954600090815b8181101561108f57846001600160a01b03166009828154811061105b5761105b61207c565b6000918252602090912001546001600160a01b03160361107d5780925061108f565b80611087816120a8565b915050611036565b5082600360008282546110a291906120eb565b90915550506001600160a01b0384166000908152600860209081526040808320839055600590915281205560096110da6001836120eb565b815481106110ea576110ea61207c565b600091825260209091200154600980546001600160a01b0390921691849081106111165761111661207c565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600980548061115557611155612391565b6001900381819060005260206000200160006101000a8154906001600160a01b030219169055905560066000600a84815481106111945761119461207c565b60009182526020808320909101546001600160a01b03168352820192909252604001812055600a6111c66001836120eb565b815481106111d6576111d661207c565b600091825260209091200154600a80546001600160a01b0390921691849081106112025761120261207c565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600a80548061124157611241612391565b6001900381819060005260206000200160006101000a8154906001600160a01b030219169055905560076000600b84815481106112805761128061207c565b60009182526020808320909101546001600160a01b03168352820192909252604001812055600b6112b26001836120eb565b815481106112c2576112c261207c565b600091825260209091200154600b80546001600160a01b0390921691849081106112ee576112ee61207c565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600b80548061132d5761132d612391565b600082815260209020810160001990810180546001600160a01b031916905501905550505050565b61135e81611b0c565b80516001600160a01b031660009081526005602052604081205490819003611396578151610ff8906001600160a01b03166014611968565b60095460005b818110156116ed5783600001516001600160a01b0316600982815481106113c5576113c561207c565b6000918252602090912001546001600160a01b0316036116db5782600360008282546113f191906120eb565b909155505060608401516003805460009061140d9084906120c1565b9250508190555083602001516001600160a01b0316600a82815481106114355761143561207c565b6000918252602090912001546001600160a01b03161461154d576020808501516001600160a01b0316600090815260069091526040902054156114c85760405162461bcd60e51b815260206004820152603760248201526000805160206125098339815191526044820152763337b910323ab83634b1b0ba32b21033b7bb32b93737b960491b6064820152608401610364565b60066000600a83815481106114df576114df61207c565b60009182526020808320909101546001600160a01b03168352828101939093526040909101812055840151600a80548390811061151e5761151e61207c565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b83604001516001600160a01b0316600b828154811061156e5761156e61207c565b6000918252602090912001546001600160a01b031614611689576040808501516001600160a01b0316600090815260076020522054156116025760405162461bcd60e51b815260206004820152603b602482015260008051602061250983398151915260448201527a3337b910323ab83634b1b0ba32b210313934b233b2903b37ba32b960291b6064820152608401610364565b60076000600b83815481106116195761161961207c565b60009182526020808320909101546001600160a01b031683528201929092526040908101822091909155840151600b80548390811061165a5761165a61207c565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b50505060608101805182516001600160a01b0390811660009081526005602090815260408083209490945584518187015184168352600682528483205593519483015190911681526007909252902055565b806116e5816120a8565b91505061139c565b50505050565b6080810151156117455760405162461bcd60e51b815260206004820152602960248201526000805160206124e983398151915260448201526819081c995c5d595cdd60ba1b6064820152608401610364565b61174e81611b0c565b80516001600160a01b031660009081526005602052604090205415611793578051611783906001600160a01b03166014611968565b60405160200161100891906123a7565b6020808201516001600160a01b0316600090815260069091526040902054156117de576117ce81602001516001600160a01b03166014611968565b60405160200161100891906123e6565b6040808201516001600160a01b0316600090815260076020522054156118265761181681604001516001600160a01b03166014611968565b6040516020016110089190612459565b8051600980546001808201835560009283527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af90910180546001600160a01b03199081166001600160a01b0395861617909155606085018051865186168552600560209081526040808720929092558088018051600a805480890182559089527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80180548716918a16919091179055835190518816875260068252828720558188018051600b8054978801815588527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db99096018054909516958816959095179093558151935186168552600783528085209390935585519094168352600890528120439055905160038054919290916119609084906120c1565b909155505050565b606060006119778360026120d4565b6119829060026120c1565b6001600160401b0381111561199957611999612066565b6040519080825280601f01601f1916602001820160405280156119c3576020820181803683370190505b509050600360fc1b816000815181106119de576119de61207c565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611a0d57611a0d61207c565b60200101906001600160f81b031916908160001a9053506000611a318460026120d4565b611a3c9060016120c1565b90505b6001811115611ab4576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611a7057611a7061207c565b1a60f81b828281518110611a8657611a8661207c565b60200101906001600160f81b031916908160001a90535060049490941c93611aad816124d1565b9050611a3f565b508315611b035760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610364565b90505b92915050565b6000816060015111611b5f5760405162461bcd60e51b815260206004820152602860248201526000805160206124e983398151915260448201526719081dd95a59da1d60c21b6064820152608401610364565b6040805160038082526080820190925260009160208201606080368337019050509050816000015181600081518110611b9a57611b9a61207c565b60200260200101906001600160a01b031690816001600160a01b031681525050816020015181600181518110611bd257611bd261207c565b60200260200101906001600160a01b031690816001600160a01b031681525050816040015181600281518110611c0a57611c0a61207c565b60200260200101906001600160a01b031690816001600160a01b031681525050611c3381611ca3565b156103775760405162461bcd60e51b815260206004820152603a60248201527f526f6e696e547275737465644f7267616e697a6174696f6e3a207468726565206044820152791859191c995cdcd95cc81b5d5cdd08189948191a5cdd1a5b98dd60321b6064820152608401610364565b60008151600003611cb657506000919050565b60005b60018351611cc791906120eb565b811015611d61576000611cdb8260016120c1565b90505b8351811015611d4e57838181518110611cf957611cf961207c565b60200260200101516001600160a01b0316848381518110611d1c57611d1c61207c565b60200260200101516001600160a01b031603611d3c575060019392505050565b80611d46816120a8565b915050611cde565b5080611d59816120a8565b915050611cb9565b50600092915050565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b60008083601f840112611daa57600080fd5b5081356001600160401b03811115611dc157600080fd5b60208301915083602060a083028501011115610ac357600080fd5b60008060208385031215611def57600080fd5b82356001600160401b03811115611e0557600080fd5b611e1185828601611d98565b90969095509350505050565b80516001600160a01b0390811683526020808301518216908401526040808301519091169083015260608082015190830152608090810151910152565b6020808252825182820181905260009190848201906040850190845b81811015611e9c57611e89838551611e1d565b9284019260a09290920191600101611e76565b50909695505050505050565b80356001600160a01b0381168114611ebf57600080fd5b919050565b600060208284031215611ed657600080fd5b610c8282611ea8565b60008060208385031215611ef257600080fd5b82356001600160401b0380821115611f0957600080fd5b818501915085601f830112611f1d57600080fd5b813581811115611f2c57600080fd5b8660208260051b8501011115611f4157600080fd5b60209290920196919550909350505050565b6020808252825182820181905260009190848201906040850190845b81811015611e9c57835183529284019291840191600101611f6f565b60008060008060608587031215611fa157600080fd5b84356001600160401b03811115611fb757600080fd5b611fc387828801611d98565b90989097506020870135966040013595509350505050565b60008060408385031215611fee57600080fd5b50508035926020909101359150565b60006020828403121561200f57600080fd5b5035919050565b60a08101611b068284611e1d565b60208082526022908201527f48617350726f787941646d696e3a20756e617574686f72697a65642073656e6460408201526132b960f11b606082015260800190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016120ba576120ba612092565b5060010190565b80820180821115611b0657611b06612092565b8082028115828204841417611b0657611b06612092565b81810381811115611b0657611b06612092565b60008261211b57634e487b7160e01b600052601260045260246000fd5b500490565b6020808252602e908201526000805160206124e983398151915260408201526d0c840c2e4e4c2f240d8cadccee8d60931b606082015260800190565b60208082528181018390526000908460408401835b8681101561219d576001600160a01b0361218a84611ea8565b1682529183019190830190600101612171565b509695505050505050565b600060a082840312156121ba57600080fd5b60405160a081016001600160401b03811182821017156121ea57634e487b7160e01b600052604160045260246000fd5b6040526121f683611ea8565b815261220460208401611ea8565b602082015261221560408401611ea8565b604082015260608301356060820152608083013560808201528091505092915050565b6020808252818101839052600090604080840186845b878110156122b4576001600160a01b038061226884611ea8565b16845280612277878501611ea8565b168685015280612288868501611ea8565b168486015250606082810135908401526080808301359084015260a0928301929091019060010161224e565b5090979650505050505050565b7f526f6e696e547275737465644f7267616e697a6174696f6e3a20636f6e73656e81526b039bab99030b2323932b9b9960a51b6020820152602c0190565b60005b8381101561231a578181015183820152602001612302565b50506000910152565b600061232e826122c1565b835161233e8183602088016122ff565b6c081a5cc81b9bdd081859191959609a1b9101908152600d019392505050565b602081526000825180602084015261237d8160408501602087016122ff565b601f01601f19169190910160400192915050565b634e487b7160e01b600052603160045260246000fd5b60006123b2826122c1565b83516123c28183602088016122ff565b7020697320616464656420616c726561647960781b91019081526011019392505050565b7f526f6e696e547275737465644f7267616e697a6174696f6e3a20676f76656e6f8152690391030b2323932b9b9960b51b60208201526000825161243181602a8501602087016122ff565b7020697320616464656420616c726561647960781b602a939091019283015250603b01919050565b7f526f6e696e547275737465644f7267616e697a6174696f6e3a2062726964676581526e0103b37ba32b91030b2323932b9b99608d1b6020820152600082516124a981602f8501602087016122ff565b7020697320616464656420616c726561647960781b602f939091019283015250604001919050565b6000816124e0576124e0612092565b50600019019056fe526f6e696e547275737465644f7267616e697a6174696f6e3a20696e76616c69526f6e696e547275737465644f7267616e697a6174696f6e3a20717565727920a2646970667358221220171fedbb4d0e07d0f093c403c3df05c9996d7e7a3d24de0b489d3201b599112464736f6c63430008110033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101125760003560e01c80630ed285df14610117578063150740051461012c57806341feed1c1461014a578063520fce621461018157806356241911146101a15780635f14a1c3146101ca57806370823625146101dd5780637c37103c146101f05780637de5dedd14610203578063926323d51461020b578063a85c7d6e14610213578063b505a07c14610226578063b9c3620914610239578063cacf8fb514610261578063cc7e6b3b14610269578063d78392f81461027c578063d9d5dadb146102a5578063dafae408146102b8578063db6693a2146102db578063e75235b8146102fb578063e8c0685e14610306578063f09267c214610319575b600080fd5b61012a610125366004611ddc565b61032c565b005b61013461037b565b6040516101419190611e5a565b60405180910390f35b610173610158366004611ec4565b6001600160a01b031660009081526005602052604090205490565b604051908152602001610141565b61019461018f366004611edf565b610550565b6040516101419190611f53565b6101736101af366004611ec4565b6001600160a01b031660009081526007602052604090205490565b6101736101d8366004611edf565b610624565b6101946101eb366004611edf565b610693565b61012a6101fe366004611f8b565b610760565b610173610889565b600354610173565b61012a610221366004611edf565b6108c6565b61012a610234366004611ddc565b6109a5565b61024c610247366004611fdb565b610a79565b60408051928352602083019190915201610141565b600954610173565b610194610277366004611edf565b610aca565b61017361028a366004611ec4565b6001600160a01b031660009081526006602052604090205490565b6101736102b3366004611edf565b610b97565b6102cb6102c6366004611ffd565b610c06565b6040519015158152602001610141565b6102ee6102e9366004611ec4565b610c2d565b6040516101419190612016565b60015460025461024c565b610173610314366004611edf565b610d03565b6102ee610327366004611ffd565b610d72565b610334610e55565b6001600160a01b0316336001600160a01b03161461036d5760405162461bcd60e51b815260040161036490612024565b60405180910390fd5b6103778282610e83565b5050565b6009546060906001600160401b0381111561039857610398612066565b6040519080825280602002602001820160405280156103d157816020015b6103be611d6a565b8152602001906001900390816103b65790505b5090506000805b825181101561054b57600981815481106103f4576103f461207c565b9060005260206000200160009054906101000a90046001600160a01b03169150818382815181106104275761042761207c565b60209081029190910101516001600160a01b039091169052600a8054829081106104535761045361207c565b9060005260206000200160009054906101000a90046001600160a01b03168382815181106104835761048361207c565b6020026020010151602001906001600160a01b031690816001600160a01b031681525050600b81815481106104ba576104ba61207c565b9060005260206000200160009054906101000a90046001600160a01b03168382815181106104ea576104ea61207c565b6020908102919091018101516001600160a01b03928316604091820152918416600090815260059091522054835184908390811061052a5761052a61207c565b60209081029190910101516060015280610543816120a8565b9150506103d8565b505090565b6060816001600160401b0381111561056a5761056a612066565b604051908082528060200260200182016040528015610593578160200160208202803683370190505b50905060005b815181101561061d57600560008585848181106105b8576105b861207c565b90506020020160208101906105cd9190611ec4565b6001600160a01b03166001600160a01b03168152602001908152602001600020548282815181106106005761060061207c565b602090810291909101015280610615816120a8565b915050610599565b5092915050565b6000805b8281101561061d57600660008585848181106106465761064661207c565b905060200201602081019061065b9190611ec4565b6001600160a01b0316815260208101919091526040016000205461067f90836120c1565b91508061068b816120a8565b915050610628565b6060816001600160401b038111156106ad576106ad612066565b6040519080825280602002602001820160405280156106d6578160200160208202803683370190505b50905060005b815181101561061d57600760008585848181106106fb576106fb61207c565b90506020020160208101906107109190611ec4565b6001600160a01b03166001600160a01b03168152602001908152602001600020548282815181106107435761074361207c565b602090810291909101015280610758816120a8565b9150506106dc565b600054610100900460ff16158080156107805750600054600160ff909116105b8061079a5750303b15801561079a575060005460ff166001145b6107fd5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610364565b6000805460ff191660011790558015610820576000805461ff0019166101001790555b8315610830576108308585610e83565b61083a8383610f02565b50508015610882576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b600060025460016002546003546001546108a391906120d4565b6108ad91906120c1565b6108b791906120eb565b6108c191906120fe565b905090565b6108ce610e55565b6001600160a01b0316336001600160a01b0316146108fe5760405162461bcd60e51b815260040161036490612024565b8061091b5760405162461bcd60e51b815260040161036490612120565b60005b818110156109675761095583838381811061093b5761093b61207c565b90506020020160208101906109509190611ec4565b610fc3565b8061095f816120a8565b91505061091e565b507f121945697ac30ee0fc67821492cb685c65f0ea4d7f1b710fde44d6e2237f43a7828260405161099992919061215c565b60405180910390a15050565b6109ad610e55565b6001600160a01b0316336001600160a01b0316146109dd5760405162461bcd60e51b815260040161036490612024565b806109fa5760405162461bcd60e51b815260040161036490612120565b60005b81811015610a4757610a35838383818110610a1a57610a1a61207c565b905060a00201803603810190610a3091906121a8565b611355565b80610a3f816120a8565b9150506109fd565b507fe887c8106c09d1770c0ef0bf8ca62c54766f18b07506801865501783376cbeda8282604051610999929190612238565b600080610a84610e55565b6001600160a01b0316336001600160a01b031614610ab45760405162461bcd60e51b815260040161036490612024565b610abe8484610f02565b915091505b9250929050565b6060816001600160401b03811115610ae457610ae4612066565b604051908082528060200260200182016040528015610b0d578160200160208202803683370190505b50905060005b815181101561061d5760066000858584818110610b3257610b3261207c565b9050602002016020810190610b479190611ec4565b6001600160a01b03166001600160a01b0316815260200190815260200160002054828281518110610b7a57610b7a61207c565b602090810291909101015280610b8f816120a8565b915050610b13565b6000805b8281101561061d5760076000858584818110610bb957610bb961207c565b9050602002016020810190610bce9190611ec4565b6001600160a01b03168152602081019190915260400160002054610bf290836120c1565b915080610bfe816120a8565b915050610b9b565b6000600354600154610c1891906120d4565b600254610c2590846120d4565b101592915050565b610c35611d6a565b60005b600954811015610c9b57826001600160a01b031660098281548110610c5f57610c5f61207c565b6000918252602090912001546001600160a01b031603610c8957610c8281610d72565b9392505050565b80610c93816120a8565b915050610c38565b5060405162461bcd60e51b8152602060048201526042602482015260008051602061250983398151915260448201527f666f72206e6f6e2d6578697374656e7420636f6e73656e737573206164647265606482015261737360f01b608482015260a401610364565b6000805b8281101561061d5760056000858584818110610d2557610d2561207c565b9050602002016020810190610d3a9190611ec4565b6001600160a01b03168152602081019190915260400160002054610d5e90836120c1565b915080610d6a816120a8565b915050610d07565b610d7a611d6a565b600060098381548110610d8f57610d8f61207c565b9060005260206000200160009054906101000a90046001600160a01b031690506040518060a00160405280826001600160a01b03168152602001600a8581548110610ddc57610ddc61207c565b600091825260209182902001546001600160a01b03168252600b8054929091019186908110610e0d57610e0d61207c565b60009182526020808320909101546001600160a01b03908116845294909416808252600585526040808320548487015290825260089094528390205492019190915292915050565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b031690565b60005b81811015610ed057610ebe838383818110610ea357610ea361207c565b905060a00201803603810190610eb991906121a8565b6116f3565b80610ec8816120a8565b915050610e86565b507fc753dbf7952c70ff6b9fa7b626403aa1d2230d97136b635bd5e85bec72bcca6c8282604051610999929190612238565b60008082841115610f575760405162461bcd60e51b815260206004820152602b60248201526000805160206124e983398151915260448201526a19081d1a1c995cda1bdb1960aa1b6064820152608401610364565b50506001805460028054928590558390556004805491929184918691906000610f7f836120a8565b9091555060408051868152602081018690527f976f8a9c5bdf8248dec172376d6e2b80a8e3df2f0328e381c6db8e1cf138c0f8910160405180910390a49250929050565b6001600160a01b0381166000908152600560205260408120549081900361102e57610ff8826001600160a01b03166014611968565b6040516020016110089190612323565b60408051601f198184030181529082905262461bcd60e51b82526103649160040161235e565b600954600090815b8181101561108f57846001600160a01b03166009828154811061105b5761105b61207c565b6000918252602090912001546001600160a01b03160361107d5780925061108f565b80611087816120a8565b915050611036565b5082600360008282546110a291906120eb565b90915550506001600160a01b0384166000908152600860209081526040808320839055600590915281205560096110da6001836120eb565b815481106110ea576110ea61207c565b600091825260209091200154600980546001600160a01b0390921691849081106111165761111661207c565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600980548061115557611155612391565b6001900381819060005260206000200160006101000a8154906001600160a01b030219169055905560066000600a84815481106111945761119461207c565b60009182526020808320909101546001600160a01b03168352820192909252604001812055600a6111c66001836120eb565b815481106111d6576111d661207c565b600091825260209091200154600a80546001600160a01b0390921691849081106112025761120261207c565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600a80548061124157611241612391565b6001900381819060005260206000200160006101000a8154906001600160a01b030219169055905560076000600b84815481106112805761128061207c565b60009182526020808320909101546001600160a01b03168352820192909252604001812055600b6112b26001836120eb565b815481106112c2576112c261207c565b600091825260209091200154600b80546001600160a01b0390921691849081106112ee576112ee61207c565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600b80548061132d5761132d612391565b600082815260209020810160001990810180546001600160a01b031916905501905550505050565b61135e81611b0c565b80516001600160a01b031660009081526005602052604081205490819003611396578151610ff8906001600160a01b03166014611968565b60095460005b818110156116ed5783600001516001600160a01b0316600982815481106113c5576113c561207c565b6000918252602090912001546001600160a01b0316036116db5782600360008282546113f191906120eb565b909155505060608401516003805460009061140d9084906120c1565b9250508190555083602001516001600160a01b0316600a82815481106114355761143561207c565b6000918252602090912001546001600160a01b03161461154d576020808501516001600160a01b0316600090815260069091526040902054156114c85760405162461bcd60e51b815260206004820152603760248201526000805160206125098339815191526044820152763337b910323ab83634b1b0ba32b21033b7bb32b93737b960491b6064820152608401610364565b60066000600a83815481106114df576114df61207c565b60009182526020808320909101546001600160a01b03168352828101939093526040909101812055840151600a80548390811061151e5761151e61207c565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b83604001516001600160a01b0316600b828154811061156e5761156e61207c565b6000918252602090912001546001600160a01b031614611689576040808501516001600160a01b0316600090815260076020522054156116025760405162461bcd60e51b815260206004820152603b602482015260008051602061250983398151915260448201527a3337b910323ab83634b1b0ba32b210313934b233b2903b37ba32b960291b6064820152608401610364565b60076000600b83815481106116195761161961207c565b60009182526020808320909101546001600160a01b031683528201929092526040908101822091909155840151600b80548390811061165a5761165a61207c565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b50505060608101805182516001600160a01b0390811660009081526005602090815260408083209490945584518187015184168352600682528483205593519483015190911681526007909252902055565b806116e5816120a8565b91505061139c565b50505050565b6080810151156117455760405162461bcd60e51b815260206004820152602960248201526000805160206124e983398151915260448201526819081c995c5d595cdd60ba1b6064820152608401610364565b61174e81611b0c565b80516001600160a01b031660009081526005602052604090205415611793578051611783906001600160a01b03166014611968565b60405160200161100891906123a7565b6020808201516001600160a01b0316600090815260069091526040902054156117de576117ce81602001516001600160a01b03166014611968565b60405160200161100891906123e6565b6040808201516001600160a01b0316600090815260076020522054156118265761181681604001516001600160a01b03166014611968565b6040516020016110089190612459565b8051600980546001808201835560009283527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af90910180546001600160a01b03199081166001600160a01b0395861617909155606085018051865186168552600560209081526040808720929092558088018051600a805480890182559089527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80180548716918a16919091179055835190518816875260068252828720558188018051600b8054978801815588527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db99096018054909516958816959095179093558151935186168552600783528085209390935585519094168352600890528120439055905160038054919290916119609084906120c1565b909155505050565b606060006119778360026120d4565b6119829060026120c1565b6001600160401b0381111561199957611999612066565b6040519080825280601f01601f1916602001820160405280156119c3576020820181803683370190505b509050600360fc1b816000815181106119de576119de61207c565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611a0d57611a0d61207c565b60200101906001600160f81b031916908160001a9053506000611a318460026120d4565b611a3c9060016120c1565b90505b6001811115611ab4576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611a7057611a7061207c565b1a60f81b828281518110611a8657611a8661207c565b60200101906001600160f81b031916908160001a90535060049490941c93611aad816124d1565b9050611a3f565b508315611b035760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610364565b90505b92915050565b6000816060015111611b5f5760405162461bcd60e51b815260206004820152602860248201526000805160206124e983398151915260448201526719081dd95a59da1d60c21b6064820152608401610364565b6040805160038082526080820190925260009160208201606080368337019050509050816000015181600081518110611b9a57611b9a61207c565b60200260200101906001600160a01b031690816001600160a01b031681525050816020015181600181518110611bd257611bd261207c565b60200260200101906001600160a01b031690816001600160a01b031681525050816040015181600281518110611c0a57611c0a61207c565b60200260200101906001600160a01b031690816001600160a01b031681525050611c3381611ca3565b156103775760405162461bcd60e51b815260206004820152603a60248201527f526f6e696e547275737465644f7267616e697a6174696f6e3a207468726565206044820152791859191c995cdcd95cc81b5d5cdd08189948191a5cdd1a5b98dd60321b6064820152608401610364565b60008151600003611cb657506000919050565b60005b60018351611cc791906120eb565b811015611d61576000611cdb8260016120c1565b90505b8351811015611d4e57838181518110611cf957611cf961207c565b60200260200101516001600160a01b0316848381518110611d1c57611d1c61207c565b60200260200101516001600160a01b031603611d3c575060019392505050565b80611d46816120a8565b915050611cde565b5080611d59816120a8565b915050611cb9565b50600092915050565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b60008083601f840112611daa57600080fd5b5081356001600160401b03811115611dc157600080fd5b60208301915083602060a083028501011115610ac357600080fd5b60008060208385031215611def57600080fd5b82356001600160401b03811115611e0557600080fd5b611e1185828601611d98565b90969095509350505050565b80516001600160a01b0390811683526020808301518216908401526040808301519091169083015260608082015190830152608090810151910152565b6020808252825182820181905260009190848201906040850190845b81811015611e9c57611e89838551611e1d565b9284019260a09290920191600101611e76565b50909695505050505050565b80356001600160a01b0381168114611ebf57600080fd5b919050565b600060208284031215611ed657600080fd5b610c8282611ea8565b60008060208385031215611ef257600080fd5b82356001600160401b0380821115611f0957600080fd5b818501915085601f830112611f1d57600080fd5b813581811115611f2c57600080fd5b8660208260051b8501011115611f4157600080fd5b60209290920196919550909350505050565b6020808252825182820181905260009190848201906040850190845b81811015611e9c57835183529284019291840191600101611f6f565b60008060008060608587031215611fa157600080fd5b84356001600160401b03811115611fb757600080fd5b611fc387828801611d98565b90989097506020870135966040013595509350505050565b60008060408385031215611fee57600080fd5b50508035926020909101359150565b60006020828403121561200f57600080fd5b5035919050565b60a08101611b068284611e1d565b60208082526022908201527f48617350726f787941646d696e3a20756e617574686f72697a65642073656e6460408201526132b960f11b606082015260800190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016120ba576120ba612092565b5060010190565b80820180821115611b0657611b06612092565b8082028115828204841417611b0657611b06612092565b81810381811115611b0657611b06612092565b60008261211b57634e487b7160e01b600052601260045260246000fd5b500490565b6020808252602e908201526000805160206124e983398151915260408201526d0c840c2e4e4c2f240d8cadccee8d60931b606082015260800190565b60208082528181018390526000908460408401835b8681101561219d576001600160a01b0361218a84611ea8565b1682529183019190830190600101612171565b509695505050505050565b600060a082840312156121ba57600080fd5b60405160a081016001600160401b03811182821017156121ea57634e487b7160e01b600052604160045260246000fd5b6040526121f683611ea8565b815261220460208401611ea8565b602082015261221560408401611ea8565b604082015260608301356060820152608083013560808201528091505092915050565b6020808252818101839052600090604080840186845b878110156122b4576001600160a01b038061226884611ea8565b16845280612277878501611ea8565b168685015280612288868501611ea8565b168486015250606082810135908401526080808301359084015260a0928301929091019060010161224e565b5090979650505050505050565b7f526f6e696e547275737465644f7267616e697a6174696f6e3a20636f6e73656e81526b039bab99030b2323932b9b9960a51b6020820152602c0190565b60005b8381101561231a578181015183820152602001612302565b50506000910152565b600061232e826122c1565b835161233e8183602088016122ff565b6c081a5cc81b9bdd081859191959609a1b9101908152600d019392505050565b602081526000825180602084015261237d8160408501602087016122ff565b601f01601f19169190910160400192915050565b634e487b7160e01b600052603160045260246000fd5b60006123b2826122c1565b83516123c28183602088016122ff565b7020697320616464656420616c726561647960781b91019081526011019392505050565b7f526f6e696e547275737465644f7267616e697a6174696f6e3a20676f76656e6f8152690391030b2323932b9b9960b51b60208201526000825161243181602a8501602087016122ff565b7020697320616464656420616c726561647960781b602a939091019283015250603b01919050565b7f526f6e696e547275737465644f7267616e697a6174696f6e3a2062726964676581526e0103b37ba32b91030b2323932b9b99608d1b6020820152600082516124a981602f8501602087016122ff565b7020697320616464656420616c726561647960781b602f939091019283015250604001919050565b6000816124e0576124e0612092565b50600019019056fe526f6e696e547275737465644f7267616e697a6174696f6e3a20696e76616c69526f6e696e547275737465644f7267616e697a6174696f6e3a20717565727920a2646970667358221220171fedbb4d0e07d0f093c403c3df05c9996d7e7a3d24de0b489d3201b599112464736f6c63430008110033", + "numDeployments": 6, + "solcInputHash": "95921af9e3b453fd5a2d5edf43163a69", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"voter\",\"type\":\"address\"}],\"name\":\"ErrBridgeVoterIsAlreadyAdded\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"ErrConsensusAddressIsAlreadyAdded\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"ErrConsensusAddressIsNotAdded\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"}],\"name\":\"ErrDuplicated\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrEmptyArray\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"ErrGovernorAddressIsAlreadyAdded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidRequest\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"}],\"name\":\"ErrInvalidThreshold\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"}],\"name\":\"ErrInvalidVoteWeight\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrQueryForDupplicated\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrQueryForNonExistentConsensusAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"},{\"internalType\":\"enum RoleAccess\",\"name\":\"expectedRole\",\"type\":\"uint8\"}],\"name\":\"ErrUnauthorized\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"numerator\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"denominator\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousNumerator\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousDenominator\",\"type\":\"uint256\"}],\"name\":\"ThresholdUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"governor\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"bridgeVoter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"weight\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"addedBlock\",\"type\":\"uint256\"}],\"indexed\":false,\"internalType\":\"struct IRoninTrustedOrganization.TrustedOrganization[]\",\"name\":\"orgs\",\"type\":\"tuple[]\"}],\"name\":\"TrustedOrganizationsAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"orgs\",\"type\":\"address[]\"}],\"name\":\"TrustedOrganizationsRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"governor\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"bridgeVoter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"weight\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"addedBlock\",\"type\":\"uint256\"}],\"indexed\":false,\"internalType\":\"struct IRoninTrustedOrganization.TrustedOrganization[]\",\"name\":\"orgs\",\"type\":\"tuple[]\"}],\"name\":\"TrustedOrganizationsUpdated\",\"type\":\"event\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"governor\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"bridgeVoter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"weight\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"addedBlock\",\"type\":\"uint256\"}],\"internalType\":\"struct IRoninTrustedOrganization.TrustedOrganization[]\",\"name\":\"_list\",\"type\":\"tuple[]\"}],\"name\":\"addTrustedOrganizations\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_voteWeight\",\"type\":\"uint256\"}],\"name\":\"checkThreshold\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"countTrustedOrganizations\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllTrustedOrganizations\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"governor\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"bridgeVoter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"weight\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"addedBlock\",\"type\":\"uint256\"}],\"internalType\":\"struct IRoninTrustedOrganization.TrustedOrganization[]\",\"name\":\"_list\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"getBridgeVoterWeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_list\",\"type\":\"address[]\"}],\"name\":\"getBridgeVoterWeights\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_res\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"}],\"name\":\"getConsensusWeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_list\",\"type\":\"address[]\"}],\"name\":\"getConsensusWeights\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_res\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_governor\",\"type\":\"address\"}],\"name\":\"getGovernorWeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_list\",\"type\":\"address[]\"}],\"name\":\"getGovernorWeights\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_res\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"num_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"denom_\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"}],\"name\":\"getTrustedOrganization\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"governor\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"bridgeVoter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"weight\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"addedBlock\",\"type\":\"uint256\"}],\"internalType\":\"struct IRoninTrustedOrganization.TrustedOrganization\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_idx\",\"type\":\"uint256\"}],\"name\":\"getTrustedOrganizationAt\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"governor\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"bridgeVoter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"weight\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"addedBlock\",\"type\":\"uint256\"}],\"internalType\":\"struct IRoninTrustedOrganization.TrustedOrganization\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"governor\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"bridgeVoter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"weight\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"addedBlock\",\"type\":\"uint256\"}],\"internalType\":\"struct IRoninTrustedOrganization.TrustedOrganization[]\",\"name\":\"_trustedOrgs\",\"type\":\"tuple[]\"},{\"internalType\":\"uint256\",\"name\":\"__num\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"__denom\",\"type\":\"uint256\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minimumVoteWeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_list\",\"type\":\"address[]\"}],\"name\":\"removeTrustedOrganizations\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_numerator\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_denominator\",\"type\":\"uint256\"}],\"name\":\"setThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_list\",\"type\":\"address[]\"}],\"name\":\"sumBridgeVoterWeights\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_res\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_list\",\"type\":\"address[]\"}],\"name\":\"sumConsensusWeights\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_res\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_list\",\"type\":\"address[]\"}],\"name\":\"sumGovernorWeights\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_res\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalWeights\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"governor\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"bridgeVoter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"weight\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"addedBlock\",\"type\":\"uint256\"}],\"internalType\":\"struct IRoninTrustedOrganization.TrustedOrganization[]\",\"name\":\"_list\",\"type\":\"tuple[]\"}],\"name\":\"updateTrustedOrganizations\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"errors\":{\"ErrBridgeVoterIsAlreadyAdded(address)\":[{\"details\":\"Error indicating that a bridge voter has already been added.\",\"params\":{\"voter\":\"The address of the bridge voter that is already added.\"}}],\"ErrConsensusAddressIsAlreadyAdded(address)\":[{\"details\":\"Error indicating that a consensus address is already added.\",\"params\":{\"addr\":\"The address of the consensus contract that is already added.\"}}],\"ErrConsensusAddressIsNotAdded(address)\":[{\"details\":\"Error indicating that a consensus address is not added.\",\"params\":{\"addr\":\"The address of the consensus contract that is not added.\"}}],\"ErrDuplicated(bytes4)\":[{\"details\":\"Error thrown when a duplicated element is detected in an array.\",\"params\":{\"msgSig\":\"The function signature that invoke the error.\"}}],\"ErrEmptyArray()\":[{\"details\":\"Error indicating that an array is empty when it should contain elements.\"}],\"ErrGovernorAddressIsAlreadyAdded(address)\":[{\"details\":\"Error indicating that a governor address has already been added.\",\"params\":{\"addr\":\"The address of the governor that is already added.\"}}],\"ErrInvalidRequest()\":[{\"details\":\"Error indicating that a request is invalid.\"}],\"ErrInvalidThreshold(bytes4)\":[{\"details\":\"Error indicating that the provided threshold is invalid for a specific function signature.\",\"params\":{\"msgSig\":\"The function signature (bytes4) that the invalid threshold applies to.\"}}],\"ErrInvalidVoteWeight(bytes4)\":[{\"details\":\"Error indicating that a vote weight is invalid for a specific function signature.\",\"params\":{\"msgSig\":\"The function signature (bytes4) that encountered an invalid vote weight.\"}}],\"ErrQueryForDupplicated()\":[{\"details\":\"Error indicating that a query for a duplicate entry was made.\"}],\"ErrQueryForNonExistentConsensusAddress()\":[{\"details\":\"Error indicating that a query was made for a non-existent consensus address.\"}],\"ErrUnauthorized(bytes4,uint8)\":[{\"details\":\"Error indicating that the caller is unauthorized to perform a specific function.\",\"params\":{\"expectedRole\":\"The role required to perform the function.\",\"msgSig\":\"The function signature (bytes4) that the caller is unauthorized to perform.\"}}]},\"kind\":\"dev\",\"methods\":{\"addTrustedOrganizations((address,address,address,uint256,uint256)[])\":{\"details\":\"Adds a list of addresses into the trusted organization. Requirements: - The weights should larger than 0. - The method caller is admin. - The field `addedBlock` should be blank. Emits the event `TrustedOrganizationAdded` once an organization is added.\"},\"checkThreshold(uint256)\":{\"details\":\"Checks whether the `_voteWeight` passes the threshold.\"},\"countTrustedOrganizations()\":{\"details\":\"Returns the number of trusted organizations.\"},\"getAllTrustedOrganizations()\":{\"details\":\"Returns all of the trusted organizations.\"},\"getBridgeVoterWeight(address)\":{\"details\":\"Returns the weight of a bridge voter.\"},\"getBridgeVoterWeights(address[])\":{\"details\":\"Returns the weights of a list of bridge voter addresses.\"},\"getConsensusWeight(address)\":{\"details\":\"Returns the weight of a consensus.\"},\"getConsensusWeights(address[])\":{\"details\":\"Returns the weights of a list of consensus addresses.\"},\"getGovernorWeight(address)\":{\"details\":\"Returns the weight of a governor.\"},\"getGovernorWeights(address[])\":{\"details\":\"Returns the weights of a list of governor addresses.\"},\"getThreshold()\":{\"details\":\"Returns the threshold.\"},\"getTrustedOrganization(address)\":{\"details\":\"Returns the trusted organization by consensus address. Reverts once the consensus address is non-existent.\"},\"getTrustedOrganizationAt(uint256)\":{\"details\":\"Returns the trusted organization at `_index`.\"},\"initialize((address,address,address,uint256,uint256)[],uint256,uint256)\":{\"details\":\"Initializes the contract storage.\"},\"minimumVoteWeight()\":{\"details\":\"Returns the minimum vote weight to pass the threshold.\"},\"removeTrustedOrganizations(address[])\":{\"details\":\"Removes a list of addresses from the trusted organization. Requirements: - The method caller is admin. Emits the event `TrustedOrganizationRemoved` once an organization is removed.\",\"params\":{\"_consensusAddrs\":\"The list of consensus addresses linked to corresponding trusted organization that to be removed.\"}},\"setThreshold(uint256,uint256)\":{\"details\":\"Sets the threshold. Requirements: - The method caller is admin. Emits the `ThresholdUpdated` event.\"},\"sumBridgeVoterWeights(address[])\":{\"details\":\"Returns total weights of the bridge voter list.\"},\"sumConsensusWeights(address[])\":{\"details\":\"Returns total weights of the consensus list.\"},\"sumGovernorWeights(address[])\":{\"details\":\"Returns total weights of the governor list.\"},\"totalWeights()\":{\"details\":\"Returns total weights.\"},\"updateTrustedOrganizations((address,address,address,uint256,uint256)[])\":{\"details\":\"Updates weights for a list of existent trusted organization. Requirements: - The weights should larger than 0. - The method caller is admin. Emits the `TrustedOrganizationUpdated` event.\"}},\"stateVariables\":{\"_addedBlock\":{\"details\":\"Mapping from consensus address => added block\"},\"_bridgeVoterList\":{\"details\":\"Bridge voters array\"},\"_bridgeVoterWeight\":{\"details\":\"Mapping from bridge voter address => weight\"},\"_consensusList\":{\"details\":\"Consensus array\"},\"_consensusWeight\":{\"details\":\"Mapping from consensus address => weight\"},\"_governorList\":{\"details\":\"Governors array\"},\"_governorWeight\":{\"details\":\"Mapping from governor address => weight\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/multi-chains/RoninTrustedOrganization.sol\":\"RoninTrustedOrganization\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"none\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/Address.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\\n * initialization step. This is essential to configure modules that are added through upgrades and that require\\n * initialization.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2a21b14ff90012878752f230d3ffd5c3405e5938d06c97a7d89c0a64561d0d66\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd6153ce99bcdcce22b124f755e72553295be6abcd63804cfdffceb188b8bef10\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"contracts/extensions/collections/HasProxyAdmin.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/StorageSlot.sol\\\";\\nimport \\\"../../utils/CommonErrors.sol\\\";\\n\\nabstract contract HasProxyAdmin {\\n // bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n modifier onlyAdmin() {\\n _requireAdmin();\\n _;\\n }\\n\\n /**\\n * @dev Returns proxy admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n function _requireAdmin() internal view {\\n if (msg.sender != _getAdmin()) revert ErrUnauthorized(msg.sig, RoleAccess.ADMIN);\\n }\\n}\\n\",\"keccak256\":\"0x06e5962713a77abf6d5ba646e1cc1cfb6f9c50e7d52520dd82a10bf309534187\",\"license\":\"MIT\"},\"contracts/interfaces/IQuorum.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\ninterface IQuorum {\\n /// @dev Emitted when the threshold is updated\\n event ThresholdUpdated(\\n uint256 indexed nonce,\\n uint256 indexed numerator,\\n uint256 indexed denominator,\\n uint256 previousNumerator,\\n uint256 previousDenominator\\n );\\n\\n /**\\n * @dev Returns the threshold.\\n */\\n function getThreshold() external view returns (uint256 _num, uint256 _denom);\\n\\n /**\\n * @dev Checks whether the `_voteWeight` passes the threshold.\\n */\\n function checkThreshold(uint256 _voteWeight) external view returns (bool);\\n\\n /**\\n * @dev Returns the minimum vote weight to pass the threshold.\\n */\\n function minimumVoteWeight() external view returns (uint256);\\n\\n /**\\n * @dev Sets the threshold.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the `ThresholdUpdated` event.\\n *\\n */\\n function setThreshold(\\n uint256 _numerator,\\n uint256 _denominator\\n ) external returns (uint256 _previousNum, uint256 _previousDenom);\\n}\\n\",\"keccak256\":\"0x6b7920b04a73a0e1ff7404aa1a3b5fc738fc0b6154839480f666fd69b55123f0\",\"license\":\"MIT\"},\"contracts/interfaces/IRoninTrustedOrganization.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IQuorum.sol\\\";\\n\\ninterface IRoninTrustedOrganization is IQuorum {\\n /**\\n * @dev Error indicating that a query for a duplicate entry was made.\\n */\\n error ErrQueryForDupplicated();\\n\\n /**\\n * @dev Error indicating that a query was made for a non-existent consensus address.\\n */\\n error ErrQueryForNonExistentConsensusAddress();\\n\\n /**\\n * @dev Error indicating that a bridge voter has already been added.\\n * @param voter The address of the bridge voter that is already added.\\n */\\n error ErrBridgeVoterIsAlreadyAdded(address voter);\\n\\n /**\\n * @dev Error indicating that a governor address has already been added.\\n * @param addr The address of the governor that is already added.\\n */\\n error ErrGovernorAddressIsAlreadyAdded(address addr);\\n\\n /**\\n * @dev Error indicating that a consensus address is not added.\\n * @param addr The address of the consensus contract that is not added.\\n */\\n error ErrConsensusAddressIsNotAdded(address addr);\\n\\n /**\\n * @dev Error indicating that a consensus address is already added.\\n * @param addr The address of the consensus contract that is already added.\\n */\\n error ErrConsensusAddressIsAlreadyAdded(address addr);\\n\\n struct TrustedOrganization {\\n // Address of the validator that produces block, e.g. block.coinbase. This is so-called validator address.\\n address consensusAddr;\\n // Address to voting proposal\\n address governor;\\n // Address to voting bridge operators\\n address bridgeVoter;\\n // Its Weight\\n uint256 weight;\\n // The block that the organization was added\\n uint256 addedBlock;\\n }\\n\\n /// @dev Emitted when the trusted organization is added.\\n event TrustedOrganizationsAdded(TrustedOrganization[] orgs);\\n /// @dev Emitted when the trusted organization is updated.\\n event TrustedOrganizationsUpdated(TrustedOrganization[] orgs);\\n /// @dev Emitted when the trusted organization is removed.\\n event TrustedOrganizationsRemoved(address[] orgs);\\n\\n /**\\n * @dev Adds a list of addresses into the trusted organization.\\n *\\n * Requirements:\\n * - The weights should larger than 0.\\n * - The method caller is admin.\\n * - The field `addedBlock` should be blank.\\n *\\n * Emits the event `TrustedOrganizationAdded` once an organization is added.\\n *\\n */\\n function addTrustedOrganizations(TrustedOrganization[] calldata) external;\\n\\n /**\\n * @dev Updates weights for a list of existent trusted organization.\\n *\\n * Requirements:\\n * - The weights should larger than 0.\\n * - The method caller is admin.\\n *\\n * Emits the `TrustedOrganizationUpdated` event.\\n *\\n */\\n function updateTrustedOrganizations(TrustedOrganization[] calldata _list) external;\\n\\n /**\\n * @dev Removes a list of addresses from the trusted organization.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `TrustedOrganizationRemoved` once an organization is removed.\\n *\\n * @param _consensusAddrs The list of consensus addresses linked to corresponding trusted organization that to be removed.\\n */\\n function removeTrustedOrganizations(address[] calldata _consensusAddrs) external;\\n\\n /**\\n * @dev Returns total weights.\\n */\\n function totalWeights() external view returns (uint256);\\n\\n /**\\n * @dev Returns the weight of a consensus.\\n */\\n function getConsensusWeight(address _consensusAddr) external view returns (uint256);\\n\\n /**\\n * @dev Returns the weight of a governor.\\n */\\n function getGovernorWeight(address _governor) external view returns (uint256);\\n\\n /**\\n * @dev Returns the weight of a bridge voter.\\n */\\n function getBridgeVoterWeight(address _addr) external view returns (uint256);\\n\\n /**\\n * @dev Returns the weights of a list of consensus addresses.\\n */\\n function getConsensusWeights(address[] calldata _list) external view returns (uint256[] memory);\\n\\n /**\\n * @dev Returns the weights of a list of governor addresses.\\n */\\n function getGovernorWeights(address[] calldata _list) external view returns (uint256[] memory);\\n\\n /**\\n * @dev Returns the weights of a list of bridge voter addresses.\\n */\\n function getBridgeVoterWeights(address[] calldata _list) external view returns (uint256[] memory);\\n\\n /**\\n * @dev Returns total weights of the consensus list.\\n */\\n function sumConsensusWeights(address[] calldata _list) external view returns (uint256 _res);\\n\\n /**\\n * @dev Returns total weights of the governor list.\\n */\\n function sumGovernorWeights(address[] calldata _list) external view returns (uint256 _res);\\n\\n /**\\n * @dev Returns total weights of the bridge voter list.\\n */\\n function sumBridgeVoterWeights(address[] calldata _list) external view returns (uint256 _res);\\n\\n /**\\n * @dev Returns the trusted organization at `_index`.\\n */\\n function getTrustedOrganizationAt(uint256 _index) external view returns (TrustedOrganization memory);\\n\\n /**\\n * @dev Returns the number of trusted organizations.\\n */\\n function countTrustedOrganizations() external view returns (uint256);\\n\\n /**\\n * @dev Returns all of the trusted organizations.\\n */\\n function getAllTrustedOrganizations() external view returns (TrustedOrganization[] memory);\\n\\n /**\\n * @dev Returns the trusted organization by consensus address.\\n *\\n * Reverts once the consensus address is non-existent.\\n */\\n function getTrustedOrganization(address _consensusAddr) external view returns (TrustedOrganization memory);\\n}\\n\",\"keccak256\":\"0x28b0407cf740164f3ddf4a44952423604439cda580f286c6ed1edcdb59b219d0\",\"license\":\"MIT\"},\"contracts/libraries/AddressArrayUtils.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\n\\npragma solidity ^0.8.0;\\n\\nlibrary AddressArrayUtils {\\n /**\\n * @dev Error thrown when a duplicated element is detected in an array.\\n * @param msgSig The function signature that invoke the error.\\n */\\n error ErrDuplicated(bytes4 msgSig);\\n\\n /**\\n * @dev Returns whether or not there's a duplicate. Runs in O(n^2).\\n * @param A Array to search\\n * @return Returns true if duplicate, false otherwise\\n */\\n function hasDuplicate(address[] memory A) internal pure returns (bool) {\\n if (A.length == 0) {\\n return false;\\n }\\n unchecked {\\n for (uint256 i = 0; i < A.length - 1; i++) {\\n for (uint256 j = i + 1; j < A.length; j++) {\\n if (A[i] == A[j]) {\\n return true;\\n }\\n }\\n }\\n }\\n return false;\\n }\\n\\n /**\\n * @dev Returns whether two arrays of addresses are equal or not.\\n */\\n function isEqual(address[] memory _this, address[] memory _other) internal pure returns (bool yes_) {\\n // Hashing two arrays and compare their hash\\n assembly {\\n let _thisHash := keccak256(add(_this, 32), mul(mload(_this), 32))\\n let _otherHash := keccak256(add(_other, 32), mul(mload(_other), 32))\\n yes_ := eq(_thisHash, _otherHash)\\n }\\n }\\n\\n /**\\n * @dev Return the concatenated array from a and b.\\n */\\n function extend(address[] memory a, address[] memory b) internal pure returns (address[] memory c) {\\n uint256 lengthA = a.length;\\n uint256 lengthB = b.length;\\n unchecked {\\n c = new address[](lengthA + lengthB);\\n }\\n uint256 i;\\n for (; i < lengthA; ) {\\n c[i] = a[i];\\n unchecked {\\n ++i;\\n }\\n }\\n for (uint256 j; j < lengthB; ) {\\n c[i] = b[j];\\n unchecked {\\n ++i;\\n ++j;\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xaf760162653a85d6e1b24df4d33c74076f778470112f421a02050fb981242001\",\"license\":\"UNLICENSED\"},\"contracts/multi-chains/RoninTrustedOrganization.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/proxy/utils/Initializable.sol\\\";\\nimport \\\"../libraries/AddressArrayUtils.sol\\\";\\nimport \\\"../interfaces/IRoninTrustedOrganization.sol\\\";\\nimport \\\"../extensions/collections/HasProxyAdmin.sol\\\";\\n\\ncontract RoninTrustedOrganization is IRoninTrustedOrganization, HasProxyAdmin, Initializable {\\n uint256 internal _num;\\n uint256 internal _denom;\\n uint256 internal _totalWeight;\\n uint256 internal _nonce;\\n\\n /// @dev Mapping from consensus address => weight\\n mapping(address => uint256) internal _consensusWeight;\\n /// @dev Mapping from governor address => weight\\n mapping(address => uint256) internal _governorWeight;\\n /// @dev Mapping from bridge voter address => weight\\n mapping(address => uint256) internal _bridgeVoterWeight;\\n\\n /// @dev Mapping from consensus address => added block\\n mapping(address => uint256) internal _addedBlock;\\n\\n /// @dev Consensus array\\n address[] internal _consensusList;\\n /// @dev Governors array\\n address[] internal _governorList;\\n /// @dev Bridge voters array\\n address[] internal _bridgeVoterList;\\n\\n /**\\n * @dev Initializes the contract storage.\\n */\\n function initialize(\\n TrustedOrganization[] calldata _trustedOrgs,\\n uint256 __num,\\n uint256 __denom\\n ) external initializer {\\n if (_trustedOrgs.length > 0) {\\n _addTrustedOrganizations(_trustedOrgs);\\n }\\n _setThreshold(__num, __denom);\\n }\\n\\n /**\\n * @inheritdoc IQuorum\\n */\\n function getThreshold() external view virtual returns (uint256 num_, uint256 denom_) {\\n return (_num, _denom);\\n }\\n\\n /**\\n * @inheritdoc IQuorum\\n */\\n function checkThreshold(uint256 _voteWeight) external view virtual returns (bool) {\\n return _voteWeight * _denom >= _num * _totalWeight;\\n }\\n\\n /**\\n * @inheritdoc IQuorum\\n */\\n function minimumVoteWeight() external view virtual returns (uint256) {\\n return (_num * _totalWeight + _denom - 1) / _denom;\\n }\\n\\n /**\\n * @inheritdoc IQuorum\\n */\\n function setThreshold(\\n uint256 _numerator,\\n uint256 _denominator\\n ) external override onlyAdmin returns (uint256, uint256) {\\n return _setThreshold(_numerator, _denominator);\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function addTrustedOrganizations(TrustedOrganization[] calldata _list) external override onlyAdmin {\\n _addTrustedOrganizations(_list);\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function updateTrustedOrganizations(TrustedOrganization[] calldata _list) external override onlyAdmin {\\n if (_list.length == 0) revert ErrEmptyArray();\\n for (uint256 _i; _i < _list.length; ) {\\n _updateTrustedOrganization(_list[_i]);\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n emit TrustedOrganizationsUpdated(_list);\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function removeTrustedOrganizations(address[] calldata _list) external override onlyAdmin {\\n if (_list.length == 0) revert ErrEmptyArray();\\n\\n for (uint _i = 0; _i < _list.length; ) {\\n _removeTrustedOrganization(_list[_i]);\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n emit TrustedOrganizationsRemoved(_list);\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function totalWeights() external view virtual returns (uint256) {\\n return _totalWeight;\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function getConsensusWeight(address _consensusAddr) external view returns (uint256) {\\n return _consensusWeight[_consensusAddr];\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function getGovernorWeight(address _governor) external view returns (uint256) {\\n return _governorWeight[_governor];\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function getBridgeVoterWeight(address _addr) external view returns (uint256) {\\n return _bridgeVoterWeight[_addr];\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function getConsensusWeights(address[] calldata _list) external view returns (uint256[] memory _res) {\\n _res = new uint256[](_list.length);\\n for (uint _i = 0; _i < _res.length; ) {\\n _res[_i] = _consensusWeight[_list[_i]];\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function getGovernorWeights(address[] calldata _list) external view returns (uint256[] memory _res) {\\n _res = new uint256[](_list.length);\\n for (uint _i = 0; _i < _res.length; ) {\\n _res[_i] = _governorWeight[_list[_i]];\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function getBridgeVoterWeights(address[] calldata _list) external view returns (uint256[] memory _res) {\\n _res = new uint256[](_list.length);\\n for (uint _i = 0; _i < _res.length; ) {\\n _res[_i] = _bridgeVoterWeight[_list[_i]];\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function sumConsensusWeights(address[] calldata _list) external view returns (uint256 _res) {\\n for (uint _i = 0; _i < _list.length; ) {\\n _res += _consensusWeight[_list[_i]];\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function sumGovernorWeights(address[] calldata _list) external view returns (uint256 _res) {\\n for (uint _i = 0; _i < _list.length; ) {\\n _res += _governorWeight[_list[_i]];\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function sumBridgeVoterWeights(address[] calldata _list) external view returns (uint256 _res) {\\n for (uint _i = 0; _i < _list.length; ) {\\n _res += _bridgeVoterWeight[_list[_i]];\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function countTrustedOrganizations() external view override returns (uint256) {\\n return _consensusList.length;\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function getAllTrustedOrganizations() external view override returns (TrustedOrganization[] memory _list) {\\n _list = new TrustedOrganization[](_consensusList.length);\\n address _addr;\\n for (uint256 _i; _i < _list.length; ) {\\n _addr = _consensusList[_i];\\n _list[_i].consensusAddr = _addr;\\n _list[_i].governor = _governorList[_i];\\n _list[_i].bridgeVoter = _bridgeVoterList[_i];\\n _list[_i].weight = _consensusWeight[_addr];\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function getTrustedOrganization(address _consensusAddr) external view returns (TrustedOrganization memory) {\\n for (uint _i = 0; _i < _consensusList.length; ) {\\n if (_consensusList[_i] == _consensusAddr) {\\n return getTrustedOrganizationAt(_i);\\n }\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n revert ErrQueryForNonExistentConsensusAddress();\\n }\\n\\n /**\\n * @inheritdoc IRoninTrustedOrganization\\n */\\n function getTrustedOrganizationAt(uint256 _idx) public view override returns (TrustedOrganization memory) {\\n address _addr = _consensusList[_idx];\\n return\\n TrustedOrganization(\\n _addr,\\n _governorList[_idx],\\n _bridgeVoterList[_idx],\\n _consensusWeight[_addr],\\n _addedBlock[_addr]\\n );\\n }\\n\\n /**\\n * @dev Adds a list of trusted organizations.\\n */\\n function _addTrustedOrganizations(TrustedOrganization[] calldata _list) internal virtual {\\n for (uint256 _i; _i < _list.length; ) {\\n _addTrustedOrganization(_list[_i]);\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n emit TrustedOrganizationsAdded(_list);\\n }\\n\\n /**\\n * @dev Adds a trusted organization.\\n *\\n * Requirements:\\n * - The weight is larger than 0.\\n * - The consensus address is not added.\\n * - The govenor address is not added.\\n * - The bridge voter address is not added.\\n *\\n */\\n function _addTrustedOrganization(TrustedOrganization memory _v) internal virtual {\\n if (_v.addedBlock != 0) revert ErrInvalidRequest();\\n _sanityCheckTrustedOrganizationData(_v);\\n\\n if (_consensusWeight[_v.consensusAddr] > 0) revert ErrConsensusAddressIsAlreadyAdded(_v.consensusAddr);\\n\\n if (_governorWeight[_v.governor] > 0) revert ErrGovernorAddressIsAlreadyAdded(_v.governor);\\n\\n if (_bridgeVoterWeight[_v.bridgeVoter] > 0) revert ErrBridgeVoterIsAlreadyAdded(_v.bridgeVoter);\\n\\n _consensusList.push(_v.consensusAddr);\\n _consensusWeight[_v.consensusAddr] = _v.weight;\\n\\n _governorList.push(_v.governor);\\n _governorWeight[_v.governor] = _v.weight;\\n\\n _bridgeVoterList.push(_v.bridgeVoter);\\n _bridgeVoterWeight[_v.bridgeVoter] = _v.weight;\\n\\n _addedBlock[_v.consensusAddr] = block.number;\\n\\n _totalWeight += _v.weight;\\n }\\n\\n /**\\n * @dev Updates a trusted organization.\\n *\\n * Requirements:\\n * - The weight is larger than 0.\\n * - The consensus address is already added.\\n *\\n */\\n function _updateTrustedOrganization(TrustedOrganization memory _v) internal virtual {\\n _sanityCheckTrustedOrganizationData(_v);\\n\\n uint256 _weight = _consensusWeight[_v.consensusAddr];\\n if (_weight == 0) revert ErrConsensusAddressIsNotAdded(_v.consensusAddr);\\n\\n uint256 _count = _consensusList.length;\\n for (uint256 _i = 0; _i < _count; ) {\\n if (_consensusList[_i] == _v.consensusAddr) {\\n _totalWeight -= _weight;\\n _totalWeight += _v.weight;\\n\\n if (_governorList[_i] != _v.governor) {\\n if (_governorWeight[_v.governor] != 0) revert ErrQueryForDupplicated();\\n\\n delete _governorWeight[_governorList[_i]];\\n _governorList[_i] = _v.governor;\\n }\\n\\n if (_bridgeVoterList[_i] != _v.bridgeVoter) {\\n if (_bridgeVoterWeight[_v.bridgeVoter] != 0) revert ErrQueryForDupplicated();\\n\\n delete _bridgeVoterWeight[_bridgeVoterList[_i]];\\n _bridgeVoterList[_i] = _v.bridgeVoter;\\n }\\n\\n _consensusWeight[_v.consensusAddr] = _v.weight;\\n _governorWeight[_v.governor] = _v.weight;\\n _bridgeVoterWeight[_v.bridgeVoter] = _v.weight;\\n return;\\n }\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @dev Removes a trusted organization.\\n *\\n * Requirements:\\n * - The consensus address is added.\\n *\\n */\\n function _removeTrustedOrganization(address _addr) internal virtual {\\n uint256 _weight = _consensusWeight[_addr];\\n if (_weight == 0) revert ErrConsensusAddressIsNotAdded(_addr);\\n\\n uint256 _index;\\n uint256 _count = _consensusList.length;\\n for (uint256 _i = 0; _i < _count; ) {\\n if (_consensusList[_i] == _addr) {\\n _index = _i;\\n break;\\n }\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n\\n _totalWeight -= _weight;\\n\\n delete _addedBlock[_addr];\\n delete _consensusWeight[_addr];\\n _consensusList[_index] = _consensusList[_count - 1];\\n _consensusList.pop();\\n\\n delete _governorWeight[_governorList[_index]];\\n _governorList[_index] = _governorList[_count - 1];\\n _governorList.pop();\\n\\n delete _bridgeVoterWeight[_bridgeVoterList[_index]];\\n _bridgeVoterList[_index] = _bridgeVoterList[_count - 1];\\n _bridgeVoterList.pop();\\n }\\n\\n /**\\n * @dev Sets threshold and returns the old one.\\n *\\n * Emits the `ThresholdUpdated` event.\\n *\\n */\\n function _setThreshold(\\n uint256 _numerator,\\n uint256 _denominator\\n ) internal virtual returns (uint256 _previousNum, uint256 _previousDenom) {\\n if (_numerator > _denominator) revert ErrInvalidThreshold(msg.sig);\\n\\n _previousNum = _num;\\n _previousDenom = _denom;\\n _num = _numerator;\\n _denom = _denominator;\\n unchecked {\\n emit ThresholdUpdated(_nonce++, _numerator, _denominator, _previousNum, _previousDenom);\\n }\\n }\\n\\n /**\\n * @dev Hook that checks trusted organization's data. Reverts if the requirements are not met.\\n *\\n * Requirements:\\n * - The weight must be larger than 0.\\n * - The consensus address, governor address, and bridge voter address are different.\\n */\\n function _sanityCheckTrustedOrganizationData(TrustedOrganization memory _v) private pure {\\n if (_v.weight == 0) revert ErrInvalidVoteWeight(msg.sig);\\n\\n address[] memory _addresses = new address[](3);\\n _addresses[0] = _v.consensusAddr;\\n _addresses[1] = _v.governor;\\n _addresses[2] = _v.bridgeVoter;\\n\\n if (AddressArrayUtils.hasDuplicate(_addresses)) revert AddressArrayUtils.ErrDuplicated(msg.sig);\\n }\\n}\\n\",\"keccak256\":\"0x7cf1258dab3c0071272f5733b3a9ce6b1dda9d12abd055f3359934c7c1fc34f2\",\"license\":\"MIT\"},\"contracts/utils/CommonErrors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { ContractType } from \\\"./ContractType.sol\\\";\\nimport { RoleAccess } from \\\"./RoleAccess.sol\\\";\\n\\nerror ErrSyncTooFarPeriod(uint256 period, uint256 latestRewardedPeriod);\\n/**\\n * @dev Error thrown when an address is expected to be an already created externally owned account (EOA).\\n * This error indicates that the provided address is invalid for certain contract operations that require already created EOA.\\n */\\nerror ErrAddressIsNotCreatedEOA(address addr, bytes32 codehash);\\n/**\\n * @dev Error raised when a bridge operator update operation fails.\\n * @param bridgeOperator The address of the bridge operator that failed to update.\\n */\\nerror ErrBridgeOperatorUpdateFailed(address bridgeOperator);\\n/**\\n * @dev Error thrown when attempting to add a bridge operator that already exists in the contract.\\n * This error indicates that the provided bridge operator address is already registered as a bridge operator in the contract.\\n */\\nerror ErrBridgeOperatorAlreadyExisted(address bridgeOperator);\\n/**\\n * @dev The error indicating an unsupported interface.\\n * @param interfaceId The bytes4 interface identifier that is not supported.\\n * @param addr The address where the unsupported interface was encountered.\\n */\\nerror ErrUnsupportedInterface(bytes4 interfaceId, address addr);\\n/**\\n * @dev Error thrown when the return data from a callback function is invalid.\\n * @param callbackFnSig The signature of the callback function that returned invalid data.\\n * @param register The address of the register where the callback function was invoked.\\n * @param returnData The invalid return data received from the callback function.\\n */\\nerror ErrInvalidReturnData(bytes4 callbackFnSig, address register, bytes returnData);\\n/**\\n * @dev Error of set to non-contract.\\n */\\nerror ErrZeroCodeContract(address addr);\\n/**\\n * @dev Error indicating that arguments are invalid.\\n */\\nerror ErrInvalidArguments(bytes4 msgSig);\\n/**\\n * @dev Error indicating that given address is null when it should not.\\n */\\nerror ErrZeroAddress(bytes4 msgSig);\\n/**\\n * @dev Error indicating that the provided threshold is invalid for a specific function signature.\\n * @param msgSig The function signature (bytes4) that the invalid threshold applies to.\\n */\\nerror ErrInvalidThreshold(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a function can only be called by the contract itself.\\n * @param msgSig The function signature (bytes4) that can only be called by the contract itself.\\n */\\nerror ErrOnlySelfCall(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\\n * @param msgSig The function signature (bytes4) that the caller is unauthorized to perform.\\n * @param expectedRole The role required to perform the function.\\n */\\nerror ErrUnauthorized(bytes4 msgSig, RoleAccess expectedRole);\\n\\n/**\\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\\n * @param msgSig The function signature (bytes4) that the caller is unauthorized to perform.\\n */\\nerror ErrUnauthorizedCall(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\\n * @param msgSig The function signature (bytes4).\\n * @param expectedContractType The contract type required to perform the function.\\n * @param actual The actual address that called to the function.\\n */\\nerror ErrUnexpectedInternalCall(bytes4 msgSig, ContractType expectedContractType, address actual);\\n\\n/**\\n * @dev Error indicating that an array is empty when it should contain elements.\\n */\\nerror ErrEmptyArray();\\n\\n/**\\n * @dev Error indicating a mismatch in the length of input parameters or arrays for a specific function.\\n * @param msgSig The function signature (bytes4) that has a length mismatch.\\n */\\nerror ErrLengthMismatch(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a proxy call to an external contract has failed.\\n * @param msgSig The function signature (bytes4) of the proxy call that failed.\\n * @param extCallSig The function signature (bytes4) of the external contract call that failed.\\n */\\nerror ErrProxyCallFailed(bytes4 msgSig, bytes4 extCallSig);\\n\\n/**\\n * @dev Error indicating that a function tried to call a precompiled contract that is not allowed.\\n * @param msgSig The function signature (bytes4) that attempted to call a precompiled contract.\\n */\\nerror ErrCallPrecompiled(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a native token transfer has failed.\\n * @param msgSig The function signature (bytes4) of the token transfer that failed.\\n */\\nerror ErrNativeTransferFailed(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that an order is invalid.\\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid order.\\n */\\nerror ErrInvalidOrder(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that the chain ID is invalid.\\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid chain ID.\\n * @param actual Current chain ID that executing function.\\n * @param expected Expected chain ID required for the tx to success.\\n */\\nerror ErrInvalidChainId(bytes4 msgSig, uint256 actual, uint256 expected);\\n\\n/**\\n * @dev Error indicating that a vote type is not supported.\\n * @param msgSig The function signature (bytes4) of the operation that encountered an unsupported vote type.\\n */\\nerror ErrUnsupportedVoteType(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that the proposal nonce is invalid.\\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid proposal nonce.\\n */\\nerror ErrInvalidProposalNonce(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a voter has already voted.\\n * @param voter The address of the voter who has already voted.\\n */\\nerror ErrAlreadyVoted(address voter);\\n\\n/**\\n * @dev Error indicating that a signature is invalid for a specific function signature.\\n * @param msgSig The function signature (bytes4) that encountered an invalid signature.\\n */\\nerror ErrInvalidSignatures(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a relay call has failed.\\n * @param msgSig The function signature (bytes4) of the relay call that failed.\\n */\\nerror ErrRelayFailed(bytes4 msgSig);\\n/**\\n * @dev Error indicating that a vote weight is invalid for a specific function signature.\\n * @param msgSig The function signature (bytes4) that encountered an invalid vote weight.\\n */\\nerror ErrInvalidVoteWeight(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a query was made for an outdated bridge operator set.\\n */\\nerror ErrQueryForOutdatedBridgeOperatorSet();\\n\\n/**\\n * @dev Error indicating that a request is invalid.\\n */\\nerror ErrInvalidRequest();\\n\\n/**\\n * @dev Error indicating that a token standard is invalid.\\n */\\nerror ErrInvalidTokenStandard();\\n\\n/**\\n * @dev Error indicating that a token is not supported.\\n */\\nerror ErrUnsupportedToken();\\n\\n/**\\n * @dev Error indicating that a receipt kind is invalid.\\n */\\nerror ErrInvalidReceiptKind();\\n\\n/**\\n * @dev Error indicating that a receipt is invalid.\\n */\\nerror ErrInvalidReceipt();\\n\\n/**\\n * @dev Error indicating that an address is not payable.\\n */\\nerror ErrNonpayableAddress(address);\\n\\n/**\\n * @dev Error indicating that the period is already processed, i.e. scattered reward.\\n */\\nerror ErrPeriodAlreadyProcessed(uint256 requestingPeriod, uint256 latestPeriod);\\n\\n/**\\n * @dev Error thrown when an invalid vote hash is provided.\\n */\\nerror ErrInvalidVoteHash();\\n\\n/**\\n * @dev Error thrown when querying for an empty vote.\\n */\\nerror ErrQueryForEmptyVote();\\n\\n/**\\n * @dev Error thrown when querying for an expired vote.\\n */\\nerror ErrQueryForExpiredVote();\\n\\n/**\\n * @dev Error thrown when querying for a non-existent vote.\\n */\\nerror ErrQueryForNonExistentVote();\\n\",\"keccak256\":\"0x3914292a405307cba9e93085edcaf5f1203ca2d55abf998bf1d2af1e86f5a4c6\",\"license\":\"MIT\"},\"contracts/utils/ContractType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum ContractType {\\n /* 0 */ UNKNOWN,\\n /* 1 */ PAUSE_ENFORCER,\\n /* 2 */ BRIDGE,\\n /* 3 */ BRIDGE_TRACKING,\\n /* 4 */ GOVERNANCE_ADMIN,\\n /* 5 */ MAINTENANCE,\\n /* 6 */ SLASH_INDICATOR,\\n /* 7 */ STAKING_VESTING,\\n /* 8 */ VALIDATOR,\\n /* 9 */ STAKING,\\n /* 10 */ RONIN_TRUSTED_ORGANIZATION,\\n /* 11 */ BRIDGE_MANAGER,\\n /* 12 */ BRIDGE_SLASH,\\n /* 13 */ BRIDGE_REWARD\\n}\\n\",\"keccak256\":\"0xf72feff9afafcb5cadc1b05c6e0b998ea5d66c7ece57c3e482e560d0a1bb4079\",\"license\":\"MIT\"},\"contracts/utils/RoleAccess.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum RoleAccess {\\n /* 0 */ UNKNOWN,\\n /* 1 */ ADMIN,\\n /* 2 */ COINBASE,\\n /* 3 */ GOVERNOR,\\n /* 4 */ CANDIDATE_ADMIN,\\n /* 5 */ WITHDRAWAL_MIGRATOR,\\n /* 6 */ __DEPRECATED_BRIDGE_OPERATOR,\\n /* 7 */ BLOCK_PRODUCER,\\n /* 8 */ VALIDATOR_CANDIDATE\\n}\\n\",\"keccak256\":\"0xa98cec38c640c4e37f475debbcd366226f1188c3f5ea6e29de768bd33e021873\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50611e8a806100206000396000f3fe608060405234801561001057600080fd5b50600436106101425760003560e01c8063b505a07c116100b8578063d9d5dadb1161007c578063d9d5dadb146102d5578063dafae408146102e8578063db6693a21461030b578063e75235b81461032b578063e8c0685e14610336578063f09267c21461034957600080fd5b8063b505a07c14610256578063b9c3620914610269578063cacf8fb514610291578063cc7e6b3b14610299578063d78392f8146102ac57600080fd5b80635f14a1c31161010a5780635f14a1c3146101fa578063708236251461020d5780637c37103c146102205780637de5dedd14610233578063926323d51461023b578063a85c7d6e1461024357600080fd5b80630ed285df14610147578063150740051461015c57806341feed1c1461017a578063520fce62146101b157806356241911146101d1575b600080fd5b61015a6101553660046119d3565b61035c565b005b610164610372565b6040516101719190611a52565b60405180910390f35b6101a3610188366004611abc565b6001600160a01b031660009081526005602052604090205490565b604051908152602001610171565b6101c46101bf366004611ad7565b61055e565b6040516101719190611b4c565b6101a36101df366004611abc565b6001600160a01b031660009081526007602052604090205490565b6101a3610208366004611ad7565b610629565b6101c461021b366004611ad7565b61068e565b61015a61022e366004611b84565b610752565b6101a3610880565b6003546101a3565b61015a610251366004611ad7565b6108bd565b61015a6102643660046119d3565b610967565b61027c610277366004611bd5565b610a06565b60408051928352602083019190915201610171565b6009546101a3565b6101c46102a7366004611ad7565b610a27565b6101a36102ba366004611abc565b6001600160a01b031660009081526006602052604090205490565b6101a36102e3366004611ad7565b610aeb565b6102fb6102f6366004611bf7565b610b50565b6040519015158152602001610171565b61031e610319366004611abc565b610b77565b6040516101719190611c10565b60015460025461027c565b6101a3610344366004611ad7565b610c16565b61031e610357366004611bf7565b610c7b565b610364610d81565b61036e8282610ddd565b5050565b60095460609067ffffffffffffffff81111561039057610390611c24565b6040519080825280602002602001820160405280156103e957816020015b6040805160a0810182526000808252602080830182905292820181905260608201819052608082015282526000199092019101816103ae5790505b5090506000805b8251811015610559576009818154811061040c5761040c611c3a565b9060005260206000200160009054906101000a90046001600160a01b031691508183828151811061043f5761043f611c3a565b60209081029190910101516001600160a01b039091169052600a80548290811061046b5761046b611c3a565b9060005260206000200160009054906101000a90046001600160a01b031683828151811061049b5761049b611c3a565b6020026020010151602001906001600160a01b031690816001600160a01b031681525050600b81815481106104d2576104d2611c3a565b9060005260206000200160009054906101000a90046001600160a01b031683828151811061050257610502611c3a565b6020908102919091018101516001600160a01b03928316604091820152918416600090815260059091522054835184908390811061054257610542611c3a565b6020908102919091010151606001526001016103f0565b505090565b60608167ffffffffffffffff81111561057957610579611c24565b6040519080825280602002602001820160405280156105a2578160200160208202803683370190505b50905060005b815181101561062257600560008585848181106105c7576105c7611c3a565b90506020020160208101906105dc9190611abc565b6001600160a01b03166001600160a01b031681526020019081526020016000205482828151811061060f5761060f611c3a565b60209081029190910101526001016105a8565b5092915050565b6000805b82811015610622576006600085858481811061064b5761064b611c3a565b90506020020160208101906106609190611abc565b6001600160a01b031681526020810191909152604001600020546106849083611c66565b915060010161062d565b60608167ffffffffffffffff8111156106a9576106a9611c24565b6040519080825280602002602001820160405280156106d2578160200160208202803683370190505b50905060005b815181101561062257600760008585848181106106f7576106f7611c3a565b905060200201602081019061070c9190611abc565b6001600160a01b03166001600160a01b031681526020019081526020016000205482828151811061073f5761073f611c3a565b60209081029190910101526001016106d8565b600054610100900460ff16158080156107725750600054600160ff909116105b8061078c5750303b15801561078c575060005460ff166001145b6107f45760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff191660011790558015610817576000805461ff0019166101001790555b8315610827576108278585610ddd565b6108318383610e52565b50508015610879576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b6000600254600160025460035460015461089a9190611c79565b6108a49190611c66565b6108ae9190611c90565b6108b89190611ca3565b905090565b6108c5610d81565b60008190036108e7576040516316ee9d3b60e11b815260040160405180910390fd5b60005b818110156109295761092183838381811061090757610907611c3a565b905060200201602081019061091c9190611abc565b610ee8565b6001016108ea565b507f121945697ac30ee0fc67821492cb685c65f0ea4d7f1b710fde44d6e2237f43a7828260405161095b929190611cc5565b60405180910390a15050565b61096f610d81565b6000819003610991576040516316ee9d3b60e11b815260040160405180910390fd5b60005b818110156109d4576109cc8383838181106109b1576109b1611c3a565b905060a002018036038101906109c79190611d11565b61124a565b600101610994565b507fe887c8106c09d1770c0ef0bf8ca62c54766f18b07506801865501783376cbeda828260405161095b929190611da2565b600080610a11610d81565b610a1b8484610e52565b915091505b9250929050565b60608167ffffffffffffffff811115610a4257610a42611c24565b604051908082528060200260200182016040528015610a6b578160200160208202803683370190505b50905060005b81518110156106225760066000858584818110610a9057610a90611c3a565b9050602002016020810190610aa59190611abc565b6001600160a01b03166001600160a01b0316815260200190815260200160002054828281518110610ad857610ad8611c3a565b6020908102919091010152600101610a71565b6000805b828110156106225760076000858584818110610b0d57610b0d611c3a565b9050602002016020810190610b229190611abc565b6001600160a01b03168152602081019190915260400160002054610b469083611c66565b9150600101610aef565b6000600354600154610b629190611c79565b600254610b6f9084611c79565b101592915050565b6040805160a0810182526000808252602082018190529181018290526060810182905260808101829052905b600954811015610bfc57826001600160a01b031660098281548110610bca57610bca611c3a565b6000918252602090912001546001600160a01b031603610bf457610bed81610c7b565b9392505050565b600101610ba3565b5060405163e57fdbef60e01b815260040160405180910390fd5b6000805b828110156106225760056000858584818110610c3857610c38611c3a565b9050602002016020810190610c4d9190611abc565b6001600160a01b03168152602081019190915260400160002054610c719083611c66565b9150600101610c1a565b6040805160a081018252600080825260208201819052918101829052606081018290526080810191909152600060098381548110610cbb57610cbb611c3a565b9060005260206000200160009054906101000a90046001600160a01b031690506040518060a00160405280826001600160a01b03168152602001600a8581548110610d0857610d08611c3a565b600091825260209182902001546001600160a01b03168252600b8054929091019186908110610d3957610d39611c3a565b60009182526020808320909101546001600160a01b03908116845294909416808252600585526040808320548487015290825260089094528390205492019190915292915050565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b03163314610ddb576000356001600160e01b0319166001604051620f948f60ea1b81526004016107eb929190611e2b565b565b60005b81811015610e2057610e18838383818110610dfd57610dfd611c3a565b905060a00201803603810190610e139190611d11565b611571565b600101610de0565b507fc753dbf7952c70ff6b9fa7b626403aa1d2230d97136b635bd5e85bec72bcca6c828260405161095b929190611da2565b60008082841115610e84576040516387f6f09560e01b81526001600160e01b03196000351660048201526024016107eb565b50506001805460028054858455908490556004805493840190556040805183815260208101839052929391928592879290917f976f8a9c5bdf8248dec172376d6e2b80a8e3df2f0328e381c6db8e1cf138c0f8910160405180910390a49250929050565b6001600160a01b03811660009081526005602052604081205490819003610f2d576040516349f748eb60e01b81526001600160a01b03831660048201526024016107eb565b600954600090815b81811015610f8457846001600160a01b031660098281548110610f5a57610f5a611c3a565b6000918252602090912001546001600160a01b031603610f7c57809250610f84565b600101610f35565b508260036000828254610f979190611c90565b90915550506001600160a01b038416600090815260086020908152604080832083905560059091528120556009610fcf600183611c90565b81548110610fdf57610fdf611c3a565b600091825260209091200154600980546001600160a01b03909216918490811061100b5761100b611c3a565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600980548061104a5761104a611e67565b6001900381819060005260206000200160006101000a8154906001600160a01b030219169055905560066000600a848154811061108957611089611c3a565b60009182526020808320909101546001600160a01b03168352820192909252604001812055600a6110bb600183611c90565b815481106110cb576110cb611c3a565b600091825260209091200154600a80546001600160a01b0390921691849081106110f7576110f7611c3a565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600a80548061113657611136611e67565b6001900381819060005260206000200160006101000a8154906001600160a01b030219169055905560076000600b848154811061117557611175611c3a565b60009182526020808320909101546001600160a01b03168352820192909252604001812055600b6111a7600183611c90565b815481106111b7576111b7611c3a565b600091825260209091200154600b80546001600160a01b0390921691849081106111e3576111e3611c3a565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600b80548061122257611222611e67565b600082815260209020810160001990810180546001600160a01b031916905501905550505050565b611253816117bc565b80516001600160a01b03166000908152600560205260408120549081900361129c5781516040516349f748eb60e01b81526001600160a01b0390911660048201526024016107eb565b60095460005b8181101561156b5783600001516001600160a01b0316600982815481106112cb576112cb611c3a565b6000918252602090912001546001600160a01b0316036115635782600360008282546112f79190611c90565b9091555050606084015160038054600090611313908490611c66565b9250508190555083602001516001600160a01b0316600a828154811061133b5761133b611c3a565b6000918252602090912001546001600160a01b031614611416576020808501516001600160a01b031660009081526006909152604090205415611391576040516346da180960e01b815260040160405180910390fd5b60066000600a83815481106113a8576113a8611c3a565b60009182526020808320909101546001600160a01b03168352828101939093526040909101812055840151600a8054839081106113e7576113e7611c3a565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b83604001516001600160a01b0316600b828154811061143757611437611c3a565b6000918252602090912001546001600160a01b031614611511576040808501516001600160a01b03166000908152600760205220541561148a576040516346da180960e01b815260040160405180910390fd5b60076000600b83815481106114a1576114a1611c3a565b60009182526020808320909101546001600160a01b031683528201929092526040908101822091909155840151600b8054839081106114e2576114e2611c3a565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b50505060608101805182516001600160a01b0390811660009081526005602090815260408083209490945584518187015184168352600682528483205593519483015190911681526007909252902055565b6001016112a2565b50505050565b6080810151156115945760405163129c2ce160e31b815260040160405180910390fd5b61159d816117bc565b80516001600160a01b0316600090815260056020526040902054156115e357805160405163ada9a35360e01b81526001600160a01b0390911660048201526024016107eb565b6020808201516001600160a01b031660009081526006909152604090205415611630576020810151604051637f5e2f5960e11b81526001600160a01b0390911660048201526024016107eb565b6040808201516001600160a01b03166000908152600760205220541561167a576040808201519051630f69702d60e01b81526001600160a01b0390911660048201526024016107eb565b8051600980546001808201835560009283527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af90910180546001600160a01b03199081166001600160a01b0395861617909155606085018051865186168552600560209081526040808720929092558088018051600a805480890182559089527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80180548716918a16919091179055835190518816875260068252828720558188018051600b8054978801815588527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db99096018054909516958816959095179093558151935186168552600783528085209390935585519094168352600890528120439055905160038054919290916117b4908490611c66565b909155505050565b80606001516000036117ef57604051637f11b8a360e11b81526001600160e01b03196000351660048201526024016107eb565b604080516003808252608082019092526000916020820160608036833701905050905081600001518160008151811061182a5761182a611c3a565b60200260200101906001600160a01b031690816001600160a01b03168152505081602001518160018151811061186257611862611c3a565b60200260200101906001600160a01b031690816001600160a01b03168152505081604001518160028151811061189a5761189a611c3a565b60200260200101906001600160a01b031690816001600160a01b0316815250506118c3816118ef565b1561036e57604051630d697db160e11b81526001600160e01b03196000351660048201526024016107eb565b6000815160000361190257506000919050565b60005b600183510381101561198557600181015b835181101561197c5783818151811061193157611931611c3a565b60200260200101516001600160a01b031684838151811061195457611954611c3a565b60200260200101516001600160a01b031603611974575060019392505050565b600101611916565b50600101611905565b50600092915050565b60008083601f8401126119a057600080fd5b50813567ffffffffffffffff8111156119b857600080fd5b60208301915083602060a083028501011115610a2057600080fd5b600080602083850312156119e657600080fd5b823567ffffffffffffffff8111156119fd57600080fd5b611a098582860161198e565b90969095509350505050565b80516001600160a01b0390811683526020808301518216908401526040808301519091169083015260608082015190830152608090810151910152565b6020808252825182820181905260009190848201906040850190845b81811015611a9457611a81838551611a15565b9284019260a09290920191600101611a6e565b50909695505050505050565b80356001600160a01b0381168114611ab757600080fd5b919050565b600060208284031215611ace57600080fd5b610bed82611aa0565b60008060208385031215611aea57600080fd5b823567ffffffffffffffff80821115611b0257600080fd5b818501915085601f830112611b1657600080fd5b813581811115611b2557600080fd5b8660208260051b8501011115611b3a57600080fd5b60209290920196919550909350505050565b6020808252825182820181905260009190848201906040850190845b81811015611a9457835183529284019291840191600101611b68565b60008060008060608587031215611b9a57600080fd5b843567ffffffffffffffff811115611bb157600080fd5b611bbd8782880161198e565b90989097506020870135966040013595509350505050565b60008060408385031215611be857600080fd5b50508035926020909101359150565b600060208284031215611c0957600080fd5b5035919050565b60a08101611c1e8284611a15565b92915050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115611c1e57611c1e611c50565b8082028115828204841417611c1e57611c1e611c50565b81810381811115611c1e57611c1e611c50565b600082611cc057634e487b7160e01b600052601260045260246000fd5b500490565b60208082528181018390526000908460408401835b86811015611d06576001600160a01b03611cf384611aa0565b1682529183019190830190600101611cda565b509695505050505050565b600060a08284031215611d2357600080fd5b60405160a0810181811067ffffffffffffffff82111715611d5457634e487b7160e01b600052604160045260246000fd5b604052611d6083611aa0565b8152611d6e60208401611aa0565b6020820152611d7f60408401611aa0565b604082015260608301356060820152608083013560808201528091505092915050565b6020808252818101839052600090604080840186845b87811015611e1e576001600160a01b0380611dd284611aa0565b16845280611de1878501611aa0565b168685015280611df2868501611aa0565b168486015250606082810135908401526080808301359084015260a09283019290910190600101611db8565b5090979650505050505050565b6001600160e01b0319831681526040810160098310611e5a57634e487b7160e01b600052602160045260246000fd5b8260208301529392505050565b634e487b7160e01b600052603160045260246000fdfea164736f6c6343000811000a", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101425760003560e01c8063b505a07c116100b8578063d9d5dadb1161007c578063d9d5dadb146102d5578063dafae408146102e8578063db6693a21461030b578063e75235b81461032b578063e8c0685e14610336578063f09267c21461034957600080fd5b8063b505a07c14610256578063b9c3620914610269578063cacf8fb514610291578063cc7e6b3b14610299578063d78392f8146102ac57600080fd5b80635f14a1c31161010a5780635f14a1c3146101fa578063708236251461020d5780637c37103c146102205780637de5dedd14610233578063926323d51461023b578063a85c7d6e1461024357600080fd5b80630ed285df14610147578063150740051461015c57806341feed1c1461017a578063520fce62146101b157806356241911146101d1575b600080fd5b61015a6101553660046119d3565b61035c565b005b610164610372565b6040516101719190611a52565b60405180910390f35b6101a3610188366004611abc565b6001600160a01b031660009081526005602052604090205490565b604051908152602001610171565b6101c46101bf366004611ad7565b61055e565b6040516101719190611b4c565b6101a36101df366004611abc565b6001600160a01b031660009081526007602052604090205490565b6101a3610208366004611ad7565b610629565b6101c461021b366004611ad7565b61068e565b61015a61022e366004611b84565b610752565b6101a3610880565b6003546101a3565b61015a610251366004611ad7565b6108bd565b61015a6102643660046119d3565b610967565b61027c610277366004611bd5565b610a06565b60408051928352602083019190915201610171565b6009546101a3565b6101c46102a7366004611ad7565b610a27565b6101a36102ba366004611abc565b6001600160a01b031660009081526006602052604090205490565b6101a36102e3366004611ad7565b610aeb565b6102fb6102f6366004611bf7565b610b50565b6040519015158152602001610171565b61031e610319366004611abc565b610b77565b6040516101719190611c10565b60015460025461027c565b6101a3610344366004611ad7565b610c16565b61031e610357366004611bf7565b610c7b565b610364610d81565b61036e8282610ddd565b5050565b60095460609067ffffffffffffffff81111561039057610390611c24565b6040519080825280602002602001820160405280156103e957816020015b6040805160a0810182526000808252602080830182905292820181905260608201819052608082015282526000199092019101816103ae5790505b5090506000805b8251811015610559576009818154811061040c5761040c611c3a565b9060005260206000200160009054906101000a90046001600160a01b031691508183828151811061043f5761043f611c3a565b60209081029190910101516001600160a01b039091169052600a80548290811061046b5761046b611c3a565b9060005260206000200160009054906101000a90046001600160a01b031683828151811061049b5761049b611c3a565b6020026020010151602001906001600160a01b031690816001600160a01b031681525050600b81815481106104d2576104d2611c3a565b9060005260206000200160009054906101000a90046001600160a01b031683828151811061050257610502611c3a565b6020908102919091018101516001600160a01b03928316604091820152918416600090815260059091522054835184908390811061054257610542611c3a565b6020908102919091010151606001526001016103f0565b505090565b60608167ffffffffffffffff81111561057957610579611c24565b6040519080825280602002602001820160405280156105a2578160200160208202803683370190505b50905060005b815181101561062257600560008585848181106105c7576105c7611c3a565b90506020020160208101906105dc9190611abc565b6001600160a01b03166001600160a01b031681526020019081526020016000205482828151811061060f5761060f611c3a565b60209081029190910101526001016105a8565b5092915050565b6000805b82811015610622576006600085858481811061064b5761064b611c3a565b90506020020160208101906106609190611abc565b6001600160a01b031681526020810191909152604001600020546106849083611c66565b915060010161062d565b60608167ffffffffffffffff8111156106a9576106a9611c24565b6040519080825280602002602001820160405280156106d2578160200160208202803683370190505b50905060005b815181101561062257600760008585848181106106f7576106f7611c3a565b905060200201602081019061070c9190611abc565b6001600160a01b03166001600160a01b031681526020019081526020016000205482828151811061073f5761073f611c3a565b60209081029190910101526001016106d8565b600054610100900460ff16158080156107725750600054600160ff909116105b8061078c5750303b15801561078c575060005460ff166001145b6107f45760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff191660011790558015610817576000805461ff0019166101001790555b8315610827576108278585610ddd565b6108318383610e52565b50508015610879576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b6000600254600160025460035460015461089a9190611c79565b6108a49190611c66565b6108ae9190611c90565b6108b89190611ca3565b905090565b6108c5610d81565b60008190036108e7576040516316ee9d3b60e11b815260040160405180910390fd5b60005b818110156109295761092183838381811061090757610907611c3a565b905060200201602081019061091c9190611abc565b610ee8565b6001016108ea565b507f121945697ac30ee0fc67821492cb685c65f0ea4d7f1b710fde44d6e2237f43a7828260405161095b929190611cc5565b60405180910390a15050565b61096f610d81565b6000819003610991576040516316ee9d3b60e11b815260040160405180910390fd5b60005b818110156109d4576109cc8383838181106109b1576109b1611c3a565b905060a002018036038101906109c79190611d11565b61124a565b600101610994565b507fe887c8106c09d1770c0ef0bf8ca62c54766f18b07506801865501783376cbeda828260405161095b929190611da2565b600080610a11610d81565b610a1b8484610e52565b915091505b9250929050565b60608167ffffffffffffffff811115610a4257610a42611c24565b604051908082528060200260200182016040528015610a6b578160200160208202803683370190505b50905060005b81518110156106225760066000858584818110610a9057610a90611c3a565b9050602002016020810190610aa59190611abc565b6001600160a01b03166001600160a01b0316815260200190815260200160002054828281518110610ad857610ad8611c3a565b6020908102919091010152600101610a71565b6000805b828110156106225760076000858584818110610b0d57610b0d611c3a565b9050602002016020810190610b229190611abc565b6001600160a01b03168152602081019190915260400160002054610b469083611c66565b9150600101610aef565b6000600354600154610b629190611c79565b600254610b6f9084611c79565b101592915050565b6040805160a0810182526000808252602082018190529181018290526060810182905260808101829052905b600954811015610bfc57826001600160a01b031660098281548110610bca57610bca611c3a565b6000918252602090912001546001600160a01b031603610bf457610bed81610c7b565b9392505050565b600101610ba3565b5060405163e57fdbef60e01b815260040160405180910390fd5b6000805b828110156106225760056000858584818110610c3857610c38611c3a565b9050602002016020810190610c4d9190611abc565b6001600160a01b03168152602081019190915260400160002054610c719083611c66565b9150600101610c1a565b6040805160a081018252600080825260208201819052918101829052606081018290526080810191909152600060098381548110610cbb57610cbb611c3a565b9060005260206000200160009054906101000a90046001600160a01b031690506040518060a00160405280826001600160a01b03168152602001600a8581548110610d0857610d08611c3a565b600091825260209182902001546001600160a01b03168252600b8054929091019186908110610d3957610d39611c3a565b60009182526020808320909101546001600160a01b03908116845294909416808252600585526040808320548487015290825260089094528390205492019190915292915050565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b03163314610ddb576000356001600160e01b0319166001604051620f948f60ea1b81526004016107eb929190611e2b565b565b60005b81811015610e2057610e18838383818110610dfd57610dfd611c3a565b905060a00201803603810190610e139190611d11565b611571565b600101610de0565b507fc753dbf7952c70ff6b9fa7b626403aa1d2230d97136b635bd5e85bec72bcca6c828260405161095b929190611da2565b60008082841115610e84576040516387f6f09560e01b81526001600160e01b03196000351660048201526024016107eb565b50506001805460028054858455908490556004805493840190556040805183815260208101839052929391928592879290917f976f8a9c5bdf8248dec172376d6e2b80a8e3df2f0328e381c6db8e1cf138c0f8910160405180910390a49250929050565b6001600160a01b03811660009081526005602052604081205490819003610f2d576040516349f748eb60e01b81526001600160a01b03831660048201526024016107eb565b600954600090815b81811015610f8457846001600160a01b031660098281548110610f5a57610f5a611c3a565b6000918252602090912001546001600160a01b031603610f7c57809250610f84565b600101610f35565b508260036000828254610f979190611c90565b90915550506001600160a01b038416600090815260086020908152604080832083905560059091528120556009610fcf600183611c90565b81548110610fdf57610fdf611c3a565b600091825260209091200154600980546001600160a01b03909216918490811061100b5761100b611c3a565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600980548061104a5761104a611e67565b6001900381819060005260206000200160006101000a8154906001600160a01b030219169055905560066000600a848154811061108957611089611c3a565b60009182526020808320909101546001600160a01b03168352820192909252604001812055600a6110bb600183611c90565b815481106110cb576110cb611c3a565b600091825260209091200154600a80546001600160a01b0390921691849081106110f7576110f7611c3a565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600a80548061113657611136611e67565b6001900381819060005260206000200160006101000a8154906001600160a01b030219169055905560076000600b848154811061117557611175611c3a565b60009182526020808320909101546001600160a01b03168352820192909252604001812055600b6111a7600183611c90565b815481106111b7576111b7611c3a565b600091825260209091200154600b80546001600160a01b0390921691849081106111e3576111e3611c3a565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600b80548061122257611222611e67565b600082815260209020810160001990810180546001600160a01b031916905501905550505050565b611253816117bc565b80516001600160a01b03166000908152600560205260408120549081900361129c5781516040516349f748eb60e01b81526001600160a01b0390911660048201526024016107eb565b60095460005b8181101561156b5783600001516001600160a01b0316600982815481106112cb576112cb611c3a565b6000918252602090912001546001600160a01b0316036115635782600360008282546112f79190611c90565b9091555050606084015160038054600090611313908490611c66565b9250508190555083602001516001600160a01b0316600a828154811061133b5761133b611c3a565b6000918252602090912001546001600160a01b031614611416576020808501516001600160a01b031660009081526006909152604090205415611391576040516346da180960e01b815260040160405180910390fd5b60066000600a83815481106113a8576113a8611c3a565b60009182526020808320909101546001600160a01b03168352828101939093526040909101812055840151600a8054839081106113e7576113e7611c3a565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b83604001516001600160a01b0316600b828154811061143757611437611c3a565b6000918252602090912001546001600160a01b031614611511576040808501516001600160a01b03166000908152600760205220541561148a576040516346da180960e01b815260040160405180910390fd5b60076000600b83815481106114a1576114a1611c3a565b60009182526020808320909101546001600160a01b031683528201929092526040908101822091909155840151600b8054839081106114e2576114e2611c3a565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b50505060608101805182516001600160a01b0390811660009081526005602090815260408083209490945584518187015184168352600682528483205593519483015190911681526007909252902055565b6001016112a2565b50505050565b6080810151156115945760405163129c2ce160e31b815260040160405180910390fd5b61159d816117bc565b80516001600160a01b0316600090815260056020526040902054156115e357805160405163ada9a35360e01b81526001600160a01b0390911660048201526024016107eb565b6020808201516001600160a01b031660009081526006909152604090205415611630576020810151604051637f5e2f5960e11b81526001600160a01b0390911660048201526024016107eb565b6040808201516001600160a01b03166000908152600760205220541561167a576040808201519051630f69702d60e01b81526001600160a01b0390911660048201526024016107eb565b8051600980546001808201835560009283527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af90910180546001600160a01b03199081166001600160a01b0395861617909155606085018051865186168552600560209081526040808720929092558088018051600a805480890182559089527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80180548716918a16919091179055835190518816875260068252828720558188018051600b8054978801815588527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db99096018054909516958816959095179093558151935186168552600783528085209390935585519094168352600890528120439055905160038054919290916117b4908490611c66565b909155505050565b80606001516000036117ef57604051637f11b8a360e11b81526001600160e01b03196000351660048201526024016107eb565b604080516003808252608082019092526000916020820160608036833701905050905081600001518160008151811061182a5761182a611c3a565b60200260200101906001600160a01b031690816001600160a01b03168152505081602001518160018151811061186257611862611c3a565b60200260200101906001600160a01b031690816001600160a01b03168152505081604001518160028151811061189a5761189a611c3a565b60200260200101906001600160a01b031690816001600160a01b0316815250506118c3816118ef565b1561036e57604051630d697db160e11b81526001600160e01b03196000351660048201526024016107eb565b6000815160000361190257506000919050565b60005b600183510381101561198557600181015b835181101561197c5783818151811061193157611931611c3a565b60200260200101516001600160a01b031684838151811061195457611954611c3a565b60200260200101516001600160a01b031603611974575060019392505050565b600101611916565b50600101611905565b50600092915050565b60008083601f8401126119a057600080fd5b50813567ffffffffffffffff8111156119b857600080fd5b60208301915083602060a083028501011115610a2057600080fd5b600080602083850312156119e657600080fd5b823567ffffffffffffffff8111156119fd57600080fd5b611a098582860161198e565b90969095509350505050565b80516001600160a01b0390811683526020808301518216908401526040808301519091169083015260608082015190830152608090810151910152565b6020808252825182820181905260009190848201906040850190845b81811015611a9457611a81838551611a15565b9284019260a09290920191600101611a6e565b50909695505050505050565b80356001600160a01b0381168114611ab757600080fd5b919050565b600060208284031215611ace57600080fd5b610bed82611aa0565b60008060208385031215611aea57600080fd5b823567ffffffffffffffff80821115611b0257600080fd5b818501915085601f830112611b1657600080fd5b813581811115611b2557600080fd5b8660208260051b8501011115611b3a57600080fd5b60209290920196919550909350505050565b6020808252825182820181905260009190848201906040850190845b81811015611a9457835183529284019291840191600101611b68565b60008060008060608587031215611b9a57600080fd5b843567ffffffffffffffff811115611bb157600080fd5b611bbd8782880161198e565b90989097506020870135966040013595509350505050565b60008060408385031215611be857600080fd5b50508035926020909101359150565b600060208284031215611c0957600080fd5b5035919050565b60a08101611c1e8284611a15565b92915050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115611c1e57611c1e611c50565b8082028115828204841417611c1e57611c1e611c50565b81810381811115611c1e57611c1e611c50565b600082611cc057634e487b7160e01b600052601260045260246000fd5b500490565b60208082528181018390526000908460408401835b86811015611d06576001600160a01b03611cf384611aa0565b1682529183019190830190600101611cda565b509695505050505050565b600060a08284031215611d2357600080fd5b60405160a0810181811067ffffffffffffffff82111715611d5457634e487b7160e01b600052604160045260246000fd5b604052611d6083611aa0565b8152611d6e60208401611aa0565b6020820152611d7f60408401611aa0565b604082015260608301356060820152608083013560808201528091505092915050565b6020808252818101839052600090604080840186845b87811015611e1e576001600160a01b0380611dd284611aa0565b16845280611de1878501611aa0565b168685015280611df2868501611aa0565b168486015250606082810135908401526080808301359084015260a09283019290910190600101611db8565b5090979650505050505050565b6001600160e01b0319831681526040810160098310611e5a57634e487b7160e01b600052602160045260246000fd5b8260208301529392505050565b634e487b7160e01b600052603160045260246000fdfea164736f6c6343000811000a", "devdoc": { + "errors": { + "ErrBridgeVoterIsAlreadyAdded(address)": [ + { + "details": "Error indicating that a bridge voter has already been added.", + "params": { + "voter": "The address of the bridge voter that is already added." + } + } + ], + "ErrConsensusAddressIsAlreadyAdded(address)": [ + { + "details": "Error indicating that a consensus address is already added.", + "params": { + "addr": "The address of the consensus contract that is already added." + } + } + ], + "ErrConsensusAddressIsNotAdded(address)": [ + { + "details": "Error indicating that a consensus address is not added.", + "params": { + "addr": "The address of the consensus contract that is not added." + } + } + ], + "ErrDuplicated(bytes4)": [ + { + "details": "Error thrown when a duplicated element is detected in an array.", + "params": { + "msgSig": "The function signature that invoke the error." + } + } + ], + "ErrEmptyArray()": [ + { + "details": "Error indicating that an array is empty when it should contain elements." + } + ], + "ErrGovernorAddressIsAlreadyAdded(address)": [ + { + "details": "Error indicating that a governor address has already been added.", + "params": { + "addr": "The address of the governor that is already added." + } + } + ], + "ErrInvalidRequest()": [ + { + "details": "Error indicating that a request is invalid." + } + ], + "ErrInvalidThreshold(bytes4)": [ + { + "details": "Error indicating that the provided threshold is invalid for a specific function signature.", + "params": { + "msgSig": "The function signature (bytes4) that the invalid threshold applies to." + } + } + ], + "ErrInvalidVoteWeight(bytes4)": [ + { + "details": "Error indicating that a vote weight is invalid for a specific function signature.", + "params": { + "msgSig": "The function signature (bytes4) that encountered an invalid vote weight." + } + } + ], + "ErrQueryForDupplicated()": [ + { + "details": "Error indicating that a query for a duplicate entry was made." + } + ], + "ErrQueryForNonExistentConsensusAddress()": [ + { + "details": "Error indicating that a query was made for a non-existent consensus address." + } + ], + "ErrUnauthorized(bytes4,uint8)": [ + { + "details": "Error indicating that the caller is unauthorized to perform a specific function.", + "params": { + "expectedRole": "The role required to perform the function.", + "msgSig": "The function signature (bytes4) that the caller is unauthorized to perform." + } + } + ] + }, "kind": "dev", "methods": { "addTrustedOrganizations((address,address,address,uint256,uint256)[])": { @@ -840,7 +1040,7 @@ "type": "t_bool" }, { - "astId": 19320, + "astId": 22307, "contract": "contracts/multi-chains/RoninTrustedOrganization.sol:RoninTrustedOrganization", "label": "_num", "offset": 0, @@ -848,7 +1048,7 @@ "type": "t_uint256" }, { - "astId": 19322, + "astId": 22309, "contract": "contracts/multi-chains/RoninTrustedOrganization.sol:RoninTrustedOrganization", "label": "_denom", "offset": 0, @@ -856,7 +1056,7 @@ "type": "t_uint256" }, { - "astId": 19324, + "astId": 22311, "contract": "contracts/multi-chains/RoninTrustedOrganization.sol:RoninTrustedOrganization", "label": "_totalWeight", "offset": 0, @@ -864,7 +1064,7 @@ "type": "t_uint256" }, { - "astId": 19326, + "astId": 22313, "contract": "contracts/multi-chains/RoninTrustedOrganization.sol:RoninTrustedOrganization", "label": "_nonce", "offset": 0, @@ -872,7 +1072,7 @@ "type": "t_uint256" }, { - "astId": 19331, + "astId": 22318, "contract": "contracts/multi-chains/RoninTrustedOrganization.sol:RoninTrustedOrganization", "label": "_consensusWeight", "offset": 0, @@ -880,7 +1080,7 @@ "type": "t_mapping(t_address,t_uint256)" }, { - "astId": 19336, + "astId": 22323, "contract": "contracts/multi-chains/RoninTrustedOrganization.sol:RoninTrustedOrganization", "label": "_governorWeight", "offset": 0, @@ -888,7 +1088,7 @@ "type": "t_mapping(t_address,t_uint256)" }, { - "astId": 19341, + "astId": 22328, "contract": "contracts/multi-chains/RoninTrustedOrganization.sol:RoninTrustedOrganization", "label": "_bridgeVoterWeight", "offset": 0, @@ -896,7 +1096,7 @@ "type": "t_mapping(t_address,t_uint256)" }, { - "astId": 19346, + "astId": 22333, "contract": "contracts/multi-chains/RoninTrustedOrganization.sol:RoninTrustedOrganization", "label": "_addedBlock", "offset": 0, @@ -904,7 +1104,7 @@ "type": "t_mapping(t_address,t_uint256)" }, { - "astId": 19350, + "astId": 22337, "contract": "contracts/multi-chains/RoninTrustedOrganization.sol:RoninTrustedOrganization", "label": "_consensusList", "offset": 0, @@ -912,7 +1112,7 @@ "type": "t_array(t_address)dyn_storage" }, { - "astId": 19354, + "astId": 22341, "contract": "contracts/multi-chains/RoninTrustedOrganization.sol:RoninTrustedOrganization", "label": "_governorList", "offset": 0, @@ -920,7 +1120,7 @@ "type": "t_array(t_address)dyn_storage" }, { - "astId": 19358, + "astId": 22345, "contract": "contracts/multi-chains/RoninTrustedOrganization.sol:RoninTrustedOrganization", "label": "_bridgeVoterList", "offset": 0, diff --git a/deployments/ronin-testnet/RoninValidatorSetLogic.json b/deployments/ronin-testnet/RoninValidatorSetLogic.json index 1c2f9a6dd..624af9396 100644 --- a/deployments/ronin-testnet/RoninValidatorSetLogic.json +++ b/deployments/ronin-testnet/RoninValidatorSetLogic.json @@ -1,5 +1,5 @@ { - "address": "0x679f49c06ee7c0e6b7c4f0f869a534a3533c7dd2", + "address": "0xb65B875BE27E5E399FCbfc99c60574218DE2692B", "abi": [ { "inputs": [], @@ -2047,39 +2047,39 @@ "type": "receive" } ], - "transactionHash": "0x09d9aa0f5f817d0886f5343a5c082dc9fe32099e1fe90eca3f1fd1a557b1d520", + "transactionHash": "0xe0fb7133540d74c3e1a4e706afcf21474236e1727d5d6c50b5d0caeb297f21a9", "receipt": { "to": null, - "from": "0x968d0cd7343f711216817e617d3f92a23dc91c07", - "contractAddress": "0x679f49c06ee7c0e6b7c4f0f869a534a3533c7dd2", - "transactionIndex": "0x0", - "gasUsed": "0x3f3e2a", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000080000000000000000000000000000000800000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000", - "blockHash": "0xe546c290dccb2e53c1dc15a4525ecd6342de7a1798505175231f694f87a9ea73", - "transactionHash": "0x09d9aa0f5f817d0886f5343a5c082dc9fe32099e1fe90eca3f1fd1a557b1d520", + "from": "0x968D0Cd7343f711216817E617d3f92a23dC91c07", + "contractAddress": "0xb65B875BE27E5E399FCbfc99c60574218DE2692B", + "transactionIndex": 0, + "gasUsed": "4144682", + "logsBloom": "0x00000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000140000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x1341137bf23031916f59a3d935a61dd2b832b1ac93f919f3f04786b7282e95df", + "transactionHash": "0xe0fb7133540d74c3e1a4e706afcf21474236e1727d5d6c50b5d0caeb297f21a9", "logs": [ { - "address": "0x679f49c06ee7c0e6b7c4f0f869a534a3533c7dd2", + "transactionIndex": 0, + "blockNumber": 19351171, + "transactionHash": "0xe0fb7133540d74c3e1a4e706afcf21474236e1727d5d6c50b5d0caeb297f21a9", + "address": "0xb65B875BE27E5E399FCbfc99c60574218DE2692B", "topics": [ "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" ], "data": "0x00000000000000000000000000000000000000000000000000000000000000ff", - "blockNumber": "0x12294f3", - "transactionHash": "0x09d9aa0f5f817d0886f5343a5c082dc9fe32099e1fe90eca3f1fd1a557b1d520", - "transactionIndex": "0x0", - "blockHash": "0xe546c290dccb2e53c1dc15a4525ecd6342de7a1798505175231f694f87a9ea73", - "logIndex": "0x0", - "removed": false + "logIndex": 0, + "blockHash": "0x1341137bf23031916f59a3d935a61dd2b832b1ac93f919f3f04786b7282e95df" } ], - "blockNumber": "0x12294f3", - "cumulativeGasUsed": "0x3f3e2a", - "status": "0x1" + "blockNumber": 19351171, + "cumulativeGasUsed": "4144682", + "status": 1, + "byzantium": true }, "args": [], - "numDeployments": 10, - "solcInputHash": "391431ae2d12b53e8d8ece51e5badeb1", - "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"ErrAlreadyRequestedEmergencyExit\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrAlreadyRequestedRevokingCandidate\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrAlreadyRequestedUpdatingCommissionRate\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrAlreadyWrappedEpoch\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrAtEndOfEpochOnly\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrCallPrecompiled\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrCallerMustBeCoinbase\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"validator\",\"type\":\"address\"}],\"name\":\"ErrCannotBailout\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"}],\"name\":\"ErrContractTypeNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrExceedsMaxNumberOfCandidate\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrExistentCandidate\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_candidateAdminAddr\",\"type\":\"address\"}],\"name\":\"ErrExistentCandidateAdmin\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_treasuryAddr\",\"type\":\"address\"}],\"name\":\"ErrExistentTreasury\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"},{\"internalType\":\"uint256\",\"name\":\"currentBalance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"sendAmount\",\"type\":\"uint256\"}],\"name\":\"ErrInsufficientBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidCommissionRate\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidEffectiveDaysOnwards\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidMaxPrioritizedValidatorNumber\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidMinEffectiveDaysOnwards\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrNonExistentCandidate\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"}],\"name\":\"ErrRecipientRevert\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrTrustedOrgCannotRenounce\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"},{\"internalType\":\"enum RoleAccess\",\"name\":\"expectedRole\",\"type\":\"uint8\"}],\"name\":\"ErrUnauthorized\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrUnauthorizedReceiveRON\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"},{\"internalType\":\"enum ContractType\",\"name\":\"expectedContractType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"actual\",\"type\":\"address\"}],\"name\":\"ErrUnexpectedInternalCall\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"ErrZeroCodeContract\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NonExistentRecyclingInfo\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"epoch\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"consensusAddrs\",\"type\":\"address[]\"}],\"name\":\"BlockProducerSetUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"coinbaseAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"rewardAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"enum ICoinbaseExecution.BlockRewardDeprecatedType\",\"name\":\"deprecatedType\",\"type\":\"uint8\"}],\"name\":\"BlockRewardDeprecated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"coinbaseAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"submittedAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bonusAmount\",\"type\":\"uint256\"}],\"name\":\"BlockRewardSubmitted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"bridgeOperator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipientAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"BridgeOperatorRewardDistributed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"bridgeOperator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"contractBalance\",\"type\":\"uint256\"}],\"name\":\"BridgeOperatorRewardDistributionFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"epoch\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"bridgeOperators\",\"type\":\"address[]\"}],\"name\":\"BridgeOperatorSetUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"treasuryAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"name\":\"CandidateGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"revokingTimestamp\",\"type\":\"uint256\"}],\"name\":\"CandidateRevokingTimestampUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"topupDeadline\",\"type\":\"uint256\"}],\"name\":\"CandidateTopupDeadlineUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"consensusAddrs\",\"type\":\"address[]\"}],\"name\":\"CandidatesRevoked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"effectiveTimestamp\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"rate\",\"type\":\"uint256\"}],\"name\":\"CommissionRateUpdateScheduled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"rate\",\"type\":\"uint256\"}],\"name\":\"CommissionRateUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"ContractUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipientAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"}],\"name\":\"DeprecatedRewardRecycleFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipientAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"DeprecatedRewardRecycled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"EmergencyExitLockedAmountUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"unlockedAmount\",\"type\":\"uint256\"}],\"name\":\"EmergencyExitLockedFundReleased\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"unlockedAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"contractBalance\",\"type\":\"uint256\"}],\"name\":\"EmergencyExitLockedFundReleasingFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lockedAmount\",\"type\":\"uint256\"}],\"name\":\"EmergencyExitRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"EmergencyExpiryDurationUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"MaxPrioritizedValidatorNumberUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"threshold\",\"type\":\"uint256\"}],\"name\":\"MaxValidatorCandidateUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"MaxValidatorNumberUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"numOfDays\",\"type\":\"uint256\"}],\"name\":\"MinEffectiveDaysOnwardsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MiningRewardDistributed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"contractBalance\",\"type\":\"uint256\"}],\"name\":\"MiningRewardDistributionFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"totalAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"consensusAddrs\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"name\":\"StakingRewardDistributed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"totalAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"consensusAddrs\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"contractBalance\",\"type\":\"uint256\"}],\"name\":\"StakingRewardDistributionFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"jailedUntil\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"deductedStakingAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"blockProducerRewardDeprecated\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"bridgeOperatorRewardDeprecated\",\"type\":\"bool\"}],\"name\":\"ValidatorPunished\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"consensusAddrs\",\"type\":\"address[]\"}],\"name\":\"ValidatorSetUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"validator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"}],\"name\":\"ValidatorUnjailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"periodNumber\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"epochNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"periodEnding\",\"type\":\"bool\"}],\"name\":\"WrappedUpEpoch\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"DEFAULT_ADDITION_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"PERIOD_DURATION\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"checkJailed\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_blockNum\",\"type\":\"uint256\"}],\"name\":\"checkJailedAtBlock\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_addrList\",\"type\":\"address[]\"}],\"name\":\"checkManyJailed\",\"outputs\":[{\"internalType\":\"bool[]\",\"name\":\"_result\",\"type\":\"bool[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_blockProducer\",\"type\":\"address\"}],\"name\":\"checkMiningRewardDeprecated\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_result\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_blockProducer\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_period\",\"type\":\"uint256\"}],\"name\":\"checkMiningRewardDeprecatedAtPeriod\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_result\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentPeriod\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentPeriodStartAtBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"emergencyExitLockedAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"emergencyExpiryDuration\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_block\",\"type\":\"uint256\"}],\"name\":\"epochEndingAt\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_block\",\"type\":\"uint256\"}],\"name\":\"epochOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_candidateAdmin\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address payable\",\"name\":\"_treasuryAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_commissionRate\",\"type\":\"uint256\"}],\"name\":\"execApplyValidatorCandidate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_validatorAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_period\",\"type\":\"uint256\"}],\"name\":\"execBailOut\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_secLeftToRevoke\",\"type\":\"uint256\"}],\"name\":\"execEmergencyExit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address payable\",\"name\":\"_recipient\",\"type\":\"address\"}],\"name\":\"execReleaseLockedFundForEmergencyExitRequest\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_secsLeft\",\"type\":\"uint256\"}],\"name\":\"execRequestRenounceCandidate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_effectiveDaysOnwards\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_commissionRate\",\"type\":\"uint256\"}],\"name\":\"execRequestUpdateCommissionRate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_validatorAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_newJailedUntil\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_slashAmount\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"_cannotBailout\",\"type\":\"bool\"}],\"name\":\"execSlash\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBlockProducers\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"_result\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_candidate\",\"type\":\"address\"}],\"name\":\"getCandidateInfo\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address payable\",\"name\":\"treasuryAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"______deprecatedbridgeOperatorAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"commissionRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"revokingTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"topupDeadline\",\"type\":\"uint256\"}],\"internalType\":\"struct ICandidateManager.ValidatorCandidate\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCandidateInfos\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address payable\",\"name\":\"treasuryAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"______deprecatedbridgeOperatorAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"commissionRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"revokingTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"topupDeadline\",\"type\":\"uint256\"}],\"internalType\":\"struct ICandidateManager.ValidatorCandidate[]\",\"name\":\"_list\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_candidate\",\"type\":\"address\"}],\"name\":\"getCommissionChangeSchedule\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"effectiveTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"commissionRate\",\"type\":\"uint256\"}],\"internalType\":\"struct ICandidateManager.CommissionSchedule\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"}],\"name\":\"getContract\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"contract_\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"}],\"name\":\"getEmergencyExitInfo\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"lockedAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"recyclingAt\",\"type\":\"uint256\"}],\"internalType\":\"struct ICommonInfo.EmergencyExitInfo\",\"name\":\"_info\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"getJailedTimeLeft\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"isJailed_\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"blockLeft_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"epochLeft_\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_blockNum\",\"type\":\"uint256\"}],\"name\":\"getJailedTimeLeftAtBlock\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"isJailed_\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"blockLeft_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"epochLeft_\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLastUpdatedBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getValidatorCandidates\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getValidators\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"_validatorList\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"__slashIndicatorContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"__stakingContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"__stakingVestingContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"__maintenanceContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"__roninTrustedOrganizationContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"__maxValidatorNumber\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"__maxValidatorCandidate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"__maxPrioritizedValidatorNumber\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"__minEffectiveDaysOnwards\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"__numberOfBlocksInEpoch\",\"type\":\"uint256\"},{\"internalType\":\"uint256[2]\",\"name\":\"__emergencyExitConfigs\",\"type\":\"uint256[2]\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initializeV2\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"isBlockProducer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_candidate\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_admin\",\"type\":\"address\"}],\"name\":\"isCandidateAdmin\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isPeriodEnding\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"isValidatorCandidate\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxPrioritizedValidatorNumber\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_maximumPrioritizedValidatorNumber\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxValidatorCandidate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxValidatorNumber\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_maximumValidatorNumber\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minEffectiveDaysOnwards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"numberOfBlocksInEpoch\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_numberOfBlocks\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"precompilePickValidatorSetAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"precompileSortValidatorsAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setContract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_emergencyExitLockedAmount\",\"type\":\"uint256\"}],\"name\":\"setEmergencyExitLockedAmount\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_emergencyExpiryDuration\",\"type\":\"uint256\"}],\"name\":\"setEmergencyExpiryDuration\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_number\",\"type\":\"uint256\"}],\"name\":\"setMaxPrioritizedValidatorNumber\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_number\",\"type\":\"uint256\"}],\"name\":\"setMaxValidatorCandidate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_max\",\"type\":\"uint256\"}],\"name\":\"setMaxValidatorNumber\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_numOfDays\",\"type\":\"uint256\"}],\"name\":\"setMinEffectiveDaysOnwards\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"submitBlockReward\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalBlockProducers\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_total\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalDeprecatedReward\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_epoch\",\"type\":\"uint256\"}],\"name\":\"tryGetPeriodOfEpoch\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_filled\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"_periodNumber\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"validatorCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"wrapUpEpoch\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"errors\":{\"ErrAlreadyRequestedEmergencyExit()\":[{\"details\":\"Error of already requested emergency exit before.\"}],\"ErrAlreadyRequestedRevokingCandidate()\":[{\"details\":\"Error of already requested revoking candidate before.\"}],\"ErrAlreadyRequestedUpdatingCommissionRate()\":[{\"details\":\"Error of commission change schedule exists.\"}],\"ErrAlreadyWrappedEpoch()\":[{\"details\":\"Error of query for already wrapped up epoch\"}],\"ErrAtEndOfEpochOnly()\":[{\"details\":\"Error of only allowed at the end of epoch\"}],\"ErrCallPrecompiled()\":[{\"details\":\"Error of call to precompile fails.\"}],\"ErrCallerMustBeCoinbase()\":[{\"details\":\"Error of method caller must be coinbase\"}],\"ErrCannotBailout(address)\":[{\"details\":\"Error of cannot bailout due to high tier slash.\"}],\"ErrContractTypeNotFound(uint8)\":[{\"details\":\"Error of invalid role.\"}],\"ErrExceedsMaxNumberOfCandidate()\":[{\"details\":\"Error of exceeding maximum number of candidates.\"}],\"ErrExistentCandidate()\":[{\"details\":\"Error of querying for already existent candidate.\"}],\"ErrExistentCandidateAdmin(address)\":[{\"details\":\"Error of candidate admin already exists.\"}],\"ErrExistentTreasury(address)\":[{\"details\":\"Error of treasury already exists.\"}],\"ErrInsufficientBalance(bytes4,uint256,uint256)\":[{\"details\":\"Error of sender has insufficient balance.\"}],\"ErrInvalidCommissionRate()\":[{\"details\":\"Error of invalid commission rate.\"}],\"ErrInvalidEffectiveDaysOnwards()\":[{\"details\":\"Error of invalid effective days onwards.\"}],\"ErrInvalidMaxPrioritizedValidatorNumber()\":[{\"details\":\"Error thrown when an invalid maximum prioritized validator number is provided.\"}],\"ErrInvalidMinEffectiveDaysOnwards()\":[{\"details\":\"Error of invalid min effective days onwards.\"}],\"ErrNonExistentCandidate()\":[{\"details\":\"Error of querying for non-existent candidate.\"}],\"ErrRecipientRevert(bytes4)\":[{\"details\":\"Error of recipient not accepting RON when transfer RON.\"}],\"ErrTrustedOrgCannotRenounce()\":[{\"details\":\"Error of trusted org cannot renounce.\"}],\"ErrUnauthorized(bytes4,uint8)\":[{\"details\":\"Error indicating that the caller is unauthorized to perform a specific function.\",\"params\":{\"expectedRole\":\"The role required to perform the function.\",\"msgSig\":\"The function signature (bytes4) that the caller is unauthorized to perform.\"}}],\"ErrUnauthorizedReceiveRON()\":[{\"details\":\"Error thrown when receives RON from neither staking vesting contract nor staking contract\"}],\"ErrUnexpectedInternalCall(bytes4,uint8,address)\":[{\"details\":\"Error indicating that the caller is unauthorized to perform a specific function.\",\"params\":{\"actual\":\"The actual address that called to the function.\",\"expectedContractType\":\"The contract type required to perform the function.\",\"msgSig\":\"The function signature (bytes4).\"}}],\"ErrZeroCodeContract(address)\":[{\"details\":\"Error of set to non-contract.\"}],\"NonExistentRecyclingInfo()\":[{\"details\":\"Error thrown when queries for a non existent info.\"}]},\"kind\":\"dev\",\"methods\":{\"checkJailed(address)\":{\"details\":\"Returns whether the validator are put in jail (cannot join the set of validators) during the current period.\"},\"checkJailedAtBlock(address,uint256)\":{\"details\":\"Returns whether the validator are put in jail (cannot join the set of validators) at a specific block.\"},\"checkManyJailed(address[])\":{\"details\":\"Returns whether the validators are put in jail (cannot join the set of validators) during the current period.\"},\"checkMiningRewardDeprecated(address)\":{\"details\":\"Returns whether the incoming reward of the block producer is deprecated during the current period.\"},\"checkMiningRewardDeprecatedAtPeriod(address,uint256)\":{\"details\":\"Returns whether the incoming reward of the block producer is deprecated during a specific period.\"},\"currentPeriod()\":{\"details\":\"Returns the period index from the current block.\"},\"currentPeriodStartAtBlock()\":{\"details\":\"Returns the block number that the current period starts at.\"},\"emergencyExitLockedAmount()\":{\"details\":\"Returns the amount of RON to lock from a consensus address.\"},\"emergencyExpiryDuration()\":{\"details\":\"Returns the duration that an emergency request is expired and the fund will be recycled.\"},\"epochEndingAt(uint256)\":{\"details\":\"Returns whether the epoch ending is at the block number `_block`.\"},\"epochOf(uint256)\":{\"details\":\"Returns the epoch index from the block number.\"},\"execApplyValidatorCandidate(address,address,address,uint256)\":{\"details\":\"Grants a validator candidate. Requirements: - The method caller is staking contract. Emits the event `CandidateGranted`.\"},\"execBailOut(address,uint256)\":{\"details\":\"Finalize the bailout request from slash indicator contract. Requirements: - The method caller is slash indicator contract. Emits the event `ValidatorUnjailed`.\"},\"execEmergencyExit(address,uint256)\":{\"details\":\"Fallback function of `IStaking-requestEmergencyExit`. Requirements: - The method caller is staking contract.\"},\"execReleaseLockedFundForEmergencyExitRequest(address,address)\":{\"details\":\"Unlocks fund for emergency exit request. Requirements: - The method caller is admin. Emits the event `EmergencyExitLockedFundReleased` if the fund is successfully unlocked. Emits the event `EmergencyExitLockedFundReleasingFailed` if the fund is failed to unlock.\"},\"execRequestRenounceCandidate(address,uint256)\":{\"details\":\"Requests to revoke a validator candidate in next `_secsLeft` seconds. Requirements: - The method caller is staking contract. Emits the event `CandidateRevokingTimestampUpdated`.\"},\"execRequestUpdateCommissionRate(address,uint256,uint256)\":{\"details\":\"Fallback function of `CandidateStaking-requestUpdateCommissionRate`. Requirements: - The method caller is the staking contract. - The `_effectiveTimestamp` must be the beginning of a UTC day, and at least from 7 days onwards - The `_rate` must be in range of [0_00; 100_00]. Emits the event `CommissionRateUpdateScheduled`.\"},\"execSlash(address,uint256,uint256,bool)\":{\"details\":\"Finalize the slash request from slash indicator contract. Requirements: - The method caller is slash indicator contract. Emits the event `ValidatorPunished`.\"},\"getBlockProducers()\":{\"details\":\"Returns the current block producer list.\"},\"getCandidateInfo(address)\":{\"details\":\"Returns the info of a candidate.\"},\"getCandidateInfos()\":{\"details\":\"Returns all candidate info.\"},\"getCommissionChangeSchedule(address)\":{\"details\":\"Returns the schedule of changing commission rate of a candidate address.\"},\"getContract(uint8)\":{\"details\":\"Returns the address of a contract with a specific role. Throws an error if no contract is set for the specified role.\",\"params\":{\"contractType\":\"The role of the contract to retrieve.\"},\"returns\":{\"contract_\":\"The address of the contract with the specified role.\"}},\"getEmergencyExitInfo(address)\":{\"details\":\"Returns the emergency exit request.\"},\"getJailedTimeLeft(address)\":{\"details\":\"Returns whether the validator are put in jail and the number of block and epoch that he still is in the jail.\"},\"getJailedTimeLeftAtBlock(address,uint256)\":{\"details\":\"Returns whether the validator are put in jail at a specific block and the number of block and epoch that he still is in the jail.\"},\"getLastUpdatedBlock()\":{\"details\":\"Returns the block that validator set was updated.\"},\"getValidatorCandidates()\":{\"details\":\"Returns the validator candidate.\"},\"getValidators()\":{\"details\":\"Returns the current validator list.\"},\"initialize(address,address,address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256[2])\":{\"details\":\"Initializes the contract storage.\"},\"isBlockProducer(address)\":{\"details\":\"Returns whether the address is block producer or not.\"},\"isCandidateAdmin(address,address)\":{\"details\":\"Returns whether the address is the candidate admin.\"},\"isPeriodEnding()\":{\"details\":\"Returns whether the period ending at the current block number.\"},\"isValidatorCandidate(address)\":{\"details\":\"Returns whether the address is a validator (candidate).\"},\"maxPrioritizedValidatorNumber()\":{\"details\":\"Returns the number of reserved slots for prioritized validators.\"},\"maxValidatorCandidate()\":{\"details\":\"Returns the maximum number of validator candidate.\"},\"maxValidatorNumber()\":{\"details\":\"Returns the maximum number of validators in the epoch.\"},\"minEffectiveDaysOnwards()\":{\"details\":\"Returns the minimum number of days to the effective date of commission rate change.\"},\"numberOfBlocksInEpoch()\":{\"details\":\"Returns the number of blocks in a epoch.\"},\"precompilePickValidatorSetAddress()\":{\"details\":\"Gets the address of the precompile of picking validator set\"},\"precompileSortValidatorsAddress()\":{\"details\":\"Gets the address of the precompile of sorting validators\"},\"setContract(uint8,address)\":{\"details\":\"Sets the address of a contract with a specific role. Emits the event {ContractUpdated}.\",\"params\":{\"addr\":\"The address of the contract to set.\",\"contractType\":\"The role of the contract to set.\"}},\"setEmergencyExitLockedAmount(uint256)\":{\"details\":\"Sets the amount of RON to lock from a consensus address. Requirements: - The method caller is admin. Emits the event `EmergencyExitLockedAmountUpdated`.\"},\"setEmergencyExpiryDuration(uint256)\":{\"details\":\"Sets the duration that an emergency request is expired and the fund will be recycled. Requirements: - The method caller is admin. Emits the event `EmergencyExpiryDurationUpdated`.\"},\"setMaxPrioritizedValidatorNumber(uint256)\":{\"details\":\"Updates the number of reserved slots for prioritized validators Requirements: - The method caller is admin Emits the event `MaxPrioritizedValidatorNumberUpdated`\"},\"setMaxValidatorCandidate(uint256)\":{\"details\":\"Sets the maximum number of validator candidate. Requirements: - The method caller is admin. Emits the `MaxValidatorCandidateUpdated` event.\"},\"setMaxValidatorNumber(uint256)\":{\"details\":\"Updates the max validator number Requirements: - The method caller is admin Emits the event `MaxValidatorNumberUpdated`\"},\"setMinEffectiveDaysOnwards(uint256)\":{\"details\":\"Sets the minimum number of days to the effective date of commision rate change. Requirements: - The method caller is admin. Emits the `MinEffectiveDaysOnwardsUpdated` event.\"},\"submitBlockReward()\":{\"details\":\"Submits reward of the current block. Requirements: - The method caller is coinbase. Emits the event `MiningRewardDeprecated` if the coinbase is slashed or no longer be a block producer. Emits the event `BlockRewardSubmitted` for the valid call.\"},\"totalBlockProducers()\":{\"details\":\"Returns total numbers of the block producers.\"},\"totalDeprecatedReward()\":{\"details\":\"Returns the total deprecated reward, which includes reward that is not sent for slashed validators and unsastified bridge operators\"},\"tryGetPeriodOfEpoch(uint256)\":{\"details\":\"Tries to get the period index from the epoch number.\"},\"wrapUpEpoch()\":{\"details\":\"Wraps up the current epoch. Requirements: - The method must be called when the current epoch is ending. - The epoch is not wrapped yet. - The method caller is coinbase. Emits the event `MiningRewardDistributed` when some validator has reward distributed. Emits the event `StakingRewardDistributed` when some staking pool has reward distributed. Emits the event `BlockProducerSetUpdated` when the epoch is wrapped up. Emits the event `BridgeOperatorSetUpdated` when the epoch is wrapped up at period ending. Emits the event `ValidatorSetUpdated` when the epoch is wrapped up at period ending, and the validator set gets updated. Emits the event `WrappedUpEpoch`.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/ronin/validator/RoninValidatorSet.sol\":\"RoninValidatorSet\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/proxy/utils/Initializable.sol\":{\"keccak256\":\"0x2a21b14ff90012878752f230d3ffd5c3405e5938d06c97a7d89c0a64561d0d66\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://3313a8f9bb1f9476857c9050067b31982bf2140b83d84f3bc0cec1f62bbe947f\",\"dweb:/ipfs/Qma17Pk8NRe7aB4UD3jjVxk7nSFaov3eQyv86hcyqkwJRV\"]},\"@openzeppelin/contracts/utils/Address.sol\":{\"keccak256\":\"0xd6153ce99bcdcce22b124f755e72553295be6abcd63804cfdffceb188b8bef10\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://35c47bece3c03caaa07fab37dd2bb3413bfbca20db7bd9895024390e0a469487\",\"dweb:/ipfs/QmPGWT2x3QHcKxqe6gRmAkdakhbaRgx3DLzcakHz5M4eXG\"]},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://39e096c60a6eb1c6a257122d515496bd92d0c6a693a8f07acb6aa4b1263e95d4\",\"dweb:/ipfs/QmPs5trJBacCiSkezP6tpevapuRYWNY6mqSFzsMCJj7e6B\"]},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://be161e54f24e5c6fae81a12db1a8ae87bc5ae1b0ddc805d82a1440a68455088f\",\"dweb:/ipfs/QmP7C3CHdY9urF4dEMb9wmsp1wMxHF6nhA2yQE5SKiPAdy\"]},\"contracts/extensions/RONTransferHelper.sol\":{\"keccak256\":\"0xdece837caa8da00fe031b8139ada009330b8bef149af12b535913c021ab94d0e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://11af5018dd76ccfca6c4cfb886019987d88830c02efcec999c02d3e6d907475a\",\"dweb:/ipfs/QmNyEcRDvrCENivjdmw3TxMFDBcQNvEUzHorra7HkERLWf\"]},\"contracts/extensions/collections/HasContracts.sol\":{\"keccak256\":\"0x9e1dceb68827adfb8c8184662f29ab5fe14e292a632878150e3b0b6c61bc1dce\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b8903232a7a609b250a1ff2e9522a2366979652145af74637f9c0089916e3da3\",\"dweb:/ipfs/QmVoxZamJEhjYhr9RKVSAKGzakgqmFLfZXhZcDGor7DZe5\"]},\"contracts/extensions/collections/HasProxyAdmin.sol\":{\"keccak256\":\"0x06e5962713a77abf6d5ba646e1cc1cfb6f9c50e7d52520dd82a10bf309534187\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ed488e893c5010f08025c7d5be779631eba1b93bc3f361a818704471326201ea\",\"dweb:/ipfs/QmQxHpZDbHKSdzHgbvQqKdTQoyAjG25itjFLytsjnEGy4f\"]},\"contracts/extensions/consumers/GlobalConfigConsumer.sol\":{\"keccak256\":\"0x96d6b1ea4c8e126a8c2468683e7513d195f8e05456d85dd8f259ab049347b527\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://23a7906515d4648b243fb01f8053b1595e8c1c62fa9745b56ed296372da6ebdf\",\"dweb:/ipfs/QmdUjefqn52Hu7bjAKYJMRanPy7fdKqJAtnqSB2793Zhfm\"]},\"contracts/extensions/consumers/PercentageConsumer.sol\":{\"keccak256\":\"0x5dc54a24348c5d614de1b4805dddeab4dda72f9f0636b27bf0ed295fee017dcf\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://e97f64c7f3522d605c5e8d6d96d568e0b8cb6b2f21cc288d508cbe43b831f5d9\",\"dweb:/ipfs/QmT9hBanREurnngznkfTAhHu4qDQu3F3hPXTzKgKjSWz7r\"]},\"contracts/interfaces/IMaintenance.sol\":{\"keccak256\":\"0xd399a23652fc0180280f0079dd4be420d807774bcf6bc12672f4238480e757e9\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://76bb142eea221ccdf55d69a74adfd9edb4adb2243e9e9294dfac5a38b5525c70\",\"dweb:/ipfs/QmW6ST9Ahwdx7RuvKiiPBuebsFmgoqPs5zUrSLiDyh7Xrz\"]},\"contracts/interfaces/IQuorum.sol\":{\"keccak256\":\"0x6b7920b04a73a0e1ff7404aa1a3b5fc738fc0b6154839480f666fd69b55123f0\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://a8c81134e4632e1240aead39fd5393b376a4be53668caf2a390f511f3c6d422d\",\"dweb:/ipfs/QmWPaQPP1WkpdPjLhK7wFXsih8HWs6kRQqjX5zGLu6McGH\"]},\"contracts/interfaces/IRoninGovernanceAdmin.sol\":{\"keccak256\":\"0x4ee85b5dc2b33068bc7cbe168ae26328a6459f98c558aba5d9e5a1d6aead0da8\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://2a3f3608d19c73d5b60a22317fa0594778aad515a6d9c5dc5b7bad8f5ac1f4f9\",\"dweb:/ipfs/QmYTPxJJGG9oycJDupSRv6YQaS8k3GuA46LmVZ3tStTpg2\"]},\"contracts/interfaces/IRoninTrustedOrganization.sol\":{\"keccak256\":\"0x28b0407cf740164f3ddf4a44952423604439cda580f286c6ed1edcdb59b219d0\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://39a4bd18d5a200d3bd290ef6b275ca325eeb7dae766e1bc7f053c5ad9ef79136\",\"dweb:/ipfs/QmYWkxdyTk4WsEUWWyo2oTtAVreNagVioVzdCknX8Lzare\"]},\"contracts/interfaces/IStakingVesting.sol\":{\"keccak256\":\"0x2ff4922cdba4d9094210734d890ec7e644bc25efb711f741bbe2016a9dff9e2a\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://25cafa285ceed17b2efebd107c7b91d751efffac757e032b805fc5e2e7852cd1\",\"dweb:/ipfs/QmRPR6HuBB96oLDXmxzx64NtT35VDJgeAYqDiXkiGMtFFm\"]},\"contracts/interfaces/collections/IHasContracts.sol\":{\"keccak256\":\"0x99d8213d857e30d367155abd15dc42730afdfbbac3a22dfb3b95ffea2083a92e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://03390ff29b496e244faf4eab55565712f0aea5fecdcb915e3c5866ef29d5686d\",\"dweb:/ipfs/QmdGpXn3VSxfNvjFBxfho7rc41JTq5m6bonrfmpzShhRVs\"]},\"contracts/interfaces/consumers/PeriodWrapperConsumer.sol\":{\"keccak256\":\"0xb6777e3c364306eb8d5355583c1aca44de9d351cb40ddf1cea832206d4aad272\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://f158da03631d0e3c4558a18fc50e7f2416172983cfbb14a158dd4fc7c83c7053\",\"dweb:/ipfs/QmX8Vq2sKEAckrMEN5W5LaUzE7ppdaR7scv8amyV1YEXGG\"]},\"contracts/interfaces/slash-indicator/IBaseSlash.sol\":{\"keccak256\":\"0x04d449f2852840566dfff4e3673929f6e9b8d9b5fc5b29744bf4f344dc7f9bc0\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://556068b57b4594d9ca8e23bd3cc49e2b58f3a149faacf597d2650f355bae63f5\",\"dweb:/ipfs/QmR5Bc9GQsyiGPGSxNxxT2uP2QbSW17KiWGJ3yRyuvGGUU\"]},\"contracts/interfaces/slash-indicator/ICreditScore.sol\":{\"keccak256\":\"0x26021ddf339495816692ea9f8545b4054d0ffb9c5ad11049cac4f3718a0bbc2d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://78be72af4c66b1156e34285cebbe996c9e12a1dddc7064ba19dc31c9ca29f04a\",\"dweb:/ipfs/QmQc6Qziq8FK22pHezjNK6anUpdRtLyTnUfbiYdo7KBFDT\"]},\"contracts/interfaces/slash-indicator/ISlashBridgeOperator.sol\":{\"keccak256\":\"0x3ea38604baf3bc5a12dd1a243eec2052de9ee2cb171222a2e5b0e5202d301471\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://efe7768c54473cdd7ea25abf571302059266a7aeff5a29bada77ac1364b0af0c\",\"dweb:/ipfs/QmfXxeWbvybKEb13wBBJgmYT1N9p7txEGnZPPKNwP1AhHL\"]},\"contracts/interfaces/slash-indicator/ISlashBridgeVoting.sol\":{\"keccak256\":\"0x89751cbf99adf7dbd165fbbba5d6b62b5c47f8486322a7abb27d6d6aef345fae\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4d3d95b75ae204e2d7734590f9ae2adfec28e786c981a990157888ca9bc0a9b8\",\"dweb:/ipfs/QmSeRfhkrHiN1CNFQWZbVLvfPFw4jJQg8sm6uK1PLMcsvg\"]},\"contracts/interfaces/slash-indicator/ISlashDoubleSign.sol\":{\"keccak256\":\"0x5b7c9b07d0f97c589789eb0775411825df2163bdf893fb5df1113415b91b91ed\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://12d9e0d0dc03be251d4f0e1e928c19ae0c465992d7a1da6abdcdbf8f34095e6f\",\"dweb:/ipfs/QmQkXqx1eMxts6q9RdGjAfjTZq4MaDwZWDBpMXMCazkX41\"]},\"contracts/interfaces/slash-indicator/ISlashIndicator.sol\":{\"keccak256\":\"0xe8b8fde3af614735cb304bc1eb82b05d65ede4df804b5d555787e5d5ecb95ec0\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://7c457aec7776026962e2a9e606f6b4bb76de6c4407ff5ca0197348c3a991612e\",\"dweb:/ipfs/QmPGBqNCqkUFvcktSryxS99Apzqq6MZF7S28hVrockzanS\"]},\"contracts/interfaces/slash-indicator/ISlashUnavailability.sol\":{\"keccak256\":\"0x458a7ae130a59b59b7f095fe3d4db8f779e0614041e5615f0afd36c543ac2046\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://947dcfcf74803babe38e80b37d234796cda3831a2f19936e98a0954c3936ee0e\",\"dweb:/ipfs/QmQW8ux3awTt8BNH6NnWtPNSBvWTA36wR35bTj1Eymx1D6\"]},\"contracts/interfaces/staking/IBaseStaking.sol\":{\"keccak256\":\"0x90517268a0e31147d97772c9ae518caa5eb8c03efe3b369e3c6d5166422f5962\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://cb491a0f017e3426a4c96344e65a1e3f26603759758159c8a75b731029a574d9\",\"dweb:/ipfs/QmTQ6jhx6pzzPdubogP5ktSyrhg5PspbCVaQaeHS4AJDg7\"]},\"contracts/interfaces/staking/ICandidateStaking.sol\":{\"keccak256\":\"0x9bc6ba6d13f00d9928c0add35ee6406906e16ed86207d373460930c0a75e5938\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://36091a688331967fbfff2890250653dc15906bf0f7bad1fe4019fb7db6c8a44f\",\"dweb:/ipfs/Qme2NLnJHrwa9pWA2aJevECkpgoN83EJFMofcJEhL24DN9\"]},\"contracts/interfaces/staking/IDelegatorStaking.sol\":{\"keccak256\":\"0x6dd71bf0c17a65da0dee49b98e4b038c1dd0e74f5473d03570421ceebd5b7084\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://c4b494d452bdfd70169edbc8fe348ccde87b626fa3eda23af15cf9b4c2287f51\",\"dweb:/ipfs/QmZ1EiHHUWE1ATTSoYs2iKQLw5YTV7zpQ9zBU6SNFUTAFP\"]},\"contracts/interfaces/staking/IRewardPool.sol\":{\"keccak256\":\"0x52349fecb897b3b8288d8732923551382822c0c5fb8db9c6b094d080a16a2129\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://67c0c9c2a736e1ba3bf329edef9d7d675dc86a5efe569fe49f9611896acd0667\",\"dweb:/ipfs/Qmc31DL6bovfqbdRb4a3Cqg1Gge8mC82Q43uh2HmS7YGvT\"]},\"contracts/interfaces/staking/IStaking.sol\":{\"keccak256\":\"0xd302d4a78203e277fb95a89de7ae32a3102129d3fbd64fc75f92d18be0443408\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://8ed162378c575055c0dff266b578780d3799613cf7912c0adb7428e35f70231f\",\"dweb:/ipfs/QmbnSRJwU3jee9zcvW12cYRuGpqThtx9zHzpGPQdsp6sNy\"]},\"contracts/interfaces/validator/ICandidateManager.sol\":{\"keccak256\":\"0x9ab205c736f1bcc9a3debe06e08d829f4857141d940e6f608236f136193a7f49\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://89fe20c6aafc45d103394283c8e8aec047de384044c6e0d1a16e191703969088\",\"dweb:/ipfs/QmWLW5QjyboHGSadKgojvy8DU1qWJTXdvATEx24pJEEkzx\"]},\"contracts/interfaces/validator/ICoinbaseExecution.sol\":{\"keccak256\":\"0xe4060b7e3b04a0043bd334011fe4ba67c990b0484dad52d7f14b35040989b6ab\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://a9fb73aa9276081e364d1d43f6404878d37c1d7e089cc2482f973011e7890056\",\"dweb:/ipfs/QmNVYGSLQpDFYTEgP8UBFbtxbRksE2Ybyc1QL5rGztgdQe\"]},\"contracts/interfaces/validator/IEmergencyExit.sol\":{\"keccak256\":\"0x45161abd1e3db83052a06889a0e3a7a5e7ee3306478601d58ac4ed32ccaa75ad\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://06091b25304096f52e46fa2f5c693e5dcf30697cb4f25e6eac075a7daea2f2cd\",\"dweb:/ipfs/QmQxNvAdqydyWCjQt3gfXXB8a5dAiLZgCdiJQCtM7Ah19b\"]},\"contracts/interfaces/validator/IRoninValidatorSet.sol\":{\"keccak256\":\"0x813f34747aea4dfb53bbc147abf8dbe5999ce73111c2db99bcb3efb4cf75bb3d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://e858204fc0e1f733b3b8482326a52fb150eb6c657881b7f2a7721d52826f7e4f\",\"dweb:/ipfs/QmboahnNNTeXjcELXsWZUq93wyvQQRMbimm27xDta85wEc\"]},\"contracts/interfaces/validator/ISlashingExecution.sol\":{\"keccak256\":\"0x80362c42fdc0ee06543a2abbffee961fe51c15a7c5e18933a9c34897e50d07fe\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0c1c0f19417522bc7b2926920c31406a2d1e8489e3b4ba61a6b10c31b6aa39a6\",\"dweb:/ipfs/QmTJeCNmgiMbKXnNJAG96YAZ99wu2haY9d8ffn8jU3UBEf\"]},\"contracts/interfaces/validator/info-fragments/ICommonInfo.sol\":{\"keccak256\":\"0x3fdfa86da33b889e5153075ffc028d6b0c607480a96b532fbbbc48ac7bbf27c9\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://8c586009b6c57b4e0daf60123bf4b133a91a42a1d803c332ba0bdaecab871f18\",\"dweb:/ipfs/QmUT8bLX8MfVjLBs1pXEYXFob5YtAq9tEGBz3KV1WKac4B\"]},\"contracts/interfaces/validator/info-fragments/IJailingInfo.sol\":{\"keccak256\":\"0x2b1846b05ca1d636299fb929c1bd7b392b236f5e3f7aa3e7eea2c6d57b8836fb\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://db41b9c12cde1d32f060db3b81eeee93a512cf0188aadfa9e262d9cc15714ef8\",\"dweb:/ipfs/QmfJkTv1kpfbHtz2hQiWhBZN1r725YAnZMHo71gmgQ4J43\"]},\"contracts/interfaces/validator/info-fragments/ITimingInfo.sol\":{\"keccak256\":\"0x77b86a68149389fed0eb0c5b8d56f278d3bd103ba64f504697d709b24c3212d5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://8a0c87e2e9c661730fdecd3cacc54a630ac2dfd35218dcbe41b70bb15d16aea2\",\"dweb:/ipfs/QmcLD62ZZ6YVSECvx7515PVXymbP8SRwayZsy6r4NAiPLJ\"]},\"contracts/interfaces/validator/info-fragments/IValidatorInfoV2.sol\":{\"keccak256\":\"0x6213c188a1323b242a098394b91caf9481e257bd57a0804cb2aa890377a993ed\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://c119c54dedbcf0d4254a08b97231e8d6a961893654622290e8e2077a3f8c2e1f\",\"dweb:/ipfs/QmZNSAbJYkm8JTi8TnXEyHEs95WoxQD4Q43wYzFLUg8Xv4\"]},\"contracts/libraries/AddressArrayUtils.sol\":{\"keccak256\":\"0xaf760162653a85d6e1b24df4d33c74076f778470112f421a02050fb981242001\",\"license\":\"UNLICENSED\",\"urls\":[\"bzz-raw://3a413f290b8e81540bc6feb739bcfbacf56419b2e657bbce5be43826569b4406\",\"dweb:/ipfs/QmWRjGLBXs7WK92oPm51QpjxMYGuMTBx85Pv7QcGbUZE72\"]},\"contracts/libraries/EnumFlags.sol\":{\"keccak256\":\"0xa712f0d1a323ee39f23eb3ee3278b4ec25fe2e536b1ccc629578c66f277c088d\",\"license\":\"UNLICENSED\",\"urls\":[\"bzz-raw://1b05f2717fd40454d68d411ab7bbbf5e3bb8ea6d7f27d335b1338362305904a2\",\"dweb:/ipfs/QmaiGASjWNVyfFzguu5xoKFRcLqGg67DHSd5422b5k6rbb\"]},\"contracts/libraries/Math.sol\":{\"keccak256\":\"0xd73170f448c644a47024c7dbcf4afc3cc7ad27f61737c6ea4c3b543ec5cdb7e9\",\"license\":\"UNLICENSED\",\"urls\":[\"bzz-raw://b4af5bb4d7c57d10844b31211dc52762f69c33f99fe90bf8bd4086b0f7ece4da\",\"dweb:/ipfs/Qma1Gtmp2Y5YMxAXS7XpUQHkc4auz95W6CevSLmD5CFrrB\"]},\"contracts/precompile-usages/PCUPickValidatorSet.sol\":{\"keccak256\":\"0xcb57a021897a773d11be9d98a195e0653f2124b7e95e84c4832b57d9d36d67e1\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://62cfabee3f0ad5ab8ba6b5f318ff33e68a3e532649a958b51fac6ae559ca95c0\",\"dweb:/ipfs/QmPJkxM87o2LGsqSRgTQnnaZJtZRXeRu7ZbGzwNXggMCsr\"]},\"contracts/precompile-usages/PCUSortValidators.sol\":{\"keccak256\":\"0xf2f21d25f9d1b77e591542440c839d98125ae3c41c73de7c42f8c46d95eac717\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://52b9340ff9f29ef0bcf0552142fe1df4036bdea579bf0d023bd3e65d0f706233\",\"dweb:/ipfs/Qmbv3QcysrYQiZiGC9A9Hj6EPRPu52fWFHDhmyX5nfUoqn\"]},\"contracts/precompile-usages/PrecompiledUsage.sol\":{\"keccak256\":\"0x76facc3f3a8dd573c826bbbfedaa5cd8ef30963fbabd8c163c0c72b6efea5551\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://6d7c9e940ba3e89d832b615239ba9e4af44471b3701bd1f480924a7e2c434f63\",\"dweb:/ipfs/QmPtxtdPgTzyw7WpzpLBCX7anYbq5q7zwarz1PzVAFX4zz\"]},\"contracts/ronin/validator/CandidateManager.sol\":{\"keccak256\":\"0x852ddb043e7435ba8ed2f112972d9f09149015840b70dc6f037f4150961a2edc\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://53db09ca50e952fb536905533d596a4654941b21857f13a39a8bf775a7e8fd21\",\"dweb:/ipfs/QmRbS9vzuGxzJsojJRrSdtMuHwYWqM3i1DrXP3w7gjzSJU\"]},\"contracts/ronin/validator/CoinbaseExecution.sol\":{\"keccak256\":\"0x9f818e88e11f25dce245165cd104a9b8bf0c904c21fde8ecc9313f24fb00a827\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b03e01f3a1bbf132386c8fddc2d936e9504e169dc7052d36c219bcf98a680455\",\"dweb:/ipfs/QmYG4U5SkTtw9JvgzUTdFCTVj5dgGJHVtchQpZdymU8XnT\"]},\"contracts/ronin/validator/EmergencyExit.sol\":{\"keccak256\":\"0x7b57a4e3afd9099caa0498ec60fc6cf660512784ca0f864ff44fa1aac6cd26c2\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://da721099dc33a82d6af75154c4f26ca8ca8e6786fe6321d8a58f02c12f0603b9\",\"dweb:/ipfs/QmbqcxVGHyBDkwLR8JjfrB4htcSgdV6FMw89E28QUwMEuA\"]},\"contracts/ronin/validator/RoninValidatorSet.sol\":{\"keccak256\":\"0x69547a144aef031d948dc6fa2c05e0d6aca6023fe9b09b3d40b41c251f37a551\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://8b028767b516a684f65f1c3a6cce9beb70e4894c7d0600636b02d7e869ce1d5f\",\"dweb:/ipfs/Qmdx6dr5RSoU1r8KNutM32GoU5J3MYyy5ur79gACJUSAkn\"]},\"contracts/ronin/validator/SlashingExecution.sol\":{\"keccak256\":\"0x8ae9d88b6c97d3f18b5b047f5a7ecd31b2bd5e7edbedada2b00b468b4a7e3085\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://420455008d11de5f3b5e26ea2c1a88099fde2a9191fa037f5185c4968cfa2244\",\"dweb:/ipfs/QmYc6T3UYEVMeVCa3fJD2JWuaFaCK1pgpijCX8fsLFWhye\"]},\"contracts/ronin/validator/storage-fragments/CommonStorage.sol\":{\"keccak256\":\"0x56e06043fee00341e9523875a58ac171bd039dcf87802f219ca280c974ed8950\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://8b1dac932316a05dc92978de50fdf983c359beb3aa40fe44e043de081012531f\",\"dweb:/ipfs/QmW1Hd5FRNhCArPCRT4XKqm1pcKQ1NGTtG9imsXHddY5tx\"]},\"contracts/ronin/validator/storage-fragments/JailingStorage.sol\":{\"keccak256\":\"0xdef0c07a95baaff5c23b5cacf7747f50a76a150875ae118f8553fe3ae0d15498\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4c64a137711f1aa3504d9c9dac1cf0be859bad338a56fc581b164aee29adce69\",\"dweb:/ipfs/Qmd135rnBhmZjzEiNXym12zRnN6JGKkckgsucUWE7usF8d\"]},\"contracts/ronin/validator/storage-fragments/TimingStorage.sol\":{\"keccak256\":\"0xc545f119b8b8978d793b62f2495dc2d49c3f416791459b9833bdc65f4dae8e7f\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://dd26180c3dcd0765e292dd187e686c006ce2b41404898a24886b504d16f7234d\",\"dweb:/ipfs/QmV8dbzzqH7y7D8Hxshpanirb2GZaq9evLoWEurrvqQGrE\"]},\"contracts/ronin/validator/storage-fragments/ValidatorInfoStorageV2.sol\":{\"keccak256\":\"0x8dcaf0d7024b6cd0929312f717311afadbbbafed6e84f7b0887118796b555d04\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://8716ecf828b03a9ce00ece5cf4b45d75f7151b3ac6b882f1814f7a458dba0fdb\",\"dweb:/ipfs/QmPJWGck6jxKiDX7pB6cCrJ1D4DAtyeBhfKA3Ta2CSVEoT\"]},\"contracts/utils/CommonErrors.sol\":{\"keccak256\":\"0x951a466bb76f385554960531e63e64a5bd314df341bb6c95e6e81448d6984ac0\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://2e07fedf9208e970b7ba3ea52a55acf83b3ac4699b16c2c567c544629af5eb71\",\"dweb:/ipfs/QmekMV6Qrch9HS58pkUuMGrRFEt77LT27wQUcSGrFws9t8\"]},\"contracts/utils/ContractType.sol\":{\"keccak256\":\"0xf72feff9afafcb5cadc1b05c6e0b998ea5d66c7ece57c3e482e560d0a1bb4079\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://09c69b08a505c43bae20a550c2b6653dab026023f710df6c231c3c1cb4b16225\",\"dweb:/ipfs/QmVV4AaXnfSnHbnwc7A91hkv1gGqgD9vPQKfjve3mgZemi\"]},\"contracts/utils/DeprecatedSlots.sol\":{\"keccak256\":\"0xe93504aed9f67a6d399475c7162560f2ac4f793fab5b67fe504fc694ac9a2892\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://66205963116e22bb24d9f2e0c1a38a27c4c0c3cf50693bc5f3177068cba37612\",\"dweb:/ipfs/Qmb1hZg6Df4zLeDMPMH4WZVpyLFe7A4TTBEtR6HHddSohC\"]},\"contracts/utils/IdentityGuard.sol\":{\"keccak256\":\"0x2e1aef91018590d52fa9ca9e63708c8ef3e9ee7061e8947d4bb30b07d721a229\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://fd2f836448ce5e0f395090f5eacfdc26f80c84b0a708b256573329cc6ecb9035\",\"dweb:/ipfs/QmdbhcsfHZiFyRZnX54Eh6WwzRRZ9PwyozBxDLmbqL2Ps5\"]},\"contracts/utils/RoleAccess.sol\":{\"keccak256\":\"0xa98cec38c640c4e37f475debbcd366226f1188c3f5ea6e29de768bd33e021873\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ecf0bc5d9b1017db9adc4b28684ab6d796d43a7530cb346e43f5d3a36df03f44\",\"dweb:/ipfs/QmV82ANfHy8RYghXuLCZ4Enfqbnvswq4Qc8ZNY2nSRTXRW\"]}},\"version\":1}", - "bytecode": "0x60806040523480156200001157600080fd5b506200001c62000022565b620000e4565b600054610100900460ff16156200008f5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff9081161015620000e2576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b61498780620000f46000396000f3fe60806040526004361061028a5760003560e01c806303827884146102a157806304d971ab146102ca57806306040618146102fa5780630f43a6771461030f57806311662dc2146103255780631196ab661461036257806315b5ebde14610382578063217f35c2146103a257806323c65eb0146103b757806328bde1e1146103d75780632924de7114610404578063297a8fca146104245780632d784a98146104395780632f78204c1461046657806331a8aef514610486578063367ec12b146104a65780633b3159b6146104c6578063468c96ae146104e357806349096d261461051a5780634d8df0631461053c5780634de2b7351461055c5780634ee4d72b146105895780634f2a693f1461059e57806352091f17146105be5780635248184a146105c65780635cd8a76b146105e8578063605239a1146105fd57806365244ece146106125780636558954f146106325780636611f84314610649578063690b7536146106695780636aa1c2ef1461067e57806372e46810146106935780637593ff711461069b578063823a7b9c146106bb578063865e6fd3146106db578063873a5a70146106fb57806387c891bd1461071b5780638d559c381461073057806396585fc2146107445780639e94b9ec14610764578063a0c3f2d214610779578063a3d545f514610799578063a66c0f77146107b9578063a7c2f119146107ce578063b7ab4db5146107ee578063ba77b06c14610803578063c3c8b5d614610818578063c94aaa0214610838578063cba44de914610858578063d09f1ab41461086d578063dd716ad314610882578063de981f1b146108a2578063e5125a1d146108c2578063edb194bb146108e2578063eeb629a814610944578063f883afaf1461095957610299565b3661029957610297610979565b005b610297610979565b3480156102ad57600080fd5b506102b76104b081565b6040519081526020015b60405180910390f35b3480156102d657600080fd5b506102ea6102e5366004613e74565b6109e2565b60405190151581526020016102c1565b34801561030657600080fd5b506102b7610a09565b34801561031b57600080fd5b506102b760aa5481565b34801561033157600080fd5b50610345610340366004613ead565b610a19565b6040805193151584526020840192909252908201526060016102c1565b34801561036e57600080fd5b5061029761037d366004613ed9565b610a9c565b34801561038e57600080fd5b5061029761039d366004613ead565b610ab0565b3480156103ae57600080fd5b506102ea610bb1565b3480156103c357600080fd5b506102ea6103d2366004613ead565b610bc6565b3480156103e357600080fd5b506103f76103f2366004613ef2565b610bd9565b6040516102c19190613f63565b34801561041057600080fd5b506102ea61041f366004613ef2565b610c7c565b34801561043057600080fd5b506004546102b7565b34801561044557600080fd5b50610459610454366004613ef2565b610c88565b6040516102c19190613f71565b34801561047257600080fd5b50610297610481366004613f96565b610cea565b34801561049257600080fd5b506102ea6104a1366004613ead565b610f05565b3480156104b257600080fd5b506102976104c1366004613ff1565b610f11565b3480156104d257600080fd5b5060685b6040516102c191906140b7565b3480156104ef57600080fd5b506105036104fe366004613ed9565b611044565b6040805192151583526020830191909152016102c1565b34801561052657600080fd5b5061052f611082565b6040516102c1919061410f565b34801561054857600080fd5b50610297610557366004613ed9565b611161565b34801561056857600080fd5b5061057c610577366004614122565b611172565b6040516102c19190614196565b34801561059557600080fd5b5060e4546102b7565b3480156105aa57600080fd5b506102976105b9366004613ed9565b611223565b610297611234565b3480156105d257600080fd5b506105db6115c5565b6040516102c191906141dc565b3480156105f457600080fd5b506102976116ea565b34801561060957600080fd5b506072546102b7565b34801561061e57600080fd5b506102ea61062d366004613ef2565b611823565b34801561063e57600080fd5b506102b76201518081565b34801561065557600080fd5b50610297610664366004613ed9565b61185d565b34801561067557600080fd5b5060e5546102b7565b34801561068a57600080fd5b506001546102b7565b61029761186e565b3480156106a757600080fd5b506102ea6106b6366004613ed9565b611ab2565b3480156106c757600080fd5b506102976106d6366004613ed9565b611ad6565b3480156106e757600080fd5b506102976106f636600461422d565b611ae7565b34801561070757600080fd5b506102ea610716366004613ef2565b611b06565b34801561072757600080fd5b506002546102b7565b34801561073c57600080fd5b5060666104d6565b34801561075057600080fd5b5061034561075f366004613ef2565b611b1d565b34801561077057600080fd5b506102b7611b39565b34801561078557600080fd5b506102ea610794366004613ef2565b611b7c565b3480156107a557600080fd5b506102b76107b4366004613ed9565b611b99565b3480156107c557600080fd5b5060e6546102b7565b3480156107da57600080fd5b506102976107e9366004613ead565b611ba4565b3480156107fa57600080fd5b5061052f611de7565b34801561080f57600080fd5b5061052f611e8d565b34801561082457600080fd5b50610297610833366004613e74565b611eef565b34801561084457600080fd5b50610297610853366004613ed9565b612146565b34801561086457600080fd5b506076546102b7565b34801561087957600080fd5b5060a9546102b7565b34801561088e57600080fd5b5061029761089d366004613ead565b612157565b3480156108ae57600080fd5b506104d66108bd366004614249565b6121dd565b3480156108ce57600080fd5b506102976108dd366004614264565b61223a565b3480156108ee57600080fd5b506104596108fd366004613ef2565b6040805180820190915260008082526020820152506001600160a01b0316600090815260776020908152604091829020825180840190935280548352600101549082015290565b34801561095057600080fd5b5060ad546102b7565b34801561096557600080fd5b50610297610974366004614299565b612348565b61098360076121dd565b6001600160a01b0316336001600160a01b0316141580156109bf57506109a960096121dd565b6001600160a01b0316336001600160a01b031614155b156109e05760405160016234baed60e01b0319815260040160405180910390fd5b565b6001600160a01b038281166000908152607560205260409020548116908216145b92915050565b6000610a1460035490565b905090565b6001600160a01b0382166000908152603a60205260408120548190819084811015610a4f57600080600093509350935050610a95565b60019350610a5d8582614300565b610a68906001614313565b9250610a7385611b99565b610a7c82611b99565b610a869190614300565b610a91906001614313565b9150505b9250925092565b610aa4612548565b610aad81612591565b50565b6006610abb816125e8565b6001600160a01b0383166000908152603c60205260409020544311610afe57826040516353e0424d60e01b8152600401610af591906140b7565b60405180910390fd5b6001600160a01b038316600081815260386020908152604080832086845282528083208054600160ff199182168117909255948452603783528184208785529092529091208054909216909155610b559043614300565b6001600160a01b0384166000818152603a6020526040908190209290925590517f6bb2436cb6b6eb65d5a52fac2ae0373a77ade6661e523ef3004ee2d5524e6c6e90610ba49085815260200190565b60405180910390a2505050565b6000610a14610bbf42612634565b6003541090565b6000610bd28383612643565b9392505050565b610be1613e23565b610bea82611b7c565b610c075760405163a64b34ad60e01b815260040160405180910390fd5b506001600160a01b03908116600090815260756020908152604091829020825160e081018452815485168152600182015485169281019290925260028101548416928201929092526003820154909216606083015260048101546080830152600581015460a08301526006015460c082015290565b6000610a038243610bc6565b604080518082018252600080825260209182018190526001600160a01b038416815260e882528281208351808501909452805484526001015491830182905203610ce5576040516370fdd4f160e11b815260040160405180910390fd5b919050565b6006610cf5816125e8565b6000610cff610a09565b6001600160a01b03871660008181526037602090815260408083208584528252808320805460ff1916600117905592825260e181528282205460e090915291902054919250610d4d91614313565b60e46000828254610d5e9190614313565b90915550506001600160a01b038616600090815260e06020908152604080832083905560e18252808320839055603a909152902054610d9e908690612663565b6001600160a01b0387166000908152603a60205260409020558315610e54576000610dc960096121dd565b6001600160a01b0316632715805e88876040518363ffffffff1660e01b8152600401610df6929190614326565b6020604051808303816000875af1158015610e15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e39919061433f565b90508060e46000828254610e4d9190614313565b9091555050505b8215610e98576001600160a01b0386166000908152603c6020526040902054610e7e908690612663565b6001600160a01b0387166000908152603c60205260409020555b6001600160a01b0386166000818152603a6020908152604080832054815190815291820188905260019082015260608101919091528291907f54ce99c5ce1fc9f61656d4a0fb2697974d0c973ac32eecaefe06fcf18b8ef68a9060800160405180910390a3505050505050565b6000610bd2838361267a565b600054610100900460ff1615808015610f315750600054600160ff909116105b80610f4b5750303b158015610f4b575060005460ff166001145b610f675760405162461bcd60e51b8152600401610af590614358565b6000805460ff191660011790558015610f8a576000805461ff0019166101001790555b610f9560068e6126a5565b610fa060098d6126a5565b610fab60078c6126a5565b610fb660058b6126a5565b610fc1600a8a6126a5565b610fca87612730565b610fd386612765565b610fdc8561279a565b610fe584612591565b610fef82356127f2565b610ffc6020830135612827565b60018390558015611035576000805461ff0019169055604051600181526000805160206149328339815191529060200160405180910390a15b50505050505050505050505050565b60008061105043611b99565b8311158061106b575060008381526005602052604090205415155b600093845260056020526040909320549293915050565b606060aa546001600160401b0381111561109e5761109e6143bc565b6040519080825280602002602001820160405280156110c7578160200160208202803683370190505b5090506000805b825181101561115b57600081815260ab60205260409020546110f8906001600160a01b0316611823565b1561115357600081815260ab60205260409020546001600160a01b03168383611120816143d2565b945081518110611132576111326143a6565b60200260200101906001600160a01b031690816001600160a01b0316815250505b6001016110ce565b50815290565b611169612548565b610aad81612827565b6060816001600160401b0381111561118c5761118c6143bc565b6040519080825280602002602001820160405280156111b5578160200160208202803683370190505b50905060005b8281101561121c576111f28484838181106111d8576111d86143a6565b90506020020160208101906111ed9190613ef2565b61285c565b828281518110611204576112046143a6565b911515602092830291909101909101526001016111bb565b5092915050565b61122b612548565b610aad81612765565b61123c612868565b600061124733611823565b801561125957506112573361285c565b155b801561127357506112713361126c610a09565b61267a565b155b9050600061128160076121dd565b604051630634f5b960e01b81528315156004820152600060248201526001600160a01b039190911690630634f5b9906044016060604051808303816000875af11580156112d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f691906143eb565b5091505081611345573460e460008282546113119190614313565b9091555050604051339060008051602061491283398151915290611339903490600190614438565b60405180910390a25050565b336001600160a01b03167f0ede5c3be8625943fa64003cd4b91230089411249f3059bac6500873543ca9b1348360405161138092919061445c565b60405180910390a26000611392610a09565b905060006113a08334614313565b3360009081526038602090815260408083208684529091528120549192509060ff16156114985760006113d360066121dd565b6001600160a01b031663c6391fa26040518163ffffffff1660e01b8152600401608060405180830381865afa158015611410573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611434919061446a565b9350505050612710818461144891906144a0565b61145291906144cd565b91508160e460008282546114669190614313565b909155505060405133906000805160206149128339815191529061148e908590600290614438565b60405180910390a2505b6114a28183614300565b91506000806114b160096121dd565b6001600160a01b0316634530d2026040518163ffffffff1660e01b81526004016040805180830381865afa1580156114ed573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061151191906144e1565b336000908152607560205260408120600401549294509092509061153f906115399084612888565b84612663565b9050600061271061155087846144a0565b61155a91906144cd565b33600090815260e0602052604081208054929350839290919061157e908490614313565b90915550600090506115908288614300565b33600090815260e160205260408120805492935083929091906115b4908490614313565b909155505050505050505050505050565b6073546060906001600160401b038111156115e2576115e26143bc565b60405190808252806020026020018201604052801561161b57816020015b611608613e23565b8152602001906001900390816116005790505b50905060005b81518110156116e6576075600060738381548110611641576116416143a6565b60009182526020808320909101546001600160a01b039081168452838201949094526040928301909120825160e081018452815485168152600182015485169281019290925260028101548416928201929092526003820154909216606083015260048101546080830152600581015460a08301526006015460c082015282518390839081106116d3576116d36143a6565b6020908102919091010152600101611621565b5090565b600054600290610100900460ff1615801561170c575060005460ff8083169116105b6117285760405162461bcd60e51b8152600401610af590614358565b6000805461ffff191660ff831617610100179055607154611754906009906001600160a01b03166126a5565b606f5461176c906005906001600160a01b03166126a5565b607054611784906006906001600160a01b03166126a5565b606d5461179c906007906001600160a01b03166126a5565b60a8546117b490600a906001600160a01b03166126a5565b607180546001600160a01b0319908116909155606f8054821690556070805482169055606d805482169055606e80548216905560a8805490911690556000805461ff001916905560405160ff82168152600080516020614932833981519152906020015b60405180910390a150565b6001600160a01b038116600090815260ac6020526040812054610a039060019060ff16600381111561185757611857614422565b90612897565b611865612548565b610aad816127f2565b611876612868565b61187f43611ab2565b61189c57604051636c74eecf60e01b815260040160405180910390fd5b6118a543611b99565b6118b0600254611b99565b106118ce57604051632458f64160e01b815260040160405180910390fd5b4360025560006118dd42612634565b905060006118ec826003541090565b905060006118f8611de7565b90506060600061190743611b99565b90506000611916826001614313565b90506000611922610a09565b90508515611a4c5760008061193783886128ca565b9150915061194783888484612a73565b61194f612b7d565b611957612cd1565b600061196360066121dd565b604051631da0214360e21b81529091506001600160a01b03821690637680850c90611994908b908890600401614505565b600060405180830381600087803b1580156119ae57600080fd5b505af11580156119c2573d6000803e3d6000fd5b505050506119cf8a612dfa565b8051919950975015611a3a576040516303e1697b60e11b81526001600160a01b038216906307c2d2f690611a07908a9060040161410f565b600060405180830381600087803b158015611a2157600080fd5b505af1158015611a35573d6000803e3d6000fd5b505050505b611a45436001614313565b6004555050505b611a57878387612f8b565b82817f0195462033384fec211477c56217da64a58bd405e0bed331ba4ded67e4ae4ce788604051611a8c911515815260200190565b60405180910390a350600090815260056020526040902085905550505060039190915550565b600060018054611ac29190614300565b600154611acf9084614527565b1492915050565b611ade612548565b610aad81612730565b611aef612548565b611af88161320c565b611b0282826126a5565b5050565b600080611b11610a09565b9050610bd2838261267a565b6000806000611b2c8443610a19565b9250925092509193909250565b6000805b60aa548110156116e657600081815260ab6020526040902054611b68906001600160a01b0316611823565b15611b74576001909101905b600101611b3d565b6001600160a01b0316600090815260746020526040902054151590565b6000610a0382613239565b6009611baf816125e8565b6001600160a01b038316600090815260e860205260409020600181015415611bea5760405163057aab3160e31b815260040160405180910390fd5b6000611bf68442614313565b6001600160a01b0386166000908152607560205260409020909150611c1b9082613254565b6001600160a01b0385166000908152603b602052604080822083905560e554905163138ac02f60e11b81523391632715805e91611c5c918a91600401614326565b6020604051808303816000875af1158015611c7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c9f919061433f565b90508015611d9c57600060e65442611cb79190614313565b60e78054600180820183556000929092527f6cb0db1d7354dfb4a1464318006df0643cafe2002a86a29ff8560f900fef28a10180546001600160a01b0319166001600160a01b038b1617905583865585018190559050611d156132d0565b6001600160a01b0388811660008181526075602052604090819020600201549051630a2fae5760e41b81526004810192909252821660248201524260448201526064810184905291169063a2fae57090608401600060405180830381600087803b158015611d8257600080fd5b505af1158015611d96573d6000803e3d6000fd5b50505050505b856001600160a01b03167f77a1a819870c0f4d04c3ca4cc2881a0393136abc28bd651af50aedade94a27c482604051611dd791815260200190565b60405180910390a2505050505050565b606060aa546001600160401b03811115611e0357611e036143bc565b604051908082528060200260200182016040528015611e2c578160200160208202803683370190505b50905060005b81518110156116e657600081815260ab602052604090205482516001600160a01b03909116908190849084908110611e6c57611e6c6143a6565b6001600160a01b039092166020928302919091019091015250600101611e32565b60606073805480602002602001604051908101604052809291908181526020018280548015611ee557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611ec7575b5050505050905090565b611ef7612548565b6001600160a01b038216600090815260e8602052604090206001015415611b025760e7548060005b82811015611f6e57846001600160a01b031660e78281548110611f4457611f446143a6565b6000918252602090912001546001600160a01b031603611f6657809150611f6e565b600101611f1f565b50818103611f7c5750505050565b6001600160a01b038416600090815260e86020526040902054801561213f576001600160a01b038516600090815260e86020526040812081815560019081019190915583111561203e5760e7611fd3600185614300565b81548110611fe357611fe36143a6565b60009182526020909120015460e780546001600160a01b03909216918490811061200f5761200f6143a6565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b60e780548061204f5761204f61453b565b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b038716825260e9905260409020805460ff191660011790556120a184826104b06132fe565b156120fa57836001600160a01b0316856001600160a01b03167f7229136a18186c71a86246c012af3bb1df6460ef163934bbdccd6368abdd41e4836040516120eb91815260200190565b60405180910390a35050505050565b836001600160a01b0316856001600160a01b03167f3747d14eb72ad3e35cba9c3e00dab3b8d15b40cac6bdbd08402356e4f69f30a183476040516120eb92919061445c565b5050505050565b61214e612548565b610aad8161279a565b6009612162816125e8565b61216b8361335e565b156121895760405163030081e760e01b815260040160405180910390fd5b6001600160a01b03831660009081526075602052604090206005810154156121c45760405163fab9167360e01b815260040160405180910390fd5b6121d7816121d28542614313565b613254565b50505050565b60006121e76133de565b600083600d8111156121fb576121fb614422565b60ff1681526020810191909152604001600020546001600160a01b0316905080610ce5578160405163409140df60e11b8152600401610af59190614565565b6009612245816125e8565b6001600160a01b0384166000908152607760205260409020541561227c57604051632f32dcdd60e11b815260040160405180910390fd5b61271082111561229f57604051631b8454a360e21b815260040160405180910390fd5b6076548310156122c25760405163fa0ae69360e01b815260040160405180910390fd5b6001600160a01b03841660009081526077602052604081209062015180856122ea82426144cd565b6122f49190614313565b6122fe91906144a0565b808355600183018590556040519091506001600160a01b038716907f6ebafd1bb6316b2f63198a81b05cff2149c6eaae1784466a6d062b4391900f2190611dd7908490889061445c565b6009612353816125e8565b607354607254811061237857604051638616841b60e01b815260040160405180910390fd5b61238185611b7c565b1561239f57604051638ad9cdf960e01b815260040160405180910390fd5b6127108311156123c257604051631b8454a360e21b815260040160405180910390fd5b60005b60735481101561247757600060756000607384815481106123e8576123e86143a6565b60009182526020808320909101546001600160a01b0390811684529083019390935260409091019020805490925081169089160361243b578760405163fc3d8c7560e01b8152600401610af591906140b7565b60028101546001600160a01b039081169087160361246e5785604051632d33a7e760e11b8152600401610af591906140b7565b506001016123c5565b506001600160a01b038581166000818152607460209081526040808320861990556073805460018082019092557ff79bde9ddd17963ebce6f7d021d60de7c2bd0db944d23c900c0c0e775f5300520180546001600160a01b031990811687179091556075909352818420805484168d881690811782559181018054851687179055600281018054909416968b1696871790935560048301899055905191949093909290917f1ca451a9920472b99355a9cf74185bf017604a7849c113f020888ecec9db93669190a450505050505050565b6125506132d0565b6001600160a01b0316336001600160a01b0316146109e0576000356001600160e01b0319166001604051620f948f60ea1b8152600401610af5929190614573565b60018110156125b3576040516317b8970f60e01b815260040160405180910390fd5b60768190556040518181527f266d432ffe659e3565750d26ec685b822a58041eee724b67a5afec3168a2526790602001611818565b6125f1816121dd565b6001600160a01b0316336001600160a01b031614610aad576000356001600160e01b03191681336040516320e0f98d60e21b8152600401610af593929190614594565b6000610a0362015180836144cd565b6001600160a01b03919091166000908152603a6020526040902054101590565b6000818310156126735781610bd2565b5090919050565b6001600160a01b03919091166000908152603760209081526040808320938352929052205460ff1690565b806126ae6133de565b600084600d8111156126c2576126c2614422565b60ff168152602081019190915260400160002080546001600160a01b0319166001600160a01b03928316179055811682600d81111561270357612703614422565b6040517f865d1c228a8ea13709cfe61f346f7ff67f1bbd4a18ff31ad3e7147350d317c5990600090a35050565b60a98190556040518181527fb5464c05fd0e0f000c535850116cda2742ee1f7b34384cb920ad7b8e802138b590602001611818565b60728190556040518181527f82d5dc32d1b741512ad09c32404d7e7921e8934c6222343d95f55f7a2b9b2ab490602001611818565b60a9548111156127bd576040516355408ce960e11b815260040160405180910390fd5b60ad8190556040518181527fa9588dc77416849bd922605ce4fc806712281ad8a8f32d4238d6c8cca548e15e90602001611818565b60e58190556040518181527f17a6c3eb965cdd7439982da25abf85be88f0f772ca33198f548e2f99fee0289a90602001611818565b60e68190556040518181527f0a50c66137118f386332efb949231ddd3946100dbf880003daca37ddd9e0662b90602001611818565b6000610a038243612643565b3341146109e0576040516309f358fd60e01b815260040160405180910390fd5b60008183106126735781610bd2565b60008160038111156128ab576128ab614422565b8360038111156128bd576128bd614422565b1660ff1615159392505050565b6000606060008084516001600160401b038111156128ea576128ea6143bc565b604051908082528060200260200182016040528015612913578160200160208202803683370190505b50925060005b8551811015612a6957858181518110612934576129346143a6565b6020908102919091018101516001600160a01b038082166000908152607590935260409092206002015490945016915061296d8361285c565b158015612981575061297f838861267a565b155b156129f5576001600160a01b038316600090815260e160205260409020546129a99086614313565b6001600160a01b038416600090815260e160205260409020548551919650908590839081106129da576129da6143a6565b6020026020010181815250506129f08383613402565b612a3b565b6001600160a01b038316600090815260e1602090815260408083205460e090925290912054612a249190614313565b60e46000828254612a359190614313565b90915550505b6001600160a01b038316600090815260e16020908152604080832083905560e0909152812055600101612919565b5050509250929050565b6000612a7f60096121dd565b9050821561213f57612a9181846134ca565b15612b395760405163566bce2360e11b81526001600160a01b0382169063acd79c4690612ac690879086908a906004016145fb565b600060405180830381600087803b158015612ae057600080fd5b505af1158015612af4573d6000803e3d6000fd5b505050507f9e242ca1ef9dde96eb71ef8d19a3f0f6a619b63e4c0d3998771387103656d087838584604051612b2b93929190614631565b60405180910390a1506121d7565b7fe5668ec1bb2b6bb144a50f810e388da4b1d7d3fc05fcb9d588a1aac59d248f8983858447604051612b6e9493929190614666565b60405180910390a15050505050565b60e754600080805b838310156121d75760e78381548110612ba057612ba06143a6565b60009182526020808320909101546001600160a01b031680835260e89091526040909120600181015491935091504210612cc657805460e48054600090612be8908490614313565b90915550506001600160a01b038216600090815260e860205260408120818155600101819055612c17856146a3565b9450841115612c8e5760e78481548110612c3357612c336143a6565b60009182526020909120015460e780546001600160a01b039092169185908110612c5f57612c5f6143a6565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b60e7805480612c9f57612c9f61453b565b600082815260209020810160001990810180546001600160a01b0319169055019055612b85565b600190920191612b85565b60e4548015610aad576000612ce660076121dd565b600060e481905560408051600481526024810182526020810180516001600160e01b03166359f778df60e01b179052905192935090916001600160a01b038416918591612d3391906146ba565b60006040518083038185875af1925050503d8060008114612d70576040519150601f19603f3d011682016040523d82523d6000602084013e612d75565b606091505b505090508015612dba57816001600160a01b03167fc447c884574da5878be39c403db2245c22530c99b579ea7bcbb3720e1d110dc884604051610ba491815260200190565b816001600160a01b03167fa0561a59abed308fcd0556834574739d778cc6229018039a24ddda0f86aa0b738447604051610ba492919061445c565b505050565b606080612e0683613526565b90506000612e1460096121dd565b6001600160a01b03166391f8723f60736040518263ffffffff1660e01b8152600401612e4091906146e9565b600060405180830381865afa158015612e5d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612e859190810190614780565b90506000612e93600a6121dd565b6001600160a01b031663520fce6260736040518263ffffffff1660e01b8152600401612ebf91906146e9565b600060405180830381865afa158015612edc573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612f049190810190614780565b90506000612f736073805480602002602001604051908101604052809291908181526020018280548015612f6157602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612f43575b5050505050848460a95460ad54613a10565b9095509050612f83858288613ada565b505050915091565b6000612f9760056121dd565b6001600160a01b031663fdadda8183612fb1436001614313565b6040518363ffffffff1660e01b8152600401612fce929190614505565b600060405180830381865afa158015612feb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526130139190810190614815565b905060005b82518110156131c5576000838281518110613035576130356143a6565b6020908102919091018101516001600160a01b0381166000908152603b90925260408220549092504211159061306a83611823565b905060006130828461307d436001614313565b612643565b806130a3575085858151811061309a5761309a6143a6565b60200260200101515b806130ab5750825b159050811580156130b95750805b15613134576001600160a01b038416600090815260ac60205260409020546130f89060019060ff1660038111156130f2576130f2614422565b90613c1a565b6001600160a01b038516600090815260ac60205260409020805460ff1916600183600381111561312a5761312a614422565b02179055506131b6565b81801561313f575080155b156131b6576001600160a01b038416600090815260ac602052604090205461317e9060019060ff16600381111561317857613178614422565b90613c55565b6001600160a01b038516600090815260ac60205260409020805460ff191660018360038111156131b0576131b0614422565b02179055505b84600101945050505050613018565b5082847f283b50d76057d5f828df85bc87724c6af604e9b55c363a07c9faa2a2cd688b826131f1611082565b6040516131fe919061410f565b60405180910390a350505050565b806001600160a01b03163b600003610aad5780604051630bfc64a360e21b8152600401610af591906140b7565b60006001548261324991906144cd565b610a03906001614313565b600182015461326b906001600160a01b0316611b7c565b6132885760405163a64b34ad60e01b815260040160405180910390fd5b6005820181905560018201546040518281526001600160a01b03909116907fb9a1e33376bfbda9092f2d1e37662c1b435aab0d3fa8da3acc8f37ee222f99e790602001611339565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b031690565b6000836001600160a01b0316838390604051600060405180830381858888f193505050503d806000811461334e576040519150601f19603f3d011682016040523d82523d6000602084013e613353565b606091505b509095945050505050565b60008061336b600a6121dd565b6001600160a01b03166341feed1c846040518263ffffffff1660e01b815260040161339691906140b7565b602060405180830381865afa1580156133b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133d7919061433f565b1192915050565b7fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb90565b6001600160a01b038216600090815260e060205260409020548015612df55761342e82826104b06132fe565b1561348557816001600160a01b0316836001600160a01b03167f1ce7a1c4702402cd393500acb1de5bd927727a54e144a587d328f1b679abe4ec8360405161347891815260200190565b60405180910390a3505050565b816001600160a01b0316836001600160a01b03167f6c69e09ee5c5ac33c0cd57787261c5bade070a392ab34a4b5487c6868f723f6e834760405161347892919061445c565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114613517576040519150601f19603f3d011682016040523d82523d6000602084013e61351c565b606091505b5090949350505050565b6060600061353460096121dd565b90506000816001600160a01b031663af2454296040518163ffffffff1660e01b8152600401602060405180830381865afa158015613576573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061359a919061433f565b90506000826001600160a01b031663909791dd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156135dc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613600919061433f565b90506000836001600160a01b03166342ef3c3460736040518263ffffffff1660e01b815260040161363191906146e9565b600060405180830381865afa15801561364e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526136769190810190614780565b6073549091506000816001600160401b03811115613696576136966143bc565b6040519080825280602002602001820160405280156136bf578160200160208202803683370190505b50965060008060005b8483101561396157607383815481106136e3576136e36143a6565b60009182526020808320909101546001600160a01b03168083526075909152604090912060068101548851929450909250151590889088908690811061372b5761372b6143a6565b60200260200101511015613787578061378257600061374a8a42614313565b600684018190556040518181529091506001600160a01b038516906000805160206148f28339815191529060200160405180910390a2505b6137c8565b80156137c8578160060160009055826001600160a01b03166000805160206148f283398151915260006040516137bf91815260200190565b60405180910390a25b600082600501546000141580156137e3575042836005015411155b8061380657506001600160a01b038416600090815260e9602052604090205460ff165b905060008360060154600014158015613823575042846006015411155b9050818061382e5750805b156138c0578861383d896146a3565b98508881518110613850576138506143a6565b602002602001015189878151811061386a5761386a6143a6565b602002602001018181525050848d888060010199508151811061388f5761388f6143a6565b60200260200101906001600160a01b031690816001600160a01b0316815250506138b885613c91565b5050506136c8565b6001600160a01b03851660009081526077602052604090205480158015906138e85750428111155b15613951576001600160a01b0386166000818152607760209081526040808320600181018054918590559390935560048901839055518281529192917f86d576c20e383fc2413ef692209cc48ddad5e52f25db5b32f8f7ec5076461ae9910160405180910390a2505b5050600190940193506136c89050565b5050508087528015613a05577f4eaf233b9dc25a5552c1927feee1412eea69add17c2485c831c2e60e234f3c918760405161399c919061410f565b60405180910390a160405163e22d1c9d60e01b81526001600160a01b0387169063e22d1c9d906139d2908a908c90600401614505565b600060405180830381600087803b1580156139ec57600080fd5b505af1158015613a00573d6000803e3d6000fd5b505050505b505050505050919050565b60606000806068905060008888888888604051602401613a349594939291906148a3565b60408051601f19818403018152919052602080820180516001600160e01b0316633bca0a8960e11b17905281518b519293506001929091600091613a77916144a0565b613a82906040614313565b90506020840181888483895afa613a9857600093505b503d613aa357600092505b60208701965082613ac757604051630fc2632160e01b815260040160405180910390fd5b8651955050505050509550959350505050565b815b60aa54811015613b2e57600081815260ab6020818152604080842080546001600160a01b0316855260ac8352908420805460ff19169055928490525280546001600160a01b0319169055600101613adc565b5060005b82811015613b6e57600081815260ab60209081526040808320546001600160a01b0316835260ac9091529020805460ff19169055600101613b32565b5060005b82811015613be2576000848281518110613b8e57613b8e6143a6565b6020908102919091018101516001600160a01b0316600081815260ac83526040808220805460ff1916600317905585825260ab9093529190912080546001600160a01b031916909117905550600101613b72565b508160aa81905550807f3d0eea40644a206ec25781dd5bb3b60eb4fa1264b993c3bddf3c73b14f29ef5e84604051610ba4919061410f565b6000816003811115613c2e57613c2e614422565b836003811115613c4057613c40614422565b1760ff166003811115610bd257610bd2614422565b6000816003811115613c6957613c69614422565b19836003811115613c7c57613c7c614422565b1660ff166003811115610bd257610bd2614422565b6001600160a01b038116600090815260e960209081526040808320805460ff191690556074909152812054610aad91839190819003613cce575050565b6001600160a01b038216600090815260756020908152604080832080546001600160a01b031990811682556001808301805483169055600283018054831690556003830180549092169091556004820185905560058201859055600690910184905560748352818420849055607790925282208281558101829055607380549091613d5891614300565b81548110613d6857613d686143a6565b6000918252602090912001546001600160a01b03908116915083168114613deb576001600160a01b0381166000908152607460205260409020829055607380548291908419908110613dbc57613dbc6143a6565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b6073805480613dfc57613dfc61453b565b600082815260209020810160001990810180546001600160a01b0319169055019055505050565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081019190915290565b6001600160a01b0381168114610aad57600080fd5b60008060408385031215613e8757600080fd5b8235613e9281613e5f565b91506020830135613ea281613e5f565b809150509250929050565b60008060408385031215613ec057600080fd5b8235613ecb81613e5f565b946020939093013593505050565b600060208284031215613eeb57600080fd5b5035919050565b600060208284031215613f0457600080fd5b8135610bd281613e5f565b60018060a01b03808251168352806020830151166020840152806040830151166040840152806060830151166060840152506080810151608083015260a081015160a083015260c081015160c08301525050565b60e08101610a038284613f0f565b815181526020808301519082015260408101610a03565b8015158114610aad57600080fd5b60008060008060808587031215613fac57600080fd5b8435613fb781613e5f565b935060208501359250604085013591506060850135613fd581613f88565b939692955090935050565b8060408101831015610a0357600080fd5b6000806000806000806000806000806000806101a08d8f03121561401457600080fd5b8c3561401f81613e5f565b9b5060208d013561402f81613e5f565b9a5060408d013561403f81613e5f565b995060608d013561404f81613e5f565b985060808d013561405f81613e5f565b975060a08d013561406f81613e5f565b965060c08d0135955060e08d013594506101008d013593506101208d013592506101408d013591506140a58e6101608f01613fe0565b90509295989b509295989b509295989b565b6001600160a01b0391909116815260200190565b600081518084526020808501945080840160005b838110156141045781516001600160a01b0316875295820195908201906001016140df565b509495945050505050565b602081526000610bd260208301846140cb565b6000806020838503121561413557600080fd5b82356001600160401b038082111561414c57600080fd5b818501915085601f83011261416057600080fd5b81358181111561416f57600080fd5b8660208260051b850101111561418457600080fd5b60209290920196919550909350505050565b6020808252825182820181905260009190848201906040850190845b818110156141d05783511515835292840192918401916001016141b2565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156141d05761420b838551613f0f565b9284019260e092909201916001016141f8565b8035600e8110610ce557600080fd5b6000806040838503121561424057600080fd5b613e928361421e565b60006020828403121561425b57600080fd5b610bd28261421e565b60008060006060848603121561427957600080fd5b833561428481613e5f565b95602085013595506040909401359392505050565b600080600080608085870312156142af57600080fd5b84356142ba81613e5f565b935060208501356142ca81613e5f565b925060408501356142da81613e5f565b9396929550929360600135925050565b634e487b7160e01b600052601160045260246000fd5b81810381811115610a0357610a036142ea565b80820180821115610a0357610a036142ea565b6001600160a01b03929092168252602082015260400190565b60006020828403121561435157600080fd5b5051919050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6000600182016143e4576143e46142ea565b5060010190565b60008060006060848603121561440057600080fd5b835161440b81613f88565b602085015160409095015190969495509392505050565b634e487b7160e01b600052602160045260246000fd5b828152604081016003831061444f5761444f614422565b8260208301529392505050565b918252602082015260400190565b6000806000806080858703121561448057600080fd5b505082516020840151604085015160609095015191969095509092509050565b8082028115828204841417610a0357610a036142ea565b634e487b7160e01b600052601260045260246000fd5b6000826144dc576144dc6144b7565b500490565b600080604083850312156144f457600080fd5b505080516020909101519092909150565b60408152600061451860408301856140cb565b90508260208301529392505050565b600082614536576145366144b7565b500690565b634e487b7160e01b600052603160045260246000fd5b600e811061456157614561614422565b9052565b60208101610a038284614551565b6001600160e01b031983168152604081016009831061444f5761444f614422565b6001600160e01b031984168152606081016145b26020830185614551565b6001600160a01b03929092166040919091015292915050565b600081518084526020808501945080840160005b83811015614104578151875295820195908201906001016145df565b60608152600061460e60608301866140cb565b828103602084015261462081866145cb565b915050826040830152949350505050565b83815260606020820152600061464a60608301856140cb565b828103604084015261465c81856145cb565b9695505050505050565b84815260806020820152600061467f60808301866140cb565b828103604084015261469181866145cb565b91505082606083015295945050505050565b6000816146b2576146b26142ea565b506000190190565b6000825160005b818110156146db57602081860181015185830152016146c1565b506000920191825250919050565b6020808252825482820181905260008481528281209092916040850190845b818110156141d05783546001600160a01b031683526001938401939285019201614708565b604051601f8201601f191681016001600160401b0381118282101715614755576147556143bc565b604052919050565b60006001600160401b03821115614776576147766143bc565b5060051b60200190565b6000602080838503121561479357600080fd5b82516001600160401b038111156147a957600080fd5b8301601f810185136147ba57600080fd5b80516147cd6147c88261475d565b61472d565b81815260059190911b820183019083810190878311156147ec57600080fd5b928401925b8284101561480a578351825292840192908401906147f1565b979650505050505050565b6000602080838503121561482857600080fd5b82516001600160401b0381111561483e57600080fd5b8301601f8101851361484f57600080fd5b805161485d6147c88261475d565b81815260059190911b8201830190838101908783111561487c57600080fd5b928401925b8284101561480a57835161489481613f88565b82529284019290840190614881565b60a0815260006148b660a08301886140cb565b82810360208401526148c881886145cb565b905082810360408401526148dc81876145cb565b6060840195909552505060800152939250505056fe88f854e137380c14d63f6ed99781bf13402167cf55bac49bcd44d4f2d6a342754042bb9a70998f80a86d9963f0d2132e9b11c8ad94d207c6141c8e34b05ce53e7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498a264697066735822122028db0b8869b9abe9bea21850b91647f2ba6b3ce7b184adbbd19f8dc75e7b2af264736f6c63430008110033", - "deployedBytecode": "0x60806040526004361061028a5760003560e01c806303827884146102a157806304d971ab146102ca57806306040618146102fa5780630f43a6771461030f57806311662dc2146103255780631196ab661461036257806315b5ebde14610382578063217f35c2146103a257806323c65eb0146103b757806328bde1e1146103d75780632924de7114610404578063297a8fca146104245780632d784a98146104395780632f78204c1461046657806331a8aef514610486578063367ec12b146104a65780633b3159b6146104c6578063468c96ae146104e357806349096d261461051a5780634d8df0631461053c5780634de2b7351461055c5780634ee4d72b146105895780634f2a693f1461059e57806352091f17146105be5780635248184a146105c65780635cd8a76b146105e8578063605239a1146105fd57806365244ece146106125780636558954f146106325780636611f84314610649578063690b7536146106695780636aa1c2ef1461067e57806372e46810146106935780637593ff711461069b578063823a7b9c146106bb578063865e6fd3146106db578063873a5a70146106fb57806387c891bd1461071b5780638d559c381461073057806396585fc2146107445780639e94b9ec14610764578063a0c3f2d214610779578063a3d545f514610799578063a66c0f77146107b9578063a7c2f119146107ce578063b7ab4db5146107ee578063ba77b06c14610803578063c3c8b5d614610818578063c94aaa0214610838578063cba44de914610858578063d09f1ab41461086d578063dd716ad314610882578063de981f1b146108a2578063e5125a1d146108c2578063edb194bb146108e2578063eeb629a814610944578063f883afaf1461095957610299565b3661029957610297610979565b005b610297610979565b3480156102ad57600080fd5b506102b76104b081565b6040519081526020015b60405180910390f35b3480156102d657600080fd5b506102ea6102e5366004613e74565b6109e2565b60405190151581526020016102c1565b34801561030657600080fd5b506102b7610a09565b34801561031b57600080fd5b506102b760aa5481565b34801561033157600080fd5b50610345610340366004613ead565b610a19565b6040805193151584526020840192909252908201526060016102c1565b34801561036e57600080fd5b5061029761037d366004613ed9565b610a9c565b34801561038e57600080fd5b5061029761039d366004613ead565b610ab0565b3480156103ae57600080fd5b506102ea610bb1565b3480156103c357600080fd5b506102ea6103d2366004613ead565b610bc6565b3480156103e357600080fd5b506103f76103f2366004613ef2565b610bd9565b6040516102c19190613f63565b34801561041057600080fd5b506102ea61041f366004613ef2565b610c7c565b34801561043057600080fd5b506004546102b7565b34801561044557600080fd5b50610459610454366004613ef2565b610c88565b6040516102c19190613f71565b34801561047257600080fd5b50610297610481366004613f96565b610cea565b34801561049257600080fd5b506102ea6104a1366004613ead565b610f05565b3480156104b257600080fd5b506102976104c1366004613ff1565b610f11565b3480156104d257600080fd5b5060685b6040516102c191906140b7565b3480156104ef57600080fd5b506105036104fe366004613ed9565b611044565b6040805192151583526020830191909152016102c1565b34801561052657600080fd5b5061052f611082565b6040516102c1919061410f565b34801561054857600080fd5b50610297610557366004613ed9565b611161565b34801561056857600080fd5b5061057c610577366004614122565b611172565b6040516102c19190614196565b34801561059557600080fd5b5060e4546102b7565b3480156105aa57600080fd5b506102976105b9366004613ed9565b611223565b610297611234565b3480156105d257600080fd5b506105db6115c5565b6040516102c191906141dc565b3480156105f457600080fd5b506102976116ea565b34801561060957600080fd5b506072546102b7565b34801561061e57600080fd5b506102ea61062d366004613ef2565b611823565b34801561063e57600080fd5b506102b76201518081565b34801561065557600080fd5b50610297610664366004613ed9565b61185d565b34801561067557600080fd5b5060e5546102b7565b34801561068a57600080fd5b506001546102b7565b61029761186e565b3480156106a757600080fd5b506102ea6106b6366004613ed9565b611ab2565b3480156106c757600080fd5b506102976106d6366004613ed9565b611ad6565b3480156106e757600080fd5b506102976106f636600461422d565b611ae7565b34801561070757600080fd5b506102ea610716366004613ef2565b611b06565b34801561072757600080fd5b506002546102b7565b34801561073c57600080fd5b5060666104d6565b34801561075057600080fd5b5061034561075f366004613ef2565b611b1d565b34801561077057600080fd5b506102b7611b39565b34801561078557600080fd5b506102ea610794366004613ef2565b611b7c565b3480156107a557600080fd5b506102b76107b4366004613ed9565b611b99565b3480156107c557600080fd5b5060e6546102b7565b3480156107da57600080fd5b506102976107e9366004613ead565b611ba4565b3480156107fa57600080fd5b5061052f611de7565b34801561080f57600080fd5b5061052f611e8d565b34801561082457600080fd5b50610297610833366004613e74565b611eef565b34801561084457600080fd5b50610297610853366004613ed9565b612146565b34801561086457600080fd5b506076546102b7565b34801561087957600080fd5b5060a9546102b7565b34801561088e57600080fd5b5061029761089d366004613ead565b612157565b3480156108ae57600080fd5b506104d66108bd366004614249565b6121dd565b3480156108ce57600080fd5b506102976108dd366004614264565b61223a565b3480156108ee57600080fd5b506104596108fd366004613ef2565b6040805180820190915260008082526020820152506001600160a01b0316600090815260776020908152604091829020825180840190935280548352600101549082015290565b34801561095057600080fd5b5060ad546102b7565b34801561096557600080fd5b50610297610974366004614299565b612348565b61098360076121dd565b6001600160a01b0316336001600160a01b0316141580156109bf57506109a960096121dd565b6001600160a01b0316336001600160a01b031614155b156109e05760405160016234baed60e01b0319815260040160405180910390fd5b565b6001600160a01b038281166000908152607560205260409020548116908216145b92915050565b6000610a1460035490565b905090565b6001600160a01b0382166000908152603a60205260408120548190819084811015610a4f57600080600093509350935050610a95565b60019350610a5d8582614300565b610a68906001614313565b9250610a7385611b99565b610a7c82611b99565b610a869190614300565b610a91906001614313565b9150505b9250925092565b610aa4612548565b610aad81612591565b50565b6006610abb816125e8565b6001600160a01b0383166000908152603c60205260409020544311610afe57826040516353e0424d60e01b8152600401610af591906140b7565b60405180910390fd5b6001600160a01b038316600081815260386020908152604080832086845282528083208054600160ff199182168117909255948452603783528184208785529092529091208054909216909155610b559043614300565b6001600160a01b0384166000818152603a6020526040908190209290925590517f6bb2436cb6b6eb65d5a52fac2ae0373a77ade6661e523ef3004ee2d5524e6c6e90610ba49085815260200190565b60405180910390a2505050565b6000610a14610bbf42612634565b6003541090565b6000610bd28383612643565b9392505050565b610be1613e23565b610bea82611b7c565b610c075760405163a64b34ad60e01b815260040160405180910390fd5b506001600160a01b03908116600090815260756020908152604091829020825160e081018452815485168152600182015485169281019290925260028101548416928201929092526003820154909216606083015260048101546080830152600581015460a08301526006015460c082015290565b6000610a038243610bc6565b604080518082018252600080825260209182018190526001600160a01b038416815260e882528281208351808501909452805484526001015491830182905203610ce5576040516370fdd4f160e11b815260040160405180910390fd5b919050565b6006610cf5816125e8565b6000610cff610a09565b6001600160a01b03871660008181526037602090815260408083208584528252808320805460ff1916600117905592825260e181528282205460e090915291902054919250610d4d91614313565b60e46000828254610d5e9190614313565b90915550506001600160a01b038616600090815260e06020908152604080832083905560e18252808320839055603a909152902054610d9e908690612663565b6001600160a01b0387166000908152603a60205260409020558315610e54576000610dc960096121dd565b6001600160a01b0316632715805e88876040518363ffffffff1660e01b8152600401610df6929190614326565b6020604051808303816000875af1158015610e15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e39919061433f565b90508060e46000828254610e4d9190614313565b9091555050505b8215610e98576001600160a01b0386166000908152603c6020526040902054610e7e908690612663565b6001600160a01b0387166000908152603c60205260409020555b6001600160a01b0386166000818152603a6020908152604080832054815190815291820188905260019082015260608101919091528291907f54ce99c5ce1fc9f61656d4a0fb2697974d0c973ac32eecaefe06fcf18b8ef68a9060800160405180910390a3505050505050565b6000610bd2838361267a565b600054610100900460ff1615808015610f315750600054600160ff909116105b80610f4b5750303b158015610f4b575060005460ff166001145b610f675760405162461bcd60e51b8152600401610af590614358565b6000805460ff191660011790558015610f8a576000805461ff0019166101001790555b610f9560068e6126a5565b610fa060098d6126a5565b610fab60078c6126a5565b610fb660058b6126a5565b610fc1600a8a6126a5565b610fca87612730565b610fd386612765565b610fdc8561279a565b610fe584612591565b610fef82356127f2565b610ffc6020830135612827565b60018390558015611035576000805461ff0019169055604051600181526000805160206149328339815191529060200160405180910390a15b50505050505050505050505050565b60008061105043611b99565b8311158061106b575060008381526005602052604090205415155b600093845260056020526040909320549293915050565b606060aa546001600160401b0381111561109e5761109e6143bc565b6040519080825280602002602001820160405280156110c7578160200160208202803683370190505b5090506000805b825181101561115b57600081815260ab60205260409020546110f8906001600160a01b0316611823565b1561115357600081815260ab60205260409020546001600160a01b03168383611120816143d2565b945081518110611132576111326143a6565b60200260200101906001600160a01b031690816001600160a01b0316815250505b6001016110ce565b50815290565b611169612548565b610aad81612827565b6060816001600160401b0381111561118c5761118c6143bc565b6040519080825280602002602001820160405280156111b5578160200160208202803683370190505b50905060005b8281101561121c576111f28484838181106111d8576111d86143a6565b90506020020160208101906111ed9190613ef2565b61285c565b828281518110611204576112046143a6565b911515602092830291909101909101526001016111bb565b5092915050565b61122b612548565b610aad81612765565b61123c612868565b600061124733611823565b801561125957506112573361285c565b155b801561127357506112713361126c610a09565b61267a565b155b9050600061128160076121dd565b604051630634f5b960e01b81528315156004820152600060248201526001600160a01b039190911690630634f5b9906044016060604051808303816000875af11580156112d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f691906143eb565b5091505081611345573460e460008282546113119190614313565b9091555050604051339060008051602061491283398151915290611339903490600190614438565b60405180910390a25050565b336001600160a01b03167f0ede5c3be8625943fa64003cd4b91230089411249f3059bac6500873543ca9b1348360405161138092919061445c565b60405180910390a26000611392610a09565b905060006113a08334614313565b3360009081526038602090815260408083208684529091528120549192509060ff16156114985760006113d360066121dd565b6001600160a01b031663c6391fa26040518163ffffffff1660e01b8152600401608060405180830381865afa158015611410573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611434919061446a565b9350505050612710818461144891906144a0565b61145291906144cd565b91508160e460008282546114669190614313565b909155505060405133906000805160206149128339815191529061148e908590600290614438565b60405180910390a2505b6114a28183614300565b91506000806114b160096121dd565b6001600160a01b0316634530d2026040518163ffffffff1660e01b81526004016040805180830381865afa1580156114ed573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061151191906144e1565b336000908152607560205260408120600401549294509092509061153f906115399084612888565b84612663565b9050600061271061155087846144a0565b61155a91906144cd565b33600090815260e0602052604081208054929350839290919061157e908490614313565b90915550600090506115908288614300565b33600090815260e160205260408120805492935083929091906115b4908490614313565b909155505050505050505050505050565b6073546060906001600160401b038111156115e2576115e26143bc565b60405190808252806020026020018201604052801561161b57816020015b611608613e23565b8152602001906001900390816116005790505b50905060005b81518110156116e6576075600060738381548110611641576116416143a6565b60009182526020808320909101546001600160a01b039081168452838201949094526040928301909120825160e081018452815485168152600182015485169281019290925260028101548416928201929092526003820154909216606083015260048101546080830152600581015460a08301526006015460c082015282518390839081106116d3576116d36143a6565b6020908102919091010152600101611621565b5090565b600054600290610100900460ff1615801561170c575060005460ff8083169116105b6117285760405162461bcd60e51b8152600401610af590614358565b6000805461ffff191660ff831617610100179055607154611754906009906001600160a01b03166126a5565b606f5461176c906005906001600160a01b03166126a5565b607054611784906006906001600160a01b03166126a5565b606d5461179c906007906001600160a01b03166126a5565b60a8546117b490600a906001600160a01b03166126a5565b607180546001600160a01b0319908116909155606f8054821690556070805482169055606d805482169055606e80548216905560a8805490911690556000805461ff001916905560405160ff82168152600080516020614932833981519152906020015b60405180910390a150565b6001600160a01b038116600090815260ac6020526040812054610a039060019060ff16600381111561185757611857614422565b90612897565b611865612548565b610aad816127f2565b611876612868565b61187f43611ab2565b61189c57604051636c74eecf60e01b815260040160405180910390fd5b6118a543611b99565b6118b0600254611b99565b106118ce57604051632458f64160e01b815260040160405180910390fd5b4360025560006118dd42612634565b905060006118ec826003541090565b905060006118f8611de7565b90506060600061190743611b99565b90506000611916826001614313565b90506000611922610a09565b90508515611a4c5760008061193783886128ca565b9150915061194783888484612a73565b61194f612b7d565b611957612cd1565b600061196360066121dd565b604051631da0214360e21b81529091506001600160a01b03821690637680850c90611994908b908890600401614505565b600060405180830381600087803b1580156119ae57600080fd5b505af11580156119c2573d6000803e3d6000fd5b505050506119cf8a612dfa565b8051919950975015611a3a576040516303e1697b60e11b81526001600160a01b038216906307c2d2f690611a07908a9060040161410f565b600060405180830381600087803b158015611a2157600080fd5b505af1158015611a35573d6000803e3d6000fd5b505050505b611a45436001614313565b6004555050505b611a57878387612f8b565b82817f0195462033384fec211477c56217da64a58bd405e0bed331ba4ded67e4ae4ce788604051611a8c911515815260200190565b60405180910390a350600090815260056020526040902085905550505060039190915550565b600060018054611ac29190614300565b600154611acf9084614527565b1492915050565b611ade612548565b610aad81612730565b611aef612548565b611af88161320c565b611b0282826126a5565b5050565b600080611b11610a09565b9050610bd2838261267a565b6000806000611b2c8443610a19565b9250925092509193909250565b6000805b60aa548110156116e657600081815260ab6020526040902054611b68906001600160a01b0316611823565b15611b74576001909101905b600101611b3d565b6001600160a01b0316600090815260746020526040902054151590565b6000610a0382613239565b6009611baf816125e8565b6001600160a01b038316600090815260e860205260409020600181015415611bea5760405163057aab3160e31b815260040160405180910390fd5b6000611bf68442614313565b6001600160a01b0386166000908152607560205260409020909150611c1b9082613254565b6001600160a01b0385166000908152603b602052604080822083905560e554905163138ac02f60e11b81523391632715805e91611c5c918a91600401614326565b6020604051808303816000875af1158015611c7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c9f919061433f565b90508015611d9c57600060e65442611cb79190614313565b60e78054600180820183556000929092527f6cb0db1d7354dfb4a1464318006df0643cafe2002a86a29ff8560f900fef28a10180546001600160a01b0319166001600160a01b038b1617905583865585018190559050611d156132d0565b6001600160a01b0388811660008181526075602052604090819020600201549051630a2fae5760e41b81526004810192909252821660248201524260448201526064810184905291169063a2fae57090608401600060405180830381600087803b158015611d8257600080fd5b505af1158015611d96573d6000803e3d6000fd5b50505050505b856001600160a01b03167f77a1a819870c0f4d04c3ca4cc2881a0393136abc28bd651af50aedade94a27c482604051611dd791815260200190565b60405180910390a2505050505050565b606060aa546001600160401b03811115611e0357611e036143bc565b604051908082528060200260200182016040528015611e2c578160200160208202803683370190505b50905060005b81518110156116e657600081815260ab602052604090205482516001600160a01b03909116908190849084908110611e6c57611e6c6143a6565b6001600160a01b039092166020928302919091019091015250600101611e32565b60606073805480602002602001604051908101604052809291908181526020018280548015611ee557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611ec7575b5050505050905090565b611ef7612548565b6001600160a01b038216600090815260e8602052604090206001015415611b025760e7548060005b82811015611f6e57846001600160a01b031660e78281548110611f4457611f446143a6565b6000918252602090912001546001600160a01b031603611f6657809150611f6e565b600101611f1f565b50818103611f7c5750505050565b6001600160a01b038416600090815260e86020526040902054801561213f576001600160a01b038516600090815260e86020526040812081815560019081019190915583111561203e5760e7611fd3600185614300565b81548110611fe357611fe36143a6565b60009182526020909120015460e780546001600160a01b03909216918490811061200f5761200f6143a6565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b60e780548061204f5761204f61453b565b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b038716825260e9905260409020805460ff191660011790556120a184826104b06132fe565b156120fa57836001600160a01b0316856001600160a01b03167f7229136a18186c71a86246c012af3bb1df6460ef163934bbdccd6368abdd41e4836040516120eb91815260200190565b60405180910390a35050505050565b836001600160a01b0316856001600160a01b03167f3747d14eb72ad3e35cba9c3e00dab3b8d15b40cac6bdbd08402356e4f69f30a183476040516120eb92919061445c565b5050505050565b61214e612548565b610aad8161279a565b6009612162816125e8565b61216b8361335e565b156121895760405163030081e760e01b815260040160405180910390fd5b6001600160a01b03831660009081526075602052604090206005810154156121c45760405163fab9167360e01b815260040160405180910390fd5b6121d7816121d28542614313565b613254565b50505050565b60006121e76133de565b600083600d8111156121fb576121fb614422565b60ff1681526020810191909152604001600020546001600160a01b0316905080610ce5578160405163409140df60e11b8152600401610af59190614565565b6009612245816125e8565b6001600160a01b0384166000908152607760205260409020541561227c57604051632f32dcdd60e11b815260040160405180910390fd5b61271082111561229f57604051631b8454a360e21b815260040160405180910390fd5b6076548310156122c25760405163fa0ae69360e01b815260040160405180910390fd5b6001600160a01b03841660009081526077602052604081209062015180856122ea82426144cd565b6122f49190614313565b6122fe91906144a0565b808355600183018590556040519091506001600160a01b038716907f6ebafd1bb6316b2f63198a81b05cff2149c6eaae1784466a6d062b4391900f2190611dd7908490889061445c565b6009612353816125e8565b607354607254811061237857604051638616841b60e01b815260040160405180910390fd5b61238185611b7c565b1561239f57604051638ad9cdf960e01b815260040160405180910390fd5b6127108311156123c257604051631b8454a360e21b815260040160405180910390fd5b60005b60735481101561247757600060756000607384815481106123e8576123e86143a6565b60009182526020808320909101546001600160a01b0390811684529083019390935260409091019020805490925081169089160361243b578760405163fc3d8c7560e01b8152600401610af591906140b7565b60028101546001600160a01b039081169087160361246e5785604051632d33a7e760e11b8152600401610af591906140b7565b506001016123c5565b506001600160a01b038581166000818152607460209081526040808320861990556073805460018082019092557ff79bde9ddd17963ebce6f7d021d60de7c2bd0db944d23c900c0c0e775f5300520180546001600160a01b031990811687179091556075909352818420805484168d881690811782559181018054851687179055600281018054909416968b1696871790935560048301899055905191949093909290917f1ca451a9920472b99355a9cf74185bf017604a7849c113f020888ecec9db93669190a450505050505050565b6125506132d0565b6001600160a01b0316336001600160a01b0316146109e0576000356001600160e01b0319166001604051620f948f60ea1b8152600401610af5929190614573565b60018110156125b3576040516317b8970f60e01b815260040160405180910390fd5b60768190556040518181527f266d432ffe659e3565750d26ec685b822a58041eee724b67a5afec3168a2526790602001611818565b6125f1816121dd565b6001600160a01b0316336001600160a01b031614610aad576000356001600160e01b03191681336040516320e0f98d60e21b8152600401610af593929190614594565b6000610a0362015180836144cd565b6001600160a01b03919091166000908152603a6020526040902054101590565b6000818310156126735781610bd2565b5090919050565b6001600160a01b03919091166000908152603760209081526040808320938352929052205460ff1690565b806126ae6133de565b600084600d8111156126c2576126c2614422565b60ff168152602081019190915260400160002080546001600160a01b0319166001600160a01b03928316179055811682600d81111561270357612703614422565b6040517f865d1c228a8ea13709cfe61f346f7ff67f1bbd4a18ff31ad3e7147350d317c5990600090a35050565b60a98190556040518181527fb5464c05fd0e0f000c535850116cda2742ee1f7b34384cb920ad7b8e802138b590602001611818565b60728190556040518181527f82d5dc32d1b741512ad09c32404d7e7921e8934c6222343d95f55f7a2b9b2ab490602001611818565b60a9548111156127bd576040516355408ce960e11b815260040160405180910390fd5b60ad8190556040518181527fa9588dc77416849bd922605ce4fc806712281ad8a8f32d4238d6c8cca548e15e90602001611818565b60e58190556040518181527f17a6c3eb965cdd7439982da25abf85be88f0f772ca33198f548e2f99fee0289a90602001611818565b60e68190556040518181527f0a50c66137118f386332efb949231ddd3946100dbf880003daca37ddd9e0662b90602001611818565b6000610a038243612643565b3341146109e0576040516309f358fd60e01b815260040160405180910390fd5b60008183106126735781610bd2565b60008160038111156128ab576128ab614422565b8360038111156128bd576128bd614422565b1660ff1615159392505050565b6000606060008084516001600160401b038111156128ea576128ea6143bc565b604051908082528060200260200182016040528015612913578160200160208202803683370190505b50925060005b8551811015612a6957858181518110612934576129346143a6565b6020908102919091018101516001600160a01b038082166000908152607590935260409092206002015490945016915061296d8361285c565b158015612981575061297f838861267a565b155b156129f5576001600160a01b038316600090815260e160205260409020546129a99086614313565b6001600160a01b038416600090815260e160205260409020548551919650908590839081106129da576129da6143a6565b6020026020010181815250506129f08383613402565b612a3b565b6001600160a01b038316600090815260e1602090815260408083205460e090925290912054612a249190614313565b60e46000828254612a359190614313565b90915550505b6001600160a01b038316600090815260e16020908152604080832083905560e0909152812055600101612919565b5050509250929050565b6000612a7f60096121dd565b9050821561213f57612a9181846134ca565b15612b395760405163566bce2360e11b81526001600160a01b0382169063acd79c4690612ac690879086908a906004016145fb565b600060405180830381600087803b158015612ae057600080fd5b505af1158015612af4573d6000803e3d6000fd5b505050507f9e242ca1ef9dde96eb71ef8d19a3f0f6a619b63e4c0d3998771387103656d087838584604051612b2b93929190614631565b60405180910390a1506121d7565b7fe5668ec1bb2b6bb144a50f810e388da4b1d7d3fc05fcb9d588a1aac59d248f8983858447604051612b6e9493929190614666565b60405180910390a15050505050565b60e754600080805b838310156121d75760e78381548110612ba057612ba06143a6565b60009182526020808320909101546001600160a01b031680835260e89091526040909120600181015491935091504210612cc657805460e48054600090612be8908490614313565b90915550506001600160a01b038216600090815260e860205260408120818155600101819055612c17856146a3565b9450841115612c8e5760e78481548110612c3357612c336143a6565b60009182526020909120015460e780546001600160a01b039092169185908110612c5f57612c5f6143a6565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b60e7805480612c9f57612c9f61453b565b600082815260209020810160001990810180546001600160a01b0319169055019055612b85565b600190920191612b85565b60e4548015610aad576000612ce660076121dd565b600060e481905560408051600481526024810182526020810180516001600160e01b03166359f778df60e01b179052905192935090916001600160a01b038416918591612d3391906146ba565b60006040518083038185875af1925050503d8060008114612d70576040519150601f19603f3d011682016040523d82523d6000602084013e612d75565b606091505b505090508015612dba57816001600160a01b03167fc447c884574da5878be39c403db2245c22530c99b579ea7bcbb3720e1d110dc884604051610ba491815260200190565b816001600160a01b03167fa0561a59abed308fcd0556834574739d778cc6229018039a24ddda0f86aa0b738447604051610ba492919061445c565b505050565b606080612e0683613526565b90506000612e1460096121dd565b6001600160a01b03166391f8723f60736040518263ffffffff1660e01b8152600401612e4091906146e9565b600060405180830381865afa158015612e5d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612e859190810190614780565b90506000612e93600a6121dd565b6001600160a01b031663520fce6260736040518263ffffffff1660e01b8152600401612ebf91906146e9565b600060405180830381865afa158015612edc573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612f049190810190614780565b90506000612f736073805480602002602001604051908101604052809291908181526020018280548015612f6157602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612f43575b5050505050848460a95460ad54613a10565b9095509050612f83858288613ada565b505050915091565b6000612f9760056121dd565b6001600160a01b031663fdadda8183612fb1436001614313565b6040518363ffffffff1660e01b8152600401612fce929190614505565b600060405180830381865afa158015612feb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526130139190810190614815565b905060005b82518110156131c5576000838281518110613035576130356143a6565b6020908102919091018101516001600160a01b0381166000908152603b90925260408220549092504211159061306a83611823565b905060006130828461307d436001614313565b612643565b806130a3575085858151811061309a5761309a6143a6565b60200260200101515b806130ab5750825b159050811580156130b95750805b15613134576001600160a01b038416600090815260ac60205260409020546130f89060019060ff1660038111156130f2576130f2614422565b90613c1a565b6001600160a01b038516600090815260ac60205260409020805460ff1916600183600381111561312a5761312a614422565b02179055506131b6565b81801561313f575080155b156131b6576001600160a01b038416600090815260ac602052604090205461317e9060019060ff16600381111561317857613178614422565b90613c55565b6001600160a01b038516600090815260ac60205260409020805460ff191660018360038111156131b0576131b0614422565b02179055505b84600101945050505050613018565b5082847f283b50d76057d5f828df85bc87724c6af604e9b55c363a07c9faa2a2cd688b826131f1611082565b6040516131fe919061410f565b60405180910390a350505050565b806001600160a01b03163b600003610aad5780604051630bfc64a360e21b8152600401610af591906140b7565b60006001548261324991906144cd565b610a03906001614313565b600182015461326b906001600160a01b0316611b7c565b6132885760405163a64b34ad60e01b815260040160405180910390fd5b6005820181905560018201546040518281526001600160a01b03909116907fb9a1e33376bfbda9092f2d1e37662c1b435aab0d3fa8da3acc8f37ee222f99e790602001611339565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b031690565b6000836001600160a01b0316838390604051600060405180830381858888f193505050503d806000811461334e576040519150601f19603f3d011682016040523d82523d6000602084013e613353565b606091505b509095945050505050565b60008061336b600a6121dd565b6001600160a01b03166341feed1c846040518263ffffffff1660e01b815260040161339691906140b7565b602060405180830381865afa1580156133b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133d7919061433f565b1192915050565b7fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb90565b6001600160a01b038216600090815260e060205260409020548015612df55761342e82826104b06132fe565b1561348557816001600160a01b0316836001600160a01b03167f1ce7a1c4702402cd393500acb1de5bd927727a54e144a587d328f1b679abe4ec8360405161347891815260200190565b60405180910390a3505050565b816001600160a01b0316836001600160a01b03167f6c69e09ee5c5ac33c0cd57787261c5bade070a392ab34a4b5487c6868f723f6e834760405161347892919061445c565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114613517576040519150601f19603f3d011682016040523d82523d6000602084013e61351c565b606091505b5090949350505050565b6060600061353460096121dd565b90506000816001600160a01b031663af2454296040518163ffffffff1660e01b8152600401602060405180830381865afa158015613576573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061359a919061433f565b90506000826001600160a01b031663909791dd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156135dc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613600919061433f565b90506000836001600160a01b03166342ef3c3460736040518263ffffffff1660e01b815260040161363191906146e9565b600060405180830381865afa15801561364e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526136769190810190614780565b6073549091506000816001600160401b03811115613696576136966143bc565b6040519080825280602002602001820160405280156136bf578160200160208202803683370190505b50965060008060005b8483101561396157607383815481106136e3576136e36143a6565b60009182526020808320909101546001600160a01b03168083526075909152604090912060068101548851929450909250151590889088908690811061372b5761372b6143a6565b60200260200101511015613787578061378257600061374a8a42614313565b600684018190556040518181529091506001600160a01b038516906000805160206148f28339815191529060200160405180910390a2505b6137c8565b80156137c8578160060160009055826001600160a01b03166000805160206148f283398151915260006040516137bf91815260200190565b60405180910390a25b600082600501546000141580156137e3575042836005015411155b8061380657506001600160a01b038416600090815260e9602052604090205460ff165b905060008360060154600014158015613823575042846006015411155b9050818061382e5750805b156138c0578861383d896146a3565b98508881518110613850576138506143a6565b602002602001015189878151811061386a5761386a6143a6565b602002602001018181525050848d888060010199508151811061388f5761388f6143a6565b60200260200101906001600160a01b031690816001600160a01b0316815250506138b885613c91565b5050506136c8565b6001600160a01b03851660009081526077602052604090205480158015906138e85750428111155b15613951576001600160a01b0386166000818152607760209081526040808320600181018054918590559390935560048901839055518281529192917f86d576c20e383fc2413ef692209cc48ddad5e52f25db5b32f8f7ec5076461ae9910160405180910390a2505b5050600190940193506136c89050565b5050508087528015613a05577f4eaf233b9dc25a5552c1927feee1412eea69add17c2485c831c2e60e234f3c918760405161399c919061410f565b60405180910390a160405163e22d1c9d60e01b81526001600160a01b0387169063e22d1c9d906139d2908a908c90600401614505565b600060405180830381600087803b1580156139ec57600080fd5b505af1158015613a00573d6000803e3d6000fd5b505050505b505050505050919050565b60606000806068905060008888888888604051602401613a349594939291906148a3565b60408051601f19818403018152919052602080820180516001600160e01b0316633bca0a8960e11b17905281518b519293506001929091600091613a77916144a0565b613a82906040614313565b90506020840181888483895afa613a9857600093505b503d613aa357600092505b60208701965082613ac757604051630fc2632160e01b815260040160405180910390fd5b8651955050505050509550959350505050565b815b60aa54811015613b2e57600081815260ab6020818152604080842080546001600160a01b0316855260ac8352908420805460ff19169055928490525280546001600160a01b0319169055600101613adc565b5060005b82811015613b6e57600081815260ab60209081526040808320546001600160a01b0316835260ac9091529020805460ff19169055600101613b32565b5060005b82811015613be2576000848281518110613b8e57613b8e6143a6565b6020908102919091018101516001600160a01b0316600081815260ac83526040808220805460ff1916600317905585825260ab9093529190912080546001600160a01b031916909117905550600101613b72565b508160aa81905550807f3d0eea40644a206ec25781dd5bb3b60eb4fa1264b993c3bddf3c73b14f29ef5e84604051610ba4919061410f565b6000816003811115613c2e57613c2e614422565b836003811115613c4057613c40614422565b1760ff166003811115610bd257610bd2614422565b6000816003811115613c6957613c69614422565b19836003811115613c7c57613c7c614422565b1660ff166003811115610bd257610bd2614422565b6001600160a01b038116600090815260e960209081526040808320805460ff191690556074909152812054610aad91839190819003613cce575050565b6001600160a01b038216600090815260756020908152604080832080546001600160a01b031990811682556001808301805483169055600283018054831690556003830180549092169091556004820185905560058201859055600690910184905560748352818420849055607790925282208281558101829055607380549091613d5891614300565b81548110613d6857613d686143a6565b6000918252602090912001546001600160a01b03908116915083168114613deb576001600160a01b0381166000908152607460205260409020829055607380548291908419908110613dbc57613dbc6143a6565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b6073805480613dfc57613dfc61453b565b600082815260209020810160001990810180546001600160a01b0319169055019055505050565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081019190915290565b6001600160a01b0381168114610aad57600080fd5b60008060408385031215613e8757600080fd5b8235613e9281613e5f565b91506020830135613ea281613e5f565b809150509250929050565b60008060408385031215613ec057600080fd5b8235613ecb81613e5f565b946020939093013593505050565b600060208284031215613eeb57600080fd5b5035919050565b600060208284031215613f0457600080fd5b8135610bd281613e5f565b60018060a01b03808251168352806020830151166020840152806040830151166040840152806060830151166060840152506080810151608083015260a081015160a083015260c081015160c08301525050565b60e08101610a038284613f0f565b815181526020808301519082015260408101610a03565b8015158114610aad57600080fd5b60008060008060808587031215613fac57600080fd5b8435613fb781613e5f565b935060208501359250604085013591506060850135613fd581613f88565b939692955090935050565b8060408101831015610a0357600080fd5b6000806000806000806000806000806000806101a08d8f03121561401457600080fd5b8c3561401f81613e5f565b9b5060208d013561402f81613e5f565b9a5060408d013561403f81613e5f565b995060608d013561404f81613e5f565b985060808d013561405f81613e5f565b975060a08d013561406f81613e5f565b965060c08d0135955060e08d013594506101008d013593506101208d013592506101408d013591506140a58e6101608f01613fe0565b90509295989b509295989b509295989b565b6001600160a01b0391909116815260200190565b600081518084526020808501945080840160005b838110156141045781516001600160a01b0316875295820195908201906001016140df565b509495945050505050565b602081526000610bd260208301846140cb565b6000806020838503121561413557600080fd5b82356001600160401b038082111561414c57600080fd5b818501915085601f83011261416057600080fd5b81358181111561416f57600080fd5b8660208260051b850101111561418457600080fd5b60209290920196919550909350505050565b6020808252825182820181905260009190848201906040850190845b818110156141d05783511515835292840192918401916001016141b2565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156141d05761420b838551613f0f565b9284019260e092909201916001016141f8565b8035600e8110610ce557600080fd5b6000806040838503121561424057600080fd5b613e928361421e565b60006020828403121561425b57600080fd5b610bd28261421e565b60008060006060848603121561427957600080fd5b833561428481613e5f565b95602085013595506040909401359392505050565b600080600080608085870312156142af57600080fd5b84356142ba81613e5f565b935060208501356142ca81613e5f565b925060408501356142da81613e5f565b9396929550929360600135925050565b634e487b7160e01b600052601160045260246000fd5b81810381811115610a0357610a036142ea565b80820180821115610a0357610a036142ea565b6001600160a01b03929092168252602082015260400190565b60006020828403121561435157600080fd5b5051919050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6000600182016143e4576143e46142ea565b5060010190565b60008060006060848603121561440057600080fd5b835161440b81613f88565b602085015160409095015190969495509392505050565b634e487b7160e01b600052602160045260246000fd5b828152604081016003831061444f5761444f614422565b8260208301529392505050565b918252602082015260400190565b6000806000806080858703121561448057600080fd5b505082516020840151604085015160609095015191969095509092509050565b8082028115828204841417610a0357610a036142ea565b634e487b7160e01b600052601260045260246000fd5b6000826144dc576144dc6144b7565b500490565b600080604083850312156144f457600080fd5b505080516020909101519092909150565b60408152600061451860408301856140cb565b90508260208301529392505050565b600082614536576145366144b7565b500690565b634e487b7160e01b600052603160045260246000fd5b600e811061456157614561614422565b9052565b60208101610a038284614551565b6001600160e01b031983168152604081016009831061444f5761444f614422565b6001600160e01b031984168152606081016145b26020830185614551565b6001600160a01b03929092166040919091015292915050565b600081518084526020808501945080840160005b83811015614104578151875295820195908201906001016145df565b60608152600061460e60608301866140cb565b828103602084015261462081866145cb565b915050826040830152949350505050565b83815260606020820152600061464a60608301856140cb565b828103604084015261465c81856145cb565b9695505050505050565b84815260806020820152600061467f60808301866140cb565b828103604084015261469181866145cb565b91505082606083015295945050505050565b6000816146b2576146b26142ea565b506000190190565b6000825160005b818110156146db57602081860181015185830152016146c1565b506000920191825250919050565b6020808252825482820181905260008481528281209092916040850190845b818110156141d05783546001600160a01b031683526001938401939285019201614708565b604051601f8201601f191681016001600160401b0381118282101715614755576147556143bc565b604052919050565b60006001600160401b03821115614776576147766143bc565b5060051b60200190565b6000602080838503121561479357600080fd5b82516001600160401b038111156147a957600080fd5b8301601f810185136147ba57600080fd5b80516147cd6147c88261475d565b61472d565b81815260059190911b820183019083810190878311156147ec57600080fd5b928401925b8284101561480a578351825292840192908401906147f1565b979650505050505050565b6000602080838503121561482857600080fd5b82516001600160401b0381111561483e57600080fd5b8301601f8101851361484f57600080fd5b805161485d6147c88261475d565b81815260059190911b8201830190838101908783111561487c57600080fd5b928401925b8284101561480a57835161489481613f88565b82529284019290840190614881565b60a0815260006148b660a08301886140cb565b82810360208401526148c881886145cb565b905082810360408401526148dc81876145cb565b6060840195909552505060800152939250505056fe88f854e137380c14d63f6ed99781bf13402167cf55bac49bcd44d4f2d6a342754042bb9a70998f80a86d9963f0d2132e9b11c8ad94d207c6141c8e34b05ce53e7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498a264697066735822122028db0b8869b9abe9bea21850b91647f2ba6b3ce7b184adbbd19f8dc75e7b2af264736f6c63430008110033" + "numDeployments": 11, + "solcInputHash": "d85d6f97c6f4b4f4d9c883d9b13849c8", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"ErrAlreadyRequestedEmergencyExit\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrAlreadyRequestedRevokingCandidate\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrAlreadyRequestedUpdatingCommissionRate\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrAlreadyWrappedEpoch\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrAtEndOfEpochOnly\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrCallPrecompiled\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrCallerMustBeCoinbase\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"validator\",\"type\":\"address\"}],\"name\":\"ErrCannotBailout\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"}],\"name\":\"ErrContractTypeNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrExceedsMaxNumberOfCandidate\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrExistentCandidate\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_candidateAdminAddr\",\"type\":\"address\"}],\"name\":\"ErrExistentCandidateAdmin\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_treasuryAddr\",\"type\":\"address\"}],\"name\":\"ErrExistentTreasury\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"},{\"internalType\":\"uint256\",\"name\":\"currentBalance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"sendAmount\",\"type\":\"uint256\"}],\"name\":\"ErrInsufficientBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidCommissionRate\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidEffectiveDaysOnwards\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidMaxPrioritizedValidatorNumber\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidMinEffectiveDaysOnwards\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrNonExistentCandidate\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"}],\"name\":\"ErrRecipientRevert\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrTrustedOrgCannotRenounce\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"},{\"internalType\":\"enum RoleAccess\",\"name\":\"expectedRole\",\"type\":\"uint8\"}],\"name\":\"ErrUnauthorized\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrUnauthorizedReceiveRON\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"},{\"internalType\":\"enum ContractType\",\"name\":\"expectedContractType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"actual\",\"type\":\"address\"}],\"name\":\"ErrUnexpectedInternalCall\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"ErrZeroCodeContract\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NonExistentRecyclingInfo\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"epoch\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"consensusAddrs\",\"type\":\"address[]\"}],\"name\":\"BlockProducerSetUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"coinbaseAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"rewardAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"enum ICoinbaseExecution.BlockRewardDeprecatedType\",\"name\":\"deprecatedType\",\"type\":\"uint8\"}],\"name\":\"BlockRewardDeprecated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"coinbaseAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"submittedAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bonusAmount\",\"type\":\"uint256\"}],\"name\":\"BlockRewardSubmitted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"bridgeOperator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipientAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"BridgeOperatorRewardDistributed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"bridgeOperator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"contractBalance\",\"type\":\"uint256\"}],\"name\":\"BridgeOperatorRewardDistributionFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"epoch\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"bridgeOperators\",\"type\":\"address[]\"}],\"name\":\"BridgeOperatorSetUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"treasuryAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"name\":\"CandidateGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"revokingTimestamp\",\"type\":\"uint256\"}],\"name\":\"CandidateRevokingTimestampUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"topupDeadline\",\"type\":\"uint256\"}],\"name\":\"CandidateTopupDeadlineUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"consensusAddrs\",\"type\":\"address[]\"}],\"name\":\"CandidatesRevoked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"effectiveTimestamp\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"rate\",\"type\":\"uint256\"}],\"name\":\"CommissionRateUpdateScheduled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"rate\",\"type\":\"uint256\"}],\"name\":\"CommissionRateUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"ContractUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipientAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"}],\"name\":\"DeprecatedRewardRecycleFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipientAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"DeprecatedRewardRecycled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"EmergencyExitLockedAmountUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"unlockedAmount\",\"type\":\"uint256\"}],\"name\":\"EmergencyExitLockedFundReleased\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"unlockedAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"contractBalance\",\"type\":\"uint256\"}],\"name\":\"EmergencyExitLockedFundReleasingFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lockedAmount\",\"type\":\"uint256\"}],\"name\":\"EmergencyExitRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"EmergencyExpiryDurationUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"MaxPrioritizedValidatorNumberUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"threshold\",\"type\":\"uint256\"}],\"name\":\"MaxValidatorCandidateUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"MaxValidatorNumberUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"numOfDays\",\"type\":\"uint256\"}],\"name\":\"MinEffectiveDaysOnwardsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MiningRewardDistributed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"contractBalance\",\"type\":\"uint256\"}],\"name\":\"MiningRewardDistributionFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"totalAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"consensusAddrs\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"name\":\"StakingRewardDistributed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"totalAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"consensusAddrs\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"contractBalance\",\"type\":\"uint256\"}],\"name\":\"StakingRewardDistributionFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"jailedUntil\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"deductedStakingAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"blockProducerRewardDeprecated\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"bridgeOperatorRewardDeprecated\",\"type\":\"bool\"}],\"name\":\"ValidatorPunished\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"consensusAddrs\",\"type\":\"address[]\"}],\"name\":\"ValidatorSetUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"validator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"}],\"name\":\"ValidatorUnjailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"periodNumber\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"epochNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"periodEnding\",\"type\":\"bool\"}],\"name\":\"WrappedUpEpoch\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"DEFAULT_ADDITION_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"PERIOD_DURATION\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"checkJailed\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_blockNum\",\"type\":\"uint256\"}],\"name\":\"checkJailedAtBlock\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_addrList\",\"type\":\"address[]\"}],\"name\":\"checkManyJailed\",\"outputs\":[{\"internalType\":\"bool[]\",\"name\":\"_result\",\"type\":\"bool[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_blockProducer\",\"type\":\"address\"}],\"name\":\"checkMiningRewardDeprecated\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_result\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_blockProducer\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_period\",\"type\":\"uint256\"}],\"name\":\"checkMiningRewardDeprecatedAtPeriod\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_result\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentPeriod\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentPeriodStartAtBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"emergencyExitLockedAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"emergencyExpiryDuration\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_block\",\"type\":\"uint256\"}],\"name\":\"epochEndingAt\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_block\",\"type\":\"uint256\"}],\"name\":\"epochOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_candidateAdmin\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address payable\",\"name\":\"_treasuryAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_commissionRate\",\"type\":\"uint256\"}],\"name\":\"execApplyValidatorCandidate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_validatorAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_period\",\"type\":\"uint256\"}],\"name\":\"execBailOut\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_secLeftToRevoke\",\"type\":\"uint256\"}],\"name\":\"execEmergencyExit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address payable\",\"name\":\"_recipient\",\"type\":\"address\"}],\"name\":\"execReleaseLockedFundForEmergencyExitRequest\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_secsLeft\",\"type\":\"uint256\"}],\"name\":\"execRequestRenounceCandidate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_effectiveDaysOnwards\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_commissionRate\",\"type\":\"uint256\"}],\"name\":\"execRequestUpdateCommissionRate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_validatorAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_newJailedUntil\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_slashAmount\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"_cannotBailout\",\"type\":\"bool\"}],\"name\":\"execSlash\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBlockProducers\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"_result\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_candidate\",\"type\":\"address\"}],\"name\":\"getCandidateInfo\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address payable\",\"name\":\"treasuryAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"______deprecatedbridgeOperatorAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"commissionRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"revokingTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"topupDeadline\",\"type\":\"uint256\"}],\"internalType\":\"struct ICandidateManager.ValidatorCandidate\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCandidateInfos\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address payable\",\"name\":\"treasuryAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"______deprecatedbridgeOperatorAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"commissionRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"revokingTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"topupDeadline\",\"type\":\"uint256\"}],\"internalType\":\"struct ICandidateManager.ValidatorCandidate[]\",\"name\":\"_list\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_candidate\",\"type\":\"address\"}],\"name\":\"getCommissionChangeSchedule\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"effectiveTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"commissionRate\",\"type\":\"uint256\"}],\"internalType\":\"struct ICandidateManager.CommissionSchedule\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"}],\"name\":\"getContract\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"contract_\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"}],\"name\":\"getEmergencyExitInfo\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"lockedAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"recyclingAt\",\"type\":\"uint256\"}],\"internalType\":\"struct ICommonInfo.EmergencyExitInfo\",\"name\":\"_info\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"getJailedTimeLeft\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"isJailed_\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"blockLeft_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"epochLeft_\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_blockNum\",\"type\":\"uint256\"}],\"name\":\"getJailedTimeLeftAtBlock\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"isJailed_\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"blockLeft_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"epochLeft_\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLastUpdatedBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getValidatorCandidates\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getValidators\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"_validatorList\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"__slashIndicatorContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"__stakingContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"__stakingVestingContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"__maintenanceContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"__roninTrustedOrganizationContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"__maxValidatorNumber\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"__maxValidatorCandidate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"__maxPrioritizedValidatorNumber\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"__minEffectiveDaysOnwards\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"__numberOfBlocksInEpoch\",\"type\":\"uint256\"},{\"internalType\":\"uint256[2]\",\"name\":\"__emergencyExitConfigs\",\"type\":\"uint256[2]\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initializeV2\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"isBlockProducer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_candidate\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_admin\",\"type\":\"address\"}],\"name\":\"isCandidateAdmin\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isPeriodEnding\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"isValidatorCandidate\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxPrioritizedValidatorNumber\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_maximumPrioritizedValidatorNumber\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxValidatorCandidate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxValidatorNumber\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_maximumValidatorNumber\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minEffectiveDaysOnwards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"numberOfBlocksInEpoch\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_numberOfBlocks\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"precompilePickValidatorSetAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"precompileSortValidatorsAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setContract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_emergencyExitLockedAmount\",\"type\":\"uint256\"}],\"name\":\"setEmergencyExitLockedAmount\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_emergencyExpiryDuration\",\"type\":\"uint256\"}],\"name\":\"setEmergencyExpiryDuration\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_number\",\"type\":\"uint256\"}],\"name\":\"setMaxPrioritizedValidatorNumber\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_number\",\"type\":\"uint256\"}],\"name\":\"setMaxValidatorCandidate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_max\",\"type\":\"uint256\"}],\"name\":\"setMaxValidatorNumber\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_numOfDays\",\"type\":\"uint256\"}],\"name\":\"setMinEffectiveDaysOnwards\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"submitBlockReward\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalBlockProducers\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_total\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalDeprecatedReward\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_epoch\",\"type\":\"uint256\"}],\"name\":\"tryGetPeriodOfEpoch\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_filled\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"_periodNumber\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"validatorCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"wrapUpEpoch\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"errors\":{\"ErrAlreadyRequestedEmergencyExit()\":[{\"details\":\"Error of already requested emergency exit before.\"}],\"ErrAlreadyRequestedRevokingCandidate()\":[{\"details\":\"Error of already requested revoking candidate before.\"}],\"ErrAlreadyRequestedUpdatingCommissionRate()\":[{\"details\":\"Error of commission change schedule exists.\"}],\"ErrAlreadyWrappedEpoch()\":[{\"details\":\"Error of query for already wrapped up epoch\"}],\"ErrAtEndOfEpochOnly()\":[{\"details\":\"Error of only allowed at the end of epoch\"}],\"ErrCallPrecompiled()\":[{\"details\":\"Error of call to precompile fails.\"}],\"ErrCallerMustBeCoinbase()\":[{\"details\":\"Error of method caller must be coinbase\"}],\"ErrCannotBailout(address)\":[{\"details\":\"Error of cannot bailout due to high tier slash.\"}],\"ErrContractTypeNotFound(uint8)\":[{\"details\":\"Error of invalid role.\"}],\"ErrExceedsMaxNumberOfCandidate()\":[{\"details\":\"Error of exceeding maximum number of candidates.\"}],\"ErrExistentCandidate()\":[{\"details\":\"Error of querying for already existent candidate.\"}],\"ErrExistentCandidateAdmin(address)\":[{\"details\":\"Error of candidate admin already exists.\"}],\"ErrExistentTreasury(address)\":[{\"details\":\"Error of treasury already exists.\"}],\"ErrInsufficientBalance(bytes4,uint256,uint256)\":[{\"details\":\"Error of sender has insufficient balance.\"}],\"ErrInvalidCommissionRate()\":[{\"details\":\"Error of invalid commission rate.\"}],\"ErrInvalidEffectiveDaysOnwards()\":[{\"details\":\"Error of invalid effective days onwards.\"}],\"ErrInvalidMaxPrioritizedValidatorNumber()\":[{\"details\":\"Error thrown when an invalid maximum prioritized validator number is provided.\"}],\"ErrInvalidMinEffectiveDaysOnwards()\":[{\"details\":\"Error of invalid min effective days onwards.\"}],\"ErrNonExistentCandidate()\":[{\"details\":\"Error of querying for non-existent candidate.\"}],\"ErrRecipientRevert(bytes4)\":[{\"details\":\"Error of recipient not accepting RON when transfer RON.\"}],\"ErrTrustedOrgCannotRenounce()\":[{\"details\":\"Error of trusted org cannot renounce.\"}],\"ErrUnauthorized(bytes4,uint8)\":[{\"details\":\"Error indicating that the caller is unauthorized to perform a specific function.\",\"params\":{\"expectedRole\":\"The role required to perform the function.\",\"msgSig\":\"The function signature (bytes4) that the caller is unauthorized to perform.\"}}],\"ErrUnauthorizedReceiveRON()\":[{\"details\":\"Error thrown when receives RON from neither staking vesting contract nor staking contract\"}],\"ErrUnexpectedInternalCall(bytes4,uint8,address)\":[{\"details\":\"Error indicating that the caller is unauthorized to perform a specific function.\",\"params\":{\"actual\":\"The actual address that called to the function.\",\"expectedContractType\":\"The contract type required to perform the function.\",\"msgSig\":\"The function signature (bytes4).\"}}],\"ErrZeroCodeContract(address)\":[{\"details\":\"Error of set to non-contract.\"}],\"NonExistentRecyclingInfo()\":[{\"details\":\"Error thrown when queries for a non existent info.\"}]},\"kind\":\"dev\",\"methods\":{\"checkJailed(address)\":{\"details\":\"Returns whether the validator are put in jail (cannot join the set of validators) during the current period.\"},\"checkJailedAtBlock(address,uint256)\":{\"details\":\"Returns whether the validator are put in jail (cannot join the set of validators) at a specific block.\"},\"checkManyJailed(address[])\":{\"details\":\"Returns whether the validators are put in jail (cannot join the set of validators) during the current period.\"},\"checkMiningRewardDeprecated(address)\":{\"details\":\"Returns whether the incoming reward of the block producer is deprecated during the current period.\"},\"checkMiningRewardDeprecatedAtPeriod(address,uint256)\":{\"details\":\"Returns whether the incoming reward of the block producer is deprecated during a specific period.\"},\"currentPeriod()\":{\"details\":\"Returns the period index from the current block.\"},\"currentPeriodStartAtBlock()\":{\"details\":\"Returns the block number that the current period starts at.\"},\"emergencyExitLockedAmount()\":{\"details\":\"Returns the amount of RON to lock from a consensus address.\"},\"emergencyExpiryDuration()\":{\"details\":\"Returns the duration that an emergency request is expired and the fund will be recycled.\"},\"epochEndingAt(uint256)\":{\"details\":\"Returns whether the epoch ending is at the block number `_block`.\"},\"epochOf(uint256)\":{\"details\":\"Returns the epoch index from the block number.\"},\"execApplyValidatorCandidate(address,address,address,uint256)\":{\"details\":\"Grants a validator candidate. Requirements: - The method caller is staking contract. Emits the event `CandidateGranted`.\"},\"execBailOut(address,uint256)\":{\"details\":\"Finalize the bailout request from slash indicator contract. Requirements: - The method caller is slash indicator contract. Emits the event `ValidatorUnjailed`.\"},\"execEmergencyExit(address,uint256)\":{\"details\":\"Fallback function of `IStaking-requestEmergencyExit`. Requirements: - The method caller is staking contract.\"},\"execReleaseLockedFundForEmergencyExitRequest(address,address)\":{\"details\":\"Unlocks fund for emergency exit request. Requirements: - The method caller is admin. Emits the event `EmergencyExitLockedFundReleased` if the fund is successfully unlocked. Emits the event `EmergencyExitLockedFundReleasingFailed` if the fund is failed to unlock.\"},\"execRequestRenounceCandidate(address,uint256)\":{\"details\":\"Requests to revoke a validator candidate in next `_secsLeft` seconds. Requirements: - The method caller is staking contract. Emits the event `CandidateRevokingTimestampUpdated`.\"},\"execRequestUpdateCommissionRate(address,uint256,uint256)\":{\"details\":\"Fallback function of `CandidateStaking-requestUpdateCommissionRate`. Requirements: - The method caller is the staking contract. - The `_effectiveTimestamp` must be the beginning of a UTC day, and at least from 7 days onwards - The `_rate` must be in range of [0_00; 100_00]. Emits the event `CommissionRateUpdateScheduled`.\"},\"execSlash(address,uint256,uint256,bool)\":{\"details\":\"Finalize the slash request from slash indicator contract. Requirements: - The method caller is slash indicator contract. Emits the event `ValidatorPunished`.\"},\"getBlockProducers()\":{\"details\":\"Returns the current block producer list.\"},\"getCandidateInfo(address)\":{\"details\":\"Returns the info of a candidate.\"},\"getCandidateInfos()\":{\"details\":\"Returns all candidate info.\"},\"getCommissionChangeSchedule(address)\":{\"details\":\"Returns the schedule of changing commission rate of a candidate address.\"},\"getContract(uint8)\":{\"details\":\"Returns the address of a contract with a specific role. Throws an error if no contract is set for the specified role.\",\"params\":{\"contractType\":\"The role of the contract to retrieve.\"},\"returns\":{\"contract_\":\"The address of the contract with the specified role.\"}},\"getEmergencyExitInfo(address)\":{\"details\":\"Returns the emergency exit request.\"},\"getJailedTimeLeft(address)\":{\"details\":\"Returns whether the validator are put in jail and the number of block and epoch that he still is in the jail.\"},\"getJailedTimeLeftAtBlock(address,uint256)\":{\"details\":\"Returns whether the validator are put in jail at a specific block and the number of block and epoch that he still is in the jail.\"},\"getLastUpdatedBlock()\":{\"details\":\"Returns the block that validator set was updated.\"},\"getValidatorCandidates()\":{\"details\":\"Returns the validator candidate.\"},\"getValidators()\":{\"details\":\"Returns the current validator list.\"},\"initialize(address,address,address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256[2])\":{\"details\":\"Initializes the contract storage.\"},\"isBlockProducer(address)\":{\"details\":\"Returns whether the address is block producer or not.\"},\"isCandidateAdmin(address,address)\":{\"details\":\"Returns whether the address is the candidate admin.\"},\"isPeriodEnding()\":{\"details\":\"Returns whether the period ending at the current block number.\"},\"isValidatorCandidate(address)\":{\"details\":\"Returns whether the address is a validator (candidate).\"},\"maxPrioritizedValidatorNumber()\":{\"details\":\"Returns the number of reserved slots for prioritized validators.\"},\"maxValidatorCandidate()\":{\"details\":\"Returns the maximum number of validator candidate.\"},\"maxValidatorNumber()\":{\"details\":\"Returns the maximum number of validators in the epoch.\"},\"minEffectiveDaysOnwards()\":{\"details\":\"Returns the minimum number of days to the effective date of commission rate change.\"},\"numberOfBlocksInEpoch()\":{\"details\":\"Returns the number of blocks in a epoch.\"},\"precompilePickValidatorSetAddress()\":{\"details\":\"Gets the address of the precompile of picking validator set\"},\"precompileSortValidatorsAddress()\":{\"details\":\"Gets the address of the precompile of sorting validators\"},\"setContract(uint8,address)\":{\"details\":\"Sets the address of a contract with a specific role. Emits the event {ContractUpdated}.\",\"params\":{\"addr\":\"The address of the contract to set.\",\"contractType\":\"The role of the contract to set.\"}},\"setEmergencyExitLockedAmount(uint256)\":{\"details\":\"Sets the amount of RON to lock from a consensus address. Requirements: - The method caller is admin. Emits the event `EmergencyExitLockedAmountUpdated`.\"},\"setEmergencyExpiryDuration(uint256)\":{\"details\":\"Sets the duration that an emergency request is expired and the fund will be recycled. Requirements: - The method caller is admin. Emits the event `EmergencyExpiryDurationUpdated`.\"},\"setMaxPrioritizedValidatorNumber(uint256)\":{\"details\":\"Updates the number of reserved slots for prioritized validators Requirements: - The method caller is admin Emits the event `MaxPrioritizedValidatorNumberUpdated`\"},\"setMaxValidatorCandidate(uint256)\":{\"details\":\"Sets the maximum number of validator candidate. Requirements: - The method caller is admin. Emits the `MaxValidatorCandidateUpdated` event.\"},\"setMaxValidatorNumber(uint256)\":{\"details\":\"Updates the max validator number Requirements: - The method caller is admin Emits the event `MaxValidatorNumberUpdated`\"},\"setMinEffectiveDaysOnwards(uint256)\":{\"details\":\"Sets the minimum number of days to the effective date of commision rate change. Requirements: - The method caller is admin. Emits the `MinEffectiveDaysOnwardsUpdated` event.\"},\"submitBlockReward()\":{\"details\":\"Submits reward of the current block. Requirements: - The method caller is coinbase. Emits the event `MiningRewardDeprecated` if the coinbase is slashed or no longer be a block producer. Emits the event `BlockRewardSubmitted` for the valid call.\"},\"totalBlockProducers()\":{\"details\":\"Returns total numbers of the block producers.\"},\"totalDeprecatedReward()\":{\"details\":\"Returns the total deprecated reward, which includes reward that is not sent for slashed validators and unsastified bridge operators\"},\"tryGetPeriodOfEpoch(uint256)\":{\"details\":\"Tries to get the period index from the epoch number.\"},\"wrapUpEpoch()\":{\"details\":\"Wraps up the current epoch. Requirements: - The method must be called when the current epoch is ending. - The epoch is not wrapped yet. - The method caller is coinbase. Emits the event `MiningRewardDistributed` when some validator has reward distributed. Emits the event `StakingRewardDistributed` when some staking pool has reward distributed. Emits the event `BlockProducerSetUpdated` when the epoch is wrapped up. Emits the event `BridgeOperatorSetUpdated` when the epoch is wrapped up at period ending. Emits the event `ValidatorSetUpdated` when the epoch is wrapped up at period ending, and the validator set gets updated. Emits the event `WrappedUpEpoch`.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/ronin/validator/RoninValidatorSet.sol\":\"RoninValidatorSet\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://383fb7b8181016ac5ccf07bc9cdb7c1b5045ea36e2cc4df52bcbf20396fc7688\",\"dweb:/ipfs/QmYJ7Cg4WmE3rR8KGQxjUCXFfTH6TcwZ2Z1f6tPrq7jHFr\"]},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://96b6d77a20bebd4eb06b801d3d020c7e82be13bd535cb0d0a6b7181c51dab5d5\",\"dweb:/ipfs/QmPUR9Cv9jNFdQX6PtBfaBW1ZCnKwiu65R2VD5kbdanDyn\"]},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://89c2a0f70157c13845be5cb49b078a6374fee3a78fa950052a3af26190255da8\",\"dweb:/ipfs/QmUcvMEQH1oMM2pUyMuDiBUKdvvnTz1NRB8bmPHrVq8725\"]},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://8831721b6f4cc26534d190f9f1631c3f59c9ff38efdd911f85e0882b8e360472\",\"dweb:/ipfs/QmQZnLErZNStirSQ13ZNWQgvEYUtGE5tXYwn4QUPaVUfPN\"]},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ada1e030c0231db8d143b44ce92b4d1158eedb087880cad6d8cc7bd7ebe7b354\",\"dweb:/ipfs/QmWZ2NHZweRpz1U9GF6R1h65ri76dnX7fNxLBeM2t5N5Ce\"]},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://a6c4477d480bac20d681ade0e712b77ad828acf530a1d5c0abc5fb78068a05a1\",\"dweb:/ipfs/QmdBqsK8CcUceTeWzhHwFDEvKMoHimwtV96Lbim7ZBtCb8\"]},\"@openzeppelin/contracts/proxy/utils/Initializable.sol\":{\"keccak256\":\"0x2a21b14ff90012878752f230d3ffd5c3405e5938d06c97a7d89c0a64561d0d66\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://3313a8f9bb1f9476857c9050067b31982bf2140b83d84f3bc0cec1f62bbe947f\",\"dweb:/ipfs/Qma17Pk8NRe7aB4UD3jjVxk7nSFaov3eQyv86hcyqkwJRV\"]},\"@openzeppelin/contracts/utils/Address.sol\":{\"keccak256\":\"0xd6153ce99bcdcce22b124f755e72553295be6abcd63804cfdffceb188b8bef10\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://35c47bece3c03caaa07fab37dd2bb3413bfbca20db7bd9895024390e0a469487\",\"dweb:/ipfs/QmPGWT2x3QHcKxqe6gRmAkdakhbaRgx3DLzcakHz5M4eXG\"]},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://39e096c60a6eb1c6a257122d515496bd92d0c6a693a8f07acb6aa4b1263e95d4\",\"dweb:/ipfs/QmPs5trJBacCiSkezP6tpevapuRYWNY6mqSFzsMCJj7e6B\"]},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://be161e54f24e5c6fae81a12db1a8ae87bc5ae1b0ddc805d82a1440a68455088f\",\"dweb:/ipfs/QmP7C3CHdY9urF4dEMb9wmsp1wMxHF6nhA2yQE5SKiPAdy\"]},\"contracts/extensions/RONTransferHelper.sol\":{\"keccak256\":\"0xdece837caa8da00fe031b8139ada009330b8bef149af12b535913c021ab94d0e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://11af5018dd76ccfca6c4cfb886019987d88830c02efcec999c02d3e6d907475a\",\"dweb:/ipfs/QmNyEcRDvrCENivjdmw3TxMFDBcQNvEUzHorra7HkERLWf\"]},\"contracts/extensions/TransparentUpgradeableProxyV2.sol\":{\"keccak256\":\"0x6609392ea7d3174439b5715100bee82528fe6e4aff28927d48c27db8475e88c5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://370c93bc1e962fcf8eab41d217d901716769f05c51a2cb25aae12abc84e871da\",\"dweb:/ipfs/QmQYL5QrJmXCdi5UN9K7imt1iPm9ydZQm6ifShpt451afd\"]},\"contracts/extensions/collections/HasContracts.sol\":{\"keccak256\":\"0x9e1dceb68827adfb8c8184662f29ab5fe14e292a632878150e3b0b6c61bc1dce\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b8903232a7a609b250a1ff2e9522a2366979652145af74637f9c0089916e3da3\",\"dweb:/ipfs/QmVoxZamJEhjYhr9RKVSAKGzakgqmFLfZXhZcDGor7DZe5\"]},\"contracts/extensions/collections/HasProxyAdmin.sol\":{\"keccak256\":\"0x06e5962713a77abf6d5ba646e1cc1cfb6f9c50e7d52520dd82a10bf309534187\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ed488e893c5010f08025c7d5be779631eba1b93bc3f361a818704471326201ea\",\"dweb:/ipfs/QmQxHpZDbHKSdzHgbvQqKdTQoyAjG25itjFLytsjnEGy4f\"]},\"contracts/extensions/consumers/GlobalConfigConsumer.sol\":{\"keccak256\":\"0x96d6b1ea4c8e126a8c2468683e7513d195f8e05456d85dd8f259ab049347b527\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://23a7906515d4648b243fb01f8053b1595e8c1c62fa9745b56ed296372da6ebdf\",\"dweb:/ipfs/QmdUjefqn52Hu7bjAKYJMRanPy7fdKqJAtnqSB2793Zhfm\"]},\"contracts/extensions/consumers/PercentageConsumer.sol\":{\"keccak256\":\"0x5dc54a24348c5d614de1b4805dddeab4dda72f9f0636b27bf0ed295fee017dcf\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://e97f64c7f3522d605c5e8d6d96d568e0b8cb6b2f21cc288d508cbe43b831f5d9\",\"dweb:/ipfs/QmT9hBanREurnngznkfTAhHu4qDQu3F3hPXTzKgKjSWz7r\"]},\"contracts/interfaces/IMaintenance.sol\":{\"keccak256\":\"0xd399a23652fc0180280f0079dd4be420d807774bcf6bc12672f4238480e757e9\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://76bb142eea221ccdf55d69a74adfd9edb4adb2243e9e9294dfac5a38b5525c70\",\"dweb:/ipfs/QmW6ST9Ahwdx7RuvKiiPBuebsFmgoqPs5zUrSLiDyh7Xrz\"]},\"contracts/interfaces/IQuorum.sol\":{\"keccak256\":\"0x6b7920b04a73a0e1ff7404aa1a3b5fc738fc0b6154839480f666fd69b55123f0\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://a8c81134e4632e1240aead39fd5393b376a4be53668caf2a390f511f3c6d422d\",\"dweb:/ipfs/QmWPaQPP1WkpdPjLhK7wFXsih8HWs6kRQqjX5zGLu6McGH\"]},\"contracts/interfaces/IRoninGovernanceAdmin.sol\":{\"keccak256\":\"0x4ee85b5dc2b33068bc7cbe168ae26328a6459f98c558aba5d9e5a1d6aead0da8\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://2a3f3608d19c73d5b60a22317fa0594778aad515a6d9c5dc5b7bad8f5ac1f4f9\",\"dweb:/ipfs/QmYTPxJJGG9oycJDupSRv6YQaS8k3GuA46LmVZ3tStTpg2\"]},\"contracts/interfaces/IRoninTrustedOrganization.sol\":{\"keccak256\":\"0x28b0407cf740164f3ddf4a44952423604439cda580f286c6ed1edcdb59b219d0\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://39a4bd18d5a200d3bd290ef6b275ca325eeb7dae766e1bc7f053c5ad9ef79136\",\"dweb:/ipfs/QmYWkxdyTk4WsEUWWyo2oTtAVreNagVioVzdCknX8Lzare\"]},\"contracts/interfaces/IStakingVesting.sol\":{\"keccak256\":\"0x2ff4922cdba4d9094210734d890ec7e644bc25efb711f741bbe2016a9dff9e2a\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://25cafa285ceed17b2efebd107c7b91d751efffac757e032b805fc5e2e7852cd1\",\"dweb:/ipfs/QmRPR6HuBB96oLDXmxzx64NtT35VDJgeAYqDiXkiGMtFFm\"]},\"contracts/interfaces/collections/IHasContracts.sol\":{\"keccak256\":\"0x99d8213d857e30d367155abd15dc42730afdfbbac3a22dfb3b95ffea2083a92e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://03390ff29b496e244faf4eab55565712f0aea5fecdcb915e3c5866ef29d5686d\",\"dweb:/ipfs/QmdGpXn3VSxfNvjFBxfho7rc41JTq5m6bonrfmpzShhRVs\"]},\"contracts/interfaces/consumers/PeriodWrapperConsumer.sol\":{\"keccak256\":\"0xb6777e3c364306eb8d5355583c1aca44de9d351cb40ddf1cea832206d4aad272\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://f158da03631d0e3c4558a18fc50e7f2416172983cfbb14a158dd4fc7c83c7053\",\"dweb:/ipfs/QmX8Vq2sKEAckrMEN5W5LaUzE7ppdaR7scv8amyV1YEXGG\"]},\"contracts/interfaces/slash-indicator/IBaseSlash.sol\":{\"keccak256\":\"0x04d449f2852840566dfff4e3673929f6e9b8d9b5fc5b29744bf4f344dc7f9bc0\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://556068b57b4594d9ca8e23bd3cc49e2b58f3a149faacf597d2650f355bae63f5\",\"dweb:/ipfs/QmR5Bc9GQsyiGPGSxNxxT2uP2QbSW17KiWGJ3yRyuvGGUU\"]},\"contracts/interfaces/slash-indicator/ICreditScore.sol\":{\"keccak256\":\"0x26021ddf339495816692ea9f8545b4054d0ffb9c5ad11049cac4f3718a0bbc2d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://78be72af4c66b1156e34285cebbe996c9e12a1dddc7064ba19dc31c9ca29f04a\",\"dweb:/ipfs/QmQc6Qziq8FK22pHezjNK6anUpdRtLyTnUfbiYdo7KBFDT\"]},\"contracts/interfaces/slash-indicator/ISlashBridgeOperator.sol\":{\"keccak256\":\"0x3ea38604baf3bc5a12dd1a243eec2052de9ee2cb171222a2e5b0e5202d301471\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://efe7768c54473cdd7ea25abf571302059266a7aeff5a29bada77ac1364b0af0c\",\"dweb:/ipfs/QmfXxeWbvybKEb13wBBJgmYT1N9p7txEGnZPPKNwP1AhHL\"]},\"contracts/interfaces/slash-indicator/ISlashBridgeVoting.sol\":{\"keccak256\":\"0x89751cbf99adf7dbd165fbbba5d6b62b5c47f8486322a7abb27d6d6aef345fae\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4d3d95b75ae204e2d7734590f9ae2adfec28e786c981a990157888ca9bc0a9b8\",\"dweb:/ipfs/QmSeRfhkrHiN1CNFQWZbVLvfPFw4jJQg8sm6uK1PLMcsvg\"]},\"contracts/interfaces/slash-indicator/ISlashDoubleSign.sol\":{\"keccak256\":\"0x5b7c9b07d0f97c589789eb0775411825df2163bdf893fb5df1113415b91b91ed\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://12d9e0d0dc03be251d4f0e1e928c19ae0c465992d7a1da6abdcdbf8f34095e6f\",\"dweb:/ipfs/QmQkXqx1eMxts6q9RdGjAfjTZq4MaDwZWDBpMXMCazkX41\"]},\"contracts/interfaces/slash-indicator/ISlashIndicator.sol\":{\"keccak256\":\"0xe8b8fde3af614735cb304bc1eb82b05d65ede4df804b5d555787e5d5ecb95ec0\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://7c457aec7776026962e2a9e606f6b4bb76de6c4407ff5ca0197348c3a991612e\",\"dweb:/ipfs/QmPGBqNCqkUFvcktSryxS99Apzqq6MZF7S28hVrockzanS\"]},\"contracts/interfaces/slash-indicator/ISlashUnavailability.sol\":{\"keccak256\":\"0x458a7ae130a59b59b7f095fe3d4db8f779e0614041e5615f0afd36c543ac2046\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://947dcfcf74803babe38e80b37d234796cda3831a2f19936e98a0954c3936ee0e\",\"dweb:/ipfs/QmQW8ux3awTt8BNH6NnWtPNSBvWTA36wR35bTj1Eymx1D6\"]},\"contracts/interfaces/staking/IBaseStaking.sol\":{\"keccak256\":\"0x90517268a0e31147d97772c9ae518caa5eb8c03efe3b369e3c6d5166422f5962\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://cb491a0f017e3426a4c96344e65a1e3f26603759758159c8a75b731029a574d9\",\"dweb:/ipfs/QmTQ6jhx6pzzPdubogP5ktSyrhg5PspbCVaQaeHS4AJDg7\"]},\"contracts/interfaces/staking/ICandidateStaking.sol\":{\"keccak256\":\"0x9bc6ba6d13f00d9928c0add35ee6406906e16ed86207d373460930c0a75e5938\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://36091a688331967fbfff2890250653dc15906bf0f7bad1fe4019fb7db6c8a44f\",\"dweb:/ipfs/Qme2NLnJHrwa9pWA2aJevECkpgoN83EJFMofcJEhL24DN9\"]},\"contracts/interfaces/staking/IDelegatorStaking.sol\":{\"keccak256\":\"0x6dd71bf0c17a65da0dee49b98e4b038c1dd0e74f5473d03570421ceebd5b7084\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://c4b494d452bdfd70169edbc8fe348ccde87b626fa3eda23af15cf9b4c2287f51\",\"dweb:/ipfs/QmZ1EiHHUWE1ATTSoYs2iKQLw5YTV7zpQ9zBU6SNFUTAFP\"]},\"contracts/interfaces/staking/IRewardPool.sol\":{\"keccak256\":\"0x52349fecb897b3b8288d8732923551382822c0c5fb8db9c6b094d080a16a2129\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://67c0c9c2a736e1ba3bf329edef9d7d675dc86a5efe569fe49f9611896acd0667\",\"dweb:/ipfs/Qmc31DL6bovfqbdRb4a3Cqg1Gge8mC82Q43uh2HmS7YGvT\"]},\"contracts/interfaces/staking/IStaking.sol\":{\"keccak256\":\"0xd302d4a78203e277fb95a89de7ae32a3102129d3fbd64fc75f92d18be0443408\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://8ed162378c575055c0dff266b578780d3799613cf7912c0adb7428e35f70231f\",\"dweb:/ipfs/QmbnSRJwU3jee9zcvW12cYRuGpqThtx9zHzpGPQdsp6sNy\"]},\"contracts/interfaces/validator/ICandidateManager.sol\":{\"keccak256\":\"0x9ab205c736f1bcc9a3debe06e08d829f4857141d940e6f608236f136193a7f49\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://89fe20c6aafc45d103394283c8e8aec047de384044c6e0d1a16e191703969088\",\"dweb:/ipfs/QmWLW5QjyboHGSadKgojvy8DU1qWJTXdvATEx24pJEEkzx\"]},\"contracts/interfaces/validator/ICoinbaseExecution.sol\":{\"keccak256\":\"0xe4060b7e3b04a0043bd334011fe4ba67c990b0484dad52d7f14b35040989b6ab\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://a9fb73aa9276081e364d1d43f6404878d37c1d7e089cc2482f973011e7890056\",\"dweb:/ipfs/QmNVYGSLQpDFYTEgP8UBFbtxbRksE2Ybyc1QL5rGztgdQe\"]},\"contracts/interfaces/validator/IEmergencyExit.sol\":{\"keccak256\":\"0x45161abd1e3db83052a06889a0e3a7a5e7ee3306478601d58ac4ed32ccaa75ad\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://06091b25304096f52e46fa2f5c693e5dcf30697cb4f25e6eac075a7daea2f2cd\",\"dweb:/ipfs/QmQxNvAdqydyWCjQt3gfXXB8a5dAiLZgCdiJQCtM7Ah19b\"]},\"contracts/interfaces/validator/IRoninValidatorSet.sol\":{\"keccak256\":\"0x813f34747aea4dfb53bbc147abf8dbe5999ce73111c2db99bcb3efb4cf75bb3d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://e858204fc0e1f733b3b8482326a52fb150eb6c657881b7f2a7721d52826f7e4f\",\"dweb:/ipfs/QmboahnNNTeXjcELXsWZUq93wyvQQRMbimm27xDta85wEc\"]},\"contracts/interfaces/validator/ISlashingExecution.sol\":{\"keccak256\":\"0x80362c42fdc0ee06543a2abbffee961fe51c15a7c5e18933a9c34897e50d07fe\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0c1c0f19417522bc7b2926920c31406a2d1e8489e3b4ba61a6b10c31b6aa39a6\",\"dweb:/ipfs/QmTJeCNmgiMbKXnNJAG96YAZ99wu2haY9d8ffn8jU3UBEf\"]},\"contracts/interfaces/validator/info-fragments/ICommonInfo.sol\":{\"keccak256\":\"0x3fdfa86da33b889e5153075ffc028d6b0c607480a96b532fbbbc48ac7bbf27c9\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://8c586009b6c57b4e0daf60123bf4b133a91a42a1d803c332ba0bdaecab871f18\",\"dweb:/ipfs/QmUT8bLX8MfVjLBs1pXEYXFob5YtAq9tEGBz3KV1WKac4B\"]},\"contracts/interfaces/validator/info-fragments/IJailingInfo.sol\":{\"keccak256\":\"0x2b1846b05ca1d636299fb929c1bd7b392b236f5e3f7aa3e7eea2c6d57b8836fb\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://db41b9c12cde1d32f060db3b81eeee93a512cf0188aadfa9e262d9cc15714ef8\",\"dweb:/ipfs/QmfJkTv1kpfbHtz2hQiWhBZN1r725YAnZMHo71gmgQ4J43\"]},\"contracts/interfaces/validator/info-fragments/ITimingInfo.sol\":{\"keccak256\":\"0x77b86a68149389fed0eb0c5b8d56f278d3bd103ba64f504697d709b24c3212d5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://8a0c87e2e9c661730fdecd3cacc54a630ac2dfd35218dcbe41b70bb15d16aea2\",\"dweb:/ipfs/QmcLD62ZZ6YVSECvx7515PVXymbP8SRwayZsy6r4NAiPLJ\"]},\"contracts/interfaces/validator/info-fragments/IValidatorInfoV2.sol\":{\"keccak256\":\"0x6213c188a1323b242a098394b91caf9481e257bd57a0804cb2aa890377a993ed\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://c119c54dedbcf0d4254a08b97231e8d6a961893654622290e8e2077a3f8c2e1f\",\"dweb:/ipfs/QmZNSAbJYkm8JTi8TnXEyHEs95WoxQD4Q43wYzFLUg8Xv4\"]},\"contracts/libraries/AddressArrayUtils.sol\":{\"keccak256\":\"0xaf760162653a85d6e1b24df4d33c74076f778470112f421a02050fb981242001\",\"license\":\"UNLICENSED\",\"urls\":[\"bzz-raw://3a413f290b8e81540bc6feb739bcfbacf56419b2e657bbce5be43826569b4406\",\"dweb:/ipfs/QmWRjGLBXs7WK92oPm51QpjxMYGuMTBx85Pv7QcGbUZE72\"]},\"contracts/libraries/EnumFlags.sol\":{\"keccak256\":\"0xa712f0d1a323ee39f23eb3ee3278b4ec25fe2e536b1ccc629578c66f277c088d\",\"license\":\"UNLICENSED\",\"urls\":[\"bzz-raw://1b05f2717fd40454d68d411ab7bbbf5e3bb8ea6d7f27d335b1338362305904a2\",\"dweb:/ipfs/QmaiGASjWNVyfFzguu5xoKFRcLqGg67DHSd5422b5k6rbb\"]},\"contracts/libraries/Math.sol\":{\"keccak256\":\"0xd73170f448c644a47024c7dbcf4afc3cc7ad27f61737c6ea4c3b543ec5cdb7e9\",\"license\":\"UNLICENSED\",\"urls\":[\"bzz-raw://b4af5bb4d7c57d10844b31211dc52762f69c33f99fe90bf8bd4086b0f7ece4da\",\"dweb:/ipfs/Qma1Gtmp2Y5YMxAXS7XpUQHkc4auz95W6CevSLmD5CFrrB\"]},\"contracts/precompile-usages/PCUPickValidatorSet.sol\":{\"keccak256\":\"0xcb57a021897a773d11be9d98a195e0653f2124b7e95e84c4832b57d9d36d67e1\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://62cfabee3f0ad5ab8ba6b5f318ff33e68a3e532649a958b51fac6ae559ca95c0\",\"dweb:/ipfs/QmPJkxM87o2LGsqSRgTQnnaZJtZRXeRu7ZbGzwNXggMCsr\"]},\"contracts/precompile-usages/PCUSortValidators.sol\":{\"keccak256\":\"0xf2f21d25f9d1b77e591542440c839d98125ae3c41c73de7c42f8c46d95eac717\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://52b9340ff9f29ef0bcf0552142fe1df4036bdea579bf0d023bd3e65d0f706233\",\"dweb:/ipfs/Qmbv3QcysrYQiZiGC9A9Hj6EPRPu52fWFHDhmyX5nfUoqn\"]},\"contracts/precompile-usages/PrecompiledUsage.sol\":{\"keccak256\":\"0x76facc3f3a8dd573c826bbbfedaa5cd8ef30963fbabd8c163c0c72b6efea5551\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://6d7c9e940ba3e89d832b615239ba9e4af44471b3701bd1f480924a7e2c434f63\",\"dweb:/ipfs/QmPtxtdPgTzyw7WpzpLBCX7anYbq5q7zwarz1PzVAFX4zz\"]},\"contracts/ronin/validator/CandidateManager.sol\":{\"keccak256\":\"0x852ddb043e7435ba8ed2f112972d9f09149015840b70dc6f037f4150961a2edc\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://53db09ca50e952fb536905533d596a4654941b21857f13a39a8bf775a7e8fd21\",\"dweb:/ipfs/QmRbS9vzuGxzJsojJRrSdtMuHwYWqM3i1DrXP3w7gjzSJU\"]},\"contracts/ronin/validator/CoinbaseExecution.sol\":{\"keccak256\":\"0x9f818e88e11f25dce245165cd104a9b8bf0c904c21fde8ecc9313f24fb00a827\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b03e01f3a1bbf132386c8fddc2d936e9504e169dc7052d36c219bcf98a680455\",\"dweb:/ipfs/QmYG4U5SkTtw9JvgzUTdFCTVj5dgGJHVtchQpZdymU8XnT\"]},\"contracts/ronin/validator/EmergencyExit.sol\":{\"keccak256\":\"0x7b57a4e3afd9099caa0498ec60fc6cf660512784ca0f864ff44fa1aac6cd26c2\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://da721099dc33a82d6af75154c4f26ca8ca8e6786fe6321d8a58f02c12f0603b9\",\"dweb:/ipfs/QmbqcxVGHyBDkwLR8JjfrB4htcSgdV6FMw89E28QUwMEuA\"]},\"contracts/ronin/validator/RoninValidatorSet.sol\":{\"keccak256\":\"0x69547a144aef031d948dc6fa2c05e0d6aca6023fe9b09b3d40b41c251f37a551\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://8b028767b516a684f65f1c3a6cce9beb70e4894c7d0600636b02d7e869ce1d5f\",\"dweb:/ipfs/Qmdx6dr5RSoU1r8KNutM32GoU5J3MYyy5ur79gACJUSAkn\"]},\"contracts/ronin/validator/SlashingExecution.sol\":{\"keccak256\":\"0x8ae9d88b6c97d3f18b5b047f5a7ecd31b2bd5e7edbedada2b00b468b4a7e3085\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://420455008d11de5f3b5e26ea2c1a88099fde2a9191fa037f5185c4968cfa2244\",\"dweb:/ipfs/QmYc6T3UYEVMeVCa3fJD2JWuaFaCK1pgpijCX8fsLFWhye\"]},\"contracts/ronin/validator/storage-fragments/CommonStorage.sol\":{\"keccak256\":\"0x56e06043fee00341e9523875a58ac171bd039dcf87802f219ca280c974ed8950\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://8b1dac932316a05dc92978de50fdf983c359beb3aa40fe44e043de081012531f\",\"dweb:/ipfs/QmW1Hd5FRNhCArPCRT4XKqm1pcKQ1NGTtG9imsXHddY5tx\"]},\"contracts/ronin/validator/storage-fragments/JailingStorage.sol\":{\"keccak256\":\"0xdef0c07a95baaff5c23b5cacf7747f50a76a150875ae118f8553fe3ae0d15498\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4c64a137711f1aa3504d9c9dac1cf0be859bad338a56fc581b164aee29adce69\",\"dweb:/ipfs/Qmd135rnBhmZjzEiNXym12zRnN6JGKkckgsucUWE7usF8d\"]},\"contracts/ronin/validator/storage-fragments/TimingStorage.sol\":{\"keccak256\":\"0xc545f119b8b8978d793b62f2495dc2d49c3f416791459b9833bdc65f4dae8e7f\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://dd26180c3dcd0765e292dd187e686c006ce2b41404898a24886b504d16f7234d\",\"dweb:/ipfs/QmV8dbzzqH7y7D8Hxshpanirb2GZaq9evLoWEurrvqQGrE\"]},\"contracts/ronin/validator/storage-fragments/ValidatorInfoStorageV2.sol\":{\"keccak256\":\"0x8dcaf0d7024b6cd0929312f717311afadbbbafed6e84f7b0887118796b555d04\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://8716ecf828b03a9ce00ece5cf4b45d75f7151b3ac6b882f1814f7a458dba0fdb\",\"dweb:/ipfs/QmPJWGck6jxKiDX7pB6cCrJ1D4DAtyeBhfKA3Ta2CSVEoT\"]},\"contracts/utils/CommonErrors.sol\":{\"keccak256\":\"0x3914292a405307cba9e93085edcaf5f1203ca2d55abf998bf1d2af1e86f5a4c6\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://20a393b945db7a075d35303ae4c0725d3f070ad8f7d614a7f0e6b289d1e738be\",\"dweb:/ipfs/QmXbGv3SAvGYJQTge9KYJiBmPYrCeXHMFDfw2K1G7R7YAa\"]},\"contracts/utils/ContractType.sol\":{\"keccak256\":\"0xf72feff9afafcb5cadc1b05c6e0b998ea5d66c7ece57c3e482e560d0a1bb4079\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://09c69b08a505c43bae20a550c2b6653dab026023f710df6c231c3c1cb4b16225\",\"dweb:/ipfs/QmVV4AaXnfSnHbnwc7A91hkv1gGqgD9vPQKfjve3mgZemi\"]},\"contracts/utils/DeprecatedSlots.sol\":{\"keccak256\":\"0xe93504aed9f67a6d399475c7162560f2ac4f793fab5b67fe504fc694ac9a2892\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://66205963116e22bb24d9f2e0c1a38a27c4c0c3cf50693bc5f3177068cba37612\",\"dweb:/ipfs/Qmb1hZg6Df4zLeDMPMH4WZVpyLFe7A4TTBEtR6HHddSohC\"]},\"contracts/utils/IdentityGuard.sol\":{\"keccak256\":\"0x2d0dfcef3636945bc1785c1fa5a05f5203c79cbb81b2eee92a3ac6a2378c2ce5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://5e4cedc10e50bfaacdc732eab78768b5e0abbc8336eeaffa15de2a7be90de504\",\"dweb:/ipfs/QmR17AgM71NkH5ZeLpmaRMzPyXAKyhafoK2TZUnLw2z3Mv\"]},\"contracts/utils/RoleAccess.sol\":{\"keccak256\":\"0xa98cec38c640c4e37f475debbcd366226f1188c3f5ea6e29de768bd33e021873\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ecf0bc5d9b1017db9adc4b28684ab6d796d43a7530cb346e43f5d3a36df03f44\",\"dweb:/ipfs/QmV82ANfHy8RYghXuLCZ4Enfqbnvswq4Qc8ZNY2nSRTXRW\"]}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b506200001c62000022565b620000e4565b600054610100900460ff16156200008f5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff9081161015620000e2576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b61498780620000f46000396000f3fe60806040526004361061028a5760003560e01c806303827884146102a157806304d971ab146102ca57806306040618146102fa5780630f43a6771461030f57806311662dc2146103255780631196ab661461036257806315b5ebde14610382578063217f35c2146103a257806323c65eb0146103b757806328bde1e1146103d75780632924de7114610404578063297a8fca146104245780632d784a98146104395780632f78204c1461046657806331a8aef514610486578063367ec12b146104a65780633b3159b6146104c6578063468c96ae146104e357806349096d261461051a5780634d8df0631461053c5780634de2b7351461055c5780634ee4d72b146105895780634f2a693f1461059e57806352091f17146105be5780635248184a146105c65780635cd8a76b146105e8578063605239a1146105fd57806365244ece146106125780636558954f146106325780636611f84314610649578063690b7536146106695780636aa1c2ef1461067e57806372e46810146106935780637593ff711461069b578063823a7b9c146106bb578063865e6fd3146106db578063873a5a70146106fb57806387c891bd1461071b5780638d559c381461073057806396585fc2146107445780639e94b9ec14610764578063a0c3f2d214610779578063a3d545f514610799578063a66c0f77146107b9578063a7c2f119146107ce578063b7ab4db5146107ee578063ba77b06c14610803578063c3c8b5d614610818578063c94aaa0214610838578063cba44de914610858578063d09f1ab41461086d578063dd716ad314610882578063de981f1b146108a2578063e5125a1d146108c2578063edb194bb146108e2578063eeb629a814610944578063f883afaf1461095957610299565b3661029957610297610979565b005b610297610979565b3480156102ad57600080fd5b506102b76104b081565b6040519081526020015b60405180910390f35b3480156102d657600080fd5b506102ea6102e5366004613e74565b6109e2565b60405190151581526020016102c1565b34801561030657600080fd5b506102b7610a09565b34801561031b57600080fd5b506102b760aa5481565b34801561033157600080fd5b50610345610340366004613ead565b610a19565b6040805193151584526020840192909252908201526060016102c1565b34801561036e57600080fd5b5061029761037d366004613ed9565b610a9c565b34801561038e57600080fd5b5061029761039d366004613ead565b610ab0565b3480156103ae57600080fd5b506102ea610bb1565b3480156103c357600080fd5b506102ea6103d2366004613ead565b610bc6565b3480156103e357600080fd5b506103f76103f2366004613ef2565b610bd9565b6040516102c19190613f63565b34801561041057600080fd5b506102ea61041f366004613ef2565b610c7c565b34801561043057600080fd5b506004546102b7565b34801561044557600080fd5b50610459610454366004613ef2565b610c88565b6040516102c19190613f71565b34801561047257600080fd5b50610297610481366004613f96565b610cea565b34801561049257600080fd5b506102ea6104a1366004613ead565b610f05565b3480156104b257600080fd5b506102976104c1366004613ff1565b610f11565b3480156104d257600080fd5b5060685b6040516102c191906140b7565b3480156104ef57600080fd5b506105036104fe366004613ed9565b611044565b6040805192151583526020830191909152016102c1565b34801561052657600080fd5b5061052f611082565b6040516102c1919061410f565b34801561054857600080fd5b50610297610557366004613ed9565b611161565b34801561056857600080fd5b5061057c610577366004614122565b611172565b6040516102c19190614196565b34801561059557600080fd5b5060e4546102b7565b3480156105aa57600080fd5b506102976105b9366004613ed9565b611223565b610297611234565b3480156105d257600080fd5b506105db6115c5565b6040516102c191906141dc565b3480156105f457600080fd5b506102976116ea565b34801561060957600080fd5b506072546102b7565b34801561061e57600080fd5b506102ea61062d366004613ef2565b611823565b34801561063e57600080fd5b506102b76201518081565b34801561065557600080fd5b50610297610664366004613ed9565b61185d565b34801561067557600080fd5b5060e5546102b7565b34801561068a57600080fd5b506001546102b7565b61029761186e565b3480156106a757600080fd5b506102ea6106b6366004613ed9565b611ab2565b3480156106c757600080fd5b506102976106d6366004613ed9565b611ad6565b3480156106e757600080fd5b506102976106f636600461422d565b611ae7565b34801561070757600080fd5b506102ea610716366004613ef2565b611b06565b34801561072757600080fd5b506002546102b7565b34801561073c57600080fd5b5060666104d6565b34801561075057600080fd5b5061034561075f366004613ef2565b611b1d565b34801561077057600080fd5b506102b7611b39565b34801561078557600080fd5b506102ea610794366004613ef2565b611b7c565b3480156107a557600080fd5b506102b76107b4366004613ed9565b611b99565b3480156107c557600080fd5b5060e6546102b7565b3480156107da57600080fd5b506102976107e9366004613ead565b611ba4565b3480156107fa57600080fd5b5061052f611de7565b34801561080f57600080fd5b5061052f611e8d565b34801561082457600080fd5b50610297610833366004613e74565b611eef565b34801561084457600080fd5b50610297610853366004613ed9565b612146565b34801561086457600080fd5b506076546102b7565b34801561087957600080fd5b5060a9546102b7565b34801561088e57600080fd5b5061029761089d366004613ead565b612157565b3480156108ae57600080fd5b506104d66108bd366004614249565b6121dd565b3480156108ce57600080fd5b506102976108dd366004614264565b61223a565b3480156108ee57600080fd5b506104596108fd366004613ef2565b6040805180820190915260008082526020820152506001600160a01b0316600090815260776020908152604091829020825180840190935280548352600101549082015290565b34801561095057600080fd5b5060ad546102b7565b34801561096557600080fd5b50610297610974366004614299565b612348565b61098360076121dd565b6001600160a01b0316336001600160a01b0316141580156109bf57506109a960096121dd565b6001600160a01b0316336001600160a01b031614155b156109e05760405160016234baed60e01b0319815260040160405180910390fd5b565b6001600160a01b038281166000908152607560205260409020548116908216145b92915050565b6000610a1460035490565b905090565b6001600160a01b0382166000908152603a60205260408120548190819084811015610a4f57600080600093509350935050610a95565b60019350610a5d8582614300565b610a68906001614313565b9250610a7385611b99565b610a7c82611b99565b610a869190614300565b610a91906001614313565b9150505b9250925092565b610aa4612548565b610aad81612591565b50565b6006610abb816125e8565b6001600160a01b0383166000908152603c60205260409020544311610afe57826040516353e0424d60e01b8152600401610af591906140b7565b60405180910390fd5b6001600160a01b038316600081815260386020908152604080832086845282528083208054600160ff199182168117909255948452603783528184208785529092529091208054909216909155610b559043614300565b6001600160a01b0384166000818152603a6020526040908190209290925590517f6bb2436cb6b6eb65d5a52fac2ae0373a77ade6661e523ef3004ee2d5524e6c6e90610ba49085815260200190565b60405180910390a2505050565b6000610a14610bbf42612634565b6003541090565b6000610bd28383612643565b9392505050565b610be1613e23565b610bea82611b7c565b610c075760405163a64b34ad60e01b815260040160405180910390fd5b506001600160a01b03908116600090815260756020908152604091829020825160e081018452815485168152600182015485169281019290925260028101548416928201929092526003820154909216606083015260048101546080830152600581015460a08301526006015460c082015290565b6000610a038243610bc6565b604080518082018252600080825260209182018190526001600160a01b038416815260e882528281208351808501909452805484526001015491830182905203610ce5576040516370fdd4f160e11b815260040160405180910390fd5b919050565b6006610cf5816125e8565b6000610cff610a09565b6001600160a01b03871660008181526037602090815260408083208584528252808320805460ff1916600117905592825260e181528282205460e090915291902054919250610d4d91614313565b60e46000828254610d5e9190614313565b90915550506001600160a01b038616600090815260e06020908152604080832083905560e18252808320839055603a909152902054610d9e908690612663565b6001600160a01b0387166000908152603a60205260409020558315610e54576000610dc960096121dd565b6001600160a01b0316632715805e88876040518363ffffffff1660e01b8152600401610df6929190614326565b6020604051808303816000875af1158015610e15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e39919061433f565b90508060e46000828254610e4d9190614313565b9091555050505b8215610e98576001600160a01b0386166000908152603c6020526040902054610e7e908690612663565b6001600160a01b0387166000908152603c60205260409020555b6001600160a01b0386166000818152603a6020908152604080832054815190815291820188905260019082015260608101919091528291907f54ce99c5ce1fc9f61656d4a0fb2697974d0c973ac32eecaefe06fcf18b8ef68a9060800160405180910390a3505050505050565b6000610bd2838361267a565b600054610100900460ff1615808015610f315750600054600160ff909116105b80610f4b5750303b158015610f4b575060005460ff166001145b610f675760405162461bcd60e51b8152600401610af590614358565b6000805460ff191660011790558015610f8a576000805461ff0019166101001790555b610f9560068e6126a5565b610fa060098d6126a5565b610fab60078c6126a5565b610fb660058b6126a5565b610fc1600a8a6126a5565b610fca87612730565b610fd386612765565b610fdc8561279a565b610fe584612591565b610fef82356127f2565b610ffc6020830135612827565b60018390558015611035576000805461ff0019169055604051600181526000805160206149328339815191529060200160405180910390a15b50505050505050505050505050565b60008061105043611b99565b8311158061106b575060008381526005602052604090205415155b600093845260056020526040909320549293915050565b606060aa546001600160401b0381111561109e5761109e6143bc565b6040519080825280602002602001820160405280156110c7578160200160208202803683370190505b5090506000805b825181101561115b57600081815260ab60205260409020546110f8906001600160a01b0316611823565b1561115357600081815260ab60205260409020546001600160a01b03168383611120816143d2565b945081518110611132576111326143a6565b60200260200101906001600160a01b031690816001600160a01b0316815250505b6001016110ce565b50815290565b611169612548565b610aad81612827565b6060816001600160401b0381111561118c5761118c6143bc565b6040519080825280602002602001820160405280156111b5578160200160208202803683370190505b50905060005b8281101561121c576111f28484838181106111d8576111d86143a6565b90506020020160208101906111ed9190613ef2565b61285c565b828281518110611204576112046143a6565b911515602092830291909101909101526001016111bb565b5092915050565b61122b612548565b610aad81612765565b61123c612868565b600061124733611823565b801561125957506112573361285c565b155b801561127357506112713361126c610a09565b61267a565b155b9050600061128160076121dd565b604051630634f5b960e01b81528315156004820152600060248201526001600160a01b039190911690630634f5b9906044016060604051808303816000875af11580156112d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f691906143eb565b5091505081611345573460e460008282546113119190614313565b9091555050604051339060008051602061491283398151915290611339903490600190614438565b60405180910390a25050565b336001600160a01b03167f0ede5c3be8625943fa64003cd4b91230089411249f3059bac6500873543ca9b1348360405161138092919061445c565b60405180910390a26000611392610a09565b905060006113a08334614313565b3360009081526038602090815260408083208684529091528120549192509060ff16156114985760006113d360066121dd565b6001600160a01b031663c6391fa26040518163ffffffff1660e01b8152600401608060405180830381865afa158015611410573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611434919061446a565b9350505050612710818461144891906144a0565b61145291906144cd565b91508160e460008282546114669190614313565b909155505060405133906000805160206149128339815191529061148e908590600290614438565b60405180910390a2505b6114a28183614300565b91506000806114b160096121dd565b6001600160a01b0316634530d2026040518163ffffffff1660e01b81526004016040805180830381865afa1580156114ed573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061151191906144e1565b336000908152607560205260408120600401549294509092509061153f906115399084612888565b84612663565b9050600061271061155087846144a0565b61155a91906144cd565b33600090815260e0602052604081208054929350839290919061157e908490614313565b90915550600090506115908288614300565b33600090815260e160205260408120805492935083929091906115b4908490614313565b909155505050505050505050505050565b6073546060906001600160401b038111156115e2576115e26143bc565b60405190808252806020026020018201604052801561161b57816020015b611608613e23565b8152602001906001900390816116005790505b50905060005b81518110156116e6576075600060738381548110611641576116416143a6565b60009182526020808320909101546001600160a01b039081168452838201949094526040928301909120825160e081018452815485168152600182015485169281019290925260028101548416928201929092526003820154909216606083015260048101546080830152600581015460a08301526006015460c082015282518390839081106116d3576116d36143a6565b6020908102919091010152600101611621565b5090565b600054600290610100900460ff1615801561170c575060005460ff8083169116105b6117285760405162461bcd60e51b8152600401610af590614358565b6000805461ffff191660ff831617610100179055607154611754906009906001600160a01b03166126a5565b606f5461176c906005906001600160a01b03166126a5565b607054611784906006906001600160a01b03166126a5565b606d5461179c906007906001600160a01b03166126a5565b60a8546117b490600a906001600160a01b03166126a5565b607180546001600160a01b0319908116909155606f8054821690556070805482169055606d805482169055606e80548216905560a8805490911690556000805461ff001916905560405160ff82168152600080516020614932833981519152906020015b60405180910390a150565b6001600160a01b038116600090815260ac6020526040812054610a039060019060ff16600381111561185757611857614422565b90612897565b611865612548565b610aad816127f2565b611876612868565b61187f43611ab2565b61189c57604051636c74eecf60e01b815260040160405180910390fd5b6118a543611b99565b6118b0600254611b99565b106118ce57604051632458f64160e01b815260040160405180910390fd5b4360025560006118dd42612634565b905060006118ec826003541090565b905060006118f8611de7565b90506060600061190743611b99565b90506000611916826001614313565b90506000611922610a09565b90508515611a4c5760008061193783886128ca565b9150915061194783888484612a73565b61194f612b7d565b611957612cd1565b600061196360066121dd565b604051631da0214360e21b81529091506001600160a01b03821690637680850c90611994908b908890600401614505565b600060405180830381600087803b1580156119ae57600080fd5b505af11580156119c2573d6000803e3d6000fd5b505050506119cf8a612dfa565b8051919950975015611a3a576040516303e1697b60e11b81526001600160a01b038216906307c2d2f690611a07908a9060040161410f565b600060405180830381600087803b158015611a2157600080fd5b505af1158015611a35573d6000803e3d6000fd5b505050505b611a45436001614313565b6004555050505b611a57878387612f8b565b82817f0195462033384fec211477c56217da64a58bd405e0bed331ba4ded67e4ae4ce788604051611a8c911515815260200190565b60405180910390a350600090815260056020526040902085905550505060039190915550565b600060018054611ac29190614300565b600154611acf9084614527565b1492915050565b611ade612548565b610aad81612730565b611aef612548565b611af88161320c565b611b0282826126a5565b5050565b600080611b11610a09565b9050610bd2838261267a565b6000806000611b2c8443610a19565b9250925092509193909250565b6000805b60aa548110156116e657600081815260ab6020526040902054611b68906001600160a01b0316611823565b15611b74576001909101905b600101611b3d565b6001600160a01b0316600090815260746020526040902054151590565b6000610a0382613239565b6009611baf816125e8565b6001600160a01b038316600090815260e860205260409020600181015415611bea5760405163057aab3160e31b815260040160405180910390fd5b6000611bf68442614313565b6001600160a01b0386166000908152607560205260409020909150611c1b9082613254565b6001600160a01b0385166000908152603b602052604080822083905560e554905163138ac02f60e11b81523391632715805e91611c5c918a91600401614326565b6020604051808303816000875af1158015611c7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c9f919061433f565b90508015611d9c57600060e65442611cb79190614313565b60e78054600180820183556000929092527f6cb0db1d7354dfb4a1464318006df0643cafe2002a86a29ff8560f900fef28a10180546001600160a01b0319166001600160a01b038b1617905583865585018190559050611d156132d0565b6001600160a01b0388811660008181526075602052604090819020600201549051630a2fae5760e41b81526004810192909252821660248201524260448201526064810184905291169063a2fae57090608401600060405180830381600087803b158015611d8257600080fd5b505af1158015611d96573d6000803e3d6000fd5b50505050505b856001600160a01b03167f77a1a819870c0f4d04c3ca4cc2881a0393136abc28bd651af50aedade94a27c482604051611dd791815260200190565b60405180910390a2505050505050565b606060aa546001600160401b03811115611e0357611e036143bc565b604051908082528060200260200182016040528015611e2c578160200160208202803683370190505b50905060005b81518110156116e657600081815260ab602052604090205482516001600160a01b03909116908190849084908110611e6c57611e6c6143a6565b6001600160a01b039092166020928302919091019091015250600101611e32565b60606073805480602002602001604051908101604052809291908181526020018280548015611ee557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611ec7575b5050505050905090565b611ef7612548565b6001600160a01b038216600090815260e8602052604090206001015415611b025760e7548060005b82811015611f6e57846001600160a01b031660e78281548110611f4457611f446143a6565b6000918252602090912001546001600160a01b031603611f6657809150611f6e565b600101611f1f565b50818103611f7c5750505050565b6001600160a01b038416600090815260e86020526040902054801561213f576001600160a01b038516600090815260e86020526040812081815560019081019190915583111561203e5760e7611fd3600185614300565b81548110611fe357611fe36143a6565b60009182526020909120015460e780546001600160a01b03909216918490811061200f5761200f6143a6565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b60e780548061204f5761204f61453b565b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b038716825260e9905260409020805460ff191660011790556120a184826104b06132fe565b156120fa57836001600160a01b0316856001600160a01b03167f7229136a18186c71a86246c012af3bb1df6460ef163934bbdccd6368abdd41e4836040516120eb91815260200190565b60405180910390a35050505050565b836001600160a01b0316856001600160a01b03167f3747d14eb72ad3e35cba9c3e00dab3b8d15b40cac6bdbd08402356e4f69f30a183476040516120eb92919061445c565b5050505050565b61214e612548565b610aad8161279a565b6009612162816125e8565b61216b8361335e565b156121895760405163030081e760e01b815260040160405180910390fd5b6001600160a01b03831660009081526075602052604090206005810154156121c45760405163fab9167360e01b815260040160405180910390fd5b6121d7816121d28542614313565b613254565b50505050565b60006121e76133de565b600083600d8111156121fb576121fb614422565b60ff1681526020810191909152604001600020546001600160a01b0316905080610ce5578160405163409140df60e11b8152600401610af59190614565565b6009612245816125e8565b6001600160a01b0384166000908152607760205260409020541561227c57604051632f32dcdd60e11b815260040160405180910390fd5b61271082111561229f57604051631b8454a360e21b815260040160405180910390fd5b6076548310156122c25760405163fa0ae69360e01b815260040160405180910390fd5b6001600160a01b03841660009081526077602052604081209062015180856122ea82426144cd565b6122f49190614313565b6122fe91906144a0565b808355600183018590556040519091506001600160a01b038716907f6ebafd1bb6316b2f63198a81b05cff2149c6eaae1784466a6d062b4391900f2190611dd7908490889061445c565b6009612353816125e8565b607354607254811061237857604051638616841b60e01b815260040160405180910390fd5b61238185611b7c565b1561239f57604051638ad9cdf960e01b815260040160405180910390fd5b6127108311156123c257604051631b8454a360e21b815260040160405180910390fd5b60005b60735481101561247757600060756000607384815481106123e8576123e86143a6565b60009182526020808320909101546001600160a01b0390811684529083019390935260409091019020805490925081169089160361243b578760405163fc3d8c7560e01b8152600401610af591906140b7565b60028101546001600160a01b039081169087160361246e5785604051632d33a7e760e11b8152600401610af591906140b7565b506001016123c5565b506001600160a01b038581166000818152607460209081526040808320861990556073805460018082019092557ff79bde9ddd17963ebce6f7d021d60de7c2bd0db944d23c900c0c0e775f5300520180546001600160a01b031990811687179091556075909352818420805484168d881690811782559181018054851687179055600281018054909416968b1696871790935560048301899055905191949093909290917f1ca451a9920472b99355a9cf74185bf017604a7849c113f020888ecec9db93669190a450505050505050565b6125506132d0565b6001600160a01b0316336001600160a01b0316146109e0576000356001600160e01b0319166001604051620f948f60ea1b8152600401610af5929190614573565b60018110156125b3576040516317b8970f60e01b815260040160405180910390fd5b60768190556040518181527f266d432ffe659e3565750d26ec685b822a58041eee724b67a5afec3168a2526790602001611818565b6125f1816121dd565b6001600160a01b0316336001600160a01b031614610aad576000356001600160e01b03191681336040516320e0f98d60e21b8152600401610af593929190614594565b6000610a0362015180836144cd565b6001600160a01b03919091166000908152603a6020526040902054101590565b6000818310156126735781610bd2565b5090919050565b6001600160a01b03919091166000908152603760209081526040808320938352929052205460ff1690565b806126ae6133de565b600084600d8111156126c2576126c2614422565b60ff168152602081019190915260400160002080546001600160a01b0319166001600160a01b03928316179055811682600d81111561270357612703614422565b6040517f865d1c228a8ea13709cfe61f346f7ff67f1bbd4a18ff31ad3e7147350d317c5990600090a35050565b60a98190556040518181527fb5464c05fd0e0f000c535850116cda2742ee1f7b34384cb920ad7b8e802138b590602001611818565b60728190556040518181527f82d5dc32d1b741512ad09c32404d7e7921e8934c6222343d95f55f7a2b9b2ab490602001611818565b60a9548111156127bd576040516355408ce960e11b815260040160405180910390fd5b60ad8190556040518181527fa9588dc77416849bd922605ce4fc806712281ad8a8f32d4238d6c8cca548e15e90602001611818565b60e58190556040518181527f17a6c3eb965cdd7439982da25abf85be88f0f772ca33198f548e2f99fee0289a90602001611818565b60e68190556040518181527f0a50c66137118f386332efb949231ddd3946100dbf880003daca37ddd9e0662b90602001611818565b6000610a038243612643565b3341146109e0576040516309f358fd60e01b815260040160405180910390fd5b60008183106126735781610bd2565b60008160038111156128ab576128ab614422565b8360038111156128bd576128bd614422565b1660ff1615159392505050565b6000606060008084516001600160401b038111156128ea576128ea6143bc565b604051908082528060200260200182016040528015612913578160200160208202803683370190505b50925060005b8551811015612a6957858181518110612934576129346143a6565b6020908102919091018101516001600160a01b038082166000908152607590935260409092206002015490945016915061296d8361285c565b158015612981575061297f838861267a565b155b156129f5576001600160a01b038316600090815260e160205260409020546129a99086614313565b6001600160a01b038416600090815260e160205260409020548551919650908590839081106129da576129da6143a6565b6020026020010181815250506129f08383613402565b612a3b565b6001600160a01b038316600090815260e1602090815260408083205460e090925290912054612a249190614313565b60e46000828254612a359190614313565b90915550505b6001600160a01b038316600090815260e16020908152604080832083905560e0909152812055600101612919565b5050509250929050565b6000612a7f60096121dd565b9050821561213f57612a9181846134ca565b15612b395760405163566bce2360e11b81526001600160a01b0382169063acd79c4690612ac690879086908a906004016145fb565b600060405180830381600087803b158015612ae057600080fd5b505af1158015612af4573d6000803e3d6000fd5b505050507f9e242ca1ef9dde96eb71ef8d19a3f0f6a619b63e4c0d3998771387103656d087838584604051612b2b93929190614631565b60405180910390a1506121d7565b7fe5668ec1bb2b6bb144a50f810e388da4b1d7d3fc05fcb9d588a1aac59d248f8983858447604051612b6e9493929190614666565b60405180910390a15050505050565b60e754600080805b838310156121d75760e78381548110612ba057612ba06143a6565b60009182526020808320909101546001600160a01b031680835260e89091526040909120600181015491935091504210612cc657805460e48054600090612be8908490614313565b90915550506001600160a01b038216600090815260e860205260408120818155600101819055612c17856146a3565b9450841115612c8e5760e78481548110612c3357612c336143a6565b60009182526020909120015460e780546001600160a01b039092169185908110612c5f57612c5f6143a6565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b60e7805480612c9f57612c9f61453b565b600082815260209020810160001990810180546001600160a01b0319169055019055612b85565b600190920191612b85565b60e4548015610aad576000612ce660076121dd565b600060e481905560408051600481526024810182526020810180516001600160e01b03166359f778df60e01b179052905192935090916001600160a01b038416918591612d3391906146ba565b60006040518083038185875af1925050503d8060008114612d70576040519150601f19603f3d011682016040523d82523d6000602084013e612d75565b606091505b505090508015612dba57816001600160a01b03167fc447c884574da5878be39c403db2245c22530c99b579ea7bcbb3720e1d110dc884604051610ba491815260200190565b816001600160a01b03167fa0561a59abed308fcd0556834574739d778cc6229018039a24ddda0f86aa0b738447604051610ba492919061445c565b505050565b606080612e0683613526565b90506000612e1460096121dd565b6001600160a01b03166391f8723f60736040518263ffffffff1660e01b8152600401612e4091906146e9565b600060405180830381865afa158015612e5d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612e859190810190614780565b90506000612e93600a6121dd565b6001600160a01b031663520fce6260736040518263ffffffff1660e01b8152600401612ebf91906146e9565b600060405180830381865afa158015612edc573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612f049190810190614780565b90506000612f736073805480602002602001604051908101604052809291908181526020018280548015612f6157602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612f43575b5050505050848460a95460ad54613a10565b9095509050612f83858288613ada565b505050915091565b6000612f9760056121dd565b6001600160a01b031663fdadda8183612fb1436001614313565b6040518363ffffffff1660e01b8152600401612fce929190614505565b600060405180830381865afa158015612feb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526130139190810190614815565b905060005b82518110156131c5576000838281518110613035576130356143a6565b6020908102919091018101516001600160a01b0381166000908152603b90925260408220549092504211159061306a83611823565b905060006130828461307d436001614313565b612643565b806130a3575085858151811061309a5761309a6143a6565b60200260200101515b806130ab5750825b159050811580156130b95750805b15613134576001600160a01b038416600090815260ac60205260409020546130f89060019060ff1660038111156130f2576130f2614422565b90613c1a565b6001600160a01b038516600090815260ac60205260409020805460ff1916600183600381111561312a5761312a614422565b02179055506131b6565b81801561313f575080155b156131b6576001600160a01b038416600090815260ac602052604090205461317e9060019060ff16600381111561317857613178614422565b90613c55565b6001600160a01b038516600090815260ac60205260409020805460ff191660018360038111156131b0576131b0614422565b02179055505b84600101945050505050613018565b5082847f283b50d76057d5f828df85bc87724c6af604e9b55c363a07c9faa2a2cd688b826131f1611082565b6040516131fe919061410f565b60405180910390a350505050565b806001600160a01b03163b600003610aad5780604051630bfc64a360e21b8152600401610af591906140b7565b60006001548261324991906144cd565b610a03906001614313565b600182015461326b906001600160a01b0316611b7c565b6132885760405163a64b34ad60e01b815260040160405180910390fd5b6005820181905560018201546040518281526001600160a01b03909116907fb9a1e33376bfbda9092f2d1e37662c1b435aab0d3fa8da3acc8f37ee222f99e790602001611339565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b031690565b6000836001600160a01b0316838390604051600060405180830381858888f193505050503d806000811461334e576040519150601f19603f3d011682016040523d82523d6000602084013e613353565b606091505b509095945050505050565b60008061336b600a6121dd565b6001600160a01b03166341feed1c846040518263ffffffff1660e01b815260040161339691906140b7565b602060405180830381865afa1580156133b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133d7919061433f565b1192915050565b7fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb90565b6001600160a01b038216600090815260e060205260409020548015612df55761342e82826104b06132fe565b1561348557816001600160a01b0316836001600160a01b03167f1ce7a1c4702402cd393500acb1de5bd927727a54e144a587d328f1b679abe4ec8360405161347891815260200190565b60405180910390a3505050565b816001600160a01b0316836001600160a01b03167f6c69e09ee5c5ac33c0cd57787261c5bade070a392ab34a4b5487c6868f723f6e834760405161347892919061445c565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114613517576040519150601f19603f3d011682016040523d82523d6000602084013e61351c565b606091505b5090949350505050565b6060600061353460096121dd565b90506000816001600160a01b031663af2454296040518163ffffffff1660e01b8152600401602060405180830381865afa158015613576573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061359a919061433f565b90506000826001600160a01b031663909791dd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156135dc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613600919061433f565b90506000836001600160a01b03166342ef3c3460736040518263ffffffff1660e01b815260040161363191906146e9565b600060405180830381865afa15801561364e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526136769190810190614780565b6073549091506000816001600160401b03811115613696576136966143bc565b6040519080825280602002602001820160405280156136bf578160200160208202803683370190505b50965060008060005b8483101561396157607383815481106136e3576136e36143a6565b60009182526020808320909101546001600160a01b03168083526075909152604090912060068101548851929450909250151590889088908690811061372b5761372b6143a6565b60200260200101511015613787578061378257600061374a8a42614313565b600684018190556040518181529091506001600160a01b038516906000805160206148f28339815191529060200160405180910390a2505b6137c8565b80156137c8578160060160009055826001600160a01b03166000805160206148f283398151915260006040516137bf91815260200190565b60405180910390a25b600082600501546000141580156137e3575042836005015411155b8061380657506001600160a01b038416600090815260e9602052604090205460ff165b905060008360060154600014158015613823575042846006015411155b9050818061382e5750805b156138c0578861383d896146a3565b98508881518110613850576138506143a6565b602002602001015189878151811061386a5761386a6143a6565b602002602001018181525050848d888060010199508151811061388f5761388f6143a6565b60200260200101906001600160a01b031690816001600160a01b0316815250506138b885613c91565b5050506136c8565b6001600160a01b03851660009081526077602052604090205480158015906138e85750428111155b15613951576001600160a01b0386166000818152607760209081526040808320600181018054918590559390935560048901839055518281529192917f86d576c20e383fc2413ef692209cc48ddad5e52f25db5b32f8f7ec5076461ae9910160405180910390a2505b5050600190940193506136c89050565b5050508087528015613a05577f4eaf233b9dc25a5552c1927feee1412eea69add17c2485c831c2e60e234f3c918760405161399c919061410f565b60405180910390a160405163e22d1c9d60e01b81526001600160a01b0387169063e22d1c9d906139d2908a908c90600401614505565b600060405180830381600087803b1580156139ec57600080fd5b505af1158015613a00573d6000803e3d6000fd5b505050505b505050505050919050565b60606000806068905060008888888888604051602401613a349594939291906148a3565b60408051601f19818403018152919052602080820180516001600160e01b0316633bca0a8960e11b17905281518b519293506001929091600091613a77916144a0565b613a82906040614313565b90506020840181888483895afa613a9857600093505b503d613aa357600092505b60208701965082613ac757604051630fc2632160e01b815260040160405180910390fd5b8651955050505050509550959350505050565b815b60aa54811015613b2e57600081815260ab6020818152604080842080546001600160a01b0316855260ac8352908420805460ff19169055928490525280546001600160a01b0319169055600101613adc565b5060005b82811015613b6e57600081815260ab60209081526040808320546001600160a01b0316835260ac9091529020805460ff19169055600101613b32565b5060005b82811015613be2576000848281518110613b8e57613b8e6143a6565b6020908102919091018101516001600160a01b0316600081815260ac83526040808220805460ff1916600317905585825260ab9093529190912080546001600160a01b031916909117905550600101613b72565b508160aa81905550807f3d0eea40644a206ec25781dd5bb3b60eb4fa1264b993c3bddf3c73b14f29ef5e84604051610ba4919061410f565b6000816003811115613c2e57613c2e614422565b836003811115613c4057613c40614422565b1760ff166003811115610bd257610bd2614422565b6000816003811115613c6957613c69614422565b19836003811115613c7c57613c7c614422565b1660ff166003811115610bd257610bd2614422565b6001600160a01b038116600090815260e960209081526040808320805460ff191690556074909152812054610aad91839190819003613cce575050565b6001600160a01b038216600090815260756020908152604080832080546001600160a01b031990811682556001808301805483169055600283018054831690556003830180549092169091556004820185905560058201859055600690910184905560748352818420849055607790925282208281558101829055607380549091613d5891614300565b81548110613d6857613d686143a6565b6000918252602090912001546001600160a01b03908116915083168114613deb576001600160a01b0381166000908152607460205260409020829055607380548291908419908110613dbc57613dbc6143a6565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b6073805480613dfc57613dfc61453b565b600082815260209020810160001990810180546001600160a01b0319169055019055505050565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081019190915290565b6001600160a01b0381168114610aad57600080fd5b60008060408385031215613e8757600080fd5b8235613e9281613e5f565b91506020830135613ea281613e5f565b809150509250929050565b60008060408385031215613ec057600080fd5b8235613ecb81613e5f565b946020939093013593505050565b600060208284031215613eeb57600080fd5b5035919050565b600060208284031215613f0457600080fd5b8135610bd281613e5f565b60018060a01b03808251168352806020830151166020840152806040830151166040840152806060830151166060840152506080810151608083015260a081015160a083015260c081015160c08301525050565b60e08101610a038284613f0f565b815181526020808301519082015260408101610a03565b8015158114610aad57600080fd5b60008060008060808587031215613fac57600080fd5b8435613fb781613e5f565b935060208501359250604085013591506060850135613fd581613f88565b939692955090935050565b8060408101831015610a0357600080fd5b6000806000806000806000806000806000806101a08d8f03121561401457600080fd5b8c3561401f81613e5f565b9b5060208d013561402f81613e5f565b9a5060408d013561403f81613e5f565b995060608d013561404f81613e5f565b985060808d013561405f81613e5f565b975060a08d013561406f81613e5f565b965060c08d0135955060e08d013594506101008d013593506101208d013592506101408d013591506140a58e6101608f01613fe0565b90509295989b509295989b509295989b565b6001600160a01b0391909116815260200190565b600081518084526020808501945080840160005b838110156141045781516001600160a01b0316875295820195908201906001016140df565b509495945050505050565b602081526000610bd260208301846140cb565b6000806020838503121561413557600080fd5b82356001600160401b038082111561414c57600080fd5b818501915085601f83011261416057600080fd5b81358181111561416f57600080fd5b8660208260051b850101111561418457600080fd5b60209290920196919550909350505050565b6020808252825182820181905260009190848201906040850190845b818110156141d05783511515835292840192918401916001016141b2565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156141d05761420b838551613f0f565b9284019260e092909201916001016141f8565b8035600e8110610ce557600080fd5b6000806040838503121561424057600080fd5b613e928361421e565b60006020828403121561425b57600080fd5b610bd28261421e565b60008060006060848603121561427957600080fd5b833561428481613e5f565b95602085013595506040909401359392505050565b600080600080608085870312156142af57600080fd5b84356142ba81613e5f565b935060208501356142ca81613e5f565b925060408501356142da81613e5f565b9396929550929360600135925050565b634e487b7160e01b600052601160045260246000fd5b81810381811115610a0357610a036142ea565b80820180821115610a0357610a036142ea565b6001600160a01b03929092168252602082015260400190565b60006020828403121561435157600080fd5b5051919050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6000600182016143e4576143e46142ea565b5060010190565b60008060006060848603121561440057600080fd5b835161440b81613f88565b602085015160409095015190969495509392505050565b634e487b7160e01b600052602160045260246000fd5b828152604081016003831061444f5761444f614422565b8260208301529392505050565b918252602082015260400190565b6000806000806080858703121561448057600080fd5b505082516020840151604085015160609095015191969095509092509050565b8082028115828204841417610a0357610a036142ea565b634e487b7160e01b600052601260045260246000fd5b6000826144dc576144dc6144b7565b500490565b600080604083850312156144f457600080fd5b505080516020909101519092909150565b60408152600061451860408301856140cb565b90508260208301529392505050565b600082614536576145366144b7565b500690565b634e487b7160e01b600052603160045260246000fd5b600e811061456157614561614422565b9052565b60208101610a038284614551565b6001600160e01b031983168152604081016009831061444f5761444f614422565b6001600160e01b031984168152606081016145b26020830185614551565b6001600160a01b03929092166040919091015292915050565b600081518084526020808501945080840160005b83811015614104578151875295820195908201906001016145df565b60608152600061460e60608301866140cb565b828103602084015261462081866145cb565b915050826040830152949350505050565b83815260606020820152600061464a60608301856140cb565b828103604084015261465c81856145cb565b9695505050505050565b84815260806020820152600061467f60808301866140cb565b828103604084015261469181866145cb565b91505082606083015295945050505050565b6000816146b2576146b26142ea565b506000190190565b6000825160005b818110156146db57602081860181015185830152016146c1565b506000920191825250919050565b6020808252825482820181905260008481528281209092916040850190845b818110156141d05783546001600160a01b031683526001938401939285019201614708565b604051601f8201601f191681016001600160401b0381118282101715614755576147556143bc565b604052919050565b60006001600160401b03821115614776576147766143bc565b5060051b60200190565b6000602080838503121561479357600080fd5b82516001600160401b038111156147a957600080fd5b8301601f810185136147ba57600080fd5b80516147cd6147c88261475d565b61472d565b81815260059190911b820183019083810190878311156147ec57600080fd5b928401925b8284101561480a578351825292840192908401906147f1565b979650505050505050565b6000602080838503121561482857600080fd5b82516001600160401b0381111561483e57600080fd5b8301601f8101851361484f57600080fd5b805161485d6147c88261475d565b81815260059190911b8201830190838101908783111561487c57600080fd5b928401925b8284101561480a57835161489481613f88565b82529284019290840190614881565b60a0815260006148b660a08301886140cb565b82810360208401526148c881886145cb565b905082810360408401526148dc81876145cb565b6060840195909552505060800152939250505056fe88f854e137380c14d63f6ed99781bf13402167cf55bac49bcd44d4f2d6a342754042bb9a70998f80a86d9963f0d2132e9b11c8ad94d207c6141c8e34b05ce53e7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498a264697066735822122006f70ed3ab8a42966754c287a14456dd2468d1bb624bb77478de83b9c05dddc164736f6c63430008110033", + "deployedBytecode": "0x60806040526004361061028a5760003560e01c806303827884146102a157806304d971ab146102ca57806306040618146102fa5780630f43a6771461030f57806311662dc2146103255780631196ab661461036257806315b5ebde14610382578063217f35c2146103a257806323c65eb0146103b757806328bde1e1146103d75780632924de7114610404578063297a8fca146104245780632d784a98146104395780632f78204c1461046657806331a8aef514610486578063367ec12b146104a65780633b3159b6146104c6578063468c96ae146104e357806349096d261461051a5780634d8df0631461053c5780634de2b7351461055c5780634ee4d72b146105895780634f2a693f1461059e57806352091f17146105be5780635248184a146105c65780635cd8a76b146105e8578063605239a1146105fd57806365244ece146106125780636558954f146106325780636611f84314610649578063690b7536146106695780636aa1c2ef1461067e57806372e46810146106935780637593ff711461069b578063823a7b9c146106bb578063865e6fd3146106db578063873a5a70146106fb57806387c891bd1461071b5780638d559c381461073057806396585fc2146107445780639e94b9ec14610764578063a0c3f2d214610779578063a3d545f514610799578063a66c0f77146107b9578063a7c2f119146107ce578063b7ab4db5146107ee578063ba77b06c14610803578063c3c8b5d614610818578063c94aaa0214610838578063cba44de914610858578063d09f1ab41461086d578063dd716ad314610882578063de981f1b146108a2578063e5125a1d146108c2578063edb194bb146108e2578063eeb629a814610944578063f883afaf1461095957610299565b3661029957610297610979565b005b610297610979565b3480156102ad57600080fd5b506102b76104b081565b6040519081526020015b60405180910390f35b3480156102d657600080fd5b506102ea6102e5366004613e74565b6109e2565b60405190151581526020016102c1565b34801561030657600080fd5b506102b7610a09565b34801561031b57600080fd5b506102b760aa5481565b34801561033157600080fd5b50610345610340366004613ead565b610a19565b6040805193151584526020840192909252908201526060016102c1565b34801561036e57600080fd5b5061029761037d366004613ed9565b610a9c565b34801561038e57600080fd5b5061029761039d366004613ead565b610ab0565b3480156103ae57600080fd5b506102ea610bb1565b3480156103c357600080fd5b506102ea6103d2366004613ead565b610bc6565b3480156103e357600080fd5b506103f76103f2366004613ef2565b610bd9565b6040516102c19190613f63565b34801561041057600080fd5b506102ea61041f366004613ef2565b610c7c565b34801561043057600080fd5b506004546102b7565b34801561044557600080fd5b50610459610454366004613ef2565b610c88565b6040516102c19190613f71565b34801561047257600080fd5b50610297610481366004613f96565b610cea565b34801561049257600080fd5b506102ea6104a1366004613ead565b610f05565b3480156104b257600080fd5b506102976104c1366004613ff1565b610f11565b3480156104d257600080fd5b5060685b6040516102c191906140b7565b3480156104ef57600080fd5b506105036104fe366004613ed9565b611044565b6040805192151583526020830191909152016102c1565b34801561052657600080fd5b5061052f611082565b6040516102c1919061410f565b34801561054857600080fd5b50610297610557366004613ed9565b611161565b34801561056857600080fd5b5061057c610577366004614122565b611172565b6040516102c19190614196565b34801561059557600080fd5b5060e4546102b7565b3480156105aa57600080fd5b506102976105b9366004613ed9565b611223565b610297611234565b3480156105d257600080fd5b506105db6115c5565b6040516102c191906141dc565b3480156105f457600080fd5b506102976116ea565b34801561060957600080fd5b506072546102b7565b34801561061e57600080fd5b506102ea61062d366004613ef2565b611823565b34801561063e57600080fd5b506102b76201518081565b34801561065557600080fd5b50610297610664366004613ed9565b61185d565b34801561067557600080fd5b5060e5546102b7565b34801561068a57600080fd5b506001546102b7565b61029761186e565b3480156106a757600080fd5b506102ea6106b6366004613ed9565b611ab2565b3480156106c757600080fd5b506102976106d6366004613ed9565b611ad6565b3480156106e757600080fd5b506102976106f636600461422d565b611ae7565b34801561070757600080fd5b506102ea610716366004613ef2565b611b06565b34801561072757600080fd5b506002546102b7565b34801561073c57600080fd5b5060666104d6565b34801561075057600080fd5b5061034561075f366004613ef2565b611b1d565b34801561077057600080fd5b506102b7611b39565b34801561078557600080fd5b506102ea610794366004613ef2565b611b7c565b3480156107a557600080fd5b506102b76107b4366004613ed9565b611b99565b3480156107c557600080fd5b5060e6546102b7565b3480156107da57600080fd5b506102976107e9366004613ead565b611ba4565b3480156107fa57600080fd5b5061052f611de7565b34801561080f57600080fd5b5061052f611e8d565b34801561082457600080fd5b50610297610833366004613e74565b611eef565b34801561084457600080fd5b50610297610853366004613ed9565b612146565b34801561086457600080fd5b506076546102b7565b34801561087957600080fd5b5060a9546102b7565b34801561088e57600080fd5b5061029761089d366004613ead565b612157565b3480156108ae57600080fd5b506104d66108bd366004614249565b6121dd565b3480156108ce57600080fd5b506102976108dd366004614264565b61223a565b3480156108ee57600080fd5b506104596108fd366004613ef2565b6040805180820190915260008082526020820152506001600160a01b0316600090815260776020908152604091829020825180840190935280548352600101549082015290565b34801561095057600080fd5b5060ad546102b7565b34801561096557600080fd5b50610297610974366004614299565b612348565b61098360076121dd565b6001600160a01b0316336001600160a01b0316141580156109bf57506109a960096121dd565b6001600160a01b0316336001600160a01b031614155b156109e05760405160016234baed60e01b0319815260040160405180910390fd5b565b6001600160a01b038281166000908152607560205260409020548116908216145b92915050565b6000610a1460035490565b905090565b6001600160a01b0382166000908152603a60205260408120548190819084811015610a4f57600080600093509350935050610a95565b60019350610a5d8582614300565b610a68906001614313565b9250610a7385611b99565b610a7c82611b99565b610a869190614300565b610a91906001614313565b9150505b9250925092565b610aa4612548565b610aad81612591565b50565b6006610abb816125e8565b6001600160a01b0383166000908152603c60205260409020544311610afe57826040516353e0424d60e01b8152600401610af591906140b7565b60405180910390fd5b6001600160a01b038316600081815260386020908152604080832086845282528083208054600160ff199182168117909255948452603783528184208785529092529091208054909216909155610b559043614300565b6001600160a01b0384166000818152603a6020526040908190209290925590517f6bb2436cb6b6eb65d5a52fac2ae0373a77ade6661e523ef3004ee2d5524e6c6e90610ba49085815260200190565b60405180910390a2505050565b6000610a14610bbf42612634565b6003541090565b6000610bd28383612643565b9392505050565b610be1613e23565b610bea82611b7c565b610c075760405163a64b34ad60e01b815260040160405180910390fd5b506001600160a01b03908116600090815260756020908152604091829020825160e081018452815485168152600182015485169281019290925260028101548416928201929092526003820154909216606083015260048101546080830152600581015460a08301526006015460c082015290565b6000610a038243610bc6565b604080518082018252600080825260209182018190526001600160a01b038416815260e882528281208351808501909452805484526001015491830182905203610ce5576040516370fdd4f160e11b815260040160405180910390fd5b919050565b6006610cf5816125e8565b6000610cff610a09565b6001600160a01b03871660008181526037602090815260408083208584528252808320805460ff1916600117905592825260e181528282205460e090915291902054919250610d4d91614313565b60e46000828254610d5e9190614313565b90915550506001600160a01b038616600090815260e06020908152604080832083905560e18252808320839055603a909152902054610d9e908690612663565b6001600160a01b0387166000908152603a60205260409020558315610e54576000610dc960096121dd565b6001600160a01b0316632715805e88876040518363ffffffff1660e01b8152600401610df6929190614326565b6020604051808303816000875af1158015610e15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e39919061433f565b90508060e46000828254610e4d9190614313565b9091555050505b8215610e98576001600160a01b0386166000908152603c6020526040902054610e7e908690612663565b6001600160a01b0387166000908152603c60205260409020555b6001600160a01b0386166000818152603a6020908152604080832054815190815291820188905260019082015260608101919091528291907f54ce99c5ce1fc9f61656d4a0fb2697974d0c973ac32eecaefe06fcf18b8ef68a9060800160405180910390a3505050505050565b6000610bd2838361267a565b600054610100900460ff1615808015610f315750600054600160ff909116105b80610f4b5750303b158015610f4b575060005460ff166001145b610f675760405162461bcd60e51b8152600401610af590614358565b6000805460ff191660011790558015610f8a576000805461ff0019166101001790555b610f9560068e6126a5565b610fa060098d6126a5565b610fab60078c6126a5565b610fb660058b6126a5565b610fc1600a8a6126a5565b610fca87612730565b610fd386612765565b610fdc8561279a565b610fe584612591565b610fef82356127f2565b610ffc6020830135612827565b60018390558015611035576000805461ff0019169055604051600181526000805160206149328339815191529060200160405180910390a15b50505050505050505050505050565b60008061105043611b99565b8311158061106b575060008381526005602052604090205415155b600093845260056020526040909320549293915050565b606060aa546001600160401b0381111561109e5761109e6143bc565b6040519080825280602002602001820160405280156110c7578160200160208202803683370190505b5090506000805b825181101561115b57600081815260ab60205260409020546110f8906001600160a01b0316611823565b1561115357600081815260ab60205260409020546001600160a01b03168383611120816143d2565b945081518110611132576111326143a6565b60200260200101906001600160a01b031690816001600160a01b0316815250505b6001016110ce565b50815290565b611169612548565b610aad81612827565b6060816001600160401b0381111561118c5761118c6143bc565b6040519080825280602002602001820160405280156111b5578160200160208202803683370190505b50905060005b8281101561121c576111f28484838181106111d8576111d86143a6565b90506020020160208101906111ed9190613ef2565b61285c565b828281518110611204576112046143a6565b911515602092830291909101909101526001016111bb565b5092915050565b61122b612548565b610aad81612765565b61123c612868565b600061124733611823565b801561125957506112573361285c565b155b801561127357506112713361126c610a09565b61267a565b155b9050600061128160076121dd565b604051630634f5b960e01b81528315156004820152600060248201526001600160a01b039190911690630634f5b9906044016060604051808303816000875af11580156112d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f691906143eb565b5091505081611345573460e460008282546113119190614313565b9091555050604051339060008051602061491283398151915290611339903490600190614438565b60405180910390a25050565b336001600160a01b03167f0ede5c3be8625943fa64003cd4b91230089411249f3059bac6500873543ca9b1348360405161138092919061445c565b60405180910390a26000611392610a09565b905060006113a08334614313565b3360009081526038602090815260408083208684529091528120549192509060ff16156114985760006113d360066121dd565b6001600160a01b031663c6391fa26040518163ffffffff1660e01b8152600401608060405180830381865afa158015611410573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611434919061446a565b9350505050612710818461144891906144a0565b61145291906144cd565b91508160e460008282546114669190614313565b909155505060405133906000805160206149128339815191529061148e908590600290614438565b60405180910390a2505b6114a28183614300565b91506000806114b160096121dd565b6001600160a01b0316634530d2026040518163ffffffff1660e01b81526004016040805180830381865afa1580156114ed573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061151191906144e1565b336000908152607560205260408120600401549294509092509061153f906115399084612888565b84612663565b9050600061271061155087846144a0565b61155a91906144cd565b33600090815260e0602052604081208054929350839290919061157e908490614313565b90915550600090506115908288614300565b33600090815260e160205260408120805492935083929091906115b4908490614313565b909155505050505050505050505050565b6073546060906001600160401b038111156115e2576115e26143bc565b60405190808252806020026020018201604052801561161b57816020015b611608613e23565b8152602001906001900390816116005790505b50905060005b81518110156116e6576075600060738381548110611641576116416143a6565b60009182526020808320909101546001600160a01b039081168452838201949094526040928301909120825160e081018452815485168152600182015485169281019290925260028101548416928201929092526003820154909216606083015260048101546080830152600581015460a08301526006015460c082015282518390839081106116d3576116d36143a6565b6020908102919091010152600101611621565b5090565b600054600290610100900460ff1615801561170c575060005460ff8083169116105b6117285760405162461bcd60e51b8152600401610af590614358565b6000805461ffff191660ff831617610100179055607154611754906009906001600160a01b03166126a5565b606f5461176c906005906001600160a01b03166126a5565b607054611784906006906001600160a01b03166126a5565b606d5461179c906007906001600160a01b03166126a5565b60a8546117b490600a906001600160a01b03166126a5565b607180546001600160a01b0319908116909155606f8054821690556070805482169055606d805482169055606e80548216905560a8805490911690556000805461ff001916905560405160ff82168152600080516020614932833981519152906020015b60405180910390a150565b6001600160a01b038116600090815260ac6020526040812054610a039060019060ff16600381111561185757611857614422565b90612897565b611865612548565b610aad816127f2565b611876612868565b61187f43611ab2565b61189c57604051636c74eecf60e01b815260040160405180910390fd5b6118a543611b99565b6118b0600254611b99565b106118ce57604051632458f64160e01b815260040160405180910390fd5b4360025560006118dd42612634565b905060006118ec826003541090565b905060006118f8611de7565b90506060600061190743611b99565b90506000611916826001614313565b90506000611922610a09565b90508515611a4c5760008061193783886128ca565b9150915061194783888484612a73565b61194f612b7d565b611957612cd1565b600061196360066121dd565b604051631da0214360e21b81529091506001600160a01b03821690637680850c90611994908b908890600401614505565b600060405180830381600087803b1580156119ae57600080fd5b505af11580156119c2573d6000803e3d6000fd5b505050506119cf8a612dfa565b8051919950975015611a3a576040516303e1697b60e11b81526001600160a01b038216906307c2d2f690611a07908a9060040161410f565b600060405180830381600087803b158015611a2157600080fd5b505af1158015611a35573d6000803e3d6000fd5b505050505b611a45436001614313565b6004555050505b611a57878387612f8b565b82817f0195462033384fec211477c56217da64a58bd405e0bed331ba4ded67e4ae4ce788604051611a8c911515815260200190565b60405180910390a350600090815260056020526040902085905550505060039190915550565b600060018054611ac29190614300565b600154611acf9084614527565b1492915050565b611ade612548565b610aad81612730565b611aef612548565b611af88161320c565b611b0282826126a5565b5050565b600080611b11610a09565b9050610bd2838261267a565b6000806000611b2c8443610a19565b9250925092509193909250565b6000805b60aa548110156116e657600081815260ab6020526040902054611b68906001600160a01b0316611823565b15611b74576001909101905b600101611b3d565b6001600160a01b0316600090815260746020526040902054151590565b6000610a0382613239565b6009611baf816125e8565b6001600160a01b038316600090815260e860205260409020600181015415611bea5760405163057aab3160e31b815260040160405180910390fd5b6000611bf68442614313565b6001600160a01b0386166000908152607560205260409020909150611c1b9082613254565b6001600160a01b0385166000908152603b602052604080822083905560e554905163138ac02f60e11b81523391632715805e91611c5c918a91600401614326565b6020604051808303816000875af1158015611c7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c9f919061433f565b90508015611d9c57600060e65442611cb79190614313565b60e78054600180820183556000929092527f6cb0db1d7354dfb4a1464318006df0643cafe2002a86a29ff8560f900fef28a10180546001600160a01b0319166001600160a01b038b1617905583865585018190559050611d156132d0565b6001600160a01b0388811660008181526075602052604090819020600201549051630a2fae5760e41b81526004810192909252821660248201524260448201526064810184905291169063a2fae57090608401600060405180830381600087803b158015611d8257600080fd5b505af1158015611d96573d6000803e3d6000fd5b50505050505b856001600160a01b03167f77a1a819870c0f4d04c3ca4cc2881a0393136abc28bd651af50aedade94a27c482604051611dd791815260200190565b60405180910390a2505050505050565b606060aa546001600160401b03811115611e0357611e036143bc565b604051908082528060200260200182016040528015611e2c578160200160208202803683370190505b50905060005b81518110156116e657600081815260ab602052604090205482516001600160a01b03909116908190849084908110611e6c57611e6c6143a6565b6001600160a01b039092166020928302919091019091015250600101611e32565b60606073805480602002602001604051908101604052809291908181526020018280548015611ee557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611ec7575b5050505050905090565b611ef7612548565b6001600160a01b038216600090815260e8602052604090206001015415611b025760e7548060005b82811015611f6e57846001600160a01b031660e78281548110611f4457611f446143a6565b6000918252602090912001546001600160a01b031603611f6657809150611f6e565b600101611f1f565b50818103611f7c5750505050565b6001600160a01b038416600090815260e86020526040902054801561213f576001600160a01b038516600090815260e86020526040812081815560019081019190915583111561203e5760e7611fd3600185614300565b81548110611fe357611fe36143a6565b60009182526020909120015460e780546001600160a01b03909216918490811061200f5761200f6143a6565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b60e780548061204f5761204f61453b565b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b038716825260e9905260409020805460ff191660011790556120a184826104b06132fe565b156120fa57836001600160a01b0316856001600160a01b03167f7229136a18186c71a86246c012af3bb1df6460ef163934bbdccd6368abdd41e4836040516120eb91815260200190565b60405180910390a35050505050565b836001600160a01b0316856001600160a01b03167f3747d14eb72ad3e35cba9c3e00dab3b8d15b40cac6bdbd08402356e4f69f30a183476040516120eb92919061445c565b5050505050565b61214e612548565b610aad8161279a565b6009612162816125e8565b61216b8361335e565b156121895760405163030081e760e01b815260040160405180910390fd5b6001600160a01b03831660009081526075602052604090206005810154156121c45760405163fab9167360e01b815260040160405180910390fd5b6121d7816121d28542614313565b613254565b50505050565b60006121e76133de565b600083600d8111156121fb576121fb614422565b60ff1681526020810191909152604001600020546001600160a01b0316905080610ce5578160405163409140df60e11b8152600401610af59190614565565b6009612245816125e8565b6001600160a01b0384166000908152607760205260409020541561227c57604051632f32dcdd60e11b815260040160405180910390fd5b61271082111561229f57604051631b8454a360e21b815260040160405180910390fd5b6076548310156122c25760405163fa0ae69360e01b815260040160405180910390fd5b6001600160a01b03841660009081526077602052604081209062015180856122ea82426144cd565b6122f49190614313565b6122fe91906144a0565b808355600183018590556040519091506001600160a01b038716907f6ebafd1bb6316b2f63198a81b05cff2149c6eaae1784466a6d062b4391900f2190611dd7908490889061445c565b6009612353816125e8565b607354607254811061237857604051638616841b60e01b815260040160405180910390fd5b61238185611b7c565b1561239f57604051638ad9cdf960e01b815260040160405180910390fd5b6127108311156123c257604051631b8454a360e21b815260040160405180910390fd5b60005b60735481101561247757600060756000607384815481106123e8576123e86143a6565b60009182526020808320909101546001600160a01b0390811684529083019390935260409091019020805490925081169089160361243b578760405163fc3d8c7560e01b8152600401610af591906140b7565b60028101546001600160a01b039081169087160361246e5785604051632d33a7e760e11b8152600401610af591906140b7565b506001016123c5565b506001600160a01b038581166000818152607460209081526040808320861990556073805460018082019092557ff79bde9ddd17963ebce6f7d021d60de7c2bd0db944d23c900c0c0e775f5300520180546001600160a01b031990811687179091556075909352818420805484168d881690811782559181018054851687179055600281018054909416968b1696871790935560048301899055905191949093909290917f1ca451a9920472b99355a9cf74185bf017604a7849c113f020888ecec9db93669190a450505050505050565b6125506132d0565b6001600160a01b0316336001600160a01b0316146109e0576000356001600160e01b0319166001604051620f948f60ea1b8152600401610af5929190614573565b60018110156125b3576040516317b8970f60e01b815260040160405180910390fd5b60768190556040518181527f266d432ffe659e3565750d26ec685b822a58041eee724b67a5afec3168a2526790602001611818565b6125f1816121dd565b6001600160a01b0316336001600160a01b031614610aad576000356001600160e01b03191681336040516320e0f98d60e21b8152600401610af593929190614594565b6000610a0362015180836144cd565b6001600160a01b03919091166000908152603a6020526040902054101590565b6000818310156126735781610bd2565b5090919050565b6001600160a01b03919091166000908152603760209081526040808320938352929052205460ff1690565b806126ae6133de565b600084600d8111156126c2576126c2614422565b60ff168152602081019190915260400160002080546001600160a01b0319166001600160a01b03928316179055811682600d81111561270357612703614422565b6040517f865d1c228a8ea13709cfe61f346f7ff67f1bbd4a18ff31ad3e7147350d317c5990600090a35050565b60a98190556040518181527fb5464c05fd0e0f000c535850116cda2742ee1f7b34384cb920ad7b8e802138b590602001611818565b60728190556040518181527f82d5dc32d1b741512ad09c32404d7e7921e8934c6222343d95f55f7a2b9b2ab490602001611818565b60a9548111156127bd576040516355408ce960e11b815260040160405180910390fd5b60ad8190556040518181527fa9588dc77416849bd922605ce4fc806712281ad8a8f32d4238d6c8cca548e15e90602001611818565b60e58190556040518181527f17a6c3eb965cdd7439982da25abf85be88f0f772ca33198f548e2f99fee0289a90602001611818565b60e68190556040518181527f0a50c66137118f386332efb949231ddd3946100dbf880003daca37ddd9e0662b90602001611818565b6000610a038243612643565b3341146109e0576040516309f358fd60e01b815260040160405180910390fd5b60008183106126735781610bd2565b60008160038111156128ab576128ab614422565b8360038111156128bd576128bd614422565b1660ff1615159392505050565b6000606060008084516001600160401b038111156128ea576128ea6143bc565b604051908082528060200260200182016040528015612913578160200160208202803683370190505b50925060005b8551811015612a6957858181518110612934576129346143a6565b6020908102919091018101516001600160a01b038082166000908152607590935260409092206002015490945016915061296d8361285c565b158015612981575061297f838861267a565b155b156129f5576001600160a01b038316600090815260e160205260409020546129a99086614313565b6001600160a01b038416600090815260e160205260409020548551919650908590839081106129da576129da6143a6565b6020026020010181815250506129f08383613402565b612a3b565b6001600160a01b038316600090815260e1602090815260408083205460e090925290912054612a249190614313565b60e46000828254612a359190614313565b90915550505b6001600160a01b038316600090815260e16020908152604080832083905560e0909152812055600101612919565b5050509250929050565b6000612a7f60096121dd565b9050821561213f57612a9181846134ca565b15612b395760405163566bce2360e11b81526001600160a01b0382169063acd79c4690612ac690879086908a906004016145fb565b600060405180830381600087803b158015612ae057600080fd5b505af1158015612af4573d6000803e3d6000fd5b505050507f9e242ca1ef9dde96eb71ef8d19a3f0f6a619b63e4c0d3998771387103656d087838584604051612b2b93929190614631565b60405180910390a1506121d7565b7fe5668ec1bb2b6bb144a50f810e388da4b1d7d3fc05fcb9d588a1aac59d248f8983858447604051612b6e9493929190614666565b60405180910390a15050505050565b60e754600080805b838310156121d75760e78381548110612ba057612ba06143a6565b60009182526020808320909101546001600160a01b031680835260e89091526040909120600181015491935091504210612cc657805460e48054600090612be8908490614313565b90915550506001600160a01b038216600090815260e860205260408120818155600101819055612c17856146a3565b9450841115612c8e5760e78481548110612c3357612c336143a6565b60009182526020909120015460e780546001600160a01b039092169185908110612c5f57612c5f6143a6565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b60e7805480612c9f57612c9f61453b565b600082815260209020810160001990810180546001600160a01b0319169055019055612b85565b600190920191612b85565b60e4548015610aad576000612ce660076121dd565b600060e481905560408051600481526024810182526020810180516001600160e01b03166359f778df60e01b179052905192935090916001600160a01b038416918591612d3391906146ba565b60006040518083038185875af1925050503d8060008114612d70576040519150601f19603f3d011682016040523d82523d6000602084013e612d75565b606091505b505090508015612dba57816001600160a01b03167fc447c884574da5878be39c403db2245c22530c99b579ea7bcbb3720e1d110dc884604051610ba491815260200190565b816001600160a01b03167fa0561a59abed308fcd0556834574739d778cc6229018039a24ddda0f86aa0b738447604051610ba492919061445c565b505050565b606080612e0683613526565b90506000612e1460096121dd565b6001600160a01b03166391f8723f60736040518263ffffffff1660e01b8152600401612e4091906146e9565b600060405180830381865afa158015612e5d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612e859190810190614780565b90506000612e93600a6121dd565b6001600160a01b031663520fce6260736040518263ffffffff1660e01b8152600401612ebf91906146e9565b600060405180830381865afa158015612edc573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612f049190810190614780565b90506000612f736073805480602002602001604051908101604052809291908181526020018280548015612f6157602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612f43575b5050505050848460a95460ad54613a10565b9095509050612f83858288613ada565b505050915091565b6000612f9760056121dd565b6001600160a01b031663fdadda8183612fb1436001614313565b6040518363ffffffff1660e01b8152600401612fce929190614505565b600060405180830381865afa158015612feb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526130139190810190614815565b905060005b82518110156131c5576000838281518110613035576130356143a6565b6020908102919091018101516001600160a01b0381166000908152603b90925260408220549092504211159061306a83611823565b905060006130828461307d436001614313565b612643565b806130a3575085858151811061309a5761309a6143a6565b60200260200101515b806130ab5750825b159050811580156130b95750805b15613134576001600160a01b038416600090815260ac60205260409020546130f89060019060ff1660038111156130f2576130f2614422565b90613c1a565b6001600160a01b038516600090815260ac60205260409020805460ff1916600183600381111561312a5761312a614422565b02179055506131b6565b81801561313f575080155b156131b6576001600160a01b038416600090815260ac602052604090205461317e9060019060ff16600381111561317857613178614422565b90613c55565b6001600160a01b038516600090815260ac60205260409020805460ff191660018360038111156131b0576131b0614422565b02179055505b84600101945050505050613018565b5082847f283b50d76057d5f828df85bc87724c6af604e9b55c363a07c9faa2a2cd688b826131f1611082565b6040516131fe919061410f565b60405180910390a350505050565b806001600160a01b03163b600003610aad5780604051630bfc64a360e21b8152600401610af591906140b7565b60006001548261324991906144cd565b610a03906001614313565b600182015461326b906001600160a01b0316611b7c565b6132885760405163a64b34ad60e01b815260040160405180910390fd5b6005820181905560018201546040518281526001600160a01b03909116907fb9a1e33376bfbda9092f2d1e37662c1b435aab0d3fa8da3acc8f37ee222f99e790602001611339565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b031690565b6000836001600160a01b0316838390604051600060405180830381858888f193505050503d806000811461334e576040519150601f19603f3d011682016040523d82523d6000602084013e613353565b606091505b509095945050505050565b60008061336b600a6121dd565b6001600160a01b03166341feed1c846040518263ffffffff1660e01b815260040161339691906140b7565b602060405180830381865afa1580156133b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133d7919061433f565b1192915050565b7fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb90565b6001600160a01b038216600090815260e060205260409020548015612df55761342e82826104b06132fe565b1561348557816001600160a01b0316836001600160a01b03167f1ce7a1c4702402cd393500acb1de5bd927727a54e144a587d328f1b679abe4ec8360405161347891815260200190565b60405180910390a3505050565b816001600160a01b0316836001600160a01b03167f6c69e09ee5c5ac33c0cd57787261c5bade070a392ab34a4b5487c6868f723f6e834760405161347892919061445c565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114613517576040519150601f19603f3d011682016040523d82523d6000602084013e61351c565b606091505b5090949350505050565b6060600061353460096121dd565b90506000816001600160a01b031663af2454296040518163ffffffff1660e01b8152600401602060405180830381865afa158015613576573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061359a919061433f565b90506000826001600160a01b031663909791dd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156135dc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613600919061433f565b90506000836001600160a01b03166342ef3c3460736040518263ffffffff1660e01b815260040161363191906146e9565b600060405180830381865afa15801561364e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526136769190810190614780565b6073549091506000816001600160401b03811115613696576136966143bc565b6040519080825280602002602001820160405280156136bf578160200160208202803683370190505b50965060008060005b8483101561396157607383815481106136e3576136e36143a6565b60009182526020808320909101546001600160a01b03168083526075909152604090912060068101548851929450909250151590889088908690811061372b5761372b6143a6565b60200260200101511015613787578061378257600061374a8a42614313565b600684018190556040518181529091506001600160a01b038516906000805160206148f28339815191529060200160405180910390a2505b6137c8565b80156137c8578160060160009055826001600160a01b03166000805160206148f283398151915260006040516137bf91815260200190565b60405180910390a25b600082600501546000141580156137e3575042836005015411155b8061380657506001600160a01b038416600090815260e9602052604090205460ff165b905060008360060154600014158015613823575042846006015411155b9050818061382e5750805b156138c0578861383d896146a3565b98508881518110613850576138506143a6565b602002602001015189878151811061386a5761386a6143a6565b602002602001018181525050848d888060010199508151811061388f5761388f6143a6565b60200260200101906001600160a01b031690816001600160a01b0316815250506138b885613c91565b5050506136c8565b6001600160a01b03851660009081526077602052604090205480158015906138e85750428111155b15613951576001600160a01b0386166000818152607760209081526040808320600181018054918590559390935560048901839055518281529192917f86d576c20e383fc2413ef692209cc48ddad5e52f25db5b32f8f7ec5076461ae9910160405180910390a2505b5050600190940193506136c89050565b5050508087528015613a05577f4eaf233b9dc25a5552c1927feee1412eea69add17c2485c831c2e60e234f3c918760405161399c919061410f565b60405180910390a160405163e22d1c9d60e01b81526001600160a01b0387169063e22d1c9d906139d2908a908c90600401614505565b600060405180830381600087803b1580156139ec57600080fd5b505af1158015613a00573d6000803e3d6000fd5b505050505b505050505050919050565b60606000806068905060008888888888604051602401613a349594939291906148a3565b60408051601f19818403018152919052602080820180516001600160e01b0316633bca0a8960e11b17905281518b519293506001929091600091613a77916144a0565b613a82906040614313565b90506020840181888483895afa613a9857600093505b503d613aa357600092505b60208701965082613ac757604051630fc2632160e01b815260040160405180910390fd5b8651955050505050509550959350505050565b815b60aa54811015613b2e57600081815260ab6020818152604080842080546001600160a01b0316855260ac8352908420805460ff19169055928490525280546001600160a01b0319169055600101613adc565b5060005b82811015613b6e57600081815260ab60209081526040808320546001600160a01b0316835260ac9091529020805460ff19169055600101613b32565b5060005b82811015613be2576000848281518110613b8e57613b8e6143a6565b6020908102919091018101516001600160a01b0316600081815260ac83526040808220805460ff1916600317905585825260ab9093529190912080546001600160a01b031916909117905550600101613b72565b508160aa81905550807f3d0eea40644a206ec25781dd5bb3b60eb4fa1264b993c3bddf3c73b14f29ef5e84604051610ba4919061410f565b6000816003811115613c2e57613c2e614422565b836003811115613c4057613c40614422565b1760ff166003811115610bd257610bd2614422565b6000816003811115613c6957613c69614422565b19836003811115613c7c57613c7c614422565b1660ff166003811115610bd257610bd2614422565b6001600160a01b038116600090815260e960209081526040808320805460ff191690556074909152812054610aad91839190819003613cce575050565b6001600160a01b038216600090815260756020908152604080832080546001600160a01b031990811682556001808301805483169055600283018054831690556003830180549092169091556004820185905560058201859055600690910184905560748352818420849055607790925282208281558101829055607380549091613d5891614300565b81548110613d6857613d686143a6565b6000918252602090912001546001600160a01b03908116915083168114613deb576001600160a01b0381166000908152607460205260409020829055607380548291908419908110613dbc57613dbc6143a6565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b6073805480613dfc57613dfc61453b565b600082815260209020810160001990810180546001600160a01b0319169055019055505050565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081019190915290565b6001600160a01b0381168114610aad57600080fd5b60008060408385031215613e8757600080fd5b8235613e9281613e5f565b91506020830135613ea281613e5f565b809150509250929050565b60008060408385031215613ec057600080fd5b8235613ecb81613e5f565b946020939093013593505050565b600060208284031215613eeb57600080fd5b5035919050565b600060208284031215613f0457600080fd5b8135610bd281613e5f565b60018060a01b03808251168352806020830151166020840152806040830151166040840152806060830151166060840152506080810151608083015260a081015160a083015260c081015160c08301525050565b60e08101610a038284613f0f565b815181526020808301519082015260408101610a03565b8015158114610aad57600080fd5b60008060008060808587031215613fac57600080fd5b8435613fb781613e5f565b935060208501359250604085013591506060850135613fd581613f88565b939692955090935050565b8060408101831015610a0357600080fd5b6000806000806000806000806000806000806101a08d8f03121561401457600080fd5b8c3561401f81613e5f565b9b5060208d013561402f81613e5f565b9a5060408d013561403f81613e5f565b995060608d013561404f81613e5f565b985060808d013561405f81613e5f565b975060a08d013561406f81613e5f565b965060c08d0135955060e08d013594506101008d013593506101208d013592506101408d013591506140a58e6101608f01613fe0565b90509295989b509295989b509295989b565b6001600160a01b0391909116815260200190565b600081518084526020808501945080840160005b838110156141045781516001600160a01b0316875295820195908201906001016140df565b509495945050505050565b602081526000610bd260208301846140cb565b6000806020838503121561413557600080fd5b82356001600160401b038082111561414c57600080fd5b818501915085601f83011261416057600080fd5b81358181111561416f57600080fd5b8660208260051b850101111561418457600080fd5b60209290920196919550909350505050565b6020808252825182820181905260009190848201906040850190845b818110156141d05783511515835292840192918401916001016141b2565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156141d05761420b838551613f0f565b9284019260e092909201916001016141f8565b8035600e8110610ce557600080fd5b6000806040838503121561424057600080fd5b613e928361421e565b60006020828403121561425b57600080fd5b610bd28261421e565b60008060006060848603121561427957600080fd5b833561428481613e5f565b95602085013595506040909401359392505050565b600080600080608085870312156142af57600080fd5b84356142ba81613e5f565b935060208501356142ca81613e5f565b925060408501356142da81613e5f565b9396929550929360600135925050565b634e487b7160e01b600052601160045260246000fd5b81810381811115610a0357610a036142ea565b80820180821115610a0357610a036142ea565b6001600160a01b03929092168252602082015260400190565b60006020828403121561435157600080fd5b5051919050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6000600182016143e4576143e46142ea565b5060010190565b60008060006060848603121561440057600080fd5b835161440b81613f88565b602085015160409095015190969495509392505050565b634e487b7160e01b600052602160045260246000fd5b828152604081016003831061444f5761444f614422565b8260208301529392505050565b918252602082015260400190565b6000806000806080858703121561448057600080fd5b505082516020840151604085015160609095015191969095509092509050565b8082028115828204841417610a0357610a036142ea565b634e487b7160e01b600052601260045260246000fd5b6000826144dc576144dc6144b7565b500490565b600080604083850312156144f457600080fd5b505080516020909101519092909150565b60408152600061451860408301856140cb565b90508260208301529392505050565b600082614536576145366144b7565b500690565b634e487b7160e01b600052603160045260246000fd5b600e811061456157614561614422565b9052565b60208101610a038284614551565b6001600160e01b031983168152604081016009831061444f5761444f614422565b6001600160e01b031984168152606081016145b26020830185614551565b6001600160a01b03929092166040919091015292915050565b600081518084526020808501945080840160005b83811015614104578151875295820195908201906001016145df565b60608152600061460e60608301866140cb565b828103602084015261462081866145cb565b915050826040830152949350505050565b83815260606020820152600061464a60608301856140cb565b828103604084015261465c81856145cb565b9695505050505050565b84815260806020820152600061467f60808301866140cb565b828103604084015261469181866145cb565b91505082606083015295945050505050565b6000816146b2576146b26142ea565b506000190190565b6000825160005b818110156146db57602081860181015185830152016146c1565b506000920191825250919050565b6020808252825482820181905260008481528281209092916040850190845b818110156141d05783546001600160a01b031683526001938401939285019201614708565b604051601f8201601f191681016001600160401b0381118282101715614755576147556143bc565b604052919050565b60006001600160401b03821115614776576147766143bc565b5060051b60200190565b6000602080838503121561479357600080fd5b82516001600160401b038111156147a957600080fd5b8301601f810185136147ba57600080fd5b80516147cd6147c88261475d565b61472d565b81815260059190911b820183019083810190878311156147ec57600080fd5b928401925b8284101561480a578351825292840192908401906147f1565b979650505050505050565b6000602080838503121561482857600080fd5b82516001600160401b0381111561483e57600080fd5b8301601f8101851361484f57600080fd5b805161485d6147c88261475d565b81815260059190911b8201830190838101908783111561487c57600080fd5b928401925b8284101561480a57835161489481613f88565b82529284019290840190614881565b60a0815260006148b660a08301886140cb565b82810360208401526148c881886145cb565b905082810360408401526148dc81876145cb565b6060840195909552505060800152939250505056fe88f854e137380c14d63f6ed99781bf13402167cf55bac49bcd44d4f2d6a342754042bb9a70998f80a86d9963f0d2132e9b11c8ad94d207c6141c8e34b05ce53e7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498a264697066735822122006f70ed3ab8a42966754c287a14456dd2468d1bb624bb77478de83b9c05dddc164736f6c63430008110033" } \ No newline at end of file diff --git a/deployments/ronin-testnet/SlashIndicatorLogic.json b/deployments/ronin-testnet/SlashIndicatorLogic.json index d8c02ec1c..2ae642996 100644 --- a/deployments/ronin-testnet/SlashIndicatorLogic.json +++ b/deployments/ronin-testnet/SlashIndicatorLogic.json @@ -1,5 +1,5 @@ { - "address": "0xfe054b9e34f0C3CaB2043e289D646b3a98538AC9", + "address": "0x2426268CB127c5F90c9759020F7D6a1Bf8349412", "abi": [ { "inputs": [], @@ -965,41 +965,41 @@ "type": "function" } ], - "transactionHash": "0x3e0ca970986fe4b58fd0cdc8d9bd4e98dd03eef925ba83cf177410d62778ed19", + "transactionHash": "0x6c045816f2e8a07d26302499b40a72ce81dcf694ca3d3af012fe798b4eac3574", "receipt": { "to": null, "from": "0x968D0Cd7343f711216817E617d3f92a23dC91c07", - "contractAddress": "0xfe054b9e34f0C3CaB2043e289D646b3a98538AC9", + "contractAddress": "0x2426268CB127c5F90c9759020F7D6a1Bf8349412", "transactionIndex": 0, "gasUsed": "2343021", - "logsBloom": "0x00000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000400000000000000010000000000000000000000000000000000000000000000040000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x0342bb070f9809149ff8b815f61d25a506267b99b53c93b1c01b7a4150922b5c", - "transactionHash": "0x3e0ca970986fe4b58fd0cdc8d9bd4e98dd03eef925ba83cf177410d62778ed19", + "logsBloom": "0x00000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000080000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x0f1e53ae203cacb62a28600d3c159c8eba3495da6b36e40d634b7ba80371bbc4", + "transactionHash": "0x6c045816f2e8a07d26302499b40a72ce81dcf694ca3d3af012fe798b4eac3574", "logs": [ { "transactionIndex": 0, - "blockNumber": 18032235, - "transactionHash": "0x3e0ca970986fe4b58fd0cdc8d9bd4e98dd03eef925ba83cf177410d62778ed19", - "address": "0xfe054b9e34f0C3CaB2043e289D646b3a98538AC9", + "blockNumber": 19351161, + "transactionHash": "0x6c045816f2e8a07d26302499b40a72ce81dcf694ca3d3af012fe798b4eac3574", + "address": "0x2426268CB127c5F90c9759020F7D6a1Bf8349412", "topics": [ "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" ], "data": "0x00000000000000000000000000000000000000000000000000000000000000ff", "logIndex": 0, - "blockHash": "0x0342bb070f9809149ff8b815f61d25a506267b99b53c93b1c01b7a4150922b5c" + "blockHash": "0x0f1e53ae203cacb62a28600d3c159c8eba3495da6b36e40d634b7ba80371bbc4" } ], - "blockNumber": 18032235, + "blockNumber": 19351161, "cumulativeGasUsed": "2343021", "status": 1, "byzantium": true }, "args": [], - "numDeployments": 7, - "solcInputHash": "6bc16cc8f779fe2f1f4f2733e87f867e", - "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"ErrCallPrecompiled\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrCallerMustBeJailedInTheCurrentPeriod\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrCannotSlashAValidatorTwiceOrSlashMoreThanOneValidatorInOneBlock\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"}],\"name\":\"ErrContractTypeNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrEvidenceAlreadySubmitted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInsufficientCreditScoreToBailOut\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidCreditScoreConfig\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidCutOffPercentageConfig\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidRatios\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidSlash\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"}],\"name\":\"ErrInvalidThreshold\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"},{\"internalType\":\"enum RoleAccess\",\"name\":\"expectedRole\",\"type\":\"uint8\"}],\"name\":\"ErrUnauthorized\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"},{\"internalType\":\"enum ContractType\",\"name\":\"expectedContractType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"actual\",\"type\":\"address\"}],\"name\":\"ErrUnexpectedInternalCall\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrValidatorHasBailedOutPreviously\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"ErrZeroCodeContract\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"validator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"usedCreditScore\",\"type\":\"uint256\"}],\"name\":\"BailedOut\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"missingVotesRatioTier1\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"missingVotesRatioTier2\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"jailDurationForMissingVotesRatioTier2\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"skipBridgeOperatorSlashingThreshold\",\"type\":\"uint256\"}],\"name\":\"BridgeOperatorSlashingConfigsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bridgeVotingThreshold\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bridgeVotingSlashAmount\",\"type\":\"uint256\"}],\"name\":\"BridgeVotingSlashingConfigsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"ContractUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"gainCreditScore\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"maxCreditScore\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bailOutCostMultiplier\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"cutOffPercentageAfterBailout\",\"type\":\"uint256\"}],\"name\":\"CreditScoreConfigsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"validators\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"creditScores\",\"type\":\"uint256[]\"}],\"name\":\"CreditScoresUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"slashDoubleSignAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"doubleSigningJailUntilBlock\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"doubleSigningOffsetLimitBlock\",\"type\":\"uint256\"}],\"name\":\"DoubleSignSlashingConfigsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"validator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"enum IBaseSlash.SlashType\",\"name\":\"slashType\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"}],\"name\":\"Slashed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"unavailabilityTier1Threshold\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"unavailabilityTier2Threshold\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"slashAmountForUnavailabilityTier2Threshold\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"jailDurationForUnavailabilityTier2Threshold\",\"type\":\"uint256\"}],\"name\":\"UnavailabilitySlashingConfigsUpdated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"}],\"name\":\"bailOut\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_validator\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_period\",\"type\":\"uint256\"}],\"name\":\"checkBailedOutAtPeriod\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_validator\",\"type\":\"address\"}],\"name\":\"currentUnavailabilityIndicator\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_validators\",\"type\":\"address[]\"}],\"name\":\"execResetCreditScores\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_tier\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_period\",\"type\":\"uint256\"}],\"name\":\"execSlashBridgeOperator\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBridgeOperatorSlashingConfigs\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"missingVotesRatioTier1_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"missingVotesRatioTier2_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"jailDurationForMissingVotesRatioTier2_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"skipBridgeOperatorSlashingThreshold_\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBridgeVotingSlashingConfigs\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"bridgeVotingThreshold_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"bridgeVotingSlashAmount_\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"}],\"name\":\"getContract\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"contract_\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_validator\",\"type\":\"address\"}],\"name\":\"getCreditScore\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCreditScoreConfigs\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"gainCreditScore_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxCreditScore_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"bailOutCostMultiplier_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"cutOffPercentageAfterBailout_\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getDoubleSignSlashingConfigs\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"slashDoubleSignAmount_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"doubleSigningJailUntilBlock_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"doubleSigningOffsetLimitBlock_\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_validators\",\"type\":\"address[]\"}],\"name\":\"getManyCreditScores\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_resultList\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_validator\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_period\",\"type\":\"uint256\"}],\"name\":\"getUnavailabilityIndicator\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getUnavailabilitySlashingConfigs\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"unavailabilityTier1Threshold_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"unavailabilityTier2Threshold_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"slashAmountForUnavailabilityTier2Threshold_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"jailDurationForUnavailabilityTier2Threshold_\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"__validatorContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"__maintenanceContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"__roninTrustedOrganizationContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"__roninGovernanceAdminContract\",\"type\":\"address\"},{\"internalType\":\"uint256[4]\",\"name\":\"_bridgeOperatorSlashingConfigs\",\"type\":\"uint256[4]\"},{\"internalType\":\"uint256[2]\",\"name\":\"_bridgeVotingSlashingConfigs\",\"type\":\"uint256[2]\"},{\"internalType\":\"uint256[3]\",\"name\":\"_doubleSignSlashingConfigs\",\"type\":\"uint256[3]\"},{\"internalType\":\"uint256[4]\",\"name\":\"_unavailabilitySlashingConfigs\",\"type\":\"uint256[4]\"},{\"internalType\":\"uint256[4]\",\"name\":\"_creditScoreConfigs\",\"type\":\"uint256[4]\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"roninGovernanceAdminContract\",\"type\":\"address\"}],\"name\":\"initializeV2\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lastUnavailabilitySlashedBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"precompileValidateDoubleSignAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_ratioTier1\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_ratioTier2\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_jailDurationTier2\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_skipSlashingThreshold\",\"type\":\"uint256\"}],\"name\":\"setBridgeOperatorSlashingConfigs\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_threshold\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_slashAmount\",\"type\":\"uint256\"}],\"name\":\"setBridgeVotingSlashingConfigs\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setContract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_gainScore\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_maxScore\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_bailOutMultiplier\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_cutOffPercentage\",\"type\":\"uint256\"}],\"name\":\"setCreditScoreConfigs\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_slashAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_jailUntilBlock\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_offsetLimitBlock\",\"type\":\"uint256\"}],\"name\":\"setDoubleSignSlashingConfigs\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_tier1Threshold\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_tier2Threshold\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_slashAmountForTier2Threshold\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_jailDurationForTier2Threshold\",\"type\":\"uint256\"}],\"name\":\"setUnavailabilitySlashingConfigs\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"}],\"name\":\"slashBridgeVoting\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_header1\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"_header2\",\"type\":\"bytes\"}],\"name\":\"slashDoubleSign\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_validatorAddr\",\"type\":\"address\"}],\"name\":\"slashUnavailability\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_validators\",\"type\":\"address[]\"},{\"internalType\":\"uint256\",\"name\":\"_period\",\"type\":\"uint256\"}],\"name\":\"updateCreditScores\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"errors\":{\"ErrCallPrecompiled()\":[{\"details\":\"Error of call to precompile fails.\"}],\"ErrCallerMustBeJailedInTheCurrentPeriod()\":[{\"details\":\"Error thrown when the caller must be jailed in the current period.\"}],\"ErrCannotSlashAValidatorTwiceOrSlashMoreThanOneValidatorInOneBlock()\":[{\"details\":\"Error thrown when attempting to slash a validator twice or slash more than one validator in one block.\"}],\"ErrContractTypeNotFound(uint8)\":[{\"details\":\"Error of invalid role.\"}],\"ErrEvidenceAlreadySubmitted()\":[{\"details\":\"Error thrown when evidence has already been submitted.\"}],\"ErrInsufficientCreditScoreToBailOut()\":[{\"details\":\"Error thrown when the caller's credit score is insufficient to bail out a situation.\"}],\"ErrInvalidCreditScoreConfig()\":[{\"details\":\"Error thrown when an invalid credit score configuration is provided.\"}],\"ErrInvalidCutOffPercentageConfig()\":[{\"details\":\"Error thrown when an invalid cut-off percentage configuration is provided.\"}],\"ErrInvalidRatios()\":[{\"details\":\"Error thrown when invalid ratios are provided.\"}],\"ErrInvalidSlash()\":[{\"details\":\"Error thrown when an invalid slash is encountered.\"}],\"ErrInvalidThreshold(bytes4)\":[{\"details\":\"Error indicating that the provided threshold is invalid for a specific function signature.\",\"params\":{\"msgSig\":\"The function signature (bytes4) that the invalid threshold applies to.\"}}],\"ErrUnauthorized(bytes4,uint8)\":[{\"details\":\"Error indicating that the caller is unauthorized to perform a specific function.\",\"params\":{\"expectedRole\":\"The role required to perform the function.\",\"msgSig\":\"The function signature (bytes4) that the caller is unauthorized to perform.\"}}],\"ErrUnexpectedInternalCall(bytes4,uint8,address)\":[{\"details\":\"Error indicating that the caller is unauthorized to perform a specific function.\",\"params\":{\"actual\":\"The actual address that called to the function.\",\"expectedContractType\":\"The contract type required to perform the function.\",\"msgSig\":\"The function signature (bytes4).\"}}],\"ErrValidatorHasBailedOutPreviously()\":[{\"details\":\"Error thrown when a validator has previously bailed out.\"}],\"ErrZeroCodeContract(address)\":[{\"details\":\"Error of set to non-contract.\"}]},\"kind\":\"dev\",\"methods\":{\"bailOut(address)\":{\"details\":\"A slashed validator use this method to get out of jail. Requirements: - The `_consensusAddr` must be a validator. - Only validator's admin can call this method. Emits the event `BailedOut`.\"},\"checkBailedOutAtPeriod(address,uint256)\":{\"details\":\"Returns the whether the `_validator` has been bailed out at the `_period`.\"},\"currentUnavailabilityIndicator(address)\":{\"details\":\"Returns the current unavailability indicator of a block producer.\"},\"execResetCreditScores(address[])\":{\"details\":\"Resets the credit score for the revoked validators. Requirements: - Only validator contract can call this method. - This method is only called at the end of each period. Emits the event `CreditScoresUpdated`.\"},\"execSlashBridgeOperator(address,uint256,uint256)\":{\"details\":\"Acknowledges bridge operator slash and emit `Slashed` event correspondingly.\",\"params\":{\"_tier\":\"The tier of the slash, in value of {1, 2}, corresponding to `SlashType.BRIDGE_OPERATOR_MISSING_VOTE_TIER_1` and `SlashType.BRIDGE_OPERATOR_MISSING_VOTE_TIER_2` Requirements: - Only validator contract can invoke this method. - Should be called only at the end of period. - Should be called only when there is slash of bridge operator. Emits the event `Slashed`.\"}},\"getBridgeOperatorSlashingConfigs()\":{\"details\":\"Returns the configs related to bridge operator slashing.\",\"returns\":{\"jailDurationForMissingVotesRatioTier2_\":\"The number of blocks to jail the corresponding block producer when its bridge operator is slashed tier-2.\",\"missingVotesRatioTier1_\":\"The bridge reward will be deprecated if (s)he missed more than this ratio.\",\"missingVotesRatioTier2_\":\"The bridge reward and mining reward will be deprecated and the corresponding block producer will be put in jail if (s)he misses more than this ratio.\",\"skipBridgeOperatorSlashingThreshold_\":\"The threshold to skip slashing the bridge operator in case the total number of votes in the bridge is too small.\"}},\"getBridgeVotingSlashingConfigs()\":{\"details\":\"Returns the configs related to bridge voting slashing.\",\"returns\":{\"bridgeVotingSlashAmount_\":\"The amount of RON to slash bridge voting.\",\"bridgeVotingThreshold_\":\"The threshold to slash when a trusted organization does not vote for bridge operators.\"}},\"getContract(uint8)\":{\"details\":\"Returns the address of a contract with a specific role. Throws an error if no contract is set for the specified role.\",\"params\":{\"contractType\":\"The role of the contract to retrieve.\"},\"returns\":{\"contract_\":\"The address of the contract with the specified role.\"}},\"getCreditScore(address)\":{\"details\":\"Returns the current credit score of the validator.\"},\"getCreditScoreConfigs()\":{\"details\":\"Returns the configs related to credit score.\",\"returns\":{\"bailOutCostMultiplier_\":\"The number that will be multiplied with the remaining jailed time to get the cost of bailing out.\",\"cutOffPercentageAfterBailout_\":\"The percentage of reward that the block producer will be cut off from until the end of the period after bailing out.\",\"gainCreditScore_\":\"The score to gain per period.\",\"maxCreditScore_\":\"The max number of credit score that a validator can hold.\"}},\"getDoubleSignSlashingConfigs()\":{\"details\":\"Returns the configs related to block producer slashing.\",\"params\":{\"_doubleSigningOffsetLimitBlock\":\"The number of block that the current block is at most far from the double signing block.\"},\"returns\":{\"doubleSigningJailUntilBlock_\":\"The block number that the punished validator will be jailed until, due to double signing.\",\"slashDoubleSignAmount_\":\"The amount of RON to slash double sign.\"}},\"getManyCreditScores(address[])\":{\"details\":\"Returns the current credit score of a list of validators.\"},\"getUnavailabilityIndicator(address,uint256)\":{\"details\":\"Helper for CreditScore contract to query indicator of the validator.\"},\"getUnavailabilitySlashingConfigs()\":{\"details\":\"Returns the configs related to block producer slashing.\",\"returns\":{\"jailDurationForUnavailabilityTier2Threshold_\":\"The number of blocks to jail a block producer when (s)he is slashed with tier-2 or tier-3.\",\"slashAmountForUnavailabilityTier2Threshold_\":\"The amount of RON to deduct from self-staking of a block producer when (s)he is slashed with tier-2 or tier-3.\",\"unavailabilityTier1Threshold_\":\"The mining reward will be deprecated, if (s)he missed more than this threshold. This threshold is applied for tier-1 and tier-3 slash.\",\"unavailabilityTier2Threshold_\":\" The mining reward will be deprecated, (s)he will be put in jailed, and will be deducted self-staking if (s)he misses more than this threshold. This threshold is applied for tier-2 slash.\"}},\"initialize(address,address,address,address,uint256[4],uint256[2],uint256[3],uint256[4],uint256[4])\":{\"details\":\"Initializes the contract storage.\"},\"precompileValidateDoubleSignAddress()\":{\"details\":\"Gets the address of the precompile of validating double sign evidence\"},\"setBridgeOperatorSlashingConfigs(uint256,uint256,uint256,uint256)\":{\"details\":\"Sets the configs to slash bridge operators. Requirements: - The method caller is admin. Emits the event `BridgeOperatorSlashingConfigsUpdated`.\",\"params\":{\"_jailDurationTier2\":\"The number of blocks to jail the corresponding block producer when its bridge operator is slashed tier-2.\",\"_ratioTier1\":\"The bridge reward will be deprecated if (s)he missed more than this ratio. Values 0-10,000 map to 0%-100%.\",\"_ratioTier2\":\"The bridge reward and mining reward will be deprecated and the corresponding block producer will be put in jail if (s)he misses more than this ratio. Values 0-10,000 map to 0%-100%.\",\"_skipSlashingThreshold\":\"The threshold to skip slashing the bridge operator in case the total number of votes in the bridge is too small.\"}},\"setBridgeVotingSlashingConfigs(uint256,uint256)\":{\"details\":\"Sets the configs to slash bridge voting. Requirements: - The method caller is admin. Emits the event `BridgeVotingSlashingConfigsUpdated`.\",\"params\":{\"_slashAmount\":\"The amount of RON to slash bridge voting.\",\"_threshold\":\"The threshold to slash when a trusted organization does not vote for bridge operators.\"}},\"setContract(uint8,address)\":{\"details\":\"Sets the address of a contract with a specific role. Emits the event {ContractUpdated}.\",\"params\":{\"addr\":\"The address of the contract to set.\",\"contractType\":\"The role of the contract to set.\"}},\"setCreditScoreConfigs(uint256,uint256,uint256,uint256)\":{\"details\":\"Sets the configs to credit score. Requirements: - The method caller is admin. Emits the event `CreditScoreConfigsUpdated`.\",\"params\":{\"_bailOutMultiplier\":\"The number that will be multiplied with the remaining jailed time to get the cost of bailing out.\",\"_cutOffPercentage\":\"The percentage of reward that the block producer will be cut off from until the end of the period after bailing out.\",\"_gainScore\":\"The score to gain per period.\",\"_maxScore\":\"The max number of credit score that a validator can hold.\"}},\"setDoubleSignSlashingConfigs(uint256,uint256,uint256)\":{\"details\":\"Sets the configs to slash block producers. Requirements: - The method caller is admin. Emits the event `DoubleSignSlashingConfigsUpdated`.\",\"params\":{\"_doubleSigningOffsetLimitBlock\":\"The number of block that the current block is at most far from the double signing block.\",\"_jailUntilBlock\":\"The block number that the punished validator will be jailed until, due to double signing.\",\"_slashAmount\":\"The amount of RON to slash double sign.\"}},\"setUnavailabilitySlashingConfigs(uint256,uint256,uint256,uint256)\":{\"details\":\"Sets the configs to slash block producers. Requirements: - The method caller is admin. Emits the event `BridgeOperatorSlashingConfigsUpdated`.\",\"params\":{\"_jailDurationForTier2Threshold\":\"The number of blocks to jail a block producer when (s)he is slashed tier-2.\",\"_slashAmountForTier2Threshold\":\"The amount of RON to deduct from self-staking of a block producer when (s)he is slashed tier-2.\",\"_tier1Threshold\":\"The mining reward will be deprecated, if (s)he missed more than this threshold.\",\"_tier2Threshold\":\"The mining reward will be deprecated, (s)he will be put in jailed, and will be deducted self-staking if (s)he misses more than this threshold.\"}},\"slashBridgeVoting(address)\":{\"details\":\"Slashes for bridge voter governance. Emits the event `Slashed`.\"},\"slashDoubleSign(address,bytes,bytes)\":{\"details\":\"Slashes for double signing. Requirements: - The method caller is coinbase. Emits the event `Slashed` if the double signing evidence of the two headers valid.\"},\"slashUnavailability(address)\":{\"details\":\"Slashes for unavailability by increasing the counter of block producer `_consensusAddr`. Requirements: - The method caller is coinbase. Emits the event `Slashed` when the threshold is reached.\"},\"updateCreditScores(address[],uint256)\":{\"details\":\"Updates the credit score for the validators. Requirements: - Only validator contract can call this method. - This method is only called at the end of each period. Emits the event `CreditScoresUpdated`.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/ronin/slash-indicator/SlashIndicator.sol\":\"SlashIndicator\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"none\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[\":@ronin/contracts/=./contracts/\",\":bridge-operator-governance/=contracts/extensions/bridge-operator-governance/\",\":collections/=contracts/extensions/collections/\",\":consumers/=contracts/extensions/consumers/\",\":ds-test/=lib/forge-std/lib/ds-test/src/\",\":forge-std/=lib/forge-std/src/\",\":forwarder/=contracts/extensions/forwarder/\",\":sequential-governance/=contracts/extensions/sequential-governance/\",\":slash-indicator/=contracts/interfaces/slash-indicator/\",\":staking/=contracts/interfaces/staking/\",\":validator/=contracts/interfaces/validator/\",\":version-control/=contracts/extensions/version-control/\"]},\"sources\":{\"@openzeppelin/contracts/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/Address.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\\n * initialization step. This is essential to configure modules that are added through upgrades and that require\\n * initialization.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2a21b14ff90012878752f230d3ffd5c3405e5938d06c97a7d89c0a64561d0d66\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd6153ce99bcdcce22b124f755e72553295be6abcd63804cfdffceb188b8bef10\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n bytes16 private constant _HEX_SYMBOLS = \\\"0123456789abcdef\\\";\\n uint8 private constant _ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n // Inspired by OraclizeAPI's implementation - MIT licence\\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\\n\\n if (value == 0) {\\n return \\\"0\\\";\\n }\\n uint256 temp = value;\\n uint256 digits;\\n while (temp != 0) {\\n digits++;\\n temp /= 10;\\n }\\n bytes memory buffer = new bytes(digits);\\n while (value != 0) {\\n digits -= 1;\\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\\n value /= 10;\\n }\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n if (value == 0) {\\n return \\\"0x00\\\";\\n }\\n uint256 temp = value;\\n uint256 length = 0;\\n while (temp != 0) {\\n length++;\\n temp >>= 8;\\n }\\n return toHexString(value, length);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\\n }\\n}\\n\",\"keccak256\":\"0xaf159a8b1923ad2a26d516089bceca9bdeaeacd04be50983ea00ba63070f08a3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Strings.sol\\\";\\n\\n/**\\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\\n *\\n * These functions can be used to verify that a message was signed by the holder\\n * of the private keys of a given address.\\n */\\nlibrary ECDSA {\\n enum RecoverError {\\n NoError,\\n InvalidSignature,\\n InvalidSignatureLength,\\n InvalidSignatureS,\\n InvalidSignatureV\\n }\\n\\n function _throwError(RecoverError error) private pure {\\n if (error == RecoverError.NoError) {\\n return; // no error: do nothing\\n } else if (error == RecoverError.InvalidSignature) {\\n revert(\\\"ECDSA: invalid signature\\\");\\n } else if (error == RecoverError.InvalidSignatureLength) {\\n revert(\\\"ECDSA: invalid signature length\\\");\\n } else if (error == RecoverError.InvalidSignatureS) {\\n revert(\\\"ECDSA: invalid signature 's' value\\\");\\n } else if (error == RecoverError.InvalidSignatureV) {\\n revert(\\\"ECDSA: invalid signature 'v' value\\\");\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature` or error string. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n *\\n * Documentation for signature generation:\\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\\n if (signature.length == 65) {\\n bytes32 r;\\n bytes32 s;\\n uint8 v;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n /// @solidity memory-safe-assembly\\n assembly {\\n r := mload(add(signature, 0x20))\\n s := mload(add(signature, 0x40))\\n v := byte(0, mload(add(signature, 0x60)))\\n }\\n return tryRecover(hash, v, r, s);\\n } else {\\n return (address(0), RecoverError.InvalidSignatureLength);\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature`. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n */\\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, signature);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\\n *\\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address, RecoverError) {\\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\\n uint8 v = uint8((uint256(vs) >> 255) + 27);\\n return tryRecover(hash, v, r, s);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\\n *\\n * _Available since v4.2._\\n */\\n function recover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address, RecoverError) {\\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\\n // the valid range for s in (301): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (302): v \\u2208 {27, 28}. Most\\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\\n //\\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\\n // these malleable signatures as well.\\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\\n return (address(0), RecoverError.InvalidSignatureS);\\n }\\n if (v != 27 && v != 28) {\\n return (address(0), RecoverError.InvalidSignatureV);\\n }\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n if (signer == address(0)) {\\n return (address(0), RecoverError.InvalidSignature);\\n }\\n\\n return (signer, RecoverError.NoError);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function recover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\\n // 32 is the length in bytes of hash,\\n // enforced by the type signature above\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n32\\\", hash));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from `s`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n\\\", Strings.toString(s.length), s));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Typed Data, created from a\\n * `domainSeparator` and a `structHash`. This produces hash corresponding\\n * to the one signed with the\\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\\n * JSON-RPC method as part of EIP-712.\\n *\\n * See {recover}.\\n */\\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19\\\\x01\\\", domainSeparator, structHash));\\n }\\n}\\n\",\"keccak256\":\"0xdb7f5c28fc61cda0bd8ab60ce288e206b791643bcd3ba464a70cbec18895a2f5\",\"license\":\"MIT\"},\"contracts/extensions/collections/HasContracts.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { HasProxyAdmin } from \\\"./HasProxyAdmin.sol\\\";\\nimport \\\"../../interfaces/collections/IHasContracts.sol\\\";\\nimport { ErrUnexpectedInternalCall } from \\\"../../utils/CommonErrors.sol\\\";\\n\\n/**\\n * @title HasContracts\\n * @dev A contract that provides functionality to manage multiple contracts with different roles.\\n */\\nabstract contract HasContracts is HasProxyAdmin, IHasContracts {\\n /// @dev value is equal to keccak256(\\\"@ronin.dpos.collections.HasContracts.slot\\\") - 1\\n bytes32 private constant _STORAGE_SLOT = 0xdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb;\\n\\n /**\\n * @dev Modifier to restrict access to functions only to contracts with a specific role.\\n * @param contractType The contract type that allowed to call\\n */\\n modifier onlyContract(ContractType contractType) virtual {\\n _requireContract(contractType);\\n _;\\n }\\n\\n /**\\n * @inheritdoc IHasContracts\\n */\\n function setContract(ContractType contractType, address addr) external virtual onlyAdmin {\\n _requireHasCode(addr);\\n _setContract(contractType, addr);\\n }\\n\\n /**\\n * @inheritdoc IHasContracts\\n */\\n function getContract(ContractType contractType) public view returns (address contract_) {\\n contract_ = _getContractMap()[uint8(contractType)];\\n if (contract_ == address(0)) revert ErrContractTypeNotFound(contractType);\\n }\\n\\n /**\\n * @dev Internal function to set the address of a contract with a specific role.\\n * @param contractType The contract type of the contract to set.\\n * @param addr The address of the contract to set.\\n */\\n function _setContract(ContractType contractType, address addr) internal virtual {\\n _getContractMap()[uint8(contractType)] = addr;\\n emit ContractUpdated(contractType, addr);\\n }\\n\\n /**\\n * @dev Internal function to check if a contract address has code.\\n * @param addr The address of the contract to check.\\n * @dev Throws an error if the contract address has no code.\\n */\\n function _requireHasCode(address addr) internal view {\\n if (addr.code.length == 0) revert ErrZeroCodeContract(addr);\\n }\\n\\n /**\\n * @dev Internal function to access the mapping of contract addresses with roles.\\n * @return contracts_ The mapping of contract addresses with roles.\\n */\\n function _getContractMap() private pure returns (mapping(uint8 => address) storage contracts_) {\\n assembly {\\n contracts_.slot := _STORAGE_SLOT\\n }\\n }\\n\\n /**\\n * @dev Internal function to check if the calling contract has a specific role.\\n * @param contractType The contract type that the calling contract must have.\\n * @dev Throws an error if the calling contract does not have the specified role.\\n */\\n function _requireContract(ContractType contractType) private view {\\n if (msg.sender != getContract(contractType)) {\\n revert ErrUnexpectedInternalCall(msg.sig, contractType, msg.sender);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0d5cda6bbab5672cc7983efd0cf1f9a4e4fb1a7a2c1cfb50d38aedd052230f91\",\"license\":\"MIT\"},\"contracts/extensions/collections/HasProxyAdmin.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/StorageSlot.sol\\\";\\nimport \\\"../../utils/CommonErrors.sol\\\";\\n\\nabstract contract HasProxyAdmin {\\n // bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n modifier onlyAdmin() {\\n _requireAdmin();\\n _;\\n }\\n\\n /**\\n * @dev Returns proxy admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n function _requireAdmin() internal view {\\n if (msg.sender != _getAdmin()) revert ErrUnauthorized(msg.sig, RoleAccess.ADMIN);\\n }\\n}\\n\",\"keccak256\":\"0x06e5962713a77abf6d5ba646e1cc1cfb6f9c50e7d52520dd82a10bf309534187\",\"license\":\"MIT\"},\"contracts/extensions/consumers/PercentageConsumer.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nabstract contract PercentageConsumer {\\n uint256 internal constant _MAX_PERCENTAGE = 100_00;\\n}\\n\",\"keccak256\":\"0x5dc54a24348c5d614de1b4805dddeab4dda72f9f0636b27bf0ed295fee017dcf\",\"license\":\"MIT\"},\"contracts/interfaces/IMaintenance.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface IMaintenance {\\n /**\\n * @dev Error thrown when attempting to schedule an already scheduled event.\\n */\\n error ErrAlreadyScheduled();\\n\\n /**\\n * @dev Error thrown when referring to a non-existent schedule.\\n */\\n error ErrUnexistedSchedule();\\n\\n /**\\n * @dev Error thrown when the end block of a schedule is out of range.\\n */\\n error ErrEndBlockOutOfRange();\\n\\n /**\\n * @dev Error thrown when the start block of a schedule is out of range.\\n */\\n error ErrStartBlockOutOfRange();\\n\\n /**\\n * @dev Error thrown when attempting to initiate maintenance while already in maintenance mode.\\n */\\n error ErrAlreadyOnMaintenance();\\n\\n /**\\n * @dev Error thrown when attempting an action before the cooldown period has ended.\\n */\\n error ErrCooldownTimeNotYetEnded();\\n\\n /**\\n * @dev Error thrown when the total number of schedules exceeds the limit.\\n */\\n error ErrTotalOfSchedulesExceeded();\\n\\n /**\\n * @dev Error thrown when an invalid maintenance duration is specified.\\n */\\n error ErrInvalidMaintenanceDuration();\\n\\n /**\\n * @dev Error thrown when an invalid maintenance duration configuration is provided.\\n */\\n error ErrInvalidMaintenanceDurationConfig();\\n\\n /**\\n * @dev Error thrown when an invalid offset is specified to start the schedule configurations.\\n */\\n error ErrInvalidOffsetToStartScheduleConfigs();\\n\\n struct Schedule {\\n uint256 from;\\n uint256 to;\\n uint256 lastUpdatedBlock;\\n uint256 requestTimestamp;\\n }\\n\\n /// @dev Emitted when a maintenance is scheduled.\\n event MaintenanceScheduled(address indexed consensusAddr, Schedule);\\n /// @dev Emitted when a schedule of maintenance is cancelled.\\n event MaintenanceScheduleCancelled(address indexed consensusAddr);\\n /// @dev Emitted when the maintenance config is updated.\\n event MaintenanceConfigUpdated(\\n uint256 minMaintenanceDurationInBlock,\\n uint256 maxMaintenanceDurationInBlock,\\n uint256 minOffsetToStartSchedule,\\n uint256 maxOffsetToStartSchedule,\\n uint256 maxSchedules,\\n uint256 cooldownSecsToMaintain\\n );\\n\\n /**\\n * @dev Returns whether the validator `_consensusAddr` maintained at the block number `_block`.\\n */\\n function checkMaintained(address _consensusAddr, uint256 _block) external view returns (bool);\\n\\n /**\\n * @dev Returns whether the validator `_consensusAddr` maintained in the inclusive range [`_fromBlock`, `_toBlock`] of blocks.\\n */\\n function checkMaintainedInBlockRange(\\n address _consensusAddr,\\n uint256 _fromBlock,\\n uint256 _toBlock\\n ) external view returns (bool);\\n\\n /**\\n * @dev Returns the bool array indicating the validators maintained at block number `_block` or not.\\n */\\n function checkManyMaintained(address[] calldata _addrList, uint256 _block) external view returns (bool[] memory);\\n\\n /**\\n * @dev Returns a bool array indicating the validators maintained in the inclusive range [`_fromBlock`, `_toBlock`] of blocks or not.\\n */\\n function checkManyMaintainedInBlockRange(\\n address[] calldata _addrList,\\n uint256 _fromBlock,\\n uint256 _toBlock\\n ) external view returns (bool[] memory);\\n\\n /**\\n * @dev Returns whether the validator `_consensusAddr` has scheduled.\\n */\\n function checkScheduled(address _consensusAddr) external view returns (bool);\\n\\n /**\\n * @dev Returns whether the validator `_consensusAddr`\\n */\\n function checkCooldownEnds(address _consensusAddr) external view returns (bool);\\n\\n /**\\n * @dev Returns the detailed schedule of the validator `_consensusAddr`.\\n */\\n function getSchedule(address _consensusAddr) external view returns (Schedule memory);\\n\\n /**\\n * @dev Returns the total of current schedules.\\n */\\n function totalSchedules() external view returns (uint256 _count);\\n\\n /**\\n * @dev Sets the duration restriction, start time restriction, and max allowed for maintenance.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n * - The max duration is larger than the min duration.\\n * - The max offset is larger than the min offset.\\n *\\n * Emits the event `MaintenanceConfigUpdated`.\\n *\\n */\\n function setMaintenanceConfig(\\n uint256 _minMaintenanceDurationInBlock,\\n uint256 _maxMaintenanceDurationInBlock,\\n uint256 _minOffsetToStartSchedule,\\n uint256 _maxOffsetToStartSchedule,\\n uint256 _maxSchedules,\\n uint256 _cooldownSecsToMaintain\\n ) external;\\n\\n /**\\n * @dev Returns the min duration for maintenance in block.\\n */\\n function minMaintenanceDurationInBlock() external view returns (uint256);\\n\\n /**\\n * @dev Returns the max duration for maintenance in block.\\n */\\n function maxMaintenanceDurationInBlock() external view returns (uint256);\\n\\n /**\\n * @dev The offset to the min block number that the schedule can start\\n */\\n function minOffsetToStartSchedule() external view returns (uint256);\\n\\n /**\\n * @dev The offset to the max block number that the schedule can start\\n */\\n function maxOffsetToStartSchedule() external view returns (uint256);\\n\\n /**\\n * @dev Returns the max number of scheduled maintenances.\\n */\\n function maxSchedules() external view returns (uint256);\\n\\n /**\\n * @dev Schedules for maintenance from `_startedAtBlock` to `_startedAtBlock`.\\n *\\n * Requirements:\\n * - The candidate `_consensusAddr` is the block producer.\\n * - The method caller is candidate admin of the candidate `_consensusAddr`.\\n * - The candidate `_consensusAddr` has no schedule yet or the previous is done.\\n * - The total number of schedules is not larger than `maxSchedules()`.\\n * - The start block must be at least `minOffsetToStartSchedule()` and at most `maxOffsetToStartSchedule()` blocks from the current block.\\n * - The end block is larger than the start block.\\n * - The scheduled duration is larger than the `minMaintenanceDurationInBlock()` and less than the `maxMaintenanceDurationInBlock()`.\\n * - The start block is at the start of an epoch.\\n * - The end block is at the end of an epoch.\\n *\\n * Emits the event `MaintenanceScheduled`.\\n *\\n */\\n function schedule(address _consensusAddr, uint256 _startedAtBlock, uint256 _endedAtBlock) external;\\n\\n /**\\n * @dev Cancel the schedule of maintenance for the `_consensusAddr`.\\n *\\n * Requirements:\\n * - The candidate `_consensusAddr` is the block producer.\\n * - The method caller is candidate admin of the candidate `_consensusAddr`.\\n * - A schedule for the `_consensusAddr` must be existent and not executed yet.\\n *\\n * Emits the event `MaintenanceScheduleCancelled`.\\n */\\n function cancelSchedule(address _consensusAddr) external;\\n}\\n\",\"keccak256\":\"0xd399a23652fc0180280f0079dd4be420d807774bcf6bc12672f4238480e757e9\",\"license\":\"MIT\"},\"contracts/interfaces/IQuorum.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\ninterface IQuorum {\\n /// @dev Emitted when the threshold is updated\\n event ThresholdUpdated(\\n uint256 indexed nonce,\\n uint256 indexed numerator,\\n uint256 indexed denominator,\\n uint256 previousNumerator,\\n uint256 previousDenominator\\n );\\n\\n /**\\n * @dev Returns the threshold.\\n */\\n function getThreshold() external view returns (uint256 _num, uint256 _denom);\\n\\n /**\\n * @dev Checks whether the `_voteWeight` passes the threshold.\\n */\\n function checkThreshold(uint256 _voteWeight) external view returns (bool);\\n\\n /**\\n * @dev Returns the minimum vote weight to pass the threshold.\\n */\\n function minimumVoteWeight() external view returns (uint256);\\n\\n /**\\n * @dev Sets the threshold.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the `ThresholdUpdated` event.\\n *\\n */\\n function setThreshold(\\n uint256 _numerator,\\n uint256 _denominator\\n ) external returns (uint256 _previousNum, uint256 _previousDenom);\\n}\\n\",\"keccak256\":\"0x6b7920b04a73a0e1ff7404aa1a3b5fc738fc0b6154839480f666fd69b55123f0\",\"license\":\"MIT\"},\"contracts/interfaces/IRoninGovernanceAdmin.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"../libraries/BridgeOperatorsBallot.sol\\\";\\n\\ninterface IRoninGovernanceAdmin {\\n /**\\n * @dev Error thrown when an invalid vote hash is provided.\\n */\\n error ErrInvalidVoteHash();\\n\\n /**\\n * @dev Error thrown when querying for an empty vote.\\n */\\n error ErrQueryForEmptyVote();\\n\\n /**\\n * @dev Error thrown when querying for an expired vote.\\n */\\n error ErrQueryForExpiredVote();\\n\\n /**\\n * @dev Error thrown when querying for a non-existent vote.\\n */\\n error ErrQueryForNonExistentVote();\\n\\n /// @dev Emitted when the bridge operators are approved.\\n event BridgeOperatorsApproved(uint256 _period, uint256 _epoch, address[] _operators);\\n /// @dev Emitted when an emergency exit poll is created.\\n event EmergencyExitPollCreated(\\n bytes32 _voteHash,\\n address _consensusAddr,\\n address _recipientAfterUnlockedFund,\\n uint256 _requestedAt,\\n uint256 _expiredAt\\n );\\n /// @dev Emitted when an emergency exit poll is approved.\\n event EmergencyExitPollApproved(bytes32 _voteHash);\\n /// @dev Emitted when an emergency exit poll is expired.\\n event EmergencyExitPollExpired(bytes32 _voteHash);\\n /// @dev Emitted when an emergency exit poll is voted.\\n event EmergencyExitPollVoted(bytes32 indexed _voteHash, address indexed _voter);\\n\\n /**\\n * @dev Returns the last voted block of the bridge voter.\\n */\\n function lastVotedBlock(address _bridgeVoter) external view returns (uint256);\\n\\n /**\\n * @dev Returns the synced bridge operator set info.\\n */\\n function lastSyncedBridgeOperatorSetInfo()\\n external\\n view\\n returns (BridgeOperatorsBallot.BridgeOperatorSet memory _bridgeOperatorSetInfo);\\n\\n /**\\n * @dev Create a vote to agree that an emergency exit is valid and should return the locked funds back.a\\n *\\n * Requirements:\\n * - The method caller is validator contract.\\n *\\n */\\n function createEmergencyExitPoll(\\n address _consensusAddr,\\n address _recipientAfterUnlockedFund,\\n uint256 _requestedAt,\\n uint256 _expiredAt\\n ) external;\\n}\\n\",\"keccak256\":\"0xd5f2c4c86448fe53db583b990c53a45fd521d1f2f294184261761e7382f49eee\",\"license\":\"MIT\"},\"contracts/interfaces/IRoninTrustedOrganization.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IQuorum.sol\\\";\\n\\ninterface IRoninTrustedOrganization is IQuorum {\\n /**\\n * @dev Error indicating that a query for a duplicate entry was made.\\n */\\n error ErrQueryForDupplicated();\\n\\n /**\\n * @dev Error indicating that a query was made for a non-existent consensus address.\\n */\\n error ErrQueryForNonExistentConsensusAddress();\\n\\n /**\\n * @dev Error indicating that a bridge voter has already been added.\\n * @param voter The address of the bridge voter that is already added.\\n */\\n error ErrBridgeVoterIsAlreadyAdded(address voter);\\n\\n /**\\n * @dev Error indicating that a governor address has already been added.\\n * @param addr The address of the governor that is already added.\\n */\\n error ErrGovernorAddressIsAlreadyAdded(address addr);\\n\\n /**\\n * @dev Error indicating that a consensus address is not added.\\n * @param addr The address of the consensus contract that is not added.\\n */\\n error ErrConsensusAddressIsNotAdded(address addr);\\n\\n /**\\n * @dev Error indicating that a consensus address is already added.\\n * @param addr The address of the consensus contract that is already added.\\n */\\n error ErrConsensusAddressIsAlreadyAdded(address addr);\\n\\n struct TrustedOrganization {\\n // Address of the validator that produces block, e.g. block.coinbase. This is so-called validator address.\\n address consensusAddr;\\n // Address to voting proposal\\n address governor;\\n // Address to voting bridge operators\\n address bridgeVoter;\\n // Its Weight\\n uint256 weight;\\n // The block that the organization was added\\n uint256 addedBlock;\\n }\\n\\n /// @dev Emitted when the trusted organization is added.\\n event TrustedOrganizationsAdded(TrustedOrganization[] orgs);\\n /// @dev Emitted when the trusted organization is updated.\\n event TrustedOrganizationsUpdated(TrustedOrganization[] orgs);\\n /// @dev Emitted when the trusted organization is removed.\\n event TrustedOrganizationsRemoved(address[] orgs);\\n\\n /**\\n * @dev Adds a list of addresses into the trusted organization.\\n *\\n * Requirements:\\n * - The weights should larger than 0.\\n * - The method caller is admin.\\n * - The field `addedBlock` should be blank.\\n *\\n * Emits the event `TrustedOrganizationAdded` once an organization is added.\\n *\\n */\\n function addTrustedOrganizations(TrustedOrganization[] calldata) external;\\n\\n /**\\n * @dev Updates weights for a list of existent trusted organization.\\n *\\n * Requirements:\\n * - The weights should larger than 0.\\n * - The method caller is admin.\\n *\\n * Emits the `TrustedOrganizationUpdated` event.\\n *\\n */\\n function updateTrustedOrganizations(TrustedOrganization[] calldata _list) external;\\n\\n /**\\n * @dev Removes a list of addresses from the trusted organization.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `TrustedOrganizationRemoved` once an organization is removed.\\n *\\n * @param _consensusAddrs The list of consensus addresses linked to corresponding trusted organization that to be removed.\\n */\\n function removeTrustedOrganizations(address[] calldata _consensusAddrs) external;\\n\\n /**\\n * @dev Returns total weights.\\n */\\n function totalWeights() external view returns (uint256);\\n\\n /**\\n * @dev Returns the weight of a consensus.\\n */\\n function getConsensusWeight(address _consensusAddr) external view returns (uint256);\\n\\n /**\\n * @dev Returns the weight of a governor.\\n */\\n function getGovernorWeight(address _governor) external view returns (uint256);\\n\\n /**\\n * @dev Returns the weight of a bridge voter.\\n */\\n function getBridgeVoterWeight(address _addr) external view returns (uint256);\\n\\n /**\\n * @dev Returns the weights of a list of consensus addresses.\\n */\\n function getConsensusWeights(address[] calldata _list) external view returns (uint256[] memory);\\n\\n /**\\n * @dev Returns the weights of a list of governor addresses.\\n */\\n function getGovernorWeights(address[] calldata _list) external view returns (uint256[] memory);\\n\\n /**\\n * @dev Returns the weights of a list of bridge voter addresses.\\n */\\n function getBridgeVoterWeights(address[] calldata _list) external view returns (uint256[] memory);\\n\\n /**\\n * @dev Returns total weights of the consensus list.\\n */\\n function sumConsensusWeights(address[] calldata _list) external view returns (uint256 _res);\\n\\n /**\\n * @dev Returns total weights of the governor list.\\n */\\n function sumGovernorWeights(address[] calldata _list) external view returns (uint256 _res);\\n\\n /**\\n * @dev Returns total weights of the bridge voter list.\\n */\\n function sumBridgeVoterWeights(address[] calldata _list) external view returns (uint256 _res);\\n\\n /**\\n * @dev Returns the trusted organization at `_index`.\\n */\\n function getTrustedOrganizationAt(uint256 _index) external view returns (TrustedOrganization memory);\\n\\n /**\\n * @dev Returns the number of trusted organizations.\\n */\\n function countTrustedOrganizations() external view returns (uint256);\\n\\n /**\\n * @dev Returns all of the trusted organizations.\\n */\\n function getAllTrustedOrganizations() external view returns (TrustedOrganization[] memory);\\n\\n /**\\n * @dev Returns the trusted organization by consensus address.\\n *\\n * Reverts once the consensus address is non-existent.\\n */\\n function getTrustedOrganization(address _consensusAddr) external view returns (TrustedOrganization memory);\\n}\\n\",\"keccak256\":\"0x28b0407cf740164f3ddf4a44952423604439cda580f286c6ed1edcdb59b219d0\",\"license\":\"MIT\"},\"contracts/interfaces/collections/IHasContracts.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport { ContractType } from \\\"../../utils/ContractType.sol\\\";\\n\\ninterface IHasContracts {\\n /// @dev Error of invalid role.\\n error ErrContractTypeNotFound(ContractType contractType);\\n /// @dev Error of set to non-contract.\\n error ErrZeroCodeContract(address addr);\\n\\n /// @dev Emitted when a contract is updated.\\n event ContractUpdated(ContractType indexed contractType, address indexed addr);\\n\\n /**\\n * @dev Returns the address of a contract with a specific role.\\n * Throws an error if no contract is set for the specified role.\\n *\\n * @param contractType The role of the contract to retrieve.\\n * @return contract_ The address of the contract with the specified role.\\n */\\n function getContract(ContractType contractType) external view returns (address contract_);\\n\\n /**\\n * @dev Sets the address of a contract with a specific role.\\n * Emits the event {ContractUpdated}.\\n * @param contractType The role of the contract to set.\\n * @param addr The address of the contract to set.\\n */\\n function setContract(ContractType contractType, address addr) external;\\n}\\n\",\"keccak256\":\"0x5947f7f706685ce9a692da732cc0f296fcf88d38a625708354180133b3451089\",\"license\":\"MIT\"},\"contracts/interfaces/slash-indicator/IBaseSlash.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface IBaseSlash {\\n enum SlashType {\\n UNKNOWN,\\n UNAVAILABILITY_TIER_1,\\n UNAVAILABILITY_TIER_2,\\n DOUBLE_SIGNING,\\n BRIDGE_VOTING,\\n BRIDGE_OPERATOR_MISSING_VOTE_TIER_1,\\n BRIDGE_OPERATOR_MISSING_VOTE_TIER_2,\\n UNAVAILABILITY_TIER_3\\n }\\n\\n /// @dev Emitted when the validator is slashed.\\n event Slashed(address indexed validator, SlashType slashType, uint256 period);\\n}\\n\",\"keccak256\":\"0x04d449f2852840566dfff4e3673929f6e9b8d9b5fc5b29744bf4f344dc7f9bc0\",\"license\":\"MIT\"},\"contracts/interfaces/slash-indicator/ICreditScore.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface ICreditScore {\\n /**\\n * @dev Error thrown when an invalid credit score configuration is provided.\\n */\\n error ErrInvalidCreditScoreConfig();\\n\\n /**\\n * @dev Error thrown when an invalid cut-off percentage configuration is provided.\\n */\\n error ErrInvalidCutOffPercentageConfig();\\n\\n /**\\n * @dev Error thrown when the caller's credit score is insufficient to bail out a situation.\\n */\\n error ErrInsufficientCreditScoreToBailOut();\\n\\n /**\\n * @dev Error thrown when a validator has previously bailed out.\\n */\\n error ErrValidatorHasBailedOutPreviously();\\n\\n /**\\n * @dev Error thrown when the caller must be jailed in the current period.\\n */\\n error ErrCallerMustBeJailedInTheCurrentPeriod();\\n\\n /// @dev Emitted when the configs to credit score is updated. See the method `setCreditScoreConfigs` for param details.\\n event CreditScoreConfigsUpdated(\\n uint256 gainCreditScore,\\n uint256 maxCreditScore,\\n uint256 bailOutCostMultiplier,\\n uint256 cutOffPercentageAfterBailout\\n );\\n /// @dev Emitted the credit score of validators is updated.\\n event CreditScoresUpdated(address[] validators, uint256[] creditScores);\\n /// @dev Emitted when a validator bailed out of jail.\\n event BailedOut(address indexed validator, uint256 period, uint256 usedCreditScore);\\n\\n /**\\n * @dev Updates the credit score for the validators.\\n *\\n * Requirements:\\n * - Only validator contract can call this method.\\n * - This method is only called at the end of each period.\\n *\\n * Emits the event `CreditScoresUpdated`.\\n *\\n */\\n function updateCreditScores(address[] calldata _validators, uint256 _period) external;\\n\\n /**\\n * @dev Resets the credit score for the revoked validators.\\n *\\n * Requirements:\\n * - Only validator contract can call this method.\\n * - This method is only called at the end of each period.\\n *\\n * Emits the event `CreditScoresUpdated`.\\n *\\n */\\n function execResetCreditScores(address[] calldata _validators) external;\\n\\n /**\\n * @dev A slashed validator use this method to get out of jail.\\n *\\n * Requirements:\\n * - The `_consensusAddr` must be a validator.\\n * - Only validator's admin can call this method.\\n *\\n * Emits the event `BailedOut`.\\n *\\n */\\n function bailOut(address _consensusAddr) external;\\n\\n /**\\n * @dev Sets the configs to credit score.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `CreditScoreConfigsUpdated`.\\n *\\n * @param _gainScore The score to gain per period.\\n * @param _maxScore The max number of credit score that a validator can hold.\\n * @param _bailOutMultiplier The number that will be multiplied with the remaining jailed time to get the cost of bailing out.\\n * @param _cutOffPercentage The percentage of reward that the block producer will be cut off from until the end of the period after bailing out.\\n *\\n */\\n function setCreditScoreConfigs(\\n uint256 _gainScore,\\n uint256 _maxScore,\\n uint256 _bailOutMultiplier,\\n uint256 _cutOffPercentage\\n ) external;\\n\\n /**\\n * @dev Returns the configs related to credit score.\\n *\\n * @return _gainCreditScore The score to gain per period.\\n * @return _maxCreditScore The max number of credit score that a validator can hold.\\n * @return _bailOutCostMultiplier The number that will be multiplied with the remaining jailed time to get the cost of bailing out.\\n * @return _cutOffPercentageAfterBailout The percentage of reward that the block producer will be cut off from until the end of the period after bailing out.\\n *\\n */\\n function getCreditScoreConfigs()\\n external\\n view\\n returns (\\n uint256 _gainCreditScore,\\n uint256 _maxCreditScore,\\n uint256 _bailOutCostMultiplier,\\n uint256 _cutOffPercentageAfterBailout\\n );\\n\\n /**\\n * @dev Returns the current credit score of the validator.\\n */\\n function getCreditScore(address _validator) external view returns (uint256);\\n\\n /**\\n * @dev Returns the current credit score of a list of validators.\\n */\\n function getManyCreditScores(address[] calldata _validators) external view returns (uint256[] memory _resultList);\\n\\n /**\\n * @dev Returns the whether the `_validator` has been bailed out at the `_period`.\\n */\\n function checkBailedOutAtPeriod(address _validator, uint256 _period) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x26021ddf339495816692ea9f8545b4054d0ffb9c5ad11049cac4f3718a0bbc2d\",\"license\":\"MIT\"},\"contracts/interfaces/slash-indicator/ISlashBridgeOperator.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IBaseSlash.sol\\\";\\n\\ninterface ISlashBridgeOperator is IBaseSlash {\\n /**\\n * @dev Error thrown when invalid ratios are provided.\\n */\\n error ErrInvalidRatios();\\n\\n /**\\n * @dev Emitted when the configs to slash bridge operator is updated. See the method\\n * `getBridgeOperatorSlashingConfigs` for param details.\\n */\\n event BridgeOperatorSlashingConfigsUpdated(\\n uint256 missingVotesRatioTier1,\\n uint256 missingVotesRatioTier2,\\n uint256 jailDurationForMissingVotesRatioTier2,\\n uint256 skipBridgeOperatorSlashingThreshold\\n );\\n\\n /**\\n * @dev Acknowledges bridge operator slash and emit `Slashed` event correspondingly.\\n * @param _tier The tier of the slash, in value of {1, 2}, corresponding to `SlashType.BRIDGE_OPERATOR_MISSING_VOTE_TIER_1`\\n * and `SlashType.BRIDGE_OPERATOR_MISSING_VOTE_TIER_2`\\n *\\n * Requirements:\\n * - Only validator contract can invoke this method.\\n * - Should be called only at the end of period.\\n * - Should be called only when there is slash of bridge operator.\\n *\\n * Emits the event `Slashed`.\\n */\\n function execSlashBridgeOperator(address _consensusAddr, uint256 _tier, uint256 _period) external;\\n\\n /**\\n * @dev Returns the configs related to bridge operator slashing.\\n *\\n * @return _missingVotesRatioTier1 The bridge reward will be deprecated if (s)he missed more than this ratio.\\n * @return _missingVotesRatioTier2 The bridge reward and mining reward will be deprecated and the corresponding\\n * block producer will be put in jail if (s)he misses more than this ratio.\\n * @return _jailDurationForMissingVotesRatioTier2 The number of blocks to jail the corresponding block producer when\\n * its bridge operator is slashed tier-2.\\n * @return _skipBridgeOperatorSlashingThreshold The threshold to skip slashing the bridge operator in case the total\\n * number of votes in the bridge is too small.\\n *\\n */\\n function getBridgeOperatorSlashingConfigs()\\n external\\n view\\n returns (\\n uint256 _missingVotesRatioTier1,\\n uint256 _missingVotesRatioTier2,\\n uint256 _jailDurationForMissingVotesRatioTier2,\\n uint256 _skipBridgeOperatorSlashingThreshold\\n );\\n\\n /**\\n * @dev Sets the configs to slash bridge operators.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `BridgeOperatorSlashingConfigsUpdated`.\\n *\\n * @param _ratioTier1 The bridge reward will be deprecated if (s)he missed more than this ratio. Values 0-10,000 map\\n * to 0%-100%.\\n * @param _ratioTier2 The bridge reward and mining reward will be deprecated and the corresponding block producer will\\n * be put in jail if (s)he misses more than this ratio. Values 0-10,000 map to 0%-100%.\\n * @param _jailDurationTier2 The number of blocks to jail the corresponding block producer when its bridge operator is\\n * slashed tier-2.\\n * @param _skipSlashingThreshold The threshold to skip slashing the bridge operator in case the total number of votes\\n * in the bridge is too small.\\n *\\n */\\n function setBridgeOperatorSlashingConfigs(\\n uint256 _ratioTier1,\\n uint256 _ratioTier2,\\n uint256 _jailDurationTier2,\\n uint256 _skipSlashingThreshold\\n ) external;\\n}\\n\",\"keccak256\":\"0x3ea38604baf3bc5a12dd1a243eec2052de9ee2cb171222a2e5b0e5202d301471\",\"license\":\"MIT\"},\"contracts/interfaces/slash-indicator/ISlashBridgeVoting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IBaseSlash.sol\\\";\\n\\ninterface ISlashBridgeVoting is IBaseSlash {\\n /**\\n * @dev Error thrown when an invalid slash is encountered.\\n */\\n error ErrInvalidSlash();\\n\\n /**\\n * @dev Emitted when the configs to slash bridge voting is updated. See the method `getBridgeVotingSlashingConfigs` for param\\n * details.\\n */\\n event BridgeVotingSlashingConfigsUpdated(uint256 bridgeVotingThreshold, uint256 bridgeVotingSlashAmount);\\n\\n /**\\n * @dev Slashes for bridge voter governance.\\n *\\n * Emits the event `Slashed`.\\n */\\n function slashBridgeVoting(address _consensusAddr) external;\\n\\n /**\\n * @dev Returns the configs related to bridge voting slashing.\\n *\\n * @return _bridgeVotingThreshold The threshold to slash when a trusted organization does not vote for bridge\\n * operators.\\n * @return _bridgeVotingSlashAmount The amount of RON to slash bridge voting.\\n *\\n */\\n function getBridgeVotingSlashingConfigs()\\n external\\n view\\n returns (uint256 _bridgeVotingThreshold, uint256 _bridgeVotingSlashAmount);\\n\\n /**\\n * @dev Sets the configs to slash bridge voting.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `BridgeVotingSlashingConfigsUpdated`.\\n *\\n * @param _threshold The threshold to slash when a trusted organization does not vote for bridge operators.\\n * @param _slashAmount The amount of RON to slash bridge voting.\\n *\\n */\\n function setBridgeVotingSlashingConfigs(uint256 _threshold, uint256 _slashAmount) external;\\n}\\n\",\"keccak256\":\"0x89751cbf99adf7dbd165fbbba5d6b62b5c47f8486322a7abb27d6d6aef345fae\",\"license\":\"MIT\"},\"contracts/interfaces/slash-indicator/ISlashDoubleSign.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IBaseSlash.sol\\\";\\n\\ninterface ISlashDoubleSign is IBaseSlash {\\n /**\\n * @dev Error thrown when evidence has already been submitted.\\n */\\n error ErrEvidenceAlreadySubmitted();\\n\\n /**\\n * @dev Emitted when the configs to slash double sign is updated. See the method `getDoubleSignSlashingConfigs`\\n * for param details.\\n */\\n event DoubleSignSlashingConfigsUpdated(\\n uint256 slashDoubleSignAmount,\\n uint256 doubleSigningJailUntilBlock,\\n uint256 doubleSigningOffsetLimitBlock\\n );\\n\\n /**\\n * @dev Slashes for double signing.\\n *\\n * Requirements:\\n * - The method caller is coinbase.\\n *\\n * Emits the event `Slashed` if the double signing evidence of the two headers valid.\\n */\\n function slashDoubleSign(address _validatorAddr, bytes calldata _header1, bytes calldata _header2) external;\\n\\n /**\\n * @dev Returns the configs related to block producer slashing.\\n *\\n * @return _slashDoubleSignAmount The amount of RON to slash double sign.\\n * @return _doubleSigningJailUntilBlock The block number that the punished validator will be jailed until, due to\\n * double signing.\\n * @param _doubleSigningOffsetLimitBlock The number of block that the current block is at most far from the double\\n * signing block.\\n *\\n */\\n function getDoubleSignSlashingConfigs()\\n external\\n view\\n returns (\\n uint256 _slashDoubleSignAmount,\\n uint256 _doubleSigningJailUntilBlock,\\n uint256 _doubleSigningOffsetLimitBlock\\n );\\n\\n /**\\n * @dev Sets the configs to slash block producers.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `DoubleSignSlashingConfigsUpdated`.\\n *\\n * @param _slashAmount The amount of RON to slash double sign.\\n * @param _jailUntilBlock The block number that the punished validator will be jailed until, due to double signing.\\n * @param _doubleSigningOffsetLimitBlock The number of block that the current block is at most far from the double\\n * signing block.\\n *\\n */\\n function setDoubleSignSlashingConfigs(\\n uint256 _slashAmount,\\n uint256 _jailUntilBlock,\\n uint256 _doubleSigningOffsetLimitBlock\\n ) external;\\n}\\n\",\"keccak256\":\"0x5b7c9b07d0f97c589789eb0775411825df2163bdf893fb5df1113415b91b91ed\",\"license\":\"MIT\"},\"contracts/interfaces/slash-indicator/ISlashIndicator.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./ISlashDoubleSign.sol\\\";\\nimport \\\"./ISlashBridgeVoting.sol\\\";\\nimport \\\"./ISlashBridgeOperator.sol\\\";\\nimport \\\"./ISlashUnavailability.sol\\\";\\nimport \\\"./ICreditScore.sol\\\";\\n\\ninterface ISlashIndicator is\\n ISlashDoubleSign,\\n ISlashBridgeVoting,\\n ISlashBridgeOperator,\\n ISlashUnavailability,\\n ICreditScore\\n{}\\n\",\"keccak256\":\"0xe8b8fde3af614735cb304bc1eb82b05d65ede4df804b5d555787e5d5ecb95ec0\",\"license\":\"MIT\"},\"contracts/interfaces/slash-indicator/ISlashUnavailability.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IBaseSlash.sol\\\";\\n\\ninterface ISlashUnavailability is IBaseSlash {\\n /**\\n * @dev Error thrown when attempting to slash a validator twice or slash more than one validator in one block.\\n */\\n error ErrCannotSlashAValidatorTwiceOrSlashMoreThanOneValidatorInOneBlock();\\n\\n /**\\n * @dev Emitted when the configs to slash bridge operator is updated. See the method `getUnavailabilitySlashingConfigs`\\n * for param details.\\n */\\n event UnavailabilitySlashingConfigsUpdated(\\n uint256 unavailabilityTier1Threshold,\\n uint256 unavailabilityTier2Threshold,\\n uint256 slashAmountForUnavailabilityTier2Threshold,\\n uint256 jailDurationForUnavailabilityTier2Threshold\\n );\\n\\n /**\\n * @dev Returns the last block that a block producer is slashed for unavailability.\\n */\\n function lastUnavailabilitySlashedBlock() external view returns (uint256);\\n\\n /**\\n * @dev Slashes for unavailability by increasing the counter of block producer `_consensusAddr`.\\n *\\n * Requirements:\\n * - The method caller is coinbase.\\n *\\n * Emits the event `Slashed` when the threshold is reached.\\n *\\n */\\n function slashUnavailability(address _consensusAddr) external;\\n\\n /**\\n * @dev Returns the current unavailability indicator of a block producer.\\n */\\n function currentUnavailabilityIndicator(address _validator) external view returns (uint256);\\n\\n /**\\n * @dev Returns the unavailability indicator in the period `_period` of a block producer.\\n */\\n function getUnavailabilityIndicator(address _validator, uint256 _period) external view returns (uint256);\\n\\n /**\\n * @dev Returns the configs related to block producer slashing.\\n *\\n * @return _unavailabilityTier1Threshold The mining reward will be deprecated, if (s)he missed more than this\\n * threshold. This threshold is applied for tier-1 and tier-3 slash.\\n * @return _unavailabilityTier2Threshold The mining reward will be deprecated, (s)he will be put in jailed, and will\\n * be deducted self-staking if (s)he misses more than this threshold. This threshold is applied for tier-2 slash.\\n * @return _slashAmountForUnavailabilityTier2Threshold The amount of RON to deduct from self-staking of a block\\n * producer when (s)he is slashed with tier-2 or tier-3.\\n * @return _jailDurationForUnavailabilityTier2Threshold The number of blocks to jail a block producer when (s)he is\\n * slashed with tier-2 or tier-3.\\n *\\n */\\n function getUnavailabilitySlashingConfigs()\\n external\\n view\\n returns (\\n uint256 _unavailabilityTier1Threshold,\\n uint256 _unavailabilityTier2Threshold,\\n uint256 _slashAmountForUnavailabilityTier2Threshold,\\n uint256 _jailDurationForUnavailabilityTier2Threshold\\n );\\n\\n /**\\n * @dev Sets the configs to slash block producers.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `BridgeOperatorSlashingConfigsUpdated`.\\n *\\n * @param _tier1Threshold The mining reward will be deprecated, if (s)he missed more than this threshold.\\n * @param _tier2Threshold The mining reward will be deprecated, (s)he will be put in jailed, and will be deducted\\n * self-staking if (s)he misses more than this threshold.\\n * @param _slashAmountForTier2Threshold The amount of RON to deduct from self-staking of a block producer when (s)he\\n * is slashed tier-2.\\n * @param _jailDurationForTier2Threshold The number of blocks to jail a block producer when (s)he is slashed tier-2.\\n *\\n */\\n function setUnavailabilitySlashingConfigs(\\n uint256 _tier1Threshold,\\n uint256 _tier2Threshold,\\n uint256 _slashAmountForTier2Threshold,\\n uint256 _jailDurationForTier2Threshold\\n ) external;\\n}\\n\",\"keccak256\":\"0x458a7ae130a59b59b7f095fe3d4db8f779e0614041e5615f0afd36c543ac2046\",\"license\":\"MIT\"},\"contracts/interfaces/validator/ICandidateManager.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface ICandidateManager {\\n struct ValidatorCandidate {\\n // Admin of the candidate\\n address admin;\\n // Address of the validator that produces block, e.g. block.coinbase. This is so-called validator address.\\n address consensusAddr;\\n // Address that receives mining reward of the validator\\n address payable treasuryAddr;\\n // Address of the bridge operator corresponding to the candidate\\n address bridgeOperatorAddr;\\n // The percentage of reward that validators can be received, the rest goes to the delegators.\\n // Values in range [0; 100_00] stands for 0-100%\\n uint256 commissionRate;\\n // The timestamp that scheduled to revoke the candidate (no schedule=0)\\n uint256 revokingTimestamp;\\n // The deadline that the candidate must top up staking amount to keep it larger than or equal to the threshold (no deadline=0)\\n uint256 topupDeadline;\\n }\\n\\n struct CommissionSchedule {\\n // The timestamp that the commission schedule gets affected (no schedule=0).\\n uint256 effectiveTimestamp;\\n // The new commission rate. Value is in range [0; 100_00], stands for 0-100%\\n uint256 commissionRate;\\n }\\n\\n /// @dev Emitted when the maximum number of validator candidates is updated.\\n event MaxValidatorCandidateUpdated(uint256 threshold);\\n /// @dev Emitted when the min offset to the effective date of commission rate change is updated.\\n event MinEffectiveDaysOnwardsUpdated(uint256 numOfDays);\\n /// @dev Emitted when the validator candidate is granted.\\n event CandidateGranted(\\n address indexed consensusAddr,\\n address indexed treasuryAddr,\\n address indexed admin,\\n address bridgeOperator\\n );\\n /// @dev Emitted when the revoking timestamp of a candidate is updated.\\n event CandidateRevokingTimestampUpdated(address indexed consensusAddr, uint256 revokingTimestamp);\\n /// @dev Emitted when the topup deadline of a candidate is updated.\\n event CandidateTopupDeadlineUpdated(address indexed consensusAddr, uint256 topupDeadline);\\n /// @dev Emitted when the validator candidate is revoked.\\n event CandidatesRevoked(address[] consensusAddrs);\\n\\n /// @dev Emitted when a schedule for updating commission rate is set.\\n event CommissionRateUpdateScheduled(address indexed consensusAddr, uint256 effectiveTimestamp, uint256 rate);\\n /// @dev Emitted when the commission rate of a validator is updated.\\n event CommissionRateUpdated(address indexed consensusAddr, uint256 rate);\\n\\n /// @dev Error of exceeding maximum number of candidates.\\n error ErrExceedsMaxNumberOfCandidate();\\n /// @dev Error of querying for already existent candidate.\\n error ErrExistentCandidate();\\n /// @dev Error of querying for non-existent candidate.\\n error ErrNonExistentCandidate();\\n /// @dev Error of candidate admin already exists.\\n error ErrExistentCandidateAdmin(address _candidateAdminAddr);\\n /// @dev Error of treasury already exists.\\n error ErrExistentTreasury(address _treasuryAddr);\\n /// @dev Error of bridge operator already exists.\\n error ErrExistentBridgeOperator(address _bridgeOperatorAddr);\\n /// @dev Error of invalid commission rate.\\n error ErrInvalidCommissionRate();\\n /// @dev Error of invalid effective days onwards.\\n error ErrInvalidEffectiveDaysOnwards();\\n /// @dev Error of invalid min effective days onwards.\\n error ErrInvalidMinEffectiveDaysOnwards();\\n /// @dev Error of already requested revoking candidate before.\\n error ErrAlreadyRequestedRevokingCandidate();\\n /// @dev Error of commission change schedule exists.\\n error ErrAlreadyRequestedUpdatingCommissionRate();\\n /// @dev Error of trusted org cannot renounce.\\n error ErrTrustedOrgCannotRenounce();\\n\\n /**\\n * @dev Returns the maximum number of validator candidate.\\n */\\n function maxValidatorCandidate() external view returns (uint256);\\n\\n /**\\n * @dev Returns the minimum number of days to the effective date of commission rate change.\\n */\\n function minEffectiveDaysOnwards() external view returns (uint256);\\n\\n /**\\n * @dev Sets the maximum number of validator candidate.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the `MaxValidatorCandidateUpdated` event.\\n *\\n */\\n function setMaxValidatorCandidate(uint256) external;\\n\\n /**\\n * @dev Sets the minimum number of days to the effective date of commision rate change.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the `MinEffectiveDaysOnwardsUpdated` event.\\n *\\n */\\n function setMinEffectiveDaysOnwards(uint256 _numOfDays) external;\\n\\n /**\\n * @dev Grants a validator candidate.\\n *\\n * Requirements:\\n * - The method caller is staking contract.\\n *\\n * Emits the event `CandidateGranted`.\\n *\\n */\\n function execApplyValidatorCandidate(\\n address _admin,\\n address _consensusAddr,\\n address payable _treasuryAddr,\\n address _bridgeOperatorAddr,\\n uint256 _commissionRate\\n ) external;\\n\\n /**\\n * @dev Requests to revoke a validator candidate in next `_secsLeft` seconds.\\n *\\n * Requirements:\\n * - The method caller is staking contract.\\n *\\n * Emits the event `CandidateRevokingTimestampUpdated`.\\n *\\n */\\n function execRequestRenounceCandidate(address, uint256 _secsLeft) external;\\n\\n /**\\n * @dev Fallback function of `CandidateStaking-requestUpdateCommissionRate`.\\n *\\n * Requirements:\\n * - The method caller is the staking contract.\\n * - The `_effectiveTimestamp` must be the beginning of a UTC day, and at least from 7 days onwards\\n * - The `_rate` must be in range of [0_00; 100_00].\\n *\\n * Emits the event `CommissionRateUpdateScheduled`.\\n *\\n */\\n function execRequestUpdateCommissionRate(address _consensusAddr, uint256 _effectiveTimestamp, uint256 _rate) external;\\n\\n /**\\n * @dev Returns whether the address is a validator (candidate).\\n */\\n function isValidatorCandidate(address _addr) external view returns (bool);\\n\\n /**\\n * @dev Returns the validator candidate.\\n */\\n function getValidatorCandidates() external view returns (address[] memory);\\n\\n /**\\n * @dev Returns all candidate info.\\n */\\n function getCandidateInfos() external view returns (ValidatorCandidate[] memory);\\n\\n /**\\n * @dev Returns the info of a candidate.\\n */\\n function getCandidateInfo(address _candidate) external view returns (ValidatorCandidate memory);\\n\\n /**\\n * @dev Returns whether the address is the candidate admin.\\n */\\n function isCandidateAdmin(address _candidate, address _admin) external view returns (bool);\\n\\n /**\\n * @dev Returns the schedule of changing commission rate of a candidate address.\\n */\\n function getCommissionChangeSchedule(address _candidate) external view returns (CommissionSchedule memory);\\n}\\n\",\"keccak256\":\"0x01bb0823588c4e6df855ec9962d3bbc10e179f1668d006946005a0af3e73114e\",\"license\":\"MIT\"},\"contracts/interfaces/validator/ICoinbaseExecution.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./ISlashingExecution.sol\\\";\\n\\ninterface ICoinbaseExecution is ISlashingExecution {\\n enum BlockRewardDeprecatedType {\\n UNKNOWN,\\n UNAVAILABILITY,\\n AFTER_BAILOUT\\n }\\n\\n /// @dev Emitted when the validator set is updated\\n event ValidatorSetUpdated(uint256 indexed period, address[] consensusAddrs);\\n /// @dev Emitted when the bridge operator set is updated, to mirror the in-jail and maintaining status of the validator.\\n event BlockProducerSetUpdated(uint256 indexed period, uint256 indexed epoch, address[] consensusAddrs);\\n /// @dev Emitted when the bridge operator set is updated.\\n event BridgeOperatorSetUpdated(uint256 indexed period, uint256 indexed epoch, address[] bridgeOperators);\\n\\n /// @dev Emitted when the reward of the block producer is deprecated.\\n event BlockRewardDeprecated(\\n address indexed coinbaseAddr,\\n uint256 rewardAmount,\\n BlockRewardDeprecatedType deprecatedType\\n );\\n /// @dev Emitted when the block reward is submitted.\\n event BlockRewardSubmitted(address indexed coinbaseAddr, uint256 submittedAmount, uint256 bonusAmount);\\n\\n /// @dev Emitted when the block producer reward is distributed.\\n event MiningRewardDistributed(address indexed consensusAddr, address indexed recipient, uint256 amount);\\n /// @dev Emitted when the contract fails when distributing the block producer reward.\\n event MiningRewardDistributionFailed(\\n address indexed consensusAddr,\\n address indexed recipient,\\n uint256 amount,\\n uint256 contractBalance\\n );\\n\\n /// @dev Emitted when the bridge operator reward is distributed.\\n event BridgeOperatorRewardDistributed(\\n address indexed consensusAddr,\\n address indexed bridgeOperator,\\n address indexed recipientAddr,\\n uint256 amount\\n );\\n /// @dev Emitted when the contract fails when distributing the bridge operator reward.\\n event BridgeOperatorRewardDistributionFailed(\\n address indexed consensusAddr,\\n address indexed bridgeOperator,\\n address indexed recipient,\\n uint256 amount,\\n uint256 contractBalance\\n );\\n\\n /// @dev Emitted when the amount of RON reward is distributed to staking contract.\\n event StakingRewardDistributed(uint256 totalAmount, address[] consensusAddrs, uint256[] amounts);\\n /// @dev Emitted when the contracts fails when distributing the amount of RON to the staking contract.\\n event StakingRewardDistributionFailed(\\n uint256 totalAmount,\\n address[] consensusAddrs,\\n uint256[] amounts,\\n uint256 contractBalance\\n );\\n\\n /// @dev Emitted when the epoch is wrapped up.\\n event WrappedUpEpoch(uint256 indexed periodNumber, uint256 indexed epochNumber, bool periodEnding);\\n /// @dev Emitted when the bridge tracking contract's response is incorrect\\n event BridgeTrackingIncorrectlyResponded();\\n\\n /// @dev Error of method caller must be coinbase\\n error ErrCallerMustBeCoinbase();\\n /// @dev Error of only allowed at the end of epoch\\n error ErrAtEndOfEpochOnly();\\n /// @dev Error of query for already wrapped up epoch\\n error ErrAlreadyWrappedEpoch();\\n\\n /**\\n * @dev Submits reward of the current block.\\n *\\n * Requirements:\\n * - The method caller is coinbase.\\n *\\n * Emits the event `MiningRewardDeprecated` if the coinbase is slashed or no longer be a block producer.\\n * Emits the event `BlockRewardSubmitted` for the valid call.\\n *\\n */\\n function submitBlockReward() external payable;\\n\\n /**\\n * @dev Wraps up the current epoch.\\n *\\n * Requirements:\\n * - The method must be called when the current epoch is ending.\\n * - The epoch is not wrapped yet.\\n * - The method caller is coinbase.\\n *\\n * Emits the event `MiningRewardDistributed` when some validator has reward distributed.\\n * Emits the event `StakingRewardDistributed` when some staking pool has reward distributed.\\n * Emits the event `BlockProducerSetUpdated` when the epoch is wrapped up.\\n * Emits the event `BridgeOperatorSetUpdated` when the epoch is wrapped up at period ending.\\n * Emits the event `ValidatorSetUpdated` when the epoch is wrapped up at period ending, and the validator set gets updated.\\n * Emits the event `WrappedUpEpoch`.\\n *\\n */\\n function wrapUpEpoch() external payable;\\n}\\n\",\"keccak256\":\"0x42ed0bff5f8233dc6de28bd3283f98a0c16df6abc26655fc777bdc07a83ff3f5\",\"license\":\"MIT\"},\"contracts/interfaces/validator/IEmergencyExit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface IEmergencyExit {\\n /// @dev Emitted when the fund is locked from an emergency exit request\\n event EmergencyExitRequested(address indexed consensusAddr, uint256 lockedAmount);\\n /// @dev Emitted when the fund that locked from an emergency exit request is transferred to the recipient.\\n event EmergencyExitLockedFundReleased(\\n address indexed consensusAddr,\\n address indexed recipient,\\n uint256 unlockedAmount\\n );\\n /// @dev Emitted when the fund that locked from an emergency exit request is failed to transferred back.\\n event EmergencyExitLockedFundReleasingFailed(\\n address indexed consensusAddr,\\n address indexed recipient,\\n uint256 unlockedAmount,\\n uint256 contractBalance\\n );\\n\\n /// @dev Emitted when the emergency exit locked amount is updated.\\n event EmergencyExitLockedAmountUpdated(uint256 amount);\\n /// @dev Emitted when the emergency expiry duration is updated.\\n event EmergencyExpiryDurationUpdated(uint256 amount);\\n\\n /// @dev Error of already requested emergency exit before.\\n error ErrAlreadyRequestedEmergencyExit();\\n\\n /**\\n * @dev Returns the amount of RON to lock from a consensus address.\\n */\\n function emergencyExitLockedAmount() external returns (uint256);\\n\\n /**\\n * @dev Returns the duration that an emergency request is expired and the fund will be recycled.\\n */\\n function emergencyExpiryDuration() external returns (uint256);\\n\\n /**\\n * @dev Sets the amount of RON to lock from a consensus address.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `EmergencyExitLockedAmountUpdated`.\\n *\\n */\\n function setEmergencyExitLockedAmount(uint256 _emergencyExitLockedAmount) external;\\n\\n /**\\n * @dev Sets the duration that an emergency request is expired and the fund will be recycled.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `EmergencyExpiryDurationUpdated`.\\n *\\n */\\n function setEmergencyExpiryDuration(uint256 _emergencyExpiryDuration) external;\\n\\n /**\\n * @dev Unlocks fund for emergency exit request.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `EmergencyExitLockedFundReleased` if the fund is successfully unlocked.\\n * Emits the event `EmergencyExitLockedFundReleasingFailed` if the fund is failed to unlock.\\n *\\n */\\n function execReleaseLockedFundForEmergencyExitRequest(address _consensusAddr, address payable _recipient) external;\\n\\n /**\\n * @dev Fallback function of `IStaking-requestEmergencyExit`.\\n *\\n * Requirements:\\n * - The method caller is staking contract.\\n *\\n */\\n function execEmergencyExit(address _consensusAddr, uint256 _secLeftToRevoke) external;\\n}\\n\",\"keccak256\":\"0x45161abd1e3db83052a06889a0e3a7a5e7ee3306478601d58ac4ed32ccaa75ad\",\"license\":\"MIT\"},\"contracts/interfaces/validator/IRoninValidatorSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./ICandidateManager.sol\\\";\\nimport \\\"./info-fragments/ICommonInfo.sol\\\";\\nimport \\\"./ICoinbaseExecution.sol\\\";\\nimport \\\"./ISlashingExecution.sol\\\";\\nimport \\\"./IEmergencyExit.sol\\\";\\n\\ninterface IRoninValidatorSet is\\n ICandidateManager,\\n ICommonInfo,\\n ISlashingExecution,\\n ICoinbaseExecution,\\n IEmergencyExit\\n{}\\n\",\"keccak256\":\"0x813f34747aea4dfb53bbc147abf8dbe5999ce73111c2db99bcb3efb4cf75bb3d\",\"license\":\"MIT\"},\"contracts/interfaces/validator/ISlashingExecution.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface ISlashingExecution {\\n /// @dev Emitted when the validator is punished.\\n event ValidatorPunished(\\n address indexed consensusAddr,\\n uint256 indexed period,\\n uint256 jailedUntil,\\n uint256 deductedStakingAmount,\\n bool blockProducerRewardDeprecated,\\n bool bridgeOperatorRewardDeprecated\\n );\\n /// @dev Emitted when the validator get out of jail by bailout.\\n event ValidatorUnjailed(address indexed validator, uint256 period);\\n\\n /// @dev Error of cannot bailout due to high tier slash.\\n error ErrCannotBailout(address validator);\\n\\n /**\\n * @dev Finalize the slash request from slash indicator contract.\\n *\\n * Requirements:\\n * - The method caller is slash indicator contract.\\n *\\n * Emits the event `ValidatorPunished`.\\n *\\n */\\n function execSlash(\\n address _validatorAddr,\\n uint256 _newJailedUntil,\\n uint256 _slashAmount,\\n bool _cannotBailout\\n ) external;\\n\\n /**\\n * @dev Finalize the bailout request from slash indicator contract.\\n *\\n * Requirements:\\n * - The method caller is slash indicator contract.\\n *\\n * Emits the event `ValidatorUnjailed`.\\n *\\n */\\n function execBailOut(address _validatorAddr, uint256 _period) external;\\n}\\n\",\"keccak256\":\"0x80362c42fdc0ee06543a2abbffee961fe51c15a7c5e18933a9c34897e50d07fe\",\"license\":\"MIT\"},\"contracts/interfaces/validator/info-fragments/ICommonInfo.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IJailingInfo.sol\\\";\\nimport \\\"./ITimingInfo.sol\\\";\\nimport \\\"./IValidatorInfo.sol\\\";\\n\\ninterface ICommonInfo is ITimingInfo, IJailingInfo, IValidatorInfo {\\n struct EmergencyExitInfo {\\n uint256 lockedAmount;\\n // The timestamp that this locked amount will be recycled to staking vesting contract\\n uint256 recyclingAt;\\n }\\n\\n /// @dev Emitted when the deprecated reward is withdrawn.\\n event DeprecatedRewardRecycled(address indexed recipientAddr, uint256 amount);\\n /// @dev Emitted when the deprecated reward withdrawal is failed\\n event DeprecatedRewardRecycleFailed(address indexed recipientAddr, uint256 amount, uint256 balance);\\n\\n /// @dev Error thrown when receives RON from neither staking vesting contract nor staking contract\\n error ErrUnauthorizedReceiveRON();\\n /// @dev Error thrown when queries for a non existent info.\\n error NonExistentRecyclingInfo();\\n\\n /**\\n * @dev Returns the total deprecated reward, which includes reward that is not sent for slashed validators and unsastified bridge operators\\n */\\n function totalDeprecatedReward() external view returns (uint256);\\n\\n /**\\n * @dev Returns the emergency exit request.\\n */\\n function getEmergencyExitInfo(address _consensusAddr) external view returns (EmergencyExitInfo memory);\\n}\\n\",\"keccak256\":\"0xc00b1bda0c6076c9aa0631dc0c01e849d8f42cc616fe4c036f73cda0a9afe9ef\",\"license\":\"MIT\"},\"contracts/interfaces/validator/info-fragments/IJailingInfo.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface IJailingInfo {\\n /**\\n * @dev Returns whether the validator are put in jail (cannot join the set of validators) during the current period.\\n */\\n function checkJailed(address) external view returns (bool);\\n\\n /**\\n * @dev Returns whether the validator are put in jail and the number of block and epoch that he still is in the jail.\\n */\\n function getJailedTimeLeft(\\n address _addr\\n ) external view returns (bool isJailed_, uint256 blockLeft_, uint256 epochLeft_);\\n\\n /**\\n * @dev Returns whether the validator are put in jail (cannot join the set of validators) at a specific block.\\n */\\n function checkJailedAtBlock(address _addr, uint256 _blockNum) external view returns (bool);\\n\\n /**\\n * @dev Returns whether the validator are put in jail at a specific block and the number of block and epoch that he still is in the jail.\\n */\\n function getJailedTimeLeftAtBlock(\\n address _addr,\\n uint256 _blockNum\\n ) external view returns (bool isJailed_, uint256 blockLeft_, uint256 epochLeft_);\\n\\n /**\\n * @dev Returns whether the validators are put in jail (cannot join the set of validators) during the current period.\\n */\\n function checkManyJailed(address[] calldata) external view returns (bool[] memory);\\n\\n /**\\n * @dev Returns whether the incoming reward of the block producer is deprecated during the current period.\\n */\\n function checkMiningRewardDeprecated(address _blockProducer) external view returns (bool);\\n\\n /**\\n * @dev Returns whether the incoming reward of the block producer is deprecated during a specific period.\\n */\\n function checkMiningRewardDeprecatedAtPeriod(address _blockProducer, uint256 _period) external view returns (bool);\\n\\n /**\\n * @dev Returns whether the incoming reward of the validator with `_consensusAddr` is deprecated in the latest wrapped up period.\\n */\\n function checkBridgeRewardDeprecatedAtLatestPeriod(address _consensusAddr) external view returns (bool _result);\\n\\n /**\\n * @dev Returns whether the incoming reward of the validator with `_consensusAddr` is deprecated in the `_period`.\\n */\\n function checkBridgeRewardDeprecatedAtPeriod(\\n address _consensusAddr,\\n uint256 _period\\n ) external view returns (bool _result);\\n}\\n\",\"keccak256\":\"0xc854f6deb26db9cae49e1cfa85aa94d64828251fcca394fed0dd67d554da749b\",\"license\":\"MIT\"},\"contracts/interfaces/validator/info-fragments/ITimingInfo.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface ITimingInfo {\\n /**\\n * @dev Returns the block that validator set was updated.\\n */\\n function getLastUpdatedBlock() external view returns (uint256);\\n\\n /**\\n * @dev Returns the number of blocks in a epoch.\\n */\\n function numberOfBlocksInEpoch() external view returns (uint256 _numberOfBlocks);\\n\\n /**\\n * @dev Returns the epoch index from the block number.\\n */\\n function epochOf(uint256 _block) external view returns (uint256);\\n\\n /**\\n * @dev Returns whether the epoch ending is at the block number `_block`.\\n */\\n function epochEndingAt(uint256 _block) external view returns (bool);\\n\\n /**\\n * @dev Tries to get the period index from the epoch number.\\n */\\n function tryGetPeriodOfEpoch(uint256 _epoch) external view returns (bool _filled, uint256 _periodNumber);\\n\\n /**\\n * @dev Returns whether the period ending at the current block number.\\n */\\n function isPeriodEnding() external view returns (bool);\\n\\n /**\\n * @dev Returns the period index from the current block.\\n */\\n function currentPeriod() external view returns (uint256);\\n\\n /**\\n * @dev Returns the block number that the current period starts at.\\n */\\n function currentPeriodStartAtBlock() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x77b86a68149389fed0eb0c5b8d56f278d3bd103ba64f504697d709b24c3212d5\",\"license\":\"MIT\"},\"contracts/interfaces/validator/info-fragments/IValidatorInfo.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"../../../libraries/EnumFlags.sol\\\";\\n\\ninterface IValidatorInfo {\\n /**\\n * @dev Error thrown when an invalid maximum prioritized validator number is provided.\\n */\\n error ErrInvalidMaxPrioritizedValidatorNumber();\\n\\n /// @dev Emitted when the number of max validator is updated.\\n event MaxValidatorNumberUpdated(uint256);\\n /// @dev Emitted when the number of reserved slots for prioritized validators is updated.\\n event MaxPrioritizedValidatorNumberUpdated(uint256);\\n\\n /**\\n * @dev Returns the maximum number of validators in the epoch.\\n */\\n function maxValidatorNumber() external view returns (uint256 _maximumValidatorNumber);\\n\\n /**\\n * @dev Returns the number of reserved slots for prioritized validators.\\n */\\n function maxPrioritizedValidatorNumber() external view returns (uint256 _maximumPrioritizedValidatorNumber);\\n\\n /**\\n * @dev Returns the current validator list.\\n */\\n function getValidators()\\n external\\n view\\n returns (\\n address[] memory _validatorList,\\n address[] memory _bridgeOperators,\\n EnumFlags.ValidatorFlag[] memory _flags\\n );\\n\\n /**\\n * @dev Returns whether the address is either a bridge operator or a block producer.\\n */\\n function isValidator(address _addr) external view returns (bool);\\n\\n /**\\n * @dev Returns the current block producer list.\\n */\\n function getBlockProducers() external view returns (address[] memory);\\n\\n /**\\n * @dev Returns whether the address is block producer or not.\\n */\\n function isBlockProducer(address _addr) external view returns (bool);\\n\\n /**\\n * @dev Returns total numbers of the block producers.\\n */\\n function totalBlockProducers() external view returns (uint256);\\n\\n /**\\n * @dev Returns the current on-working bridge operator list.\\n * @param bridgeOperatorList The list of working bridge operators.\\n * @param validatorList The list of corresponding validators.\\n */\\n function getBridgeOperators()\\n external\\n view\\n returns (address[] memory bridgeOperatorList, address[] memory validatorList);\\n\\n /**\\n * @dev Returns the bridge operator list corresponding to validator address list.\\n */\\n function getBridgeOperatorsOf(\\n address[] memory _validatorAddrs\\n ) external view returns (address[] memory bridgeOperatorList);\\n\\n /**\\n * @dev Returns whether the address is bridge operator.\\n */\\n function isBridgeOperator(address _addr) external view returns (bool isOperator);\\n\\n /**\\n * @dev Returns whether the consensus address is operating the bridge or not.\\n */\\n function isOperatingBridge(address _consensusAddr) external view returns (bool);\\n\\n /**\\n * @dev Returns total numbers of the bridge operators.\\n */\\n function totalBridgeOperators() external view returns (uint256);\\n\\n /**\\n * @dev Updates the max validator number\\n *\\n * Requirements:\\n * - The method caller is admin\\n *\\n * Emits the event `MaxValidatorNumberUpdated`\\n *\\n */\\n function setMaxValidatorNumber(uint256 _maxValidatorNumber) external;\\n\\n /**\\n * @dev Updates the number of reserved slots for prioritized validators\\n *\\n * Requirements:\\n * - The method caller is admin\\n *\\n * Emits the event `MaxPrioritizedValidatorNumberUpdated`\\n *\\n */\\n function setMaxPrioritizedValidatorNumber(uint256 _maxPrioritizedValidatorNumber) external;\\n}\\n\",\"keccak256\":\"0x3915e301358a793f14f6ecf6bca330311a9684e5144cd20d133b1905f8918f03\",\"license\":\"MIT\"},\"contracts/libraries/BridgeOperatorsBallot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\\\";\\nimport \\\"../utils/CommonErrors.sol\\\";\\n\\nlibrary BridgeOperatorsBallot {\\n /**\\n * @dev Error thrown when an invalid order of the bridge operator is detected.\\n */\\n error ErrInvalidOrderOfBridgeOperator();\\n\\n struct BridgeOperatorSet {\\n uint256 period;\\n uint256 epoch;\\n address[] operators;\\n }\\n\\n // keccak256(\\\"BridgeOperatorsBallot(uint256 period,uint256 epoch,address[] operators)\\\");\\n bytes32 public constant BRIDGE_OPERATORS_BALLOT_TYPEHASH =\\n 0xd679a49e9e099fa9ed83a5446aaec83e746b03ec6723d6f5efb29d37d7f0b78a;\\n\\n /**\\n * @dev Verifies whether the ballot is valid or not.\\n *\\n * Requirements:\\n * - The ballot is not for an empty operator set.\\n * - The operator address list is in order.\\n *\\n */\\n function verifyBallot(BridgeOperatorSet calldata _ballot) internal pure {\\n if (_ballot.operators.length == 0) revert ErrEmptyArray();\\n\\n address _addr = _ballot.operators[0];\\n for (uint _i = 1; _i < _ballot.operators.length; ) {\\n if (_addr >= _ballot.operators[_i]) revert ErrInvalidOrderOfBridgeOperator();\\n _addr = _ballot.operators[_i];\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @dev Returns hash of the ballot.\\n */\\n function hash(BridgeOperatorSet memory self) internal pure returns (bytes32 digest_) {\\n bytes32 operatorsHash;\\n address[] memory operators = self.operators;\\n\\n // return keccak256(abi.encode(BRIDGE_OPERATORS_BALLOT_TYPEHASH, _ballot.period, _ballot.epoch, _operatorsHash));\\n assembly {\\n operatorsHash := keccak256(add(operators, 32), mul(mload(operators), 32))\\n let ptr := mload(0x40)\\n mstore(ptr, BRIDGE_OPERATORS_BALLOT_TYPEHASH)\\n mstore(add(ptr, 0x20), mload(self)) // _ballot.period\\n mstore(add(ptr, 0x40), mload(add(self, 0x20))) // _ballot.epoch\\n mstore(add(ptr, 0x60), operatorsHash)\\n digest_ := keccak256(ptr, 0x80)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7671f6e599d5a33fa1e97538b1c8e04159337da5701eb6fa07b29d0566f57f81\",\"license\":\"MIT\"},\"contracts/libraries/EnumFlags.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This library implements checking flag of an enumerated value.\\n * The originated idea is inherited from [Enum.HashFlag(Enum)](https://learn.microsoft.com/en-us/dotnet/api/system.enum.hasflag?view=net-6.0) method of C#.\\n */\\nlibrary EnumFlags {\\n enum ValidatorFlag {\\n None, // bit(00)\\n BlockProducer, // bit(01)\\n BridgeOperator, // bit(10)\\n Both // bit(11)\\n }\\n\\n function isNone(ValidatorFlag _value) internal pure returns (bool) {\\n return uint8(_value) == 0;\\n }\\n\\n /**\\n * @dev Checks if `_value` has `_flag`.\\n */\\n function hasFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (bool) {\\n return (uint8(_value) & uint8(_flag)) != 0;\\n }\\n\\n /**\\n * @dev Calculate new value of `_value` after adding `_flag`.\\n */\\n function addFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (ValidatorFlag) {\\n return ValidatorFlag(uint8(_value) | uint8(_flag));\\n }\\n\\n /**\\n * @dev Calculate new value of `_value` after remove `_flag`.\\n */\\n function removeFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (ValidatorFlag) {\\n return ValidatorFlag(uint8(_value) & ~uint8(_flag));\\n }\\n}\\n\",\"keccak256\":\"0xa6c77f9d704c57854a30e57e16467a1b70b76be5331d9e53a3f9ec5e57542533\",\"license\":\"UNLICENSED\"},\"contracts/libraries/Math.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\n\\npragma solidity ^0.8.0;\\n\\nlibrary Math {\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a >= b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns whether the number `c` is in range of [a; b].\\n */\\n function inRange(uint256 c, uint256 a, uint256 b) internal pure returns (bool) {\\n return a <= c && c <= b;\\n }\\n\\n /**\\n * @dev Returns whether two inclusive ranges [x1;x2] and [y1;y2] overlap.\\n */\\n function twoRangeOverlap(uint256 x1, uint256 x2, uint256 y1, uint256 y2) internal pure returns (bool) {\\n return x1 <= y2 && y1 <= x2;\\n }\\n\\n /**\\n * @dev Returns value of a + b; in case result is larger than upperbound, upperbound is returned.\\n */\\n function addWithUpperbound(uint256 a, uint256 b, uint256 upperbound) internal pure returns (uint256) {\\n return min(a + b, upperbound);\\n }\\n\\n /**\\n * @dev Returns value of a - b; in case of negative result, 0 is returned.\\n */\\n function subNonNegative(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a - b : 0;\\n }\\n\\n /**\\n * @dev Returns value of `a + zeroable` if zerobale is not 0; otherwise, return 0.\\n */\\n function addIfNonZero(uint256 a, uint256 zeroable) internal pure returns (uint256) {\\n return zeroable != 0 ? a + zeroable : 0;\\n }\\n}\\n\",\"keccak256\":\"0xd73170f448c644a47024c7dbcf4afc3cc7ad27f61737c6ea4c3b543ec5cdb7e9\",\"license\":\"UNLICENSED\"},\"contracts/precompile-usages/PCUValidateDoubleSign.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./PrecompiledUsage.sol\\\";\\n\\nabstract contract PCUValidateDoubleSign is PrecompiledUsage {\\n /// @dev Gets the address of the precompile of validating double sign evidence\\n function precompileValidateDoubleSignAddress() public view virtual returns (address) {\\n return address(0x67);\\n }\\n\\n /**\\n * @dev Validates the two submitted block header if they are produced by the same address\\n *\\n * Note: The recover process is done by pre-compiled contract. This function is marked as\\n * virtual for implementing mocking contract for testing purpose.\\n */\\n function _pcValidateEvidence(\\n address _consensusAddr,\\n bytes calldata _header1,\\n bytes calldata _header2\\n ) internal view virtual returns (bool _validEvidence) {\\n address _smc = precompileValidateDoubleSignAddress();\\n bool _success = true;\\n\\n bytes memory _payload = abi.encodeWithSignature(\\n \\\"validatingDoubleSignProof(address,bytes,bytes)\\\",\\n _consensusAddr,\\n _header1,\\n _header2\\n );\\n uint _payloadLength = _payload.length;\\n uint[1] memory _output;\\n\\n assembly {\\n let _payloadStart := add(_payload, 0x20)\\n if iszero(staticcall(gas(), _smc, _payloadStart, _payloadLength, _output, 0x20)) {\\n _success := 0\\n }\\n\\n if iszero(returndatasize()) {\\n _success := 0\\n }\\n }\\n\\n if (!_success) revert ErrCallPrecompiled();\\n return (_output[0] != 0);\\n }\\n}\\n\",\"keccak256\":\"0x9df5b8272e1cd963d776b94e29a69ba1139f0df7404b67c213b3c5ebe19e527b\",\"license\":\"MIT\"},\"contracts/precompile-usages/PrecompiledUsage.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./PrecompiledUsage.sol\\\";\\n\\nabstract contract PrecompiledUsage {\\n /// @dev Error of call to precompile fails.\\n error ErrCallPrecompiled();\\n}\\n\",\"keccak256\":\"0x76facc3f3a8dd573c826bbbfedaa5cd8ef30963fbabd8c163c0c72b6efea5551\",\"license\":\"MIT\"},\"contracts/ronin/slash-indicator/CreditScore.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"../../interfaces/IMaintenance.sol\\\";\\nimport \\\"../../interfaces/validator/IRoninValidatorSet.sol\\\";\\nimport \\\"../../interfaces/slash-indicator/ICreditScore.sol\\\";\\nimport \\\"../../extensions/collections/HasContracts.sol\\\";\\nimport \\\"../../extensions/consumers/PercentageConsumer.sol\\\";\\nimport \\\"../../libraries/Math.sol\\\";\\nimport { HasValidatorDeprecated, HasMaintenanceDeprecated } from \\\"../../utils/DeprecatedSlots.sol\\\";\\nimport { ErrUnauthorized, RoleAccess } from \\\"../../utils/CommonErrors.sol\\\";\\n\\nabstract contract CreditScore is\\n ICreditScore,\\n HasContracts,\\n HasValidatorDeprecated,\\n HasMaintenanceDeprecated,\\n PercentageConsumer\\n{\\n /// @dev Mapping from validator address => period index => whether bailed out before\\n mapping(address => mapping(uint256 => bool)) internal _checkBailedOutAtPeriod;\\n /// @dev Mapping from validator address => credit score\\n mapping(address => uint256) internal _creditScore;\\n\\n /// @dev The max gained number of credit score per period.\\n uint256 internal _gainCreditScore;\\n /// @dev The max number of credit score that a validator can hold.\\n uint256 internal _maxCreditScore;\\n /// @dev The number that will be multiplied with the remaining jailed time to get the cost of bailing out.\\n uint256 internal _bailOutCostMultiplier;\\n /// @dev The percentage of reward to be cut off from the validator in the rest of the period after bailed out.\\n uint256 internal _cutOffPercentageAfterBailout;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n */\\n uint256[50] private ______gap;\\n\\n /**\\n * @inheritdoc ICreditScore\\n */\\n function updateCreditScores(\\n address[] calldata _validators,\\n uint256 _period\\n ) external override onlyContract(ContractType.VALIDATOR) {\\n IRoninValidatorSet _validatorContract = IRoninValidatorSet(msg.sender);\\n uint256 _periodStartAtBlock = _validatorContract.currentPeriodStartAtBlock();\\n\\n bool[] memory _jaileds = _validatorContract.checkManyJailed(_validators);\\n bool[] memory _maintaineds = IMaintenance(getContract(ContractType.MAINTENANCE)).checkManyMaintainedInBlockRange(\\n _validators,\\n _periodStartAtBlock,\\n block.number\\n );\\n uint256[] memory _updatedCreditScores = new uint256[](_validators.length);\\n\\n for (uint _i = 0; _i < _validators.length; ) {\\n address _validator = _validators[_i];\\n\\n uint256 _indicator = getUnavailabilityIndicator(_validator, _period);\\n bool _isJailedInPeriod = _jaileds[_i];\\n bool _isMaintainingInPeriod = _maintaineds[_i];\\n\\n uint256 _actualGain = (_isJailedInPeriod || _isMaintainingInPeriod)\\n ? 0\\n : Math.subNonNegative(_gainCreditScore, _indicator);\\n\\n _creditScore[_validator] = Math.addWithUpperbound(_creditScore[_validator], _actualGain, _maxCreditScore);\\n _updatedCreditScores[_i] = _creditScore[_validator];\\n unchecked {\\n ++_i;\\n }\\n }\\n\\n emit CreditScoresUpdated(_validators, _updatedCreditScores);\\n }\\n\\n function execResetCreditScores(\\n address[] calldata _validators\\n ) external override onlyContract(ContractType.VALIDATOR) {\\n uint256[] memory _updatedCreditScores = new uint256[](_validators.length);\\n for (uint _i = 0; _i < _validators.length; ) {\\n address _validator = _validators[_i];\\n delete _creditScore[_validator];\\n delete _updatedCreditScores[_i];\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n emit CreditScoresUpdated(_validators, _updatedCreditScores);\\n }\\n\\n /**\\n * @inheritdoc ICreditScore\\n */\\n function bailOut(address _consensusAddr) external override {\\n IRoninValidatorSet _validatorContract = IRoninValidatorSet(getContract(ContractType.VALIDATOR));\\n if (!_validatorContract.isValidatorCandidate(_consensusAddr))\\n revert ErrUnauthorized(msg.sig, RoleAccess.VALIDATOR_CANDIDATE);\\n\\n if (!_validatorContract.isCandidateAdmin(_consensusAddr, msg.sender))\\n revert ErrUnauthorized(msg.sig, RoleAccess.CANDIDATE_ADMIN);\\n\\n (bool _isJailed, , uint256 _jailedEpochLeft) = _validatorContract.getJailedTimeLeft(_consensusAddr);\\n if (!_isJailed) revert ErrCallerMustBeJailedInTheCurrentPeriod();\\n\\n uint256 _period = _validatorContract.currentPeriod();\\n if (_checkBailedOutAtPeriod[_consensusAddr][_period]) revert ErrValidatorHasBailedOutPreviously();\\n\\n uint256 _score = _creditScore[_consensusAddr];\\n uint256 _cost = _jailedEpochLeft * _bailOutCostMultiplier;\\n if (_score < _cost) revert ErrInsufficientCreditScoreToBailOut();\\n\\n _validatorContract.execBailOut(_consensusAddr, _period);\\n\\n _creditScore[_consensusAddr] -= _cost;\\n _setUnavailabilityIndicator(_consensusAddr, _period, 0);\\n _checkBailedOutAtPeriod[_consensusAddr][_period] = true;\\n emit BailedOut(_consensusAddr, _period, _cost);\\n }\\n\\n /**\\n * @inheritdoc ICreditScore\\n */\\n function setCreditScoreConfigs(\\n uint256 _gainScore,\\n uint256 _maxScore,\\n uint256 _bailOutMultiplier,\\n uint256 _cutOffPercentage\\n ) external override onlyAdmin {\\n _setCreditScoreConfigs(_gainScore, _maxScore, _bailOutMultiplier, _cutOffPercentage);\\n }\\n\\n /**\\n * @dev See `ISlashUnavailability`\\n */\\n function getUnavailabilityIndicator(address _validator, uint256 _period) public view virtual returns (uint256);\\n\\n /**\\n * @inheritdoc ICreditScore\\n */\\n function getCreditScoreConfigs()\\n external\\n view\\n override\\n returns (\\n uint256 gainCreditScore_,\\n uint256 maxCreditScore_,\\n uint256 bailOutCostMultiplier_,\\n uint256 cutOffPercentageAfterBailout_\\n )\\n {\\n return (_gainCreditScore, _maxCreditScore, _bailOutCostMultiplier, _cutOffPercentageAfterBailout);\\n }\\n\\n /**\\n * @inheritdoc ICreditScore\\n */\\n function getCreditScore(address _validator) external view override returns (uint256) {\\n return _creditScore[_validator];\\n }\\n\\n /**\\n * @inheritdoc ICreditScore\\n */\\n function getManyCreditScores(\\n address[] calldata _validators\\n ) public view override returns (uint256[] memory _resultList) {\\n _resultList = new uint256[](_validators.length);\\n\\n for (uint _i = 0; _i < _resultList.length; ) {\\n _resultList[_i] = _creditScore[_validators[_i]];\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @inheritdoc ICreditScore\\n */\\n function checkBailedOutAtPeriod(address _validator, uint256 _period) public view virtual override returns (bool) {\\n return _checkBailedOutAtPeriod[_validator][_period];\\n }\\n\\n /**\\n * @dev See `SlashUnavailability`.\\n */\\n function _setUnavailabilityIndicator(address _validator, uint256 _period, uint256 _indicator) internal virtual;\\n\\n /**\\n * @dev See `ICreditScore-setCreditScoreConfigs`.\\n */\\n function _setCreditScoreConfigs(\\n uint256 _gainScore,\\n uint256 _maxScore,\\n uint256 _bailOutMultiplier,\\n uint256 _cutOffPercentage\\n ) internal {\\n if (_gainScore > _maxScore) revert ErrInvalidCreditScoreConfig();\\n if (_cutOffPercentage > _MAX_PERCENTAGE) revert ErrInvalidCutOffPercentageConfig();\\n\\n _gainCreditScore = _gainScore;\\n _maxCreditScore = _maxScore;\\n _bailOutCostMultiplier = _bailOutMultiplier;\\n _cutOffPercentageAfterBailout = _cutOffPercentage;\\n emit CreditScoreConfigsUpdated(_gainScore, _maxScore, _bailOutMultiplier, _cutOffPercentage);\\n }\\n}\\n\",\"keccak256\":\"0xb4321e0140e8a0ceb0b41e8a65d6448fbb2a74c56233fb0aa4a7769016d2b5c6\",\"license\":\"MIT\"},\"contracts/ronin/slash-indicator/SlashBridgeOperator.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"../../extensions/consumers/PercentageConsumer.sol\\\";\\nimport \\\"../../extensions/collections/HasProxyAdmin.sol\\\";\\nimport \\\"../../interfaces/slash-indicator/ISlashBridgeOperator.sol\\\";\\nimport \\\"../../extensions/collections/HasContracts.sol\\\";\\nimport { HasValidatorDeprecated } from \\\"../../utils/DeprecatedSlots.sol\\\";\\n\\nabstract contract SlashBridgeOperator is\\n ISlashBridgeOperator,\\n HasProxyAdmin,\\n HasContracts,\\n HasValidatorDeprecated,\\n PercentageConsumer\\n{\\n /**\\n * @dev The bridge operators will be deprecated reward if (s)he missed more than the ratio.\\n * Values 0-10,000 map to 0%-100%.\\n */\\n uint256 internal _missingVotesRatioTier1;\\n /**\\n * @dev The bridge operators will be deprecated all rewards including bridge reward and mining reward if (s)he missed\\n * more than the ratio. Values 0-10,000 map to 0%-100%.\\n */\\n uint256 internal _missingVotesRatioTier2;\\n /// @dev The number of blocks to jail the corresponding block producer when its bridge operator is slashed tier-2.\\n uint256 internal _jailDurationForMissingVotesRatioTier2;\\n /// @dev The threshold to skip slashing the bridge operator in case the total number of votes in the bridge is too small.\\n uint256 internal _skipBridgeOperatorSlashingThreshold;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n */\\n uint256[50] private ______gap;\\n\\n /**\\n * @inheritdoc ISlashBridgeOperator\\n */\\n function getBridgeOperatorSlashingConfigs()\\n external\\n view\\n override\\n returns (\\n uint256 missingVotesRatioTier1_,\\n uint256 missingVotesRatioTier2_,\\n uint256 jailDurationForMissingVotesRatioTier2_,\\n uint256 skipBridgeOperatorSlashingThreshold_\\n )\\n {\\n return (\\n _missingVotesRatioTier1,\\n _missingVotesRatioTier2,\\n _jailDurationForMissingVotesRatioTier2,\\n _skipBridgeOperatorSlashingThreshold\\n );\\n }\\n\\n /**\\n * @inheritdoc ISlashBridgeOperator\\n */\\n function setBridgeOperatorSlashingConfigs(\\n uint256 _ratioTier1,\\n uint256 _ratioTier2,\\n uint256 _jailDurationTier2,\\n uint256 _skipSlashingThreshold\\n ) external override onlyAdmin {\\n _setBridgeOperatorSlashingConfigs(_ratioTier1, _ratioTier2, _jailDurationTier2, _skipSlashingThreshold);\\n }\\n\\n /**\\n * @inheritdoc ISlashBridgeOperator\\n */\\n function execSlashBridgeOperator(\\n address _consensusAddr,\\n uint256 _tier,\\n uint256 _period\\n ) external onlyContract(ContractType.VALIDATOR) {\\n if (_tier == 1) {\\n emit Slashed(_consensusAddr, SlashType.BRIDGE_OPERATOR_MISSING_VOTE_TIER_1, _period);\\n } else if (_tier == 2) {\\n emit Slashed(_consensusAddr, SlashType.BRIDGE_OPERATOR_MISSING_VOTE_TIER_2, _period);\\n }\\n }\\n\\n /**\\n * @dev See `ISlashBridgeOperator-setBridgeOperatorSlashingConfigs`.\\n */\\n function _setBridgeOperatorSlashingConfigs(\\n uint256 _ratioTier1,\\n uint256 _ratioTier2,\\n uint256 _jailDurationTier2,\\n uint256 _skipSlashingThreshold\\n ) internal {\\n if (_ratioTier1 > _ratioTier2 || _ratioTier1 > _MAX_PERCENTAGE || _ratioTier2 > _MAX_PERCENTAGE) {\\n revert ErrInvalidRatios();\\n }\\n\\n _missingVotesRatioTier1 = _ratioTier1;\\n _missingVotesRatioTier2 = _ratioTier2;\\n _jailDurationForMissingVotesRatioTier2 = _jailDurationTier2;\\n _skipBridgeOperatorSlashingThreshold = _skipSlashingThreshold;\\n emit BridgeOperatorSlashingConfigsUpdated(_ratioTier1, _ratioTier2, _jailDurationTier2, _skipSlashingThreshold);\\n }\\n}\\n\",\"keccak256\":\"0xb8125efc8cced5cd5e57be1e1ad25553439c6470545ef9eee79fb45d8774b18e\",\"license\":\"MIT\"},\"contracts/ronin/slash-indicator/SlashBridgeVoting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"../../libraries/Math.sol\\\";\\nimport { HasValidatorDeprecated, HasTrustedOrgDeprecated, HasGovernanceAdminDeprecated } from \\\"../../utils/DeprecatedSlots.sol\\\";\\nimport \\\"../../interfaces/IRoninGovernanceAdmin.sol\\\";\\nimport \\\"../../interfaces/slash-indicator/ISlashBridgeVoting.sol\\\";\\nimport \\\"../../interfaces/IRoninTrustedOrganization.sol\\\";\\nimport \\\"../../interfaces/validator/IRoninValidatorSet.sol\\\";\\nimport \\\"../../extensions/collections/HasContracts.sol\\\";\\n\\nabstract contract SlashBridgeVoting is\\n ISlashBridgeVoting,\\n HasContracts,\\n HasValidatorDeprecated,\\n HasTrustedOrgDeprecated,\\n HasGovernanceAdminDeprecated\\n{\\n /// @dev Mapping from validator address => period index => bridge voting slashed\\n mapping(address => mapping(uint256 => bool)) internal _bridgeVotingSlashed;\\n /// @dev The threshold to slash when a trusted organization does not vote for bridge operators.\\n uint256 internal _bridgeVotingThreshold;\\n /// @dev The amount of RON to slash bridge voting.\\n uint256 internal _bridgeVotingSlashAmount;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n */\\n uint256[50] private ______gap;\\n\\n /**\\n * @inheritdoc ISlashBridgeVoting\\n */\\n function slashBridgeVoting(address _consensusAddr) external onlyAdmin {\\n IRoninTrustedOrganization.TrustedOrganization memory _org = IRoninTrustedOrganization(\\n getContract(ContractType.RONIN_TRUSTED_ORGANIZATION)\\n ).getTrustedOrganization(_consensusAddr);\\n uint256 _lastVotedBlock = Math.max(\\n IRoninGovernanceAdmin(getContract(ContractType.GOVERNANCE_ADMIN)).lastVotedBlock(_org.bridgeVoter),\\n _org.addedBlock\\n );\\n IRoninValidatorSet _validatorContract = IRoninValidatorSet(getContract(ContractType.VALIDATOR));\\n uint256 _period = _validatorContract.currentPeriod();\\n\\n if (block.number - _lastVotedBlock <= _bridgeVotingThreshold || _bridgeVotingSlashed[_consensusAddr][_period])\\n revert ErrInvalidSlash();\\n\\n _bridgeVotingSlashed[_consensusAddr][_period] = true;\\n emit Slashed(_consensusAddr, SlashType.BRIDGE_VOTING, _period);\\n _validatorContract.execSlash(_consensusAddr, 0, _bridgeVotingSlashAmount, false);\\n }\\n\\n /**\\n * @inheritdoc ISlashBridgeVoting\\n */\\n function getBridgeVotingSlashingConfigs()\\n external\\n view\\n override\\n returns (uint256 bridgeVotingThreshold_, uint256 bridgeVotingSlashAmount_)\\n {\\n return (_bridgeVotingThreshold, _bridgeVotingSlashAmount);\\n }\\n\\n /**\\n * @inheritdoc ISlashBridgeVoting\\n */\\n function setBridgeVotingSlashingConfigs(uint256 _threshold, uint256 _slashAmount) external override onlyAdmin {\\n _setBridgeVotingSlashingConfigs(_threshold, _slashAmount);\\n }\\n\\n /**\\n * @dev See `ISlashBridgeVoting-setBridgeVotingSlashingConfigs`.\\n */\\n function _setBridgeVotingSlashingConfigs(uint256 _threshold, uint256 _slashAmount) internal {\\n _bridgeVotingThreshold = _threshold;\\n _bridgeVotingSlashAmount = _slashAmount;\\n emit BridgeVotingSlashingConfigsUpdated(_threshold, _slashAmount);\\n }\\n}\\n\",\"keccak256\":\"0x492254027f64267a46996ed12866a57745815042af0d2373343c270c930f69b4\",\"license\":\"MIT\"},\"contracts/ronin/slash-indicator/SlashDoubleSign.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"../../interfaces/slash-indicator/ISlashDoubleSign.sol\\\";\\nimport \\\"../../interfaces/validator/IRoninValidatorSet.sol\\\";\\nimport \\\"../../precompile-usages/PCUValidateDoubleSign.sol\\\";\\nimport \\\"../../extensions/collections/HasContracts.sol\\\";\\nimport { HasValidatorDeprecated } from \\\"../../utils/DeprecatedSlots.sol\\\";\\n\\nabstract contract SlashDoubleSign is ISlashDoubleSign, HasContracts, HasValidatorDeprecated, PCUValidateDoubleSign {\\n /// @dev The amount of RON to slash double sign.\\n uint256 internal _slashDoubleSignAmount;\\n /// @dev The block number that the punished validator will be jailed until, due to double signing.\\n uint256 internal _doubleSigningJailUntilBlock;\\n /** @dev The offset from the submitted block to the current block, from which double signing will be invalidated.\\n * This parameter is exposed for system transaction.\\n **/\\n uint256 internal _doubleSigningOffsetLimitBlock;\\n /// @dev Recording of submitted proof to prevent relay attack.\\n mapping(bytes32 => bool) _submittedEvidence;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n */\\n uint256[48] private ______gap;\\n\\n /**\\n * @inheritdoc ISlashDoubleSign\\n */\\n function slashDoubleSign(\\n address _consensusAddr,\\n bytes calldata _header1,\\n bytes calldata _header2\\n ) external override onlyAdmin {\\n bytes32 _header1Checksum = keccak256(_header1);\\n bytes32 _header2Checksum = keccak256(_header2);\\n\\n if (_submittedEvidence[_header1Checksum] || _submittedEvidence[_header2Checksum]) {\\n revert ErrEvidenceAlreadySubmitted();\\n }\\n\\n if (_pcValidateEvidence(_consensusAddr, _header1, _header2)) {\\n IRoninValidatorSet _validatorContract = IRoninValidatorSet(getContract(ContractType.VALIDATOR));\\n uint256 _period = _validatorContract.currentPeriod();\\n _submittedEvidence[_header1Checksum] = true;\\n _submittedEvidence[_header2Checksum] = true;\\n emit Slashed(_consensusAddr, SlashType.DOUBLE_SIGNING, _period);\\n _validatorContract.execSlash(_consensusAddr, _doubleSigningJailUntilBlock, _slashDoubleSignAmount, true);\\n }\\n }\\n\\n /**\\n * @inheritdoc ISlashDoubleSign\\n */\\n function getDoubleSignSlashingConfigs()\\n external\\n view\\n override\\n returns (\\n uint256 slashDoubleSignAmount_,\\n uint256 doubleSigningJailUntilBlock_,\\n uint256 doubleSigningOffsetLimitBlock_\\n )\\n {\\n return (_slashDoubleSignAmount, _doubleSigningJailUntilBlock, _doubleSigningOffsetLimitBlock);\\n }\\n\\n /**\\n * @inheritdoc ISlashDoubleSign\\n */\\n function setDoubleSignSlashingConfigs(\\n uint256 _slashAmount,\\n uint256 _jailUntilBlock,\\n uint256 _offsetLimitBlock\\n ) external override onlyAdmin {\\n _setDoubleSignSlashingConfigs(_slashAmount, _jailUntilBlock, _offsetLimitBlock);\\n }\\n\\n /**\\n * @dev See `ISlashDoubleSign-setDoubleSignSlashingConfigs`.\\n */\\n function _setDoubleSignSlashingConfigs(\\n uint256 _slashAmount,\\n uint256 _jailUntilBlock,\\n uint256 _offsetLimitBlock\\n ) internal {\\n _slashDoubleSignAmount = _slashAmount;\\n _doubleSigningJailUntilBlock = _jailUntilBlock;\\n _doubleSigningOffsetLimitBlock = _offsetLimitBlock;\\n emit DoubleSignSlashingConfigsUpdated(_slashAmount, _jailUntilBlock, _doubleSigningOffsetLimitBlock);\\n }\\n\\n /**\\n * @dev Returns whether the account `_addr` should be slashed or not.\\n */\\n function _shouldSlash(address _addr) internal view virtual returns (bool);\\n}\\n\",\"keccak256\":\"0x23e9c36b9fcd202323bd5b37753f577566077ad95f0275a5104f0c48fccee138\",\"license\":\"MIT\"},\"contracts/ronin/slash-indicator/SlashIndicator.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/proxy/utils/Initializable.sol\\\";\\nimport \\\"../../interfaces/slash-indicator/ISlashIndicator.sol\\\";\\nimport \\\"../../interfaces/validator/IRoninValidatorSet.sol\\\";\\nimport \\\"../../interfaces/IMaintenance.sol\\\";\\nimport \\\"./SlashDoubleSign.sol\\\";\\nimport \\\"./SlashBridgeVoting.sol\\\";\\nimport \\\"./SlashBridgeOperator.sol\\\";\\nimport \\\"./SlashUnavailability.sol\\\";\\nimport \\\"./CreditScore.sol\\\";\\n\\ncontract SlashIndicator is\\n ISlashIndicator,\\n SlashDoubleSign,\\n SlashBridgeVoting,\\n SlashBridgeOperator,\\n SlashUnavailability,\\n CreditScore,\\n Initializable\\n{\\n constructor() {\\n _disableInitializers();\\n }\\n\\n /**\\n * @dev Initializes the contract storage.\\n */\\n function initialize(\\n address __validatorContract,\\n address __maintenanceContract,\\n address __roninTrustedOrganizationContract,\\n address __roninGovernanceAdminContract,\\n // _bridgeOperatorSlashingConfigs[0]: _missingVotesRatioTier1\\n // _bridgeOperatorSlashingConfigs[1]: _missingVotesRatioTier2\\n // _bridgeOperatorSlashingConfigs[2]: _jailDurationForMissingVotesRatioTier2\\n // _bridgeOperatorSlashingConfigs[3]: _skipBridgeOperatorSlashingThreshold\\n uint256[4] calldata _bridgeOperatorSlashingConfigs,\\n // _bridgeVotingSlashingConfigs[0]: _bridgeVotingThreshold\\n // _bridgeVotingSlashingConfigs[1]: _bridgeVotingSlashAmount\\n uint256[2] calldata _bridgeVotingSlashingConfigs,\\n // _doubleSignSlashingConfigs[0]: _slashDoubleSignAmount\\n // _doubleSignSlashingConfigs[1]: _doubleSigningJailUntilBlock\\n // _doubleSignSlashingConfigs[2]: _doubleSigningOffsetLimitBlock\\n uint256[3] calldata _doubleSignSlashingConfigs,\\n // _unavailabilitySlashingConfigs[0]: _unavailabilityTier1Threshold\\n // _unavailabilitySlashingConfigs[1]: _unavailabilityTier2Threshold\\n // _unavailabilitySlashingConfigs[2]: _slashAmountForUnavailabilityTier2Threshold\\n // _unavailabilitySlashingConfigs[3]: _jailDurationForUnavailabilityTier2Threshold\\n uint256[4] calldata _unavailabilitySlashingConfigs,\\n // _creditScoreConfigs[0]: _gainCreditScore\\n // _creditScoreConfigs[1]: _maxCreditScore\\n // _creditScoreConfigs[2]: _bailOutCostMultiplier\\n // _creditScoreConfigs[3]: _cutOffPercentageAfterBailout\\n uint256[4] calldata _creditScoreConfigs\\n ) external initializer {\\n _setContract(ContractType.VALIDATOR, __validatorContract);\\n _setContract(ContractType.MAINTENANCE, __maintenanceContract);\\n _setContract(ContractType.GOVERNANCE_ADMIN, __roninGovernanceAdminContract);\\n _setContract(ContractType.RONIN_TRUSTED_ORGANIZATION, __roninTrustedOrganizationContract);\\n\\n _setBridgeOperatorSlashingConfigs(\\n _bridgeOperatorSlashingConfigs[0],\\n _bridgeOperatorSlashingConfigs[1],\\n _bridgeOperatorSlashingConfigs[2],\\n _bridgeOperatorSlashingConfigs[3]\\n );\\n _setBridgeVotingSlashingConfigs(_bridgeVotingSlashingConfigs[0], _bridgeVotingSlashingConfigs[1]);\\n _setDoubleSignSlashingConfigs(\\n _doubleSignSlashingConfigs[0],\\n _doubleSignSlashingConfigs[1],\\n _doubleSignSlashingConfigs[2]\\n );\\n _setUnavailabilitySlashingConfigs(\\n _unavailabilitySlashingConfigs[0],\\n _unavailabilitySlashingConfigs[1],\\n _unavailabilitySlashingConfigs[2],\\n _unavailabilitySlashingConfigs[3]\\n );\\n _setCreditScoreConfigs(\\n _creditScoreConfigs[0],\\n _creditScoreConfigs[1],\\n _creditScoreConfigs[2],\\n _creditScoreConfigs[3]\\n );\\n }\\n\\n function initializeV2(address roninGovernanceAdminContract) external reinitializer(2) {\\n _setContract(ContractType.VALIDATOR, ______deprecatedValidator);\\n _setContract(ContractType.MAINTENANCE, ______deprecatedMaintenance);\\n _setContract(ContractType.GOVERNANCE_ADMIN, roninGovernanceAdminContract);\\n _setContract(ContractType.RONIN_TRUSTED_ORGANIZATION, ______deprecatedTrustedOrg);\\n\\n delete ______deprecatedValidator;\\n delete ______deprecatedMaintenance;\\n delete ______deprecatedTrustedOrg;\\n delete ______deprecatedGovernanceAdmin;\\n }\\n\\n /**\\n * @dev Helper for CreditScore contract to reset the indicator of the validator after bailing out.\\n */\\n function _setUnavailabilityIndicator(\\n address _validator,\\n uint256 _period,\\n uint256 _indicator\\n ) internal override(CreditScore, SlashUnavailability) {\\n SlashUnavailability._setUnavailabilityIndicator(_validator, _period, _indicator);\\n }\\n\\n /**\\n * @dev Helper for CreditScore contract to query indicator of the validator.\\n */\\n function getUnavailabilityIndicator(\\n address _validator,\\n uint256 _period\\n ) public view override(CreditScore, ISlashUnavailability, SlashUnavailability) returns (uint256) {\\n return SlashUnavailability.getUnavailabilityIndicator(_validator, _period);\\n }\\n\\n /**\\n * @inheritdoc ICreditScore\\n */\\n function checkBailedOutAtPeriod(\\n address _validator,\\n uint256 _period\\n ) public view override(CreditScore, ICreditScore, SlashUnavailability) returns (bool) {\\n return CreditScore.checkBailedOutAtPeriod(_validator, _period);\\n }\\n\\n /**\\n * @dev Sanity check the address to be slashed\\n */\\n function _shouldSlash(address _addr) internal view override(SlashDoubleSign, SlashUnavailability) returns (bool) {\\n return\\n (msg.sender != _addr) &&\\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).isBlockProducer(_addr) &&\\n !IMaintenance(getContract(ContractType.MAINTENANCE)).checkMaintained(_addr, block.number);\\n }\\n}\\n\",\"keccak256\":\"0x0fa6ad414af5eddfa7125e8963aee9236c2500fc2b85524b9dbe0817edab5310\",\"license\":\"MIT\"},\"contracts/ronin/slash-indicator/SlashUnavailability.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./CreditScore.sol\\\";\\nimport \\\"../../interfaces/validator/IRoninValidatorSet.sol\\\";\\nimport \\\"../../interfaces/slash-indicator/ISlashUnavailability.sol\\\";\\nimport \\\"../../extensions/collections/HasContracts.sol\\\";\\nimport { HasValidatorDeprecated } from \\\"../../utils/DeprecatedSlots.sol\\\";\\nimport { ErrInvalidThreshold } from \\\"../../utils/CommonErrors.sol\\\";\\n\\nabstract contract SlashUnavailability is ISlashUnavailability, HasContracts, HasValidatorDeprecated {\\n /// @dev The last block that a validator is slashed for unavailability.\\n uint256 public lastUnavailabilitySlashedBlock;\\n /// @dev Mapping from validator address => period index => unavailability indicator.\\n mapping(address => mapping(uint256 => uint256)) internal _unavailabilityIndicator;\\n\\n /**\\n * @dev The mining reward will be deprecated, if (s)he missed more than this threshold.\\n * This threshold is applied for tier-1 and tier-3 of unavailability slash.\\n */\\n uint256 internal _unavailabilityTier1Threshold;\\n /**\\n * @dev The mining reward will be deprecated, (s)he will be put in jailed, and will be deducted\\n * self-staking if (s)he misses more than this threshold. This threshold is applied for tier-2 slash.\\n */\\n uint256 internal _unavailabilityTier2Threshold;\\n /**\\n * @dev The amount of RON to deduct from self-staking of a block producer when (s)he is slashed with\\n * tier-2 or tier-3.\\n **/\\n uint256 internal _slashAmountForUnavailabilityTier2Threshold;\\n /// @dev The number of blocks to jail a block producer when (s)he is slashed with tier-2 or tier-3.\\n uint256 internal _jailDurationForUnavailabilityTier2Threshold;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n */\\n uint256[50] private ______gap;\\n\\n modifier oncePerBlock() {\\n if (block.number <= lastUnavailabilitySlashedBlock) {\\n revert ErrCannotSlashAValidatorTwiceOrSlashMoreThanOneValidatorInOneBlock();\\n }\\n\\n lastUnavailabilitySlashedBlock = block.number;\\n _;\\n }\\n\\n /**\\n * @inheritdoc ISlashUnavailability\\n */\\n function slashUnavailability(address _validatorAddr) external override oncePerBlock {\\n if (msg.sender != block.coinbase) revert ErrUnauthorized(msg.sig, RoleAccess.COINBASE);\\n\\n if (!_shouldSlash(_validatorAddr)) {\\n // Should return instead of throwing error since this is a part of system transaction.\\n return;\\n }\\n\\n IRoninValidatorSet _validatorContract = IRoninValidatorSet(getContract(ContractType.VALIDATOR));\\n uint256 _period = _validatorContract.currentPeriod();\\n uint256 _count;\\n unchecked {\\n _count = ++_unavailabilityIndicator[_validatorAddr][_period];\\n }\\n uint256 _newJailedUntilBlock = Math.addIfNonZero(block.number, _jailDurationForUnavailabilityTier2Threshold);\\n\\n if (_count == _unavailabilityTier2Threshold) {\\n emit Slashed(_validatorAddr, SlashType.UNAVAILABILITY_TIER_2, _period);\\n _validatorContract.execSlash(\\n _validatorAddr,\\n _newJailedUntilBlock,\\n _slashAmountForUnavailabilityTier2Threshold,\\n false\\n );\\n } else if (_count == _unavailabilityTier1Threshold) {\\n bool _tier1SecondTime = checkBailedOutAtPeriod(_validatorAddr, _period);\\n if (!_tier1SecondTime) {\\n emit Slashed(_validatorAddr, SlashType.UNAVAILABILITY_TIER_1, _period);\\n _validatorContract.execSlash(_validatorAddr, 0, 0, false);\\n } else {\\n /// Handles tier-3\\n emit Slashed(_validatorAddr, SlashType.UNAVAILABILITY_TIER_3, _period);\\n _validatorContract.execSlash(\\n _validatorAddr,\\n _newJailedUntilBlock,\\n _slashAmountForUnavailabilityTier2Threshold,\\n true\\n );\\n }\\n }\\n }\\n\\n /**\\n * @inheritdoc ISlashUnavailability\\n */\\n function setUnavailabilitySlashingConfigs(\\n uint256 _tier1Threshold,\\n uint256 _tier2Threshold,\\n uint256 _slashAmountForTier2Threshold,\\n uint256 _jailDurationForTier2Threshold\\n ) external override onlyAdmin {\\n _setUnavailabilitySlashingConfigs(\\n _tier1Threshold,\\n _tier2Threshold,\\n _slashAmountForTier2Threshold,\\n _jailDurationForTier2Threshold\\n );\\n }\\n\\n /**\\n * @inheritdoc ISlashUnavailability\\n */\\n function getUnavailabilitySlashingConfigs()\\n external\\n view\\n override\\n returns (\\n uint256 unavailabilityTier1Threshold_,\\n uint256 unavailabilityTier2Threshold_,\\n uint256 slashAmountForUnavailabilityTier2Threshold_,\\n uint256 jailDurationForUnavailabilityTier2Threshold_\\n )\\n {\\n return (\\n _unavailabilityTier1Threshold,\\n _unavailabilityTier2Threshold,\\n _slashAmountForUnavailabilityTier2Threshold,\\n _jailDurationForUnavailabilityTier2Threshold\\n );\\n }\\n\\n /**\\n * @inheritdoc ISlashUnavailability\\n */\\n function currentUnavailabilityIndicator(address _validator) external view override returns (uint256) {\\n return\\n getUnavailabilityIndicator(_validator, IRoninValidatorSet(getContract(ContractType.VALIDATOR)).currentPeriod());\\n }\\n\\n /**\\n * @inheritdoc ISlashUnavailability\\n */\\n function getUnavailabilityIndicator(\\n address _validator,\\n uint256 _period\\n ) public view virtual override returns (uint256) {\\n return _unavailabilityIndicator[_validator][_period];\\n }\\n\\n /**\\n * @dev Sets the unavailability indicator of the `_validator` at `_period`.\\n */\\n function _setUnavailabilityIndicator(address _validator, uint256 _period, uint256 _indicator) internal virtual {\\n _unavailabilityIndicator[_validator][_period] = _indicator;\\n }\\n\\n /**\\n * @dev See `ISlashUnavailability-setUnavailabilitySlashingConfigs`.\\n */\\n function _setUnavailabilitySlashingConfigs(\\n uint256 _tier1Threshold,\\n uint256 _tier2Threshold,\\n uint256 _slashAmountForTier2Threshold,\\n uint256 _jailDurationForTier2Threshold\\n ) internal {\\n if (_unavailabilityTier1Threshold > _unavailabilityTier2Threshold) revert ErrInvalidThreshold(msg.sig);\\n\\n _unavailabilityTier1Threshold = _tier1Threshold;\\n _unavailabilityTier2Threshold = _tier2Threshold;\\n _slashAmountForUnavailabilityTier2Threshold = _slashAmountForTier2Threshold;\\n _jailDurationForUnavailabilityTier2Threshold = _jailDurationForTier2Threshold;\\n emit UnavailabilitySlashingConfigsUpdated(\\n _tier1Threshold,\\n _tier2Threshold,\\n _slashAmountForTier2Threshold,\\n _jailDurationForTier2Threshold\\n );\\n }\\n\\n /**\\n * @dev Returns whether the account `_addr` should be slashed or not.\\n */\\n function _shouldSlash(address _addr) internal view virtual returns (bool);\\n\\n /**\\n * @dev See `ICreditScore-checkBailedOutAtPeriod`\\n */\\n function checkBailedOutAtPeriod(address _validator, uint256 _period) public view virtual returns (bool);\\n}\\n\",\"keccak256\":\"0x77e1f62b033c810f9847fefeca1b7b4e3cf7b5dd754928fd765da57512a29b4d\",\"license\":\"MIT\"},\"contracts/utils/CommonErrors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { ContractType } from \\\"./ContractType.sol\\\";\\nimport { RoleAccess } from \\\"./RoleAccess.sol\\\";\\n\\n/**\\n * @dev Error indicating that the provided threshold is invalid for a specific function signature.\\n * @param msgSig The function signature (bytes4) that the invalid threshold applies to.\\n */\\nerror ErrInvalidThreshold(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a function can only be called by the contract itself.\\n * @param msgSig The function signature (bytes4) that can only be called by the contract itself.\\n */\\nerror ErrOnlySelfCall(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\\n * @param msgSig The function signature (bytes4) that the caller is unauthorized to perform.\\n * @param expectedRole The role required to perform the function.\\n */\\nerror ErrUnauthorized(bytes4 msgSig, RoleAccess expectedRole);\\n\\n/**\\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\\n * @param msgSig The function signature (bytes4).\\n * @param expectedContractType The contract type required to perform the function.\\n * @param actual The actual address that called to the function.\\n */\\nerror ErrUnexpectedInternalCall(bytes4 msgSig, ContractType expectedContractType, address actual);\\n\\n/**\\n * @dev Error indicating that an array is empty when it should contain elements.\\n */\\nerror ErrEmptyArray();\\n\\n/**\\n * @dev Error indicating a mismatch in the length of input parameters or arrays for a specific function.\\n * @param msgSig The function signature (bytes4) that has a length mismatch.\\n */\\nerror ErrLengthMismatch(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a proxy call to an external contract has failed.\\n * @param msgSig The function signature (bytes4) of the proxy call that failed.\\n * @param extCallSig The function signature (bytes4) of the external contract call that failed.\\n */\\nerror ErrProxyCallFailed(bytes4 msgSig, bytes4 extCallSig);\\n\\n/**\\n * @dev Error indicating that a function tried to call a precompiled contract that is not allowed.\\n * @param msgSig The function signature (bytes4) that attempted to call a precompiled contract.\\n */\\nerror ErrCallPrecompiled(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a native token transfer has failed.\\n * @param msgSig The function signature (bytes4) of the token transfer that failed.\\n */\\nerror ErrNativeTransferFailed(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that an order is invalid.\\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid order.\\n */\\nerror ErrInvalidOrder(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that the chain ID is invalid.\\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid chain ID.\\n * @param actual Current chain ID that executing function.\\n * @param expected Expected chain ID required for the tx to success.\\n */\\nerror ErrInvalidChainId(bytes4 msgSig, uint256 actual, uint256 expected);\\n\\n/**\\n * @dev Error indicating that a vote type is not supported.\\n * @param msgSig The function signature (bytes4) of the operation that encountered an unsupported vote type.\\n */\\nerror ErrUnsupportedVoteType(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that the proposal nonce is invalid.\\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid proposal nonce.\\n */\\nerror ErrInvalidProposalNonce(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a voter has already voted.\\n * @param voter The address of the voter who has already voted.\\n */\\nerror ErrAlreadyVoted(address voter);\\n\\n/**\\n * @dev Error indicating that a signature is invalid for a specific function signature.\\n * @param msgSig The function signature (bytes4) that encountered an invalid signature.\\n */\\nerror ErrInvalidSignatures(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a relay call has failed.\\n * @param msgSig The function signature (bytes4) of the relay call that failed.\\n */\\nerror ErrRelayFailed(bytes4 msgSig);\\n/**\\n * @dev Error indicating that a vote weight is invalid for a specific function signature.\\n * @param msgSig The function signature (bytes4) that encountered an invalid vote weight.\\n */\\nerror ErrInvalidVoteWeight(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a query was made for an outdated bridge operator set.\\n */\\nerror ErrQueryForOutdatedBridgeOperatorSet();\\n\\n/**\\n * @dev Error indicating that a request is invalid.\\n */\\nerror ErrInvalidRequest();\\n\\n/**\\n * @dev Error indicating that a token standard is invalid.\\n */\\nerror ErrInvalidTokenStandard();\\n\\n/**\\n * @dev Error indicating that a token is not supported.\\n */\\nerror ErrUnsupportedToken();\\n\\n/**\\n * @dev Error indicating that a receipt kind is invalid.\\n */\\nerror ErrInvalidReceiptKind();\\n\\n/**\\n * @dev Error indicating that a receipt is invalid.\\n */\\nerror ErrInvalidReceipt();\\n\",\"keccak256\":\"0xe0c75a4a82f3dc7dcf89dd5cab9ae1ec93c136b7d8210b3f9e18f3215aa69ffb\",\"license\":\"MIT\"},\"contracts/utils/ContractType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum ContractType {\\n /* 0 */ UNKNOWN,\\n /* 1 */ PAUSE_ENFORCER,\\n /* 2 */ BRIDGE,\\n /* 3 */ BRIDGE_TRACKING,\\n /* 4 */ GOVERNANCE_ADMIN,\\n /* 5 */ MAINTENANCE,\\n /* 6 */ SLASH_INDICATOR,\\n /* 7 */ STAKING_VESTING,\\n /* 8 */ VALIDATOR,\\n /* 9 */ STAKING,\\n /* 10 */ RONIN_TRUSTED_ORGANIZATION\\n}\\n\",\"keccak256\":\"0x65a0b062c8f963b4679a128abb3840167de1b10b32a8528787f47915a7d9ccc3\",\"license\":\"MIT\"},\"contracts/utils/DeprecatedSlots.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title Deprecated Contracts\\n * @dev These abstract contracts are deprecated and should not be used in new implementations.\\n * They provide functionality related to various aspects of a smart contract but have been marked\\n * as deprecated to indicate that they are no longer actively maintained or recommended for use.\\n * The purpose of these contracts is to preserve the slots for already deployed contracts.\\n */\\ncontract HasSlashIndicatorDeprecated {\\n /// @custom:deprecated Previously `_slashIndicatorContract` (non-zero value)\\n address internal ______deprecatedSlashIndicator;\\n}\\n\\ncontract HasStakingVestingDeprecated {\\n /// @custom:deprecated Previously `_stakingVestingContract` (non-zero value)\\n address internal ______deprecatedStakingVesting;\\n}\\n\\ncontract HasBridgeDeprecated {\\n /// @custom:deprecated Previously `_bridgeContract` (non-zero value)\\n address internal ______deprecatedBridge;\\n}\\n\\ncontract HasValidatorDeprecated {\\n /// @custom:deprecated Previously `_validatorContract` (non-zero value)\\n address internal ______deprecatedValidator;\\n}\\n\\ncontract HasStakingDeprecated {\\n /// @custom:deprecated Previously `_stakingContract` (non-zero value)\\n address internal ______deprecatedStakingContract;\\n}\\n\\ncontract HasMaintenanceDeprecated {\\n /// @custom:deprecated Previously `_maintenanceContract` (non-zero value)\\n address internal ______deprecatedMaintenance;\\n}\\n\\ncontract HasTrustedOrgDeprecated {\\n /// @custom:deprecated Previously `_trustedOrgContract` (non-zero value)\\n address internal ______deprecatedTrustedOrg;\\n}\\n\\ncontract HasGovernanceAdminDeprecated {\\n /// @custom:deprecated Previously `_governanceAdminContract` (non-zero value)\\n address internal ______deprecatedGovernanceAdmin;\\n}\\n\\ncontract HasBridgeTrackingDeprecated {\\n /// @custom:deprecated Previously `_bridgeTrackingContract` (non-zero value)\\n address internal ______deprecatedBridgeTracking;\\n}\\n\",\"keccak256\":\"0xe93504aed9f67a6d399475c7162560f2ac4f793fab5b67fe504fc694ac9a2892\",\"license\":\"MIT\"},\"contracts/utils/RoleAccess.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum RoleAccess {\\n /* 0 */ UNKNOWN,\\n /* 1 */ ADMIN,\\n /* 2 */ COINBASE,\\n /* 3 */ GOVERNOR,\\n /* 4 */ CANDIDATE_ADMIN,\\n /* 5 */ WITHDRAWAL_MIGRATOR,\\n /* 6 */ BRIDGE_OPERATOR,\\n /* 7 */ BLOCK_PRODUCER,\\n /* 8 */ VALIDATOR_CANDIDATE\\n}\\n\",\"keccak256\":\"0xb3e242a9cb967a64e0ef6419a6b260b647b40082102ce3ab899ab690c84957fe\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x60806040523480156200001157600080fd5b506200001c62000022565b620000e7565b61011354610100900460ff1615620000905760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b6101135460ff9081161015620000e557610113805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b6128f080620000f76000396000f3fe608060405234801561001057600080fd5b50600436106101c45760003560e01c806399103f7b116100f9578063d1f992f711610097578063df4b6ee011610071578063df4b6ee0146103f2578063f1001e7814610416578063f562b3c414610436578063fd422cd01461043f57600080fd5b8063d1f992f7146103a3578063d3dd2bdf146103b6578063de981f1b146103df57600080fd5b8063c6391fa2116100d3578063c6391fa214610359578063ccbb72ed1461036a578063cf39d13c1461037d578063d1737e271461039057600080fd5b806399103f7b14610318578063c008ce391461032b578063c2e524dc1461033e57600080fd5b806329ddc3c0116101665780637680850c116101405780637680850c146102c45780637c2b55a0146102d7578063853af1b7146102f2578063865e6fd31461030557600080fd5b806329ddc3c01461027d5780633d48fd7d146102a057806362ffe6cb146102b157600080fd5b80631079402a116101a25780631079402a146102175780631a697341146102445780631e90b2a01461025757806329b6eca91461026a57600080fd5b806307c2d2f6146101c9578063082e7420146101de5780630e1512ac14610204575b600080fd5b6101dc6101d7366004612030565b610452565b005b6101f16101ec366004612087565b610560565b6040519081526020015b60405180910390f35b6101dc6102123660046120a4565b6105d7565b606d54606e54606f546070545b6040805194855260208501939093529183015260608201526080016101fb565b6101dc610252366004612087565b6105f1565b6101dc610265366004612118565b610892565b6101dc610278366004612087565b610a7a565b61029061028b36600461219b565b610b9e565b60405190151581526020016101fb565b60a55460a65460a75460a854610224565b6101f16102bf36600461219b565b610bcd565b6101dc6102d23660046121c7565b610bf6565b60675b6040516001600160a01b0390911681526020016101fb565b6101dc610300366004612213565b610f0d565b6101dc610313366004612244565b610f23565b6101dc61032636600461228c565b610f3e565b6101dc610339366004612350565b6110a9565b603854603954604080519283526020830191909152016101fb565b60dd5460de5460df5460e054610224565b6101dc6103783660046120a4565b611133565b6101dc61038b366004612385565b611147565b6101dc61039e3660046120a4565b61115f565b6101dc6103b1366004612087565b611173565b6101f16103c4366004612087565b6001600160a01b0316600090815260dc602052604090205490565b6102da6103ed3660046123b1565b611562565b600154600254600354604080519384526020840192909252908201526060016101fb565b610429610424366004612030565b6115dd565b6040516101fb9190612407565b6101f160a35481565b6101dc61044d366004612087565b6116a8565b600861045d816119bc565b60008267ffffffffffffffff8111156104785761047861241a565b6040519080825280602002602001820160405280156104a1578160200160208202803683370190505b50905060005b8381101561051e5760008585838181106104c3576104c3612430565b90506020020160208101906104d89190612087565b6001600160a01b038116600090815260dc6020526040812055835190915083908390811061050857610508612430565b60006020918202929092010152506001016104a7565b507f8c02b2ccee964dc50649a48bd0a0446f0f9e88ecdb72d099f4ace07c39c2348084848360405161055293929190612484565b60405180910390a150505050565b60006105d1826105706008611562565b6001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa1580156105ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102bf91906124b4565b92915050565b6105df611a08565b6105eb84848484611a64565b50505050565b6105f9611a08565b6000610605600a611562565b604051636db349d160e11b81526001600160a01b038481166004830152919091169063db6693a29060240160a060405180830381865afa15801561064d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067191906124fe565b905060006106fb6106826004611562565b6040808501519051632623bd4f60e21b81526001600160a01b03918216600482015291169063988ef53c90602401602060405180830381865afa1580156106cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f191906124b4565b8360800151611af6565b905060006107096008611562565b90506000816001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa15801561074b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076f91906124b4565b60385490915061077f844361259c565b1115806107af57506001600160a01b038516600090815260376020908152604080832084845290915290205460ff165b156107cd57604051632e308a0b60e11b815260040160405180910390fd5b6001600160a01b038516600081815260376020908152604080832085845290915290819020805460ff19166001179055516000805160206128c48339815191529061081c9060049085906125c5565b60405180910390a2603954604051630bde081360e21b81526001600160a01b03841691632f78204c916108599189916000919082906004016125e3565b600060405180830381600087803b15801561087357600080fd5b505af1158015610887573d6000803e3d6000fd5b505050505050505050565b61089a611a08565b600084846040516108ac92919061260b565b60405180910390209050600083836040516108c892919061260b565b604080519182900390912060008481526004602052919091205490915060ff1680610901575060008181526004602052604090205460ff165b1561091f5760405163f27b8ec960e01b815260040160405180910390fd5b61092c8787878787611b0d565b15610a7157600061093d6008611562565b90506000816001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa15801561097f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a391906124b4565b6000858152600460205260408082208054600160ff19918216811790925587845292829020805490931617909155519091506001600160a01b038a16906000805160206128c4833981519152906109fe9060039085906125c5565b60405180910390a260025460018054604051630bde081360e21b81526001600160a01b03861693632f78204c93610a3c938f939091906004016125e3565b600060405180830381600087803b158015610a5657600080fd5b505af1158015610a6a573d6000803e3d6000fd5b5050505050505b50505050505050565b61011354600290610100900460ff16158015610a9e57506101135460ff8083169116105b610ac35760405162461bcd60e51b8152600401610aba9061261b565b60405180910390fd5b610113805461ffff191660ff831617610100179055600054610af0906008906001600160a01b0316611bb7565b606c54610b08906005906001600160a01b0316611bb7565b610b13600483611bb7565b603554610b2b90600a906001600160a01b0316611bb7565b600080546001600160a01b0319908116909155606c8054821690556035805482169055603680549091169055610113805461ff001916905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15050565b6001600160a01b038216600090815260db6020908152604080832084845290915281205460ff165b9392505050565b6001600160a01b038216600090815260a460209081526040808320848452909152812054610bc6565b6008610c01816119bc565b60003390506000816001600160a01b031663297a8fca6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c46573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c6a91906124b4565b90506000826001600160a01b0316634de2b73588886040518363ffffffff1660e01b8152600401610c9c929190612669565b600060405180830381865afa158015610cb9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ce1919081019061268d565b90506000610cef6005611562565b6001600160a01b031663ba303755898986436040518563ffffffff1660e01b8152600401610d20949392919061273a565b600060405180830381865afa158015610d3d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d65919081019061268d565b905060008767ffffffffffffffff811115610d8257610d8261241a565b604051908082528060200260200182016040528015610dab578160200160208202803683370190505b50905060005b88811015610ec65760008a8a83818110610dcd57610dcd612430565b9050602002016020810190610de29190612087565b90506000610df0828b610bcd565b90506000868481518110610e0657610e06612430565b602002602001015190506000868581518110610e2457610e24612430565b6020026020010151905060008280610e395750815b610e4e57610e4960dd5485611c5b565b610e51565b60005b6001600160a01b038616600090815260dc602052604090205460de54919250610e7b918390611c75565b6001600160a01b038616600090815260dc602052604090208190558751889088908110610eaa57610eaa612430565b6020026020010181815250508560010195505050505050610db1565b507f8c02b2ccee964dc50649a48bd0a0446f0f9e88ecdb72d099f4ace07c39c23480898983604051610efa93929190612484565b60405180910390a1505050505050505050565b610f15611a08565b610f1f8282611c92565b5050565b610f2b611a08565b610f3481611cd2565b610f1f8282611bb7565b61011354610100900460ff1615808015610f60575061011354600160ff909116105b80610f7b5750303b158015610f7b57506101135460ff166001145b610f975760405162461bcd60e51b8152600401610aba9061261b565b610113805460ff191660011790558015610fbc57610113805461ff0019166101001790555b610fc760088b611bb7565b610fd260058a611bb7565b610fdd600488611bb7565b610fe8600a89611bb7565b61100186356020880135604089013560608a0135611a64565b61101085356020870135611c92565b611024843560208601356040870135611d08565b61103d8335602085013560408601356060870135611d5d565b6110568235602084013560408501356060860135611de9565b801561109d57610113805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050505050565b60086110b4816119bc565b826001036110f357836001600160a01b03166000805160206128c48339815191526005846040516110e69291906125c5565b60405180910390a26105eb565b826002036105eb57836001600160a01b03166000805160206128c48339815191526006846040516111259291906125c5565b60405180910390a250505050565b61113b611a08565b6105eb84848484611de9565b61114f611a08565b61115a838383611d08565b505050565b611167611a08565b6105eb84848484611d5d565b600061117f6008611562565b604051635061f96960e11b81526001600160a01b0384811660048301529192509082169063a0c3f2d290602401602060405180830381865afa1580156111c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ed9190612761565b61121a576000356001600160e01b0319166008604051620f948f60ea1b8152600401610aba92919061277c565b6040516304d971ab60e01b81526001600160a01b0383811660048301523360248301528216906304d971ab90604401602060405180830381865afa158015611266573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061128a9190612761565b6112b7576000356001600160e01b0319166004604051620f948f60ea1b8152600401610aba92919061277c565b604051634b2c2fe160e11b81526001600160a01b03838116600483015260009182918416906396585fc290602401606060405180830381865afa158015611302573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132691906127aa565b92505091508161134957604051636cd31b5960e01b815260040160405180910390fd5b6000836001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa158015611389573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ad91906124b4565b6001600160a01b038616600090815260db6020908152604080832084845290915290205490915060ff16156113f557604051637674d6a960e01b815260040160405180910390fd5b6001600160a01b038516600090815260dc602052604081205460df5490919061141e90856127df565b9050808210156114415760405163462e593760e11b815260040160405180910390fd5b604051630adaf5ef60e11b81526001600160a01b038881166004830152602482018590528716906315b5ebde90604401600060405180830381600087803b15801561148b57600080fd5b505af115801561149f573d6000803e3d6000fd5b505050506001600160a01b038716600090815260dc6020526040812080548392906114cb90849061259c565b90915550506001600160a01b038716600090815260a4602090815260408083208684529091528120556001600160a01b038716600081815260db60209081526040808320878452825291829020805460ff1916600117905581518681529081018490527f7ff9f7032d565c7e8919332964b2faa33c320b53604a65d9dd1f8112e12cd39d910160405180910390a250505050505050565b60007fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb600083600a811115611599576115996125af565b60ff1681526020810191909152604001600020546001600160a01b03169050806115d8578160405163409140df60e11b8152600401610aba919061280a565b919050565b60608167ffffffffffffffff8111156115f8576115f861241a565b604051908082528060200260200182016040528015611621578160200160208202803683370190505b50905060005b81518110156116a15760dc600085858481811061164657611646612430565b905060200201602081019061165b9190612087565b6001600160a01b03166001600160a01b031681526020019081526020016000205482828151811061168e5761168e612430565b6020908102919091010152600101611627565b5092915050565b60a35443116116ca5760405163557fd09160e01b815260040160405180910390fd5b4360a3553341146116fe576000356001600160e01b0319166002604051620f948f60ea1b8152600401610aba92919061277c565b61170781611e86565b156119b95760006117186008611562565b90506000816001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa15801561175a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061177e91906124b4565b6001600160a01b038416600090815260a460209081526040808320848452909152812080546001019081905560a854929350916117bc904390611f9c565b905060a654820361186557846001600160a01b03166000805160206128c48339815191526002856040516117f19291906125c5565b60405180910390a260a754604051630bde081360e21b81526001600160a01b03861691632f78204c9161182e9189918691906000906004016125e3565b600060405180830381600087803b15801561184857600080fd5b505af115801561185c573d6000803e3d6000fd5b505050506119b4565b60a55482036119b457600061187a8685610b9e565b90508061191d57856001600160a01b03166000805160206128c48339815191526001866040516118ab9291906125c5565b60405180910390a2604051630bde081360e21b81526001600160a01b03861690632f78204c906118e6908990600090819081906004016125e3565b600060405180830381600087803b15801561190057600080fd5b505af1158015611914573d6000803e3d6000fd5b505050506119b2565b856001600160a01b03166000805160206128c48339815191526007866040516119479291906125c5565b60405180910390a260a754604051630bde081360e21b81526001600160a01b03871691632f78204c91611984918a918791906001906004016125e3565b600060405180830381600087803b15801561199e57600080fd5b505af115801561109d573d6000803e3d6000fd5b505b505050505b50565b6119c581611562565b6001600160a01b0316336001600160a01b0316146119b9576000356001600160e01b03191681336040516320e0f98d60e21b8152600401610aba93929190612818565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b03163314611a62576000356001600160e01b0319166001604051620f948f60ea1b8152600401610aba92919061277c565b565b82841180611a73575061271084115b80611a7f575061271083115b15611a9d57604051631cbe1abf60e11b815260040160405180910390fd5b606d849055606e839055606f82905560708190556040805185815260208101859052908101839052606081018290527fd24c671da2227c139fe1a5b34de15e5a67bef9b46e912916b9e0d025d51b3e3b90608001610552565b600081831015611b065781610bc6565b5090919050565b6040516000906067906001908390611b31908a908a908a908a908a90602401612878565b60408051601f198184030181529190526020810180516001600160e01b0316637fc3567760e01b1790528051909150611b68611fc6565b602083016020828483895afa611b7d57600094505b503d611b8857600093505b83611ba657604051630fc2632160e01b815260040160405180910390fd5b5115159a9950505050505050505050565b807fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb600084600a811115611bed57611bed6125af565b60ff168152602081019190915260400160002080546001600160a01b0319166001600160a01b03928316179055811682600a811115611c2e57611c2e6125af565b6040517f865d1c228a8ea13709cfe61f346f7ff67f1bbd4a18ff31ad3e7147350d317c5990600090a35050565b6000818311611c6b576000610bc6565b610bc6828461259c565b6000611c8a611c8484866128b0565b83611fb7565b949350505050565b6038829055603981905560408051838152602081018390527fbda9ec2980d7468ba6a9f363696315affca9f9770016396bdea2ac39c3e5d61a9101610b92565b806001600160a01b03163b6000036119b957604051630bfc64a360e21b81526001600160a01b0382166004820152602401610aba565b60018390556002829055600381905560408051848152602081018490529081018290527f913da102149f952dde560cef3349db8e8002e9d580c41a7551d6d45329f4306b9060600160405180910390a1505050565b60a65460a5541115611d90576040516387f6f09560e01b81526001600160e01b0319600035166004820152602401610aba565b60a584905560a683905560a782905560a88190556040805185815260208101859052908101839052606081018290527f442862e6143ad95854e7c13ff4947ec6e43bc87160e3b193e7c1abaf6e3aaa9890608001610552565b82841115611e0a5760405163112af4d160e01b815260040160405180910390fd5b612710811115611e2d5760405163382c88a360e21b815260040160405180910390fd5b60dd84905560de83905560df82905560e08190556040805185815260208101859052908101839052606081018290527fe1f9c6c73554b5fa140eead3cfd4ec3e6d4824f3ed26fb25e38376f65b95470b90608001610552565b6000336001600160a01b03831614801590611f125750611ea66008611562565b604051633292276760e11b81526001600160a01b03848116600483015291909116906365244ece90602401602060405180830381865afa158015611eee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f129190612761565b80156105d15750611f236005611562565b604051630fbeb37f60e01b81526001600160a01b0384811660048301524360248301529190911690630fbeb37f90604401602060405180830381865afa158015611f71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f959190612761565b1592915050565b600081600003611fad576000610bc6565b610bc682846128b0565b6000818310611b065781610bc6565b60405180602001604052806001906020820280368337509192915050565b60008083601f840112611ff657600080fd5b50813567ffffffffffffffff81111561200e57600080fd5b6020830191508360208260051b850101111561202957600080fd5b9250929050565b6000806020838503121561204357600080fd5b823567ffffffffffffffff81111561205a57600080fd5b61206685828601611fe4565b90969095509350505050565b6001600160a01b03811681146119b957600080fd5b60006020828403121561209957600080fd5b8135610bc681612072565b600080600080608085870312156120ba57600080fd5b5050823594602084013594506040840135936060013592509050565b60008083601f8401126120e857600080fd5b50813567ffffffffffffffff81111561210057600080fd5b60208301915083602082850101111561202957600080fd5b60008060008060006060868803121561213057600080fd5b853561213b81612072565b9450602086013567ffffffffffffffff8082111561215857600080fd5b61216489838a016120d6565b9096509450604088013591508082111561217d57600080fd5b5061218a888289016120d6565b969995985093965092949392505050565b600080604083850312156121ae57600080fd5b82356121b981612072565b946020939093013593505050565b6000806000604084860312156121dc57600080fd5b833567ffffffffffffffff8111156121f357600080fd5b6121ff86828701611fe4565b909790965060209590950135949350505050565b6000806040838503121561222657600080fd5b50508035926020909101359150565b8035600b81106115d857600080fd5b6000806040838503121561225757600080fd5b61226083612235565b9150602083013561227081612072565b809150509250929050565b80608081018310156105d157600080fd5b60008060008060008060008060006102a08a8c0312156122ab57600080fd5b89356122b681612072565b985060208a01356122c681612072565b975060408a01356122d681612072565b965060608a01356122e681612072565b95506122f58b60808c0161227b565b94506101408a018b81111561230957600080fd5b6101008b0194506101a08b018c81111561232257600080fd5b81945061232f8d8261227b565b935050506123418b6102208c0161227b565b90509295985092959850929598565b60008060006060848603121561236557600080fd5b833561237081612072565b95602085013595506040909401359392505050565b60008060006060848603121561239a57600080fd5b505081359360208301359350604090920135919050565b6000602082840312156123c357600080fd5b610bc682612235565b600081518084526020808501945080840160005b838110156123fc578151875295820195908201906001016123e0565b509495945050505050565b602081526000610bc660208301846123cc565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b8183526000602080850194508260005b858110156123fc57813561246981612072565b6001600160a01b031687529582019590820190600101612456565b604081526000612498604083018587612446565b82810360208401526124aa81856123cc565b9695505050505050565b6000602082840312156124c657600080fd5b5051919050565b604051601f8201601f1916810167ffffffffffffffff811182821017156124f6576124f661241a565b604052919050565b600060a0828403121561251057600080fd5b60405160a0810181811067ffffffffffffffff821117156125335761253361241a565b604052825161254181612072565b8152602083015161255181612072565b6020820152604083015161256481612072565b6040820152606083810151908201526080928301519281019290925250919050565b634e487b7160e01b600052601160045260246000fd5b818103818111156105d1576105d1612586565b634e487b7160e01b600052602160045260246000fd5b60408101600884106125d9576125d96125af565b9281526020015290565b6001600160a01b03949094168452602084019290925260408301521515606082015260800190565b8183823760009101908152919050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b602081526000611c8a602083018486612446565b805180151581146115d857600080fd5b600060208083850312156126a057600080fd5b825167ffffffffffffffff808211156126b857600080fd5b818501915085601f8301126126cc57600080fd5b8151818111156126de576126de61241a565b8060051b91506126ef8483016124cd565b818152918301840191848101908884111561270957600080fd5b938501935b8385101561272e5761271f8561267d565b8252938501939085019061270e565b98975050505050505050565b60608152600061274e606083018688612446565b6020830194909452506040015292915050565b60006020828403121561277357600080fd5b610bc68261267d565b6001600160e01b031983168152604081016009831061279d5761279d6125af565b8260208301529392505050565b6000806000606084860312156127bf57600080fd5b6127c88461267d565b925060208401519150604084015190509250925092565b80820281158282048414176105d1576105d1612586565b600b8110612806576128066125af565b9052565b602081016105d182846127f6565b6001600160e01b0319841681526060810161283660208301856127f6565b6001600160a01b03929092166040919091015292915050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6001600160a01b038616815260606020820181905260009061289d908301868861284f565b828103604084015261272e81858761284f565b808201808211156105d1576105d161258656fe607adba66cff84b627e3537d1c17d088a98556bccd0536a2f3590c56329023d9a164736f6c6343000811000a", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101c45760003560e01c806399103f7b116100f9578063d1f992f711610097578063df4b6ee011610071578063df4b6ee0146103f2578063f1001e7814610416578063f562b3c414610436578063fd422cd01461043f57600080fd5b8063d1f992f7146103a3578063d3dd2bdf146103b6578063de981f1b146103df57600080fd5b8063c6391fa2116100d3578063c6391fa214610359578063ccbb72ed1461036a578063cf39d13c1461037d578063d1737e271461039057600080fd5b806399103f7b14610318578063c008ce391461032b578063c2e524dc1461033e57600080fd5b806329ddc3c0116101665780637680850c116101405780637680850c146102c45780637c2b55a0146102d7578063853af1b7146102f2578063865e6fd31461030557600080fd5b806329ddc3c01461027d5780633d48fd7d146102a057806362ffe6cb146102b157600080fd5b80631079402a116101a25780631079402a146102175780631a697341146102445780631e90b2a01461025757806329b6eca91461026a57600080fd5b806307c2d2f6146101c9578063082e7420146101de5780630e1512ac14610204575b600080fd5b6101dc6101d7366004612030565b610452565b005b6101f16101ec366004612087565b610560565b6040519081526020015b60405180910390f35b6101dc6102123660046120a4565b6105d7565b606d54606e54606f546070545b6040805194855260208501939093529183015260608201526080016101fb565b6101dc610252366004612087565b6105f1565b6101dc610265366004612118565b610892565b6101dc610278366004612087565b610a7a565b61029061028b36600461219b565b610b9e565b60405190151581526020016101fb565b60a55460a65460a75460a854610224565b6101f16102bf36600461219b565b610bcd565b6101dc6102d23660046121c7565b610bf6565b60675b6040516001600160a01b0390911681526020016101fb565b6101dc610300366004612213565b610f0d565b6101dc610313366004612244565b610f23565b6101dc61032636600461228c565b610f3e565b6101dc610339366004612350565b6110a9565b603854603954604080519283526020830191909152016101fb565b60dd5460de5460df5460e054610224565b6101dc6103783660046120a4565b611133565b6101dc61038b366004612385565b611147565b6101dc61039e3660046120a4565b61115f565b6101dc6103b1366004612087565b611173565b6101f16103c4366004612087565b6001600160a01b0316600090815260dc602052604090205490565b6102da6103ed3660046123b1565b611562565b600154600254600354604080519384526020840192909252908201526060016101fb565b610429610424366004612030565b6115dd565b6040516101fb9190612407565b6101f160a35481565b6101dc61044d366004612087565b6116a8565b600861045d816119bc565b60008267ffffffffffffffff8111156104785761047861241a565b6040519080825280602002602001820160405280156104a1578160200160208202803683370190505b50905060005b8381101561051e5760008585838181106104c3576104c3612430565b90506020020160208101906104d89190612087565b6001600160a01b038116600090815260dc6020526040812055835190915083908390811061050857610508612430565b60006020918202929092010152506001016104a7565b507f8c02b2ccee964dc50649a48bd0a0446f0f9e88ecdb72d099f4ace07c39c2348084848360405161055293929190612484565b60405180910390a150505050565b60006105d1826105706008611562565b6001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa1580156105ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102bf91906124b4565b92915050565b6105df611a08565b6105eb84848484611a64565b50505050565b6105f9611a08565b6000610605600a611562565b604051636db349d160e11b81526001600160a01b038481166004830152919091169063db6693a29060240160a060405180830381865afa15801561064d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067191906124fe565b905060006106fb6106826004611562565b6040808501519051632623bd4f60e21b81526001600160a01b03918216600482015291169063988ef53c90602401602060405180830381865afa1580156106cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f191906124b4565b8360800151611af6565b905060006107096008611562565b90506000816001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa15801561074b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076f91906124b4565b60385490915061077f844361259c565b1115806107af57506001600160a01b038516600090815260376020908152604080832084845290915290205460ff165b156107cd57604051632e308a0b60e11b815260040160405180910390fd5b6001600160a01b038516600081815260376020908152604080832085845290915290819020805460ff19166001179055516000805160206128c48339815191529061081c9060049085906125c5565b60405180910390a2603954604051630bde081360e21b81526001600160a01b03841691632f78204c916108599189916000919082906004016125e3565b600060405180830381600087803b15801561087357600080fd5b505af1158015610887573d6000803e3d6000fd5b505050505050505050565b61089a611a08565b600084846040516108ac92919061260b565b60405180910390209050600083836040516108c892919061260b565b604080519182900390912060008481526004602052919091205490915060ff1680610901575060008181526004602052604090205460ff165b1561091f5760405163f27b8ec960e01b815260040160405180910390fd5b61092c8787878787611b0d565b15610a7157600061093d6008611562565b90506000816001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa15801561097f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a391906124b4565b6000858152600460205260408082208054600160ff19918216811790925587845292829020805490931617909155519091506001600160a01b038a16906000805160206128c4833981519152906109fe9060039085906125c5565b60405180910390a260025460018054604051630bde081360e21b81526001600160a01b03861693632f78204c93610a3c938f939091906004016125e3565b600060405180830381600087803b158015610a5657600080fd5b505af1158015610a6a573d6000803e3d6000fd5b5050505050505b50505050505050565b61011354600290610100900460ff16158015610a9e57506101135460ff8083169116105b610ac35760405162461bcd60e51b8152600401610aba9061261b565b60405180910390fd5b610113805461ffff191660ff831617610100179055600054610af0906008906001600160a01b0316611bb7565b606c54610b08906005906001600160a01b0316611bb7565b610b13600483611bb7565b603554610b2b90600a906001600160a01b0316611bb7565b600080546001600160a01b0319908116909155606c8054821690556035805482169055603680549091169055610113805461ff001916905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15050565b6001600160a01b038216600090815260db6020908152604080832084845290915281205460ff165b9392505050565b6001600160a01b038216600090815260a460209081526040808320848452909152812054610bc6565b6008610c01816119bc565b60003390506000816001600160a01b031663297a8fca6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c46573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c6a91906124b4565b90506000826001600160a01b0316634de2b73588886040518363ffffffff1660e01b8152600401610c9c929190612669565b600060405180830381865afa158015610cb9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ce1919081019061268d565b90506000610cef6005611562565b6001600160a01b031663ba303755898986436040518563ffffffff1660e01b8152600401610d20949392919061273a565b600060405180830381865afa158015610d3d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d65919081019061268d565b905060008767ffffffffffffffff811115610d8257610d8261241a565b604051908082528060200260200182016040528015610dab578160200160208202803683370190505b50905060005b88811015610ec65760008a8a83818110610dcd57610dcd612430565b9050602002016020810190610de29190612087565b90506000610df0828b610bcd565b90506000868481518110610e0657610e06612430565b602002602001015190506000868581518110610e2457610e24612430565b6020026020010151905060008280610e395750815b610e4e57610e4960dd5485611c5b565b610e51565b60005b6001600160a01b038616600090815260dc602052604090205460de54919250610e7b918390611c75565b6001600160a01b038616600090815260dc602052604090208190558751889088908110610eaa57610eaa612430565b6020026020010181815250508560010195505050505050610db1565b507f8c02b2ccee964dc50649a48bd0a0446f0f9e88ecdb72d099f4ace07c39c23480898983604051610efa93929190612484565b60405180910390a1505050505050505050565b610f15611a08565b610f1f8282611c92565b5050565b610f2b611a08565b610f3481611cd2565b610f1f8282611bb7565b61011354610100900460ff1615808015610f60575061011354600160ff909116105b80610f7b5750303b158015610f7b57506101135460ff166001145b610f975760405162461bcd60e51b8152600401610aba9061261b565b610113805460ff191660011790558015610fbc57610113805461ff0019166101001790555b610fc760088b611bb7565b610fd260058a611bb7565b610fdd600488611bb7565b610fe8600a89611bb7565b61100186356020880135604089013560608a0135611a64565b61101085356020870135611c92565b611024843560208601356040870135611d08565b61103d8335602085013560408601356060870135611d5d565b6110568235602084013560408501356060860135611de9565b801561109d57610113805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050505050565b60086110b4816119bc565b826001036110f357836001600160a01b03166000805160206128c48339815191526005846040516110e69291906125c5565b60405180910390a26105eb565b826002036105eb57836001600160a01b03166000805160206128c48339815191526006846040516111259291906125c5565b60405180910390a250505050565b61113b611a08565b6105eb84848484611de9565b61114f611a08565b61115a838383611d08565b505050565b611167611a08565b6105eb84848484611d5d565b600061117f6008611562565b604051635061f96960e11b81526001600160a01b0384811660048301529192509082169063a0c3f2d290602401602060405180830381865afa1580156111c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ed9190612761565b61121a576000356001600160e01b0319166008604051620f948f60ea1b8152600401610aba92919061277c565b6040516304d971ab60e01b81526001600160a01b0383811660048301523360248301528216906304d971ab90604401602060405180830381865afa158015611266573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061128a9190612761565b6112b7576000356001600160e01b0319166004604051620f948f60ea1b8152600401610aba92919061277c565b604051634b2c2fe160e11b81526001600160a01b03838116600483015260009182918416906396585fc290602401606060405180830381865afa158015611302573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132691906127aa565b92505091508161134957604051636cd31b5960e01b815260040160405180910390fd5b6000836001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa158015611389573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ad91906124b4565b6001600160a01b038616600090815260db6020908152604080832084845290915290205490915060ff16156113f557604051637674d6a960e01b815260040160405180910390fd5b6001600160a01b038516600090815260dc602052604081205460df5490919061141e90856127df565b9050808210156114415760405163462e593760e11b815260040160405180910390fd5b604051630adaf5ef60e11b81526001600160a01b038881166004830152602482018590528716906315b5ebde90604401600060405180830381600087803b15801561148b57600080fd5b505af115801561149f573d6000803e3d6000fd5b505050506001600160a01b038716600090815260dc6020526040812080548392906114cb90849061259c565b90915550506001600160a01b038716600090815260a4602090815260408083208684529091528120556001600160a01b038716600081815260db60209081526040808320878452825291829020805460ff1916600117905581518681529081018490527f7ff9f7032d565c7e8919332964b2faa33c320b53604a65d9dd1f8112e12cd39d910160405180910390a250505050505050565b60007fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb600083600a811115611599576115996125af565b60ff1681526020810191909152604001600020546001600160a01b03169050806115d8578160405163409140df60e11b8152600401610aba919061280a565b919050565b60608167ffffffffffffffff8111156115f8576115f861241a565b604051908082528060200260200182016040528015611621578160200160208202803683370190505b50905060005b81518110156116a15760dc600085858481811061164657611646612430565b905060200201602081019061165b9190612087565b6001600160a01b03166001600160a01b031681526020019081526020016000205482828151811061168e5761168e612430565b6020908102919091010152600101611627565b5092915050565b60a35443116116ca5760405163557fd09160e01b815260040160405180910390fd5b4360a3553341146116fe576000356001600160e01b0319166002604051620f948f60ea1b8152600401610aba92919061277c565b61170781611e86565b156119b95760006117186008611562565b90506000816001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa15801561175a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061177e91906124b4565b6001600160a01b038416600090815260a460209081526040808320848452909152812080546001019081905560a854929350916117bc904390611f9c565b905060a654820361186557846001600160a01b03166000805160206128c48339815191526002856040516117f19291906125c5565b60405180910390a260a754604051630bde081360e21b81526001600160a01b03861691632f78204c9161182e9189918691906000906004016125e3565b600060405180830381600087803b15801561184857600080fd5b505af115801561185c573d6000803e3d6000fd5b505050506119b4565b60a55482036119b457600061187a8685610b9e565b90508061191d57856001600160a01b03166000805160206128c48339815191526001866040516118ab9291906125c5565b60405180910390a2604051630bde081360e21b81526001600160a01b03861690632f78204c906118e6908990600090819081906004016125e3565b600060405180830381600087803b15801561190057600080fd5b505af1158015611914573d6000803e3d6000fd5b505050506119b2565b856001600160a01b03166000805160206128c48339815191526007866040516119479291906125c5565b60405180910390a260a754604051630bde081360e21b81526001600160a01b03871691632f78204c91611984918a918791906001906004016125e3565b600060405180830381600087803b15801561199e57600080fd5b505af115801561109d573d6000803e3d6000fd5b505b505050505b50565b6119c581611562565b6001600160a01b0316336001600160a01b0316146119b9576000356001600160e01b03191681336040516320e0f98d60e21b8152600401610aba93929190612818565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b03163314611a62576000356001600160e01b0319166001604051620f948f60ea1b8152600401610aba92919061277c565b565b82841180611a73575061271084115b80611a7f575061271083115b15611a9d57604051631cbe1abf60e11b815260040160405180910390fd5b606d849055606e839055606f82905560708190556040805185815260208101859052908101839052606081018290527fd24c671da2227c139fe1a5b34de15e5a67bef9b46e912916b9e0d025d51b3e3b90608001610552565b600081831015611b065781610bc6565b5090919050565b6040516000906067906001908390611b31908a908a908a908a908a90602401612878565b60408051601f198184030181529190526020810180516001600160e01b0316637fc3567760e01b1790528051909150611b68611fc6565b602083016020828483895afa611b7d57600094505b503d611b8857600093505b83611ba657604051630fc2632160e01b815260040160405180910390fd5b5115159a9950505050505050505050565b807fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb600084600a811115611bed57611bed6125af565b60ff168152602081019190915260400160002080546001600160a01b0319166001600160a01b03928316179055811682600a811115611c2e57611c2e6125af565b6040517f865d1c228a8ea13709cfe61f346f7ff67f1bbd4a18ff31ad3e7147350d317c5990600090a35050565b6000818311611c6b576000610bc6565b610bc6828461259c565b6000611c8a611c8484866128b0565b83611fb7565b949350505050565b6038829055603981905560408051838152602081018390527fbda9ec2980d7468ba6a9f363696315affca9f9770016396bdea2ac39c3e5d61a9101610b92565b806001600160a01b03163b6000036119b957604051630bfc64a360e21b81526001600160a01b0382166004820152602401610aba565b60018390556002829055600381905560408051848152602081018490529081018290527f913da102149f952dde560cef3349db8e8002e9d580c41a7551d6d45329f4306b9060600160405180910390a1505050565b60a65460a5541115611d90576040516387f6f09560e01b81526001600160e01b0319600035166004820152602401610aba565b60a584905560a683905560a782905560a88190556040805185815260208101859052908101839052606081018290527f442862e6143ad95854e7c13ff4947ec6e43bc87160e3b193e7c1abaf6e3aaa9890608001610552565b82841115611e0a5760405163112af4d160e01b815260040160405180910390fd5b612710811115611e2d5760405163382c88a360e21b815260040160405180910390fd5b60dd84905560de83905560df82905560e08190556040805185815260208101859052908101839052606081018290527fe1f9c6c73554b5fa140eead3cfd4ec3e6d4824f3ed26fb25e38376f65b95470b90608001610552565b6000336001600160a01b03831614801590611f125750611ea66008611562565b604051633292276760e11b81526001600160a01b03848116600483015291909116906365244ece90602401602060405180830381865afa158015611eee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f129190612761565b80156105d15750611f236005611562565b604051630fbeb37f60e01b81526001600160a01b0384811660048301524360248301529190911690630fbeb37f90604401602060405180830381865afa158015611f71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f959190612761565b1592915050565b600081600003611fad576000610bc6565b610bc682846128b0565b6000818310611b065781610bc6565b60405180602001604052806001906020820280368337509192915050565b60008083601f840112611ff657600080fd5b50813567ffffffffffffffff81111561200e57600080fd5b6020830191508360208260051b850101111561202957600080fd5b9250929050565b6000806020838503121561204357600080fd5b823567ffffffffffffffff81111561205a57600080fd5b61206685828601611fe4565b90969095509350505050565b6001600160a01b03811681146119b957600080fd5b60006020828403121561209957600080fd5b8135610bc681612072565b600080600080608085870312156120ba57600080fd5b5050823594602084013594506040840135936060013592509050565b60008083601f8401126120e857600080fd5b50813567ffffffffffffffff81111561210057600080fd5b60208301915083602082850101111561202957600080fd5b60008060008060006060868803121561213057600080fd5b853561213b81612072565b9450602086013567ffffffffffffffff8082111561215857600080fd5b61216489838a016120d6565b9096509450604088013591508082111561217d57600080fd5b5061218a888289016120d6565b969995985093965092949392505050565b600080604083850312156121ae57600080fd5b82356121b981612072565b946020939093013593505050565b6000806000604084860312156121dc57600080fd5b833567ffffffffffffffff8111156121f357600080fd5b6121ff86828701611fe4565b909790965060209590950135949350505050565b6000806040838503121561222657600080fd5b50508035926020909101359150565b8035600b81106115d857600080fd5b6000806040838503121561225757600080fd5b61226083612235565b9150602083013561227081612072565b809150509250929050565b80608081018310156105d157600080fd5b60008060008060008060008060006102a08a8c0312156122ab57600080fd5b89356122b681612072565b985060208a01356122c681612072565b975060408a01356122d681612072565b965060608a01356122e681612072565b95506122f58b60808c0161227b565b94506101408a018b81111561230957600080fd5b6101008b0194506101a08b018c81111561232257600080fd5b81945061232f8d8261227b565b935050506123418b6102208c0161227b565b90509295985092959850929598565b60008060006060848603121561236557600080fd5b833561237081612072565b95602085013595506040909401359392505050565b60008060006060848603121561239a57600080fd5b505081359360208301359350604090920135919050565b6000602082840312156123c357600080fd5b610bc682612235565b600081518084526020808501945080840160005b838110156123fc578151875295820195908201906001016123e0565b509495945050505050565b602081526000610bc660208301846123cc565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b8183526000602080850194508260005b858110156123fc57813561246981612072565b6001600160a01b031687529582019590820190600101612456565b604081526000612498604083018587612446565b82810360208401526124aa81856123cc565b9695505050505050565b6000602082840312156124c657600080fd5b5051919050565b604051601f8201601f1916810167ffffffffffffffff811182821017156124f6576124f661241a565b604052919050565b600060a0828403121561251057600080fd5b60405160a0810181811067ffffffffffffffff821117156125335761253361241a565b604052825161254181612072565b8152602083015161255181612072565b6020820152604083015161256481612072565b6040820152606083810151908201526080928301519281019290925250919050565b634e487b7160e01b600052601160045260246000fd5b818103818111156105d1576105d1612586565b634e487b7160e01b600052602160045260246000fd5b60408101600884106125d9576125d96125af565b9281526020015290565b6001600160a01b03949094168452602084019290925260408301521515606082015260800190565b8183823760009101908152919050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b602081526000611c8a602083018486612446565b805180151581146115d857600080fd5b600060208083850312156126a057600080fd5b825167ffffffffffffffff808211156126b857600080fd5b818501915085601f8301126126cc57600080fd5b8151818111156126de576126de61241a565b8060051b91506126ef8483016124cd565b818152918301840191848101908884111561270957600080fd5b938501935b8385101561272e5761271f8561267d565b8252938501939085019061270e565b98975050505050505050565b60608152600061274e606083018688612446565b6020830194909452506040015292915050565b60006020828403121561277357600080fd5b610bc68261267d565b6001600160e01b031983168152604081016009831061279d5761279d6125af565b8260208301529392505050565b6000806000606084860312156127bf57600080fd5b6127c88461267d565b925060208401519150604084015190509250925092565b80820281158282048414176105d1576105d1612586565b600b8110612806576128066125af565b9052565b602081016105d182846127f6565b6001600160e01b0319841681526060810161283660208301856127f6565b6001600160a01b03929092166040919091015292915050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6001600160a01b038616815260606020820181905260009061289d908301868861284f565b828103604084015261272e81858761284f565b808201808211156105d1576105d161258656fe607adba66cff84b627e3537d1c17d088a98556bccd0536a2f3590c56329023d9a164736f6c6343000811000a", + "numDeployments": 8, + "solcInputHash": "95921af9e3b453fd5a2d5edf43163a69", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"ErrCallPrecompiled\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrCallerMustBeJailedInTheCurrentPeriod\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrCannotSlashAValidatorTwiceOrSlashMoreThanOneValidatorInOneBlock\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"}],\"name\":\"ErrContractTypeNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrEvidenceAlreadySubmitted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInsufficientCreditScoreToBailOut\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidCreditScoreConfig\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidCutOffPercentageConfig\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidRatios\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidSlash\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"}],\"name\":\"ErrInvalidThreshold\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"},{\"internalType\":\"enum RoleAccess\",\"name\":\"expectedRole\",\"type\":\"uint8\"}],\"name\":\"ErrUnauthorized\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"},{\"internalType\":\"enum ContractType\",\"name\":\"expectedContractType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"actual\",\"type\":\"address\"}],\"name\":\"ErrUnexpectedInternalCall\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrValidatorHasBailedOutPreviously\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"ErrZeroCodeContract\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"validator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"usedCreditScore\",\"type\":\"uint256\"}],\"name\":\"BailedOut\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"missingVotesRatioTier1\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"missingVotesRatioTier2\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"jailDurationForMissingVotesRatioTier2\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"skipBridgeOperatorSlashingThreshold\",\"type\":\"uint256\"}],\"name\":\"BridgeOperatorSlashingConfigsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bridgeVotingThreshold\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bridgeVotingSlashAmount\",\"type\":\"uint256\"}],\"name\":\"BridgeVotingSlashingConfigsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"ContractUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"gainCreditScore\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"maxCreditScore\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bailOutCostMultiplier\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"cutOffPercentageAfterBailout\",\"type\":\"uint256\"}],\"name\":\"CreditScoreConfigsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"validators\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"creditScores\",\"type\":\"uint256[]\"}],\"name\":\"CreditScoresUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"slashDoubleSignAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"doubleSigningJailUntilBlock\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"doubleSigningOffsetLimitBlock\",\"type\":\"uint256\"}],\"name\":\"DoubleSignSlashingConfigsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"validator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"enum IBaseSlash.SlashType\",\"name\":\"slashType\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"}],\"name\":\"Slashed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"unavailabilityTier1Threshold\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"unavailabilityTier2Threshold\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"slashAmountForUnavailabilityTier2Threshold\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"jailDurationForUnavailabilityTier2Threshold\",\"type\":\"uint256\"}],\"name\":\"UnavailabilitySlashingConfigsUpdated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"}],\"name\":\"bailOut\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_validator\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_period\",\"type\":\"uint256\"}],\"name\":\"checkBailedOutAtPeriod\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_validator\",\"type\":\"address\"}],\"name\":\"currentUnavailabilityIndicator\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_validators\",\"type\":\"address[]\"}],\"name\":\"execResetCreditScores\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_tier\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_period\",\"type\":\"uint256\"}],\"name\":\"execSlashBridgeOperator\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBridgeOperatorSlashingConfigs\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"missingVotesRatioTier1_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"missingVotesRatioTier2_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"jailDurationForMissingVotesRatioTier2_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"skipBridgeOperatorSlashingThreshold_\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBridgeVotingSlashingConfigs\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"bridgeVotingThreshold_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"bridgeVotingSlashAmount_\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"}],\"name\":\"getContract\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"contract_\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_validator\",\"type\":\"address\"}],\"name\":\"getCreditScore\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCreditScoreConfigs\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"gainCreditScore_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxCreditScore_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"bailOutCostMultiplier_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"cutOffPercentageAfterBailout_\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getDoubleSignSlashingConfigs\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"slashDoubleSignAmount_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"doubleSigningJailUntilBlock_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"doubleSigningOffsetLimitBlock_\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_validators\",\"type\":\"address[]\"}],\"name\":\"getManyCreditScores\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_resultList\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_validator\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_period\",\"type\":\"uint256\"}],\"name\":\"getUnavailabilityIndicator\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getUnavailabilitySlashingConfigs\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"unavailabilityTier1Threshold_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"unavailabilityTier2Threshold_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"slashAmountForUnavailabilityTier2Threshold_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"jailDurationForUnavailabilityTier2Threshold_\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"__validatorContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"__maintenanceContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"__roninTrustedOrganizationContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"__roninGovernanceAdminContract\",\"type\":\"address\"},{\"internalType\":\"uint256[4]\",\"name\":\"_bridgeOperatorSlashingConfigs\",\"type\":\"uint256[4]\"},{\"internalType\":\"uint256[2]\",\"name\":\"_bridgeVotingSlashingConfigs\",\"type\":\"uint256[2]\"},{\"internalType\":\"uint256[3]\",\"name\":\"_doubleSignSlashingConfigs\",\"type\":\"uint256[3]\"},{\"internalType\":\"uint256[4]\",\"name\":\"_unavailabilitySlashingConfigs\",\"type\":\"uint256[4]\"},{\"internalType\":\"uint256[4]\",\"name\":\"_creditScoreConfigs\",\"type\":\"uint256[4]\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"roninGovernanceAdminContract\",\"type\":\"address\"}],\"name\":\"initializeV2\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lastUnavailabilitySlashedBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"precompileValidateDoubleSignAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_ratioTier1\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_ratioTier2\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_jailDurationTier2\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_skipSlashingThreshold\",\"type\":\"uint256\"}],\"name\":\"setBridgeOperatorSlashingConfigs\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_threshold\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_slashAmount\",\"type\":\"uint256\"}],\"name\":\"setBridgeVotingSlashingConfigs\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setContract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_gainScore\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_maxScore\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_bailOutMultiplier\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_cutOffPercentage\",\"type\":\"uint256\"}],\"name\":\"setCreditScoreConfigs\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_slashAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_jailUntilBlock\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_offsetLimitBlock\",\"type\":\"uint256\"}],\"name\":\"setDoubleSignSlashingConfigs\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_tier1Threshold\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_tier2Threshold\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_slashAmountForTier2Threshold\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_jailDurationForTier2Threshold\",\"type\":\"uint256\"}],\"name\":\"setUnavailabilitySlashingConfigs\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"}],\"name\":\"slashBridgeVoting\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_header1\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"_header2\",\"type\":\"bytes\"}],\"name\":\"slashDoubleSign\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_validatorAddr\",\"type\":\"address\"}],\"name\":\"slashUnavailability\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_validators\",\"type\":\"address[]\"},{\"internalType\":\"uint256\",\"name\":\"_period\",\"type\":\"uint256\"}],\"name\":\"updateCreditScores\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"errors\":{\"ErrCallPrecompiled()\":[{\"details\":\"Error of call to precompile fails.\"}],\"ErrCallerMustBeJailedInTheCurrentPeriod()\":[{\"details\":\"Error thrown when the caller must be jailed in the current period.\"}],\"ErrCannotSlashAValidatorTwiceOrSlashMoreThanOneValidatorInOneBlock()\":[{\"details\":\"Error thrown when attempting to slash a validator twice or slash more than one validator in one block.\"}],\"ErrContractTypeNotFound(uint8)\":[{\"details\":\"Error of invalid role.\"}],\"ErrEvidenceAlreadySubmitted()\":[{\"details\":\"Error thrown when evidence has already been submitted.\"}],\"ErrInsufficientCreditScoreToBailOut()\":[{\"details\":\"Error thrown when the caller's credit score is insufficient to bail out a situation.\"}],\"ErrInvalidCreditScoreConfig()\":[{\"details\":\"Error thrown when an invalid credit score configuration is provided.\"}],\"ErrInvalidCutOffPercentageConfig()\":[{\"details\":\"Error thrown when an invalid cut-off percentage configuration is provided.\"}],\"ErrInvalidRatios()\":[{\"details\":\"Error thrown when invalid ratios are provided.\"}],\"ErrInvalidSlash()\":[{\"details\":\"Error thrown when an invalid slash is encountered.\"}],\"ErrInvalidThreshold(bytes4)\":[{\"details\":\"Error indicating that the provided threshold is invalid for a specific function signature.\",\"params\":{\"msgSig\":\"The function signature (bytes4) that the invalid threshold applies to.\"}}],\"ErrUnauthorized(bytes4,uint8)\":[{\"details\":\"Error indicating that the caller is unauthorized to perform a specific function.\",\"params\":{\"expectedRole\":\"The role required to perform the function.\",\"msgSig\":\"The function signature (bytes4) that the caller is unauthorized to perform.\"}}],\"ErrUnexpectedInternalCall(bytes4,uint8,address)\":[{\"details\":\"Error indicating that the caller is unauthorized to perform a specific function.\",\"params\":{\"actual\":\"The actual address that called to the function.\",\"expectedContractType\":\"The contract type required to perform the function.\",\"msgSig\":\"The function signature (bytes4).\"}}],\"ErrValidatorHasBailedOutPreviously()\":[{\"details\":\"Error thrown when a validator has previously bailed out.\"}],\"ErrZeroCodeContract(address)\":[{\"details\":\"Error of set to non-contract.\"}]},\"kind\":\"dev\",\"methods\":{\"bailOut(address)\":{\"details\":\"A slashed validator use this method to get out of jail. Requirements: - The `_consensusAddr` must be a validator. - Only validator's admin can call this method. Emits the event `BailedOut`.\"},\"checkBailedOutAtPeriod(address,uint256)\":{\"details\":\"Returns the whether the `_validator` has been bailed out at the `_period`.\"},\"currentUnavailabilityIndicator(address)\":{\"details\":\"Returns the current unavailability indicator of a block producer.\"},\"execResetCreditScores(address[])\":{\"details\":\"Resets the credit score for the revoked validators. Requirements: - Only validator contract can call this method. - This method is only called at the end of each period. Emits the event `CreditScoresUpdated`.\"},\"execSlashBridgeOperator(address,uint256,uint256)\":{\"details\":\"Acknowledges bridge operator slash and emit `Slashed` event correspondingly.\",\"params\":{\"_tier\":\"The tier of the slash, in value of {1, 2}, corresponding to `SlashType.BRIDGE_OPERATOR_MISSING_VOTE_TIER_1` and `SlashType.BRIDGE_OPERATOR_MISSING_VOTE_TIER_2` Requirements: - Only validator contract can invoke this method. - Should be called only at the end of period. - Should be called only when there is slash of bridge operator. Emits the event `Slashed`.\"}},\"getBridgeOperatorSlashingConfigs()\":{\"details\":\"Returns the configs related to bridge operator slashing.\",\"returns\":{\"jailDurationForMissingVotesRatioTier2_\":\"The number of blocks to jail the corresponding block producer when its bridge operator is slashed tier-2.\",\"missingVotesRatioTier1_\":\"The bridge reward will be deprecated if (s)he missed more than this ratio.\",\"missingVotesRatioTier2_\":\"The bridge reward and mining reward will be deprecated and the corresponding block producer will be put in jail if (s)he misses more than this ratio.\",\"skipBridgeOperatorSlashingThreshold_\":\"The threshold to skip slashing the bridge operator in case the total number of votes in the bridge is too small.\"}},\"getBridgeVotingSlashingConfigs()\":{\"details\":\"Returns the configs related to bridge voting slashing.\",\"returns\":{\"bridgeVotingSlashAmount_\":\"The amount of RON to slash bridge voting.\",\"bridgeVotingThreshold_\":\"The threshold to slash when a trusted organization does not vote for bridge operators.\"}},\"getContract(uint8)\":{\"details\":\"Returns the address of a contract with a specific role. Throws an error if no contract is set for the specified role.\",\"params\":{\"contractType\":\"The role of the contract to retrieve.\"},\"returns\":{\"contract_\":\"The address of the contract with the specified role.\"}},\"getCreditScore(address)\":{\"details\":\"Returns the current credit score of the validator.\"},\"getCreditScoreConfigs()\":{\"details\":\"Returns the configs related to credit score.\",\"returns\":{\"bailOutCostMultiplier_\":\"The number that will be multiplied with the remaining jailed time to get the cost of bailing out.\",\"cutOffPercentageAfterBailout_\":\"The percentage of reward that the block producer will be cut off from until the end of the period after bailing out.\",\"gainCreditScore_\":\"The score to gain per period.\",\"maxCreditScore_\":\"The max number of credit score that a validator can hold.\"}},\"getDoubleSignSlashingConfigs()\":{\"details\":\"Returns the configs related to block producer slashing.\",\"params\":{\"_doubleSigningOffsetLimitBlock\":\"The number of block that the current block is at most far from the double signing block.\"},\"returns\":{\"doubleSigningJailUntilBlock_\":\"The block number that the punished validator will be jailed until, due to double signing.\",\"slashDoubleSignAmount_\":\"The amount of RON to slash double sign.\"}},\"getManyCreditScores(address[])\":{\"details\":\"Returns the current credit score of a list of validators.\"},\"getUnavailabilityIndicator(address,uint256)\":{\"details\":\"Helper for CreditScore contract to query indicator of the validator.\"},\"getUnavailabilitySlashingConfigs()\":{\"details\":\"Returns the configs related to block producer slashing.\",\"returns\":{\"jailDurationForUnavailabilityTier2Threshold_\":\"The number of blocks to jail a block producer when (s)he is slashed with tier-2 or tier-3.\",\"slashAmountForUnavailabilityTier2Threshold_\":\"The amount of RON to deduct from self-staking of a block producer when (s)he is slashed with tier-2 or tier-3.\",\"unavailabilityTier1Threshold_\":\"The mining reward will be deprecated, if (s)he missed more than this threshold. This threshold is applied for tier-1 and tier-3 slash.\",\"unavailabilityTier2Threshold_\":\" The mining reward will be deprecated, (s)he will be put in jailed, and will be deducted self-staking if (s)he misses more than this threshold. This threshold is applied for tier-2 slash.\"}},\"initialize(address,address,address,address,uint256[4],uint256[2],uint256[3],uint256[4],uint256[4])\":{\"details\":\"Initializes the contract storage.\"},\"precompileValidateDoubleSignAddress()\":{\"details\":\"Gets the address of the precompile of validating double sign evidence\"},\"setBridgeOperatorSlashingConfigs(uint256,uint256,uint256,uint256)\":{\"details\":\"Sets the configs to slash bridge operators. Requirements: - The method caller is admin. Emits the event `BridgeOperatorSlashingConfigsUpdated`.\",\"params\":{\"_jailDurationTier2\":\"The number of blocks to jail the corresponding block producer when its bridge operator is slashed tier-2.\",\"_ratioTier1\":\"The bridge reward will be deprecated if (s)he missed more than this ratio. Values 0-10,000 map to 0%-100%.\",\"_ratioTier2\":\"The bridge reward and mining reward will be deprecated and the corresponding block producer will be put in jail if (s)he misses more than this ratio. Values 0-10,000 map to 0%-100%.\",\"_skipSlashingThreshold\":\"The threshold to skip slashing the bridge operator in case the total number of votes in the bridge is too small.\"}},\"setBridgeVotingSlashingConfigs(uint256,uint256)\":{\"details\":\"Sets the configs to slash bridge voting. Requirements: - The method caller is admin. Emits the event `BridgeVotingSlashingConfigsUpdated`.\",\"params\":{\"_slashAmount\":\"The amount of RON to slash bridge voting.\",\"_threshold\":\"The threshold to slash when a trusted organization does not vote for bridge operators.\"}},\"setContract(uint8,address)\":{\"details\":\"Sets the address of a contract with a specific role. Emits the event {ContractUpdated}.\",\"params\":{\"addr\":\"The address of the contract to set.\",\"contractType\":\"The role of the contract to set.\"}},\"setCreditScoreConfigs(uint256,uint256,uint256,uint256)\":{\"details\":\"Sets the configs to credit score. Requirements: - The method caller is admin. Emits the event `CreditScoreConfigsUpdated`.\",\"params\":{\"_bailOutMultiplier\":\"The number that will be multiplied with the remaining jailed time to get the cost of bailing out.\",\"_cutOffPercentage\":\"The percentage of reward that the block producer will be cut off from until the end of the period after bailing out.\",\"_gainScore\":\"The score to gain per period.\",\"_maxScore\":\"The max number of credit score that a validator can hold.\"}},\"setDoubleSignSlashingConfigs(uint256,uint256,uint256)\":{\"details\":\"Sets the configs to slash block producers. Requirements: - The method caller is admin. Emits the event `DoubleSignSlashingConfigsUpdated`.\",\"params\":{\"_doubleSigningOffsetLimitBlock\":\"The number of block that the current block is at most far from the double signing block.\",\"_jailUntilBlock\":\"The block number that the punished validator will be jailed until, due to double signing.\",\"_slashAmount\":\"The amount of RON to slash double sign.\"}},\"setUnavailabilitySlashingConfigs(uint256,uint256,uint256,uint256)\":{\"details\":\"Sets the configs to slash block producers. Requirements: - The method caller is admin. Emits the event `BridgeOperatorSlashingConfigsUpdated`.\",\"params\":{\"_jailDurationForTier2Threshold\":\"The number of blocks to jail a block producer when (s)he is slashed tier-2.\",\"_slashAmountForTier2Threshold\":\"The amount of RON to deduct from self-staking of a block producer when (s)he is slashed tier-2.\",\"_tier1Threshold\":\"The mining reward will be deprecated, if (s)he missed more than this threshold.\",\"_tier2Threshold\":\"The mining reward will be deprecated, (s)he will be put in jailed, and will be deducted self-staking if (s)he misses more than this threshold.\"}},\"slashBridgeVoting(address)\":{\"details\":\"Slashes for bridge voter governance. Emits the event `Slashed`.\"},\"slashDoubleSign(address,bytes,bytes)\":{\"details\":\"Slashes for double signing. Requirements: - The method caller is coinbase. Emits the event `Slashed` if the double signing evidence of the two headers valid.\"},\"slashUnavailability(address)\":{\"details\":\"Slashes for unavailability by increasing the counter of block producer `_consensusAddr`. Requirements: - The method caller is coinbase. Emits the event `Slashed` when the threshold is reached.\"},\"updateCreditScores(address[],uint256)\":{\"details\":\"Updates the credit score for the validators. Requirements: - Only validator contract can call this method. - This method is only called at the end of each period. Emits the event `CreditScoresUpdated`.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/ronin/slash-indicator/SlashIndicator.sol\":\"SlashIndicator\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"none\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/Address.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\\n * initialization step. This is essential to configure modules that are added through upgrades and that require\\n * initialization.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2a21b14ff90012878752f230d3ffd5c3405e5938d06c97a7d89c0a64561d0d66\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd6153ce99bcdcce22b124f755e72553295be6abcd63804cfdffceb188b8bef10\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n bytes16 private constant _HEX_SYMBOLS = \\\"0123456789abcdef\\\";\\n uint8 private constant _ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n // Inspired by OraclizeAPI's implementation - MIT licence\\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\\n\\n if (value == 0) {\\n return \\\"0\\\";\\n }\\n uint256 temp = value;\\n uint256 digits;\\n while (temp != 0) {\\n digits++;\\n temp /= 10;\\n }\\n bytes memory buffer = new bytes(digits);\\n while (value != 0) {\\n digits -= 1;\\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\\n value /= 10;\\n }\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n if (value == 0) {\\n return \\\"0x00\\\";\\n }\\n uint256 temp = value;\\n uint256 length = 0;\\n while (temp != 0) {\\n length++;\\n temp >>= 8;\\n }\\n return toHexString(value, length);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\\n }\\n}\\n\",\"keccak256\":\"0xaf159a8b1923ad2a26d516089bceca9bdeaeacd04be50983ea00ba63070f08a3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Strings.sol\\\";\\n\\n/**\\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\\n *\\n * These functions can be used to verify that a message was signed by the holder\\n * of the private keys of a given address.\\n */\\nlibrary ECDSA {\\n enum RecoverError {\\n NoError,\\n InvalidSignature,\\n InvalidSignatureLength,\\n InvalidSignatureS,\\n InvalidSignatureV\\n }\\n\\n function _throwError(RecoverError error) private pure {\\n if (error == RecoverError.NoError) {\\n return; // no error: do nothing\\n } else if (error == RecoverError.InvalidSignature) {\\n revert(\\\"ECDSA: invalid signature\\\");\\n } else if (error == RecoverError.InvalidSignatureLength) {\\n revert(\\\"ECDSA: invalid signature length\\\");\\n } else if (error == RecoverError.InvalidSignatureS) {\\n revert(\\\"ECDSA: invalid signature 's' value\\\");\\n } else if (error == RecoverError.InvalidSignatureV) {\\n revert(\\\"ECDSA: invalid signature 'v' value\\\");\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature` or error string. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n *\\n * Documentation for signature generation:\\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\\n if (signature.length == 65) {\\n bytes32 r;\\n bytes32 s;\\n uint8 v;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n /// @solidity memory-safe-assembly\\n assembly {\\n r := mload(add(signature, 0x20))\\n s := mload(add(signature, 0x40))\\n v := byte(0, mload(add(signature, 0x60)))\\n }\\n return tryRecover(hash, v, r, s);\\n } else {\\n return (address(0), RecoverError.InvalidSignatureLength);\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature`. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n */\\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, signature);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\\n *\\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address, RecoverError) {\\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\\n uint8 v = uint8((uint256(vs) >> 255) + 27);\\n return tryRecover(hash, v, r, s);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\\n *\\n * _Available since v4.2._\\n */\\n function recover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address, RecoverError) {\\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\\n // the valid range for s in (301): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (302): v \\u2208 {27, 28}. Most\\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\\n //\\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\\n // these malleable signatures as well.\\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\\n return (address(0), RecoverError.InvalidSignatureS);\\n }\\n if (v != 27 && v != 28) {\\n return (address(0), RecoverError.InvalidSignatureV);\\n }\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n if (signer == address(0)) {\\n return (address(0), RecoverError.InvalidSignature);\\n }\\n\\n return (signer, RecoverError.NoError);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function recover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\\n // 32 is the length in bytes of hash,\\n // enforced by the type signature above\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n32\\\", hash));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from `s`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n\\\", Strings.toString(s.length), s));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Typed Data, created from a\\n * `domainSeparator` and a `structHash`. This produces hash corresponding\\n * to the one signed with the\\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\\n * JSON-RPC method as part of EIP-712.\\n *\\n * See {recover}.\\n */\\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19\\\\x01\\\", domainSeparator, structHash));\\n }\\n}\\n\",\"keccak256\":\"0xdb7f5c28fc61cda0bd8ab60ce288e206b791643bcd3ba464a70cbec18895a2f5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"contracts/extensions/TransparentUpgradeableProxyV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract TransparentUpgradeableProxyV2 is TransparentUpgradeableProxy {\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable TransparentUpgradeableProxy(_logic, admin_, _data) {}\\n\\n /**\\n * @dev Calls a function from the current implementation as specified by `_data`, which should be an encoded function call.\\n *\\n * Requirements:\\n * - Only the admin can call this function.\\n *\\n * Note: The proxy admin is not allowed to interact with the proxy logic through the fallback function to avoid\\n * triggering some unexpected logic. This is to allow the administrator to explicitly call the proxy, please consider\\n * reviewing the encoded data `_data` and the method which is called before using this.\\n *\\n */\\n function functionDelegateCall(bytes memory _data) public payable ifAdmin {\\n address _addr = _implementation();\\n assembly {\\n let _result := delegatecall(gas(), _addr, add(_data, 32), mload(_data), 0, 0)\\n returndatacopy(0, 0, returndatasize())\\n switch _result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x6609392ea7d3174439b5715100bee82528fe6e4aff28927d48c27db8475e88c5\",\"license\":\"MIT\"},\"contracts/extensions/collections/HasContracts.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { HasProxyAdmin } from \\\"./HasProxyAdmin.sol\\\";\\nimport \\\"../../interfaces/collections/IHasContracts.sol\\\";\\nimport { IdentityGuard } from \\\"../../utils/IdentityGuard.sol\\\";\\nimport { ErrUnexpectedInternalCall } from \\\"../../utils/CommonErrors.sol\\\";\\n\\n/**\\n * @title HasContracts\\n * @dev A contract that provides functionality to manage multiple contracts with different roles.\\n */\\nabstract contract HasContracts is HasProxyAdmin, IHasContracts, IdentityGuard {\\n /// @dev value is equal to keccak256(\\\"@ronin.dpos.collections.HasContracts.slot\\\") - 1\\n bytes32 private constant _STORAGE_SLOT = 0xdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb;\\n\\n /**\\n * @dev Modifier to restrict access to functions only to contracts with a specific role.\\n * @param contractType The contract type that allowed to call\\n */\\n modifier onlyContract(ContractType contractType) virtual {\\n _requireContract(contractType);\\n _;\\n }\\n\\n /**\\n * @inheritdoc IHasContracts\\n */\\n function setContract(ContractType contractType, address addr) external virtual onlyAdmin {\\n _requireHasCode(addr);\\n _setContract(contractType, addr);\\n }\\n\\n /**\\n * @inheritdoc IHasContracts\\n */\\n function getContract(ContractType contractType) public view returns (address contract_) {\\n contract_ = _getContractMap()[uint8(contractType)];\\n if (contract_ == address(0)) revert ErrContractTypeNotFound(contractType);\\n }\\n\\n /**\\n * @dev Internal function to set the address of a contract with a specific role.\\n * @param contractType The contract type of the contract to set.\\n * @param addr The address of the contract to set.\\n */\\n function _setContract(ContractType contractType, address addr) internal virtual {\\n _getContractMap()[uint8(contractType)] = addr;\\n emit ContractUpdated(contractType, addr);\\n }\\n\\n /**\\n * @dev Internal function to access the mapping of contract addresses with roles.\\n * @return contracts_ The mapping of contract addresses with roles.\\n */\\n function _getContractMap() private pure returns (mapping(uint8 => address) storage contracts_) {\\n assembly {\\n contracts_.slot := _STORAGE_SLOT\\n }\\n }\\n\\n /**\\n * @dev Internal function to check if the calling contract has a specific role.\\n * @param contractType The contract type that the calling contract must have.\\n * @dev Throws an error if the calling contract does not have the specified role.\\n */\\n function _requireContract(ContractType contractType) private view {\\n if (msg.sender != getContract(contractType)) {\\n revert ErrUnexpectedInternalCall(msg.sig, contractType, msg.sender);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9e1dceb68827adfb8c8184662f29ab5fe14e292a632878150e3b0b6c61bc1dce\",\"license\":\"MIT\"},\"contracts/extensions/collections/HasProxyAdmin.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/StorageSlot.sol\\\";\\nimport \\\"../../utils/CommonErrors.sol\\\";\\n\\nabstract contract HasProxyAdmin {\\n // bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n modifier onlyAdmin() {\\n _requireAdmin();\\n _;\\n }\\n\\n /**\\n * @dev Returns proxy admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n function _requireAdmin() internal view {\\n if (msg.sender != _getAdmin()) revert ErrUnauthorized(msg.sig, RoleAccess.ADMIN);\\n }\\n}\\n\",\"keccak256\":\"0x06e5962713a77abf6d5ba646e1cc1cfb6f9c50e7d52520dd82a10bf309534187\",\"license\":\"MIT\"},\"contracts/extensions/consumers/PercentageConsumer.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nabstract contract PercentageConsumer {\\n uint256 internal constant _MAX_PERCENTAGE = 100_00;\\n}\\n\",\"keccak256\":\"0x5dc54a24348c5d614de1b4805dddeab4dda72f9f0636b27bf0ed295fee017dcf\",\"license\":\"MIT\"},\"contracts/interfaces/IBridgeAdminProposal.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { BridgeOperatorsBallot } from \\\"../libraries/BridgeOperatorsBallot.sol\\\";\\n\\ninterface IBridgeAdminProposal {\\n /// @dev Emitted when the bridge operators are approved.\\n event BridgeOperatorsApproved(uint256 period, uint256 epoch, address[] operators);\\n\\n /**\\n * @dev Returns the last voted block of the bridge voter.\\n */\\n function lastVotedBlock(address bridgeVoter) external view returns (uint256);\\n\\n /**\\n * @dev Returns the synced bridge operator set info.\\n */\\n function lastSyncedBridgeOperatorSetInfo()\\n external\\n view\\n returns (BridgeOperatorsBallot.BridgeOperatorSet memory bridgeOperatorSetInfo);\\n}\\n\",\"keccak256\":\"0x38caf9faa1e53ca37b08813a8933760b1a975f821b391e7696c7ee38b69bf8c7\",\"license\":\"MIT\"},\"contracts/interfaces/IMaintenance.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface IMaintenance {\\n /**\\n * @dev Error thrown when attempting to schedule an already scheduled event.\\n */\\n error ErrAlreadyScheduled();\\n\\n /**\\n * @dev Error thrown when referring to a non-existent schedule.\\n */\\n error ErrUnexistedSchedule();\\n\\n /**\\n * @dev Error thrown when the end block of a schedule is out of range.\\n */\\n error ErrEndBlockOutOfRange();\\n\\n /**\\n * @dev Error thrown when the start block of a schedule is out of range.\\n */\\n error ErrStartBlockOutOfRange();\\n\\n /**\\n * @dev Error thrown when attempting to initiate maintenance while already in maintenance mode.\\n */\\n error ErrAlreadyOnMaintenance();\\n\\n /**\\n * @dev Error thrown when attempting an action before the cooldown period has ended.\\n */\\n error ErrCooldownTimeNotYetEnded();\\n\\n /**\\n * @dev Error thrown when the total number of schedules exceeds the limit.\\n */\\n error ErrTotalOfSchedulesExceeded();\\n\\n /**\\n * @dev Error thrown when an invalid maintenance duration is specified.\\n */\\n error ErrInvalidMaintenanceDuration();\\n\\n /**\\n * @dev Error thrown when an invalid maintenance duration configuration is provided.\\n */\\n error ErrInvalidMaintenanceDurationConfig();\\n\\n /**\\n * @dev Error thrown when an invalid offset is specified to start the schedule configurations.\\n */\\n error ErrInvalidOffsetToStartScheduleConfigs();\\n\\n struct Schedule {\\n uint256 from;\\n uint256 to;\\n uint256 lastUpdatedBlock;\\n uint256 requestTimestamp;\\n }\\n\\n /// @dev Emitted when a maintenance is scheduled.\\n event MaintenanceScheduled(address indexed consensusAddr, Schedule);\\n /// @dev Emitted when a schedule of maintenance is cancelled.\\n event MaintenanceScheduleCancelled(address indexed consensusAddr);\\n /// @dev Emitted when the maintenance config is updated.\\n event MaintenanceConfigUpdated(\\n uint256 minMaintenanceDurationInBlock,\\n uint256 maxMaintenanceDurationInBlock,\\n uint256 minOffsetToStartSchedule,\\n uint256 maxOffsetToStartSchedule,\\n uint256 maxSchedules,\\n uint256 cooldownSecsToMaintain\\n );\\n\\n /**\\n * @dev Returns whether the validator `_consensusAddr` maintained at the block number `_block`.\\n */\\n function checkMaintained(address _consensusAddr, uint256 _block) external view returns (bool);\\n\\n /**\\n * @dev Returns whether the validator `_consensusAddr` maintained in the inclusive range [`_fromBlock`, `_toBlock`] of blocks.\\n */\\n function checkMaintainedInBlockRange(\\n address _consensusAddr,\\n uint256 _fromBlock,\\n uint256 _toBlock\\n ) external view returns (bool);\\n\\n /**\\n * @dev Returns the bool array indicating the validators maintained at block number `_block` or not.\\n */\\n function checkManyMaintained(address[] calldata _addrList, uint256 _block) external view returns (bool[] memory);\\n\\n /**\\n * @dev Returns a bool array indicating the validators maintained in the inclusive range [`_fromBlock`, `_toBlock`] of blocks or not.\\n */\\n function checkManyMaintainedInBlockRange(\\n address[] calldata _addrList,\\n uint256 _fromBlock,\\n uint256 _toBlock\\n ) external view returns (bool[] memory);\\n\\n /**\\n * @dev Returns whether the validator `_consensusAddr` has scheduled.\\n */\\n function checkScheduled(address _consensusAddr) external view returns (bool);\\n\\n /**\\n * @dev Returns whether the validator `_consensusAddr`\\n */\\n function checkCooldownEnds(address _consensusAddr) external view returns (bool);\\n\\n /**\\n * @dev Returns the detailed schedule of the validator `_consensusAddr`.\\n */\\n function getSchedule(address _consensusAddr) external view returns (Schedule memory);\\n\\n /**\\n * @dev Returns the total of current schedules.\\n */\\n function totalSchedules() external view returns (uint256 _count);\\n\\n /**\\n * @dev Sets the duration restriction, start time restriction, and max allowed for maintenance.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n * - The max duration is larger than the min duration.\\n * - The max offset is larger than the min offset.\\n *\\n * Emits the event `MaintenanceConfigUpdated`.\\n *\\n */\\n function setMaintenanceConfig(\\n uint256 _minMaintenanceDurationInBlock,\\n uint256 _maxMaintenanceDurationInBlock,\\n uint256 _minOffsetToStartSchedule,\\n uint256 _maxOffsetToStartSchedule,\\n uint256 _maxSchedules,\\n uint256 _cooldownSecsToMaintain\\n ) external;\\n\\n /**\\n * @dev Returns the min duration for maintenance in block.\\n */\\n function minMaintenanceDurationInBlock() external view returns (uint256);\\n\\n /**\\n * @dev Returns the max duration for maintenance in block.\\n */\\n function maxMaintenanceDurationInBlock() external view returns (uint256);\\n\\n /**\\n * @dev The offset to the min block number that the schedule can start\\n */\\n function minOffsetToStartSchedule() external view returns (uint256);\\n\\n /**\\n * @dev The offset to the max block number that the schedule can start\\n */\\n function maxOffsetToStartSchedule() external view returns (uint256);\\n\\n /**\\n * @dev Returns the max number of scheduled maintenances.\\n */\\n function maxSchedules() external view returns (uint256);\\n\\n /**\\n * @dev Schedules for maintenance from `_startedAtBlock` to `_startedAtBlock`.\\n *\\n * Requirements:\\n * - The candidate `_consensusAddr` is the block producer.\\n * - The method caller is candidate admin of the candidate `_consensusAddr`.\\n * - The candidate `_consensusAddr` has no schedule yet or the previous is done.\\n * - The total number of schedules is not larger than `maxSchedules()`.\\n * - The start block must be at least `minOffsetToStartSchedule()` and at most `maxOffsetToStartSchedule()` blocks from the current block.\\n * - The end block is larger than the start block.\\n * - The scheduled duration is larger than the `minMaintenanceDurationInBlock()` and less than the `maxMaintenanceDurationInBlock()`.\\n * - The start block is at the start of an epoch.\\n * - The end block is at the end of an epoch.\\n *\\n * Emits the event `MaintenanceScheduled`.\\n *\\n */\\n function schedule(address _consensusAddr, uint256 _startedAtBlock, uint256 _endedAtBlock) external;\\n\\n /**\\n * @dev Cancel the schedule of maintenance for the `_consensusAddr`.\\n *\\n * Requirements:\\n * - The candidate `_consensusAddr` is the block producer.\\n * - The method caller is candidate admin of the candidate `_consensusAddr`.\\n * - A schedule for the `_consensusAddr` must be existent and not executed yet.\\n *\\n * Emits the event `MaintenanceScheduleCancelled`.\\n */\\n function cancelSchedule(address _consensusAddr) external;\\n}\\n\",\"keccak256\":\"0xd399a23652fc0180280f0079dd4be420d807774bcf6bc12672f4238480e757e9\",\"license\":\"MIT\"},\"contracts/interfaces/IQuorum.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\ninterface IQuorum {\\n /// @dev Emitted when the threshold is updated\\n event ThresholdUpdated(\\n uint256 indexed nonce,\\n uint256 indexed numerator,\\n uint256 indexed denominator,\\n uint256 previousNumerator,\\n uint256 previousDenominator\\n );\\n\\n /**\\n * @dev Returns the threshold.\\n */\\n function getThreshold() external view returns (uint256 _num, uint256 _denom);\\n\\n /**\\n * @dev Checks whether the `_voteWeight` passes the threshold.\\n */\\n function checkThreshold(uint256 _voteWeight) external view returns (bool);\\n\\n /**\\n * @dev Returns the minimum vote weight to pass the threshold.\\n */\\n function minimumVoteWeight() external view returns (uint256);\\n\\n /**\\n * @dev Sets the threshold.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the `ThresholdUpdated` event.\\n *\\n */\\n function setThreshold(\\n uint256 _numerator,\\n uint256 _denominator\\n ) external returns (uint256 _previousNum, uint256 _previousDenom);\\n}\\n\",\"keccak256\":\"0x6b7920b04a73a0e1ff7404aa1a3b5fc738fc0b6154839480f666fd69b55123f0\",\"license\":\"MIT\"},\"contracts/interfaces/IRoninTrustedOrganization.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IQuorum.sol\\\";\\n\\ninterface IRoninTrustedOrganization is IQuorum {\\n /**\\n * @dev Error indicating that a query for a duplicate entry was made.\\n */\\n error ErrQueryForDupplicated();\\n\\n /**\\n * @dev Error indicating that a query was made for a non-existent consensus address.\\n */\\n error ErrQueryForNonExistentConsensusAddress();\\n\\n /**\\n * @dev Error indicating that a bridge voter has already been added.\\n * @param voter The address of the bridge voter that is already added.\\n */\\n error ErrBridgeVoterIsAlreadyAdded(address voter);\\n\\n /**\\n * @dev Error indicating that a governor address has already been added.\\n * @param addr The address of the governor that is already added.\\n */\\n error ErrGovernorAddressIsAlreadyAdded(address addr);\\n\\n /**\\n * @dev Error indicating that a consensus address is not added.\\n * @param addr The address of the consensus contract that is not added.\\n */\\n error ErrConsensusAddressIsNotAdded(address addr);\\n\\n /**\\n * @dev Error indicating that a consensus address is already added.\\n * @param addr The address of the consensus contract that is already added.\\n */\\n error ErrConsensusAddressIsAlreadyAdded(address addr);\\n\\n struct TrustedOrganization {\\n // Address of the validator that produces block, e.g. block.coinbase. This is so-called validator address.\\n address consensusAddr;\\n // Address to voting proposal\\n address governor;\\n // Address to voting bridge operators\\n address bridgeVoter;\\n // Its Weight\\n uint256 weight;\\n // The block that the organization was added\\n uint256 addedBlock;\\n }\\n\\n /// @dev Emitted when the trusted organization is added.\\n event TrustedOrganizationsAdded(TrustedOrganization[] orgs);\\n /// @dev Emitted when the trusted organization is updated.\\n event TrustedOrganizationsUpdated(TrustedOrganization[] orgs);\\n /// @dev Emitted when the trusted organization is removed.\\n event TrustedOrganizationsRemoved(address[] orgs);\\n\\n /**\\n * @dev Adds a list of addresses into the trusted organization.\\n *\\n * Requirements:\\n * - The weights should larger than 0.\\n * - The method caller is admin.\\n * - The field `addedBlock` should be blank.\\n *\\n * Emits the event `TrustedOrganizationAdded` once an organization is added.\\n *\\n */\\n function addTrustedOrganizations(TrustedOrganization[] calldata) external;\\n\\n /**\\n * @dev Updates weights for a list of existent trusted organization.\\n *\\n * Requirements:\\n * - The weights should larger than 0.\\n * - The method caller is admin.\\n *\\n * Emits the `TrustedOrganizationUpdated` event.\\n *\\n */\\n function updateTrustedOrganizations(TrustedOrganization[] calldata _list) external;\\n\\n /**\\n * @dev Removes a list of addresses from the trusted organization.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `TrustedOrganizationRemoved` once an organization is removed.\\n *\\n * @param _consensusAddrs The list of consensus addresses linked to corresponding trusted organization that to be removed.\\n */\\n function removeTrustedOrganizations(address[] calldata _consensusAddrs) external;\\n\\n /**\\n * @dev Returns total weights.\\n */\\n function totalWeights() external view returns (uint256);\\n\\n /**\\n * @dev Returns the weight of a consensus.\\n */\\n function getConsensusWeight(address _consensusAddr) external view returns (uint256);\\n\\n /**\\n * @dev Returns the weight of a governor.\\n */\\n function getGovernorWeight(address _governor) external view returns (uint256);\\n\\n /**\\n * @dev Returns the weight of a bridge voter.\\n */\\n function getBridgeVoterWeight(address _addr) external view returns (uint256);\\n\\n /**\\n * @dev Returns the weights of a list of consensus addresses.\\n */\\n function getConsensusWeights(address[] calldata _list) external view returns (uint256[] memory);\\n\\n /**\\n * @dev Returns the weights of a list of governor addresses.\\n */\\n function getGovernorWeights(address[] calldata _list) external view returns (uint256[] memory);\\n\\n /**\\n * @dev Returns the weights of a list of bridge voter addresses.\\n */\\n function getBridgeVoterWeights(address[] calldata _list) external view returns (uint256[] memory);\\n\\n /**\\n * @dev Returns total weights of the consensus list.\\n */\\n function sumConsensusWeights(address[] calldata _list) external view returns (uint256 _res);\\n\\n /**\\n * @dev Returns total weights of the governor list.\\n */\\n function sumGovernorWeights(address[] calldata _list) external view returns (uint256 _res);\\n\\n /**\\n * @dev Returns total weights of the bridge voter list.\\n */\\n function sumBridgeVoterWeights(address[] calldata _list) external view returns (uint256 _res);\\n\\n /**\\n * @dev Returns the trusted organization at `_index`.\\n */\\n function getTrustedOrganizationAt(uint256 _index) external view returns (TrustedOrganization memory);\\n\\n /**\\n * @dev Returns the number of trusted organizations.\\n */\\n function countTrustedOrganizations() external view returns (uint256);\\n\\n /**\\n * @dev Returns all of the trusted organizations.\\n */\\n function getAllTrustedOrganizations() external view returns (TrustedOrganization[] memory);\\n\\n /**\\n * @dev Returns the trusted organization by consensus address.\\n *\\n * Reverts once the consensus address is non-existent.\\n */\\n function getTrustedOrganization(address _consensusAddr) external view returns (TrustedOrganization memory);\\n}\\n\",\"keccak256\":\"0x28b0407cf740164f3ddf4a44952423604439cda580f286c6ed1edcdb59b219d0\",\"license\":\"MIT\"},\"contracts/interfaces/collections/IHasContracts.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport { ContractType } from \\\"../../utils/ContractType.sol\\\";\\n\\ninterface IHasContracts {\\n /// @dev Error of invalid role.\\n error ErrContractTypeNotFound(ContractType contractType);\\n\\n /// @dev Emitted when a contract is updated.\\n event ContractUpdated(ContractType indexed contractType, address indexed addr);\\n\\n /**\\n * @dev Returns the address of a contract with a specific role.\\n * Throws an error if no contract is set for the specified role.\\n *\\n * @param contractType The role of the contract to retrieve.\\n * @return contract_ The address of the contract with the specified role.\\n */\\n function getContract(ContractType contractType) external view returns (address contract_);\\n\\n /**\\n * @dev Sets the address of a contract with a specific role.\\n * Emits the event {ContractUpdated}.\\n * @param contractType The role of the contract to set.\\n * @param addr The address of the contract to set.\\n */\\n function setContract(ContractType contractType, address addr) external;\\n}\\n\",\"keccak256\":\"0x99d8213d857e30d367155abd15dc42730afdfbbac3a22dfb3b95ffea2083a92e\",\"license\":\"MIT\"},\"contracts/interfaces/slash-indicator/IBaseSlash.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface IBaseSlash {\\n enum SlashType {\\n UNKNOWN,\\n UNAVAILABILITY_TIER_1,\\n UNAVAILABILITY_TIER_2,\\n DOUBLE_SIGNING,\\n BRIDGE_VOTING,\\n BRIDGE_OPERATOR_MISSING_VOTE_TIER_1,\\n BRIDGE_OPERATOR_MISSING_VOTE_TIER_2,\\n UNAVAILABILITY_TIER_3\\n }\\n\\n /// @dev Emitted when the validator is slashed.\\n event Slashed(address indexed validator, SlashType slashType, uint256 period);\\n}\\n\",\"keccak256\":\"0x04d449f2852840566dfff4e3673929f6e9b8d9b5fc5b29744bf4f344dc7f9bc0\",\"license\":\"MIT\"},\"contracts/interfaces/slash-indicator/ICreditScore.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface ICreditScore {\\n /**\\n * @dev Error thrown when an invalid credit score configuration is provided.\\n */\\n error ErrInvalidCreditScoreConfig();\\n\\n /**\\n * @dev Error thrown when an invalid cut-off percentage configuration is provided.\\n */\\n error ErrInvalidCutOffPercentageConfig();\\n\\n /**\\n * @dev Error thrown when the caller's credit score is insufficient to bail out a situation.\\n */\\n error ErrInsufficientCreditScoreToBailOut();\\n\\n /**\\n * @dev Error thrown when a validator has previously bailed out.\\n */\\n error ErrValidatorHasBailedOutPreviously();\\n\\n /**\\n * @dev Error thrown when the caller must be jailed in the current period.\\n */\\n error ErrCallerMustBeJailedInTheCurrentPeriod();\\n\\n /// @dev Emitted when the configs to credit score is updated. See the method `setCreditScoreConfigs` for param details.\\n event CreditScoreConfigsUpdated(\\n uint256 gainCreditScore,\\n uint256 maxCreditScore,\\n uint256 bailOutCostMultiplier,\\n uint256 cutOffPercentageAfterBailout\\n );\\n /// @dev Emitted the credit score of validators is updated.\\n event CreditScoresUpdated(address[] validators, uint256[] creditScores);\\n /// @dev Emitted when a validator bailed out of jail.\\n event BailedOut(address indexed validator, uint256 period, uint256 usedCreditScore);\\n\\n /**\\n * @dev Updates the credit score for the validators.\\n *\\n * Requirements:\\n * - Only validator contract can call this method.\\n * - This method is only called at the end of each period.\\n *\\n * Emits the event `CreditScoresUpdated`.\\n *\\n */\\n function updateCreditScores(address[] calldata _validators, uint256 _period) external;\\n\\n /**\\n * @dev Resets the credit score for the revoked validators.\\n *\\n * Requirements:\\n * - Only validator contract can call this method.\\n * - This method is only called at the end of each period.\\n *\\n * Emits the event `CreditScoresUpdated`.\\n *\\n */\\n function execResetCreditScores(address[] calldata _validators) external;\\n\\n /**\\n * @dev A slashed validator use this method to get out of jail.\\n *\\n * Requirements:\\n * - The `_consensusAddr` must be a validator.\\n * - Only validator's admin can call this method.\\n *\\n * Emits the event `BailedOut`.\\n *\\n */\\n function bailOut(address _consensusAddr) external;\\n\\n /**\\n * @dev Sets the configs to credit score.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `CreditScoreConfigsUpdated`.\\n *\\n * @param _gainScore The score to gain per period.\\n * @param _maxScore The max number of credit score that a validator can hold.\\n * @param _bailOutMultiplier The number that will be multiplied with the remaining jailed time to get the cost of bailing out.\\n * @param _cutOffPercentage The percentage of reward that the block producer will be cut off from until the end of the period after bailing out.\\n *\\n */\\n function setCreditScoreConfigs(\\n uint256 _gainScore,\\n uint256 _maxScore,\\n uint256 _bailOutMultiplier,\\n uint256 _cutOffPercentage\\n ) external;\\n\\n /**\\n * @dev Returns the configs related to credit score.\\n *\\n * @return _gainCreditScore The score to gain per period.\\n * @return _maxCreditScore The max number of credit score that a validator can hold.\\n * @return _bailOutCostMultiplier The number that will be multiplied with the remaining jailed time to get the cost of bailing out.\\n * @return _cutOffPercentageAfterBailout The percentage of reward that the block producer will be cut off from until the end of the period after bailing out.\\n *\\n */\\n function getCreditScoreConfigs()\\n external\\n view\\n returns (\\n uint256 _gainCreditScore,\\n uint256 _maxCreditScore,\\n uint256 _bailOutCostMultiplier,\\n uint256 _cutOffPercentageAfterBailout\\n );\\n\\n /**\\n * @dev Returns the current credit score of the validator.\\n */\\n function getCreditScore(address _validator) external view returns (uint256);\\n\\n /**\\n * @dev Returns the current credit score of a list of validators.\\n */\\n function getManyCreditScores(address[] calldata _validators) external view returns (uint256[] memory _resultList);\\n\\n /**\\n * @dev Returns the whether the `_validator` has been bailed out at the `_period`.\\n */\\n function checkBailedOutAtPeriod(address _validator, uint256 _period) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x26021ddf339495816692ea9f8545b4054d0ffb9c5ad11049cac4f3718a0bbc2d\",\"license\":\"MIT\"},\"contracts/interfaces/slash-indicator/ISlashBridgeOperator.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IBaseSlash.sol\\\";\\n\\ninterface ISlashBridgeOperator is IBaseSlash {\\n /**\\n * @dev Error thrown when invalid ratios are provided.\\n */\\n error ErrInvalidRatios();\\n\\n /**\\n * @dev Emitted when the configs to slash bridge operator is updated. See the method\\n * `getBridgeOperatorSlashingConfigs` for param details.\\n */\\n event BridgeOperatorSlashingConfigsUpdated(\\n uint256 missingVotesRatioTier1,\\n uint256 missingVotesRatioTier2,\\n uint256 jailDurationForMissingVotesRatioTier2,\\n uint256 skipBridgeOperatorSlashingThreshold\\n );\\n\\n /**\\n * @dev Acknowledges bridge operator slash and emit `Slashed` event correspondingly.\\n * @param _tier The tier of the slash, in value of {1, 2}, corresponding to `SlashType.BRIDGE_OPERATOR_MISSING_VOTE_TIER_1`\\n * and `SlashType.BRIDGE_OPERATOR_MISSING_VOTE_TIER_2`\\n *\\n * Requirements:\\n * - Only validator contract can invoke this method.\\n * - Should be called only at the end of period.\\n * - Should be called only when there is slash of bridge operator.\\n *\\n * Emits the event `Slashed`.\\n */\\n function execSlashBridgeOperator(address _consensusAddr, uint256 _tier, uint256 _period) external;\\n\\n /**\\n * @dev Returns the configs related to bridge operator slashing.\\n *\\n * @return _missingVotesRatioTier1 The bridge reward will be deprecated if (s)he missed more than this ratio.\\n * @return _missingVotesRatioTier2 The bridge reward and mining reward will be deprecated and the corresponding\\n * block producer will be put in jail if (s)he misses more than this ratio.\\n * @return _jailDurationForMissingVotesRatioTier2 The number of blocks to jail the corresponding block producer when\\n * its bridge operator is slashed tier-2.\\n * @return _skipBridgeOperatorSlashingThreshold The threshold to skip slashing the bridge operator in case the total\\n * number of votes in the bridge is too small.\\n *\\n */\\n function getBridgeOperatorSlashingConfigs()\\n external\\n view\\n returns (\\n uint256 _missingVotesRatioTier1,\\n uint256 _missingVotesRatioTier2,\\n uint256 _jailDurationForMissingVotesRatioTier2,\\n uint256 _skipBridgeOperatorSlashingThreshold\\n );\\n\\n /**\\n * @dev Sets the configs to slash bridge operators.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `BridgeOperatorSlashingConfigsUpdated`.\\n *\\n * @param _ratioTier1 The bridge reward will be deprecated if (s)he missed more than this ratio. Values 0-10,000 map\\n * to 0%-100%.\\n * @param _ratioTier2 The bridge reward and mining reward will be deprecated and the corresponding block producer will\\n * be put in jail if (s)he misses more than this ratio. Values 0-10,000 map to 0%-100%.\\n * @param _jailDurationTier2 The number of blocks to jail the corresponding block producer when its bridge operator is\\n * slashed tier-2.\\n * @param _skipSlashingThreshold The threshold to skip slashing the bridge operator in case the total number of votes\\n * in the bridge is too small.\\n *\\n */\\n function setBridgeOperatorSlashingConfigs(\\n uint256 _ratioTier1,\\n uint256 _ratioTier2,\\n uint256 _jailDurationTier2,\\n uint256 _skipSlashingThreshold\\n ) external;\\n}\\n\",\"keccak256\":\"0x3ea38604baf3bc5a12dd1a243eec2052de9ee2cb171222a2e5b0e5202d301471\",\"license\":\"MIT\"},\"contracts/interfaces/slash-indicator/ISlashBridgeVoting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IBaseSlash.sol\\\";\\n\\ninterface ISlashBridgeVoting is IBaseSlash {\\n /**\\n * @dev Error thrown when an invalid slash is encountered.\\n */\\n error ErrInvalidSlash();\\n\\n /**\\n * @dev Emitted when the configs to slash bridge voting is updated. See the method `getBridgeVotingSlashingConfigs` for param\\n * details.\\n */\\n event BridgeVotingSlashingConfigsUpdated(uint256 bridgeVotingThreshold, uint256 bridgeVotingSlashAmount);\\n\\n /**\\n * @dev Slashes for bridge voter governance.\\n *\\n * Emits the event `Slashed`.\\n */\\n function slashBridgeVoting(address _consensusAddr) external;\\n\\n /**\\n * @dev Returns the configs related to bridge voting slashing.\\n *\\n * @return _bridgeVotingThreshold The threshold to slash when a trusted organization does not vote for bridge\\n * operators.\\n * @return _bridgeVotingSlashAmount The amount of RON to slash bridge voting.\\n *\\n */\\n function getBridgeVotingSlashingConfigs()\\n external\\n view\\n returns (uint256 _bridgeVotingThreshold, uint256 _bridgeVotingSlashAmount);\\n\\n /**\\n * @dev Sets the configs to slash bridge voting.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `BridgeVotingSlashingConfigsUpdated`.\\n *\\n * @param _threshold The threshold to slash when a trusted organization does not vote for bridge operators.\\n * @param _slashAmount The amount of RON to slash bridge voting.\\n *\\n */\\n function setBridgeVotingSlashingConfigs(uint256 _threshold, uint256 _slashAmount) external;\\n}\\n\",\"keccak256\":\"0x89751cbf99adf7dbd165fbbba5d6b62b5c47f8486322a7abb27d6d6aef345fae\",\"license\":\"MIT\"},\"contracts/interfaces/slash-indicator/ISlashDoubleSign.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IBaseSlash.sol\\\";\\n\\ninterface ISlashDoubleSign is IBaseSlash {\\n /**\\n * @dev Error thrown when evidence has already been submitted.\\n */\\n error ErrEvidenceAlreadySubmitted();\\n\\n /**\\n * @dev Emitted when the configs to slash double sign is updated. See the method `getDoubleSignSlashingConfigs`\\n * for param details.\\n */\\n event DoubleSignSlashingConfigsUpdated(\\n uint256 slashDoubleSignAmount,\\n uint256 doubleSigningJailUntilBlock,\\n uint256 doubleSigningOffsetLimitBlock\\n );\\n\\n /**\\n * @dev Slashes for double signing.\\n *\\n * Requirements:\\n * - The method caller is coinbase.\\n *\\n * Emits the event `Slashed` if the double signing evidence of the two headers valid.\\n */\\n function slashDoubleSign(address _validatorAddr, bytes calldata _header1, bytes calldata _header2) external;\\n\\n /**\\n * @dev Returns the configs related to block producer slashing.\\n *\\n * @return _slashDoubleSignAmount The amount of RON to slash double sign.\\n * @return _doubleSigningJailUntilBlock The block number that the punished validator will be jailed until, due to\\n * double signing.\\n * @param _doubleSigningOffsetLimitBlock The number of block that the current block is at most far from the double\\n * signing block.\\n *\\n */\\n function getDoubleSignSlashingConfigs()\\n external\\n view\\n returns (\\n uint256 _slashDoubleSignAmount,\\n uint256 _doubleSigningJailUntilBlock,\\n uint256 _doubleSigningOffsetLimitBlock\\n );\\n\\n /**\\n * @dev Sets the configs to slash block producers.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `DoubleSignSlashingConfigsUpdated`.\\n *\\n * @param _slashAmount The amount of RON to slash double sign.\\n * @param _jailUntilBlock The block number that the punished validator will be jailed until, due to double signing.\\n * @param _doubleSigningOffsetLimitBlock The number of block that the current block is at most far from the double\\n * signing block.\\n *\\n */\\n function setDoubleSignSlashingConfigs(\\n uint256 _slashAmount,\\n uint256 _jailUntilBlock,\\n uint256 _doubleSigningOffsetLimitBlock\\n ) external;\\n}\\n\",\"keccak256\":\"0x5b7c9b07d0f97c589789eb0775411825df2163bdf893fb5df1113415b91b91ed\",\"license\":\"MIT\"},\"contracts/interfaces/slash-indicator/ISlashIndicator.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./ISlashDoubleSign.sol\\\";\\nimport \\\"./ISlashBridgeVoting.sol\\\";\\nimport \\\"./ISlashBridgeOperator.sol\\\";\\nimport \\\"./ISlashUnavailability.sol\\\";\\nimport \\\"./ICreditScore.sol\\\";\\n\\ninterface ISlashIndicator is\\n ISlashDoubleSign,\\n ISlashBridgeVoting,\\n ISlashBridgeOperator,\\n ISlashUnavailability,\\n ICreditScore\\n{}\\n\",\"keccak256\":\"0xe8b8fde3af614735cb304bc1eb82b05d65ede4df804b5d555787e5d5ecb95ec0\",\"license\":\"MIT\"},\"contracts/interfaces/slash-indicator/ISlashUnavailability.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IBaseSlash.sol\\\";\\n\\ninterface ISlashUnavailability is IBaseSlash {\\n /**\\n * @dev Error thrown when attempting to slash a validator twice or slash more than one validator in one block.\\n */\\n error ErrCannotSlashAValidatorTwiceOrSlashMoreThanOneValidatorInOneBlock();\\n\\n /**\\n * @dev Emitted when the configs to slash bridge operator is updated. See the method `getUnavailabilitySlashingConfigs`\\n * for param details.\\n */\\n event UnavailabilitySlashingConfigsUpdated(\\n uint256 unavailabilityTier1Threshold,\\n uint256 unavailabilityTier2Threshold,\\n uint256 slashAmountForUnavailabilityTier2Threshold,\\n uint256 jailDurationForUnavailabilityTier2Threshold\\n );\\n\\n /**\\n * @dev Returns the last block that a block producer is slashed for unavailability.\\n */\\n function lastUnavailabilitySlashedBlock() external view returns (uint256);\\n\\n /**\\n * @dev Slashes for unavailability by increasing the counter of block producer `_consensusAddr`.\\n *\\n * Requirements:\\n * - The method caller is coinbase.\\n *\\n * Emits the event `Slashed` when the threshold is reached.\\n *\\n */\\n function slashUnavailability(address _consensusAddr) external;\\n\\n /**\\n * @dev Returns the current unavailability indicator of a block producer.\\n */\\n function currentUnavailabilityIndicator(address _validator) external view returns (uint256);\\n\\n /**\\n * @dev Returns the unavailability indicator in the period `_period` of a block producer.\\n */\\n function getUnavailabilityIndicator(address _validator, uint256 _period) external view returns (uint256);\\n\\n /**\\n * @dev Returns the configs related to block producer slashing.\\n *\\n * @return _unavailabilityTier1Threshold The mining reward will be deprecated, if (s)he missed more than this\\n * threshold. This threshold is applied for tier-1 and tier-3 slash.\\n * @return _unavailabilityTier2Threshold The mining reward will be deprecated, (s)he will be put in jailed, and will\\n * be deducted self-staking if (s)he misses more than this threshold. This threshold is applied for tier-2 slash.\\n * @return _slashAmountForUnavailabilityTier2Threshold The amount of RON to deduct from self-staking of a block\\n * producer when (s)he is slashed with tier-2 or tier-3.\\n * @return _jailDurationForUnavailabilityTier2Threshold The number of blocks to jail a block producer when (s)he is\\n * slashed with tier-2 or tier-3.\\n *\\n */\\n function getUnavailabilitySlashingConfigs()\\n external\\n view\\n returns (\\n uint256 _unavailabilityTier1Threshold,\\n uint256 _unavailabilityTier2Threshold,\\n uint256 _slashAmountForUnavailabilityTier2Threshold,\\n uint256 _jailDurationForUnavailabilityTier2Threshold\\n );\\n\\n /**\\n * @dev Sets the configs to slash block producers.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `BridgeOperatorSlashingConfigsUpdated`.\\n *\\n * @param _tier1Threshold The mining reward will be deprecated, if (s)he missed more than this threshold.\\n * @param _tier2Threshold The mining reward will be deprecated, (s)he will be put in jailed, and will be deducted\\n * self-staking if (s)he misses more than this threshold.\\n * @param _slashAmountForTier2Threshold The amount of RON to deduct from self-staking of a block producer when (s)he\\n * is slashed tier-2.\\n * @param _jailDurationForTier2Threshold The number of blocks to jail a block producer when (s)he is slashed tier-2.\\n *\\n */\\n function setUnavailabilitySlashingConfigs(\\n uint256 _tier1Threshold,\\n uint256 _tier2Threshold,\\n uint256 _slashAmountForTier2Threshold,\\n uint256 _jailDurationForTier2Threshold\\n ) external;\\n}\\n\",\"keccak256\":\"0x458a7ae130a59b59b7f095fe3d4db8f779e0614041e5615f0afd36c543ac2046\",\"license\":\"MIT\"},\"contracts/interfaces/validator/ICandidateManager.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface ICandidateManager {\\n struct ValidatorCandidate {\\n // Admin of the candidate\\n address admin;\\n // Address of the validator that produces block, e.g. block.coinbase. This is so-called validator address.\\n address consensusAddr;\\n // Address that receives mining reward of the validator\\n address payable treasuryAddr;\\n // Address of the bridge operator corresponding to the candidate\\n address ______deprecatedbridgeOperatorAddr;\\n // The percentage of reward that validators can be received, the rest goes to the delegators.\\n // Values in range [0; 100_00] stands for 0-100%\\n uint256 commissionRate;\\n // The timestamp that scheduled to revoke the candidate (no schedule=0)\\n uint256 revokingTimestamp;\\n // The deadline that the candidate must top up staking amount to keep it larger than or equal to the threshold (no deadline=0)\\n uint256 topupDeadline;\\n }\\n\\n struct CommissionSchedule {\\n // The timestamp that the commission schedule gets affected (no schedule=0).\\n uint256 effectiveTimestamp;\\n // The new commission rate. Value is in range [0; 100_00], stands for 0-100%\\n uint256 commissionRate;\\n }\\n\\n /// @dev Emitted when the maximum number of validator candidates is updated.\\n event MaxValidatorCandidateUpdated(uint256 threshold);\\n /// @dev Emitted when the min offset to the effective date of commission rate change is updated.\\n event MinEffectiveDaysOnwardsUpdated(uint256 numOfDays);\\n /// @dev Emitted when the validator candidate is granted.\\n event CandidateGranted(address indexed consensusAddr, address indexed treasuryAddr, address indexed admin);\\n /// @dev Emitted when the revoking timestamp of a candidate is updated.\\n event CandidateRevokingTimestampUpdated(address indexed consensusAddr, uint256 revokingTimestamp);\\n /// @dev Emitted when the topup deadline of a candidate is updated.\\n event CandidateTopupDeadlineUpdated(address indexed consensusAddr, uint256 topupDeadline);\\n /// @dev Emitted when the validator candidate is revoked.\\n event CandidatesRevoked(address[] consensusAddrs);\\n\\n /// @dev Emitted when a schedule for updating commission rate is set.\\n event CommissionRateUpdateScheduled(address indexed consensusAddr, uint256 effectiveTimestamp, uint256 rate);\\n /// @dev Emitted when the commission rate of a validator is updated.\\n event CommissionRateUpdated(address indexed consensusAddr, uint256 rate);\\n\\n /// @dev Error of exceeding maximum number of candidates.\\n error ErrExceedsMaxNumberOfCandidate();\\n /// @dev Error of querying for already existent candidate.\\n error ErrExistentCandidate();\\n /// @dev Error of querying for non-existent candidate.\\n error ErrNonExistentCandidate();\\n /// @dev Error of candidate admin already exists.\\n error ErrExistentCandidateAdmin(address _candidateAdminAddr);\\n /// @dev Error of treasury already exists.\\n error ErrExistentTreasury(address _treasuryAddr);\\n /// @dev Error of invalid commission rate.\\n error ErrInvalidCommissionRate();\\n /// @dev Error of invalid effective days onwards.\\n error ErrInvalidEffectiveDaysOnwards();\\n /// @dev Error of invalid min effective days onwards.\\n error ErrInvalidMinEffectiveDaysOnwards();\\n /// @dev Error of already requested revoking candidate before.\\n error ErrAlreadyRequestedRevokingCandidate();\\n /// @dev Error of commission change schedule exists.\\n error ErrAlreadyRequestedUpdatingCommissionRate();\\n /// @dev Error of trusted org cannot renounce.\\n error ErrTrustedOrgCannotRenounce();\\n\\n /**\\n * @dev Returns the maximum number of validator candidate.\\n */\\n function maxValidatorCandidate() external view returns (uint256);\\n\\n /**\\n * @dev Returns the minimum number of days to the effective date of commission rate change.\\n */\\n function minEffectiveDaysOnwards() external view returns (uint256);\\n\\n /**\\n * @dev Sets the maximum number of validator candidate.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the `MaxValidatorCandidateUpdated` event.\\n *\\n */\\n function setMaxValidatorCandidate(uint256) external;\\n\\n /**\\n * @dev Sets the minimum number of days to the effective date of commision rate change.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the `MinEffectiveDaysOnwardsUpdated` event.\\n *\\n */\\n function setMinEffectiveDaysOnwards(uint256 _numOfDays) external;\\n\\n /**\\n * @dev Grants a validator candidate.\\n *\\n * Requirements:\\n * - The method caller is staking contract.\\n *\\n * Emits the event `CandidateGranted`.\\n *\\n */\\n function execApplyValidatorCandidate(\\n address _admin,\\n address _consensusAddr,\\n address payable _treasuryAddr,\\n uint256 _commissionRate\\n ) external;\\n\\n /**\\n * @dev Requests to revoke a validator candidate in next `_secsLeft` seconds.\\n *\\n * Requirements:\\n * - The method caller is staking contract.\\n *\\n * Emits the event `CandidateRevokingTimestampUpdated`.\\n *\\n */\\n function execRequestRenounceCandidate(address, uint256 _secsLeft) external;\\n\\n /**\\n * @dev Fallback function of `CandidateStaking-requestUpdateCommissionRate`.\\n *\\n * Requirements:\\n * - The method caller is the staking contract.\\n * - The `_effectiveTimestamp` must be the beginning of a UTC day, and at least from 7 days onwards\\n * - The `_rate` must be in range of [0_00; 100_00].\\n *\\n * Emits the event `CommissionRateUpdateScheduled`.\\n *\\n */\\n function execRequestUpdateCommissionRate(address _consensusAddr, uint256 _effectiveTimestamp, uint256 _rate) external;\\n\\n /**\\n * @dev Returns whether the address is a validator (candidate).\\n */\\n function isValidatorCandidate(address _addr) external view returns (bool);\\n\\n /**\\n * @dev Returns the validator candidate.\\n */\\n function getValidatorCandidates() external view returns (address[] memory);\\n\\n /**\\n * @dev Returns all candidate info.\\n */\\n function getCandidateInfos() external view returns (ValidatorCandidate[] memory);\\n\\n /**\\n * @dev Returns the info of a candidate.\\n */\\n function getCandidateInfo(address _candidate) external view returns (ValidatorCandidate memory);\\n\\n /**\\n * @dev Returns whether the address is the candidate admin.\\n */\\n function isCandidateAdmin(address _candidate, address _admin) external view returns (bool);\\n\\n /**\\n * @dev Returns the schedule of changing commission rate of a candidate address.\\n */\\n function getCommissionChangeSchedule(address _candidate) external view returns (CommissionSchedule memory);\\n}\\n\",\"keccak256\":\"0x9ab205c736f1bcc9a3debe06e08d829f4857141d940e6f608236f136193a7f49\",\"license\":\"MIT\"},\"contracts/interfaces/validator/ICoinbaseExecution.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./ISlashingExecution.sol\\\";\\n\\ninterface ICoinbaseExecution is ISlashingExecution {\\n enum BlockRewardDeprecatedType {\\n UNKNOWN,\\n UNAVAILABILITY,\\n AFTER_BAILOUT\\n }\\n\\n /// @dev Emitted when the validator set is updated\\n event ValidatorSetUpdated(uint256 indexed period, address[] consensusAddrs);\\n /// @dev Emitted when the bridge operator set is updated, to mirror the in-jail and maintaining status of the validator.\\n event BlockProducerSetUpdated(uint256 indexed period, uint256 indexed epoch, address[] consensusAddrs);\\n /// @dev Emitted when the bridge operator set is updated.\\n event BridgeOperatorSetUpdated(uint256 indexed period, uint256 indexed epoch, address[] bridgeOperators);\\n\\n /// @dev Emitted when the reward of the block producer is deprecated.\\n event BlockRewardDeprecated(\\n address indexed coinbaseAddr,\\n uint256 rewardAmount,\\n BlockRewardDeprecatedType deprecatedType\\n );\\n /// @dev Emitted when the block reward is submitted.\\n event BlockRewardSubmitted(address indexed coinbaseAddr, uint256 submittedAmount, uint256 bonusAmount);\\n\\n /// @dev Emitted when the block producer reward is distributed.\\n event MiningRewardDistributed(address indexed consensusAddr, address indexed recipient, uint256 amount);\\n /// @dev Emitted when the contract fails when distributing the block producer reward.\\n event MiningRewardDistributionFailed(\\n address indexed consensusAddr,\\n address indexed recipient,\\n uint256 amount,\\n uint256 contractBalance\\n );\\n\\n /// @dev Emitted when the bridge operator reward is distributed.\\n event BridgeOperatorRewardDistributed(\\n address indexed consensusAddr,\\n address indexed bridgeOperator,\\n address indexed recipientAddr,\\n uint256 amount\\n );\\n /// @dev Emitted when the contract fails when distributing the bridge operator reward.\\n event BridgeOperatorRewardDistributionFailed(\\n address indexed consensusAddr,\\n address indexed bridgeOperator,\\n address indexed recipient,\\n uint256 amount,\\n uint256 contractBalance\\n );\\n\\n /// @dev Emitted when the amount of RON reward is distributed to staking contract.\\n event StakingRewardDistributed(uint256 totalAmount, address[] consensusAddrs, uint256[] amounts);\\n /// @dev Emitted when the contracts fails when distributing the amount of RON to the staking contract.\\n event StakingRewardDistributionFailed(\\n uint256 totalAmount,\\n address[] consensusAddrs,\\n uint256[] amounts,\\n uint256 contractBalance\\n );\\n\\n /// @dev Emitted when the epoch is wrapped up.\\n event WrappedUpEpoch(uint256 indexed periodNumber, uint256 indexed epochNumber, bool periodEnding);\\n\\n /// @dev Error of method caller must be coinbase\\n error ErrCallerMustBeCoinbase();\\n /// @dev Error of only allowed at the end of epoch\\n error ErrAtEndOfEpochOnly();\\n /// @dev Error of query for already wrapped up epoch\\n error ErrAlreadyWrappedEpoch();\\n\\n /**\\n * @dev Submits reward of the current block.\\n *\\n * Requirements:\\n * - The method caller is coinbase.\\n *\\n * Emits the event `MiningRewardDeprecated` if the coinbase is slashed or no longer be a block producer.\\n * Emits the event `BlockRewardSubmitted` for the valid call.\\n *\\n */\\n function submitBlockReward() external payable;\\n\\n /**\\n * @dev Wraps up the current epoch.\\n *\\n * Requirements:\\n * - The method must be called when the current epoch is ending.\\n * - The epoch is not wrapped yet.\\n * - The method caller is coinbase.\\n *\\n * Emits the event `MiningRewardDistributed` when some validator has reward distributed.\\n * Emits the event `StakingRewardDistributed` when some staking pool has reward distributed.\\n * Emits the event `BlockProducerSetUpdated` when the epoch is wrapped up.\\n * Emits the event `BridgeOperatorSetUpdated` when the epoch is wrapped up at period ending.\\n * Emits the event `ValidatorSetUpdated` when the epoch is wrapped up at period ending, and the validator set gets updated.\\n * Emits the event `WrappedUpEpoch`.\\n *\\n */\\n function wrapUpEpoch() external payable;\\n}\\n\",\"keccak256\":\"0xe4060b7e3b04a0043bd334011fe4ba67c990b0484dad52d7f14b35040989b6ab\",\"license\":\"MIT\"},\"contracts/interfaces/validator/IEmergencyExit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface IEmergencyExit {\\n /// @dev Emitted when the fund is locked from an emergency exit request\\n event EmergencyExitRequested(address indexed consensusAddr, uint256 lockedAmount);\\n /// @dev Emitted when the fund that locked from an emergency exit request is transferred to the recipient.\\n event EmergencyExitLockedFundReleased(\\n address indexed consensusAddr,\\n address indexed recipient,\\n uint256 unlockedAmount\\n );\\n /// @dev Emitted when the fund that locked from an emergency exit request is failed to transferred back.\\n event EmergencyExitLockedFundReleasingFailed(\\n address indexed consensusAddr,\\n address indexed recipient,\\n uint256 unlockedAmount,\\n uint256 contractBalance\\n );\\n\\n /// @dev Emitted when the emergency exit locked amount is updated.\\n event EmergencyExitLockedAmountUpdated(uint256 amount);\\n /// @dev Emitted when the emergency expiry duration is updated.\\n event EmergencyExpiryDurationUpdated(uint256 amount);\\n\\n /// @dev Error of already requested emergency exit before.\\n error ErrAlreadyRequestedEmergencyExit();\\n\\n /**\\n * @dev Returns the amount of RON to lock from a consensus address.\\n */\\n function emergencyExitLockedAmount() external returns (uint256);\\n\\n /**\\n * @dev Returns the duration that an emergency request is expired and the fund will be recycled.\\n */\\n function emergencyExpiryDuration() external returns (uint256);\\n\\n /**\\n * @dev Sets the amount of RON to lock from a consensus address.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `EmergencyExitLockedAmountUpdated`.\\n *\\n */\\n function setEmergencyExitLockedAmount(uint256 _emergencyExitLockedAmount) external;\\n\\n /**\\n * @dev Sets the duration that an emergency request is expired and the fund will be recycled.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `EmergencyExpiryDurationUpdated`.\\n *\\n */\\n function setEmergencyExpiryDuration(uint256 _emergencyExpiryDuration) external;\\n\\n /**\\n * @dev Unlocks fund for emergency exit request.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `EmergencyExitLockedFundReleased` if the fund is successfully unlocked.\\n * Emits the event `EmergencyExitLockedFundReleasingFailed` if the fund is failed to unlock.\\n *\\n */\\n function execReleaseLockedFundForEmergencyExitRequest(address _consensusAddr, address payable _recipient) external;\\n\\n /**\\n * @dev Fallback function of `IStaking-requestEmergencyExit`.\\n *\\n * Requirements:\\n * - The method caller is staking contract.\\n *\\n */\\n function execEmergencyExit(address _consensusAddr, uint256 _secLeftToRevoke) external;\\n}\\n\",\"keccak256\":\"0x45161abd1e3db83052a06889a0e3a7a5e7ee3306478601d58ac4ed32ccaa75ad\",\"license\":\"MIT\"},\"contracts/interfaces/validator/IRoninValidatorSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./ICandidateManager.sol\\\";\\nimport \\\"./info-fragments/ICommonInfo.sol\\\";\\nimport \\\"./ICoinbaseExecution.sol\\\";\\nimport \\\"./ISlashingExecution.sol\\\";\\nimport \\\"./IEmergencyExit.sol\\\";\\n\\ninterface IRoninValidatorSet is\\n ICandidateManager,\\n ICommonInfo,\\n ISlashingExecution,\\n ICoinbaseExecution,\\n IEmergencyExit\\n{}\\n\",\"keccak256\":\"0x813f34747aea4dfb53bbc147abf8dbe5999ce73111c2db99bcb3efb4cf75bb3d\",\"license\":\"MIT\"},\"contracts/interfaces/validator/ISlashingExecution.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface ISlashingExecution {\\n /// @dev Emitted when the validator is punished.\\n event ValidatorPunished(\\n address indexed consensusAddr,\\n uint256 indexed period,\\n uint256 jailedUntil,\\n uint256 deductedStakingAmount,\\n bool blockProducerRewardDeprecated,\\n bool bridgeOperatorRewardDeprecated\\n );\\n /// @dev Emitted when the validator get out of jail by bailout.\\n event ValidatorUnjailed(address indexed validator, uint256 period);\\n\\n /// @dev Error of cannot bailout due to high tier slash.\\n error ErrCannotBailout(address validator);\\n\\n /**\\n * @dev Finalize the slash request from slash indicator contract.\\n *\\n * Requirements:\\n * - The method caller is slash indicator contract.\\n *\\n * Emits the event `ValidatorPunished`.\\n *\\n */\\n function execSlash(\\n address _validatorAddr,\\n uint256 _newJailedUntil,\\n uint256 _slashAmount,\\n bool _cannotBailout\\n ) external;\\n\\n /**\\n * @dev Finalize the bailout request from slash indicator contract.\\n *\\n * Requirements:\\n * - The method caller is slash indicator contract.\\n *\\n * Emits the event `ValidatorUnjailed`.\\n *\\n */\\n function execBailOut(address _validatorAddr, uint256 _period) external;\\n}\\n\",\"keccak256\":\"0x80362c42fdc0ee06543a2abbffee961fe51c15a7c5e18933a9c34897e50d07fe\",\"license\":\"MIT\"},\"contracts/interfaces/validator/info-fragments/ICommonInfo.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IJailingInfo.sol\\\";\\nimport \\\"./ITimingInfo.sol\\\";\\nimport \\\"./IValidatorInfoV2.sol\\\";\\n\\ninterface ICommonInfo is ITimingInfo, IJailingInfo, IValidatorInfoV2 {\\n struct EmergencyExitInfo {\\n uint256 lockedAmount;\\n // The timestamp that this locked amount will be recycled to staking vesting contract\\n uint256 recyclingAt;\\n }\\n\\n /// @dev Emitted when the deprecated reward is withdrawn.\\n event DeprecatedRewardRecycled(address indexed recipientAddr, uint256 amount);\\n /// @dev Emitted when the deprecated reward withdrawal is failed\\n event DeprecatedRewardRecycleFailed(address indexed recipientAddr, uint256 amount, uint256 balance);\\n\\n /// @dev Error thrown when receives RON from neither staking vesting contract nor staking contract\\n error ErrUnauthorizedReceiveRON();\\n /// @dev Error thrown when queries for a non existent info.\\n error NonExistentRecyclingInfo();\\n\\n /**\\n * @dev Returns the total deprecated reward, which includes reward that is not sent for slashed validators and unsastified bridge operators\\n */\\n function totalDeprecatedReward() external view returns (uint256);\\n\\n /**\\n * @dev Returns the emergency exit request.\\n */\\n function getEmergencyExitInfo(address _consensusAddr) external view returns (EmergencyExitInfo memory);\\n}\\n\",\"keccak256\":\"0x3fdfa86da33b889e5153075ffc028d6b0c607480a96b532fbbbc48ac7bbf27c9\",\"license\":\"MIT\"},\"contracts/interfaces/validator/info-fragments/IJailingInfo.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface IJailingInfo {\\n /**\\n * @dev Returns whether the validator are put in jail (cannot join the set of validators) during the current period.\\n */\\n function checkJailed(address) external view returns (bool);\\n\\n /**\\n * @dev Returns whether the validator are put in jail and the number of block and epoch that he still is in the jail.\\n */\\n function getJailedTimeLeft(\\n address _addr\\n ) external view returns (bool isJailed_, uint256 blockLeft_, uint256 epochLeft_);\\n\\n /**\\n * @dev Returns whether the validator are put in jail (cannot join the set of validators) at a specific block.\\n */\\n function checkJailedAtBlock(address _addr, uint256 _blockNum) external view returns (bool);\\n\\n /**\\n * @dev Returns whether the validator are put in jail at a specific block and the number of block and epoch that he still is in the jail.\\n */\\n function getJailedTimeLeftAtBlock(\\n address _addr,\\n uint256 _blockNum\\n ) external view returns (bool isJailed_, uint256 blockLeft_, uint256 epochLeft_);\\n\\n /**\\n * @dev Returns whether the validators are put in jail (cannot join the set of validators) during the current period.\\n */\\n function checkManyJailed(address[] calldata) external view returns (bool[] memory);\\n\\n /**\\n * @dev Returns whether the incoming reward of the block producer is deprecated during the current period.\\n */\\n function checkMiningRewardDeprecated(address _blockProducer) external view returns (bool);\\n\\n /**\\n * @dev Returns whether the incoming reward of the block producer is deprecated during a specific period.\\n */\\n function checkMiningRewardDeprecatedAtPeriod(address _blockProducer, uint256 _period) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x2b1846b05ca1d636299fb929c1bd7b392b236f5e3f7aa3e7eea2c6d57b8836fb\",\"license\":\"MIT\"},\"contracts/interfaces/validator/info-fragments/ITimingInfo.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface ITimingInfo {\\n /**\\n * @dev Returns the block that validator set was updated.\\n */\\n function getLastUpdatedBlock() external view returns (uint256);\\n\\n /**\\n * @dev Returns the number of blocks in a epoch.\\n */\\n function numberOfBlocksInEpoch() external view returns (uint256 _numberOfBlocks);\\n\\n /**\\n * @dev Returns the epoch index from the block number.\\n */\\n function epochOf(uint256 _block) external view returns (uint256);\\n\\n /**\\n * @dev Returns whether the epoch ending is at the block number `_block`.\\n */\\n function epochEndingAt(uint256 _block) external view returns (bool);\\n\\n /**\\n * @dev Tries to get the period index from the epoch number.\\n */\\n function tryGetPeriodOfEpoch(uint256 _epoch) external view returns (bool _filled, uint256 _periodNumber);\\n\\n /**\\n * @dev Returns whether the period ending at the current block number.\\n */\\n function isPeriodEnding() external view returns (bool);\\n\\n /**\\n * @dev Returns the period index from the current block.\\n */\\n function currentPeriod() external view returns (uint256);\\n\\n /**\\n * @dev Returns the block number that the current period starts at.\\n */\\n function currentPeriodStartAtBlock() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x77b86a68149389fed0eb0c5b8d56f278d3bd103ba64f504697d709b24c3212d5\",\"license\":\"MIT\"},\"contracts/interfaces/validator/info-fragments/IValidatorInfoV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"../../../libraries/EnumFlags.sol\\\";\\n\\ninterface IValidatorInfoV2 {\\n /**\\n * @dev Error thrown when an invalid maximum prioritized validator number is provided.\\n */\\n error ErrInvalidMaxPrioritizedValidatorNumber();\\n\\n /// @dev Emitted when the number of max validator is updated.\\n event MaxValidatorNumberUpdated(uint256);\\n /// @dev Emitted when the number of reserved slots for prioritized validators is updated.\\n event MaxPrioritizedValidatorNumberUpdated(uint256);\\n\\n /**\\n * @dev Returns the maximum number of validators in the epoch.\\n */\\n function maxValidatorNumber() external view returns (uint256 _maximumValidatorNumber);\\n\\n /**\\n * @dev Returns the number of reserved slots for prioritized validators.\\n */\\n function maxPrioritizedValidatorNumber() external view returns (uint256 _maximumPrioritizedValidatorNumber);\\n\\n /**\\n * @dev Returns the current validator list.\\n */\\n function getValidators() external view returns (address[] memory _validatorList);\\n\\n /**\\n * @dev Returns the current block producer list.\\n */\\n function getBlockProducers() external view returns (address[] memory);\\n\\n /**\\n * @dev Returns whether the address is block producer or not.\\n */\\n function isBlockProducer(address _addr) external view returns (bool);\\n\\n /**\\n * @dev Returns total numbers of the block producers.\\n */\\n function totalBlockProducers() external view returns (uint256);\\n\\n /**\\n * @dev Updates the max validator number\\n *\\n * Requirements:\\n * - The method caller is admin\\n *\\n * Emits the event `MaxValidatorNumberUpdated`\\n *\\n */\\n function setMaxValidatorNumber(uint256 _maxValidatorNumber) external;\\n\\n /**\\n * @dev Updates the number of reserved slots for prioritized validators\\n *\\n * Requirements:\\n * - The method caller is admin\\n *\\n * Emits the event `MaxPrioritizedValidatorNumberUpdated`\\n *\\n */\\n function setMaxPrioritizedValidatorNumber(uint256 _maxPrioritizedValidatorNumber) external;\\n}\\n\",\"keccak256\":\"0x6213c188a1323b242a098394b91caf9481e257bd57a0804cb2aa890377a993ed\",\"license\":\"MIT\"},\"contracts/libraries/AddressArrayUtils.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\n\\npragma solidity ^0.8.0;\\n\\nlibrary AddressArrayUtils {\\n /**\\n * @dev Error thrown when a duplicated element is detected in an array.\\n * @param msgSig The function signature that invoke the error.\\n */\\n error ErrDuplicated(bytes4 msgSig);\\n\\n /**\\n * @dev Returns whether or not there's a duplicate. Runs in O(n^2).\\n * @param A Array to search\\n * @return Returns true if duplicate, false otherwise\\n */\\n function hasDuplicate(address[] memory A) internal pure returns (bool) {\\n if (A.length == 0) {\\n return false;\\n }\\n unchecked {\\n for (uint256 i = 0; i < A.length - 1; i++) {\\n for (uint256 j = i + 1; j < A.length; j++) {\\n if (A[i] == A[j]) {\\n return true;\\n }\\n }\\n }\\n }\\n return false;\\n }\\n\\n /**\\n * @dev Returns whether two arrays of addresses are equal or not.\\n */\\n function isEqual(address[] memory _this, address[] memory _other) internal pure returns (bool yes_) {\\n // Hashing two arrays and compare their hash\\n assembly {\\n let _thisHash := keccak256(add(_this, 32), mul(mload(_this), 32))\\n let _otherHash := keccak256(add(_other, 32), mul(mload(_other), 32))\\n yes_ := eq(_thisHash, _otherHash)\\n }\\n }\\n\\n /**\\n * @dev Return the concatenated array from a and b.\\n */\\n function extend(address[] memory a, address[] memory b) internal pure returns (address[] memory c) {\\n uint256 lengthA = a.length;\\n uint256 lengthB = b.length;\\n unchecked {\\n c = new address[](lengthA + lengthB);\\n }\\n uint256 i;\\n for (; i < lengthA; ) {\\n c[i] = a[i];\\n unchecked {\\n ++i;\\n }\\n }\\n for (uint256 j; j < lengthB; ) {\\n c[i] = b[j];\\n unchecked {\\n ++i;\\n ++j;\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xaf760162653a85d6e1b24df4d33c74076f778470112f421a02050fb981242001\",\"license\":\"UNLICENSED\"},\"contracts/libraries/BridgeOperatorsBallot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\\\";\\nimport \\\"../utils/CommonErrors.sol\\\";\\n\\nlibrary BridgeOperatorsBallot {\\n /**\\n * @dev Error thrown when an invalid order of the bridge operator is detected.\\n */\\n error ErrInvalidOrderOfBridgeOperator();\\n\\n struct BridgeOperatorSet {\\n uint256 period;\\n uint256 epoch;\\n address[] operators;\\n }\\n\\n // keccak256(\\\"BridgeOperatorsBallot(uint256 period,uint256 epoch,address[] operators)\\\");\\n bytes32 public constant BRIDGE_OPERATORS_BALLOT_TYPEHASH =\\n 0xd679a49e9e099fa9ed83a5446aaec83e746b03ec6723d6f5efb29d37d7f0b78a;\\n\\n /**\\n * @dev Verifies whether the ballot is valid or not.\\n *\\n * Requirements:\\n * - The ballot is not for an empty operator set.\\n * - The operator address list is in order.\\n *\\n */\\n function verifyBallot(BridgeOperatorSet calldata _ballot) internal pure {\\n if (_ballot.operators.length == 0) revert ErrEmptyArray();\\n\\n address _addr = _ballot.operators[0];\\n for (uint _i = 1; _i < _ballot.operators.length; ) {\\n if (_addr >= _ballot.operators[_i]) revert ErrInvalidOrderOfBridgeOperator();\\n _addr = _ballot.operators[_i];\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @dev Returns hash of the ballot.\\n */\\n function hash(BridgeOperatorSet memory self) internal pure returns (bytes32 digest_) {\\n bytes32 operatorsHash;\\n address[] memory operators = self.operators;\\n\\n // return keccak256(abi.encode(BRIDGE_OPERATORS_BALLOT_TYPEHASH, _ballot.period, _ballot.epoch, _operatorsHash));\\n assembly {\\n operatorsHash := keccak256(add(operators, 32), mul(mload(operators), 32))\\n let ptr := mload(0x40)\\n mstore(ptr, BRIDGE_OPERATORS_BALLOT_TYPEHASH)\\n mstore(add(ptr, 0x20), mload(self)) // _ballot.period\\n mstore(add(ptr, 0x40), mload(add(self, 0x20))) // _ballot.epoch\\n mstore(add(ptr, 0x60), operatorsHash)\\n digest_ := keccak256(ptr, 0x80)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7671f6e599d5a33fa1e97538b1c8e04159337da5701eb6fa07b29d0566f57f81\",\"license\":\"MIT\"},\"contracts/libraries/EnumFlags.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This library implements checking flag of an enumerated value.\\n * The originated idea is inherited from [Enum.HashFlag(Enum)](https://learn.microsoft.com/en-us/dotnet/api/system.enum.hasflag?view=net-6.0) method of C#.\\n */\\nlibrary EnumFlags {\\n enum ValidatorFlag {\\n None, // bit(00)\\n BlockProducer, // bit(01)\\n DeprecatedBridgeOperator, // bit(10)\\n Both // bit(11)\\n }\\n\\n function isNone(ValidatorFlag _value) internal pure returns (bool) {\\n return uint8(_value) == 0;\\n }\\n\\n /**\\n * @dev Checks if `_value` has `_flag`.\\n */\\n function hasFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (bool) {\\n return (uint8(_value) & uint8(_flag)) != 0;\\n }\\n\\n /**\\n * @dev Calculate new value of `_value` after adding `_flag`.\\n */\\n function addFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (ValidatorFlag) {\\n return ValidatorFlag(uint8(_value) | uint8(_flag));\\n }\\n\\n /**\\n * @dev Calculate new value of `_value` after remove `_flag`.\\n */\\n function removeFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (ValidatorFlag) {\\n return ValidatorFlag(uint8(_value) & ~uint8(_flag));\\n }\\n}\\n\",\"keccak256\":\"0xa712f0d1a323ee39f23eb3ee3278b4ec25fe2e536b1ccc629578c66f277c088d\",\"license\":\"UNLICENSED\"},\"contracts/libraries/Math.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\n\\npragma solidity ^0.8.0;\\n\\nlibrary Math {\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a >= b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns whether the number `c` is in range of [a; b].\\n */\\n function inRange(uint256 c, uint256 a, uint256 b) internal pure returns (bool) {\\n return a <= c && c <= b;\\n }\\n\\n /**\\n * @dev Returns whether two inclusive ranges [x1;x2] and [y1;y2] overlap.\\n */\\n function twoRangeOverlap(uint256 x1, uint256 x2, uint256 y1, uint256 y2) internal pure returns (bool) {\\n return x1 <= y2 && y1 <= x2;\\n }\\n\\n /**\\n * @dev Returns value of a + b; in case result is larger than upperbound, upperbound is returned.\\n */\\n function addWithUpperbound(uint256 a, uint256 b, uint256 upperbound) internal pure returns (uint256) {\\n return min(a + b, upperbound);\\n }\\n\\n /**\\n * @dev Returns value of a - b; in case of negative result, 0 is returned.\\n */\\n function subNonNegative(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a - b : 0;\\n }\\n\\n /**\\n * @dev Returns value of `a + zeroable` if zerobale is not 0; otherwise, return 0.\\n */\\n function addIfNonZero(uint256 a, uint256 zeroable) internal pure returns (uint256) {\\n return zeroable != 0 ? a + zeroable : 0;\\n }\\n}\\n\",\"keccak256\":\"0xd73170f448c644a47024c7dbcf4afc3cc7ad27f61737c6ea4c3b543ec5cdb7e9\",\"license\":\"UNLICENSED\"},\"contracts/precompile-usages/PCUValidateDoubleSign.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./PrecompiledUsage.sol\\\";\\n\\nabstract contract PCUValidateDoubleSign is PrecompiledUsage {\\n /// @dev Gets the address of the precompile of validating double sign evidence\\n function precompileValidateDoubleSignAddress() public view virtual returns (address) {\\n return address(0x67);\\n }\\n\\n /**\\n * @dev Validates the two submitted block header if they are produced by the same address\\n *\\n * Note: The recover process is done by pre-compiled contract. This function is marked as\\n * virtual for implementing mocking contract for testing purpose.\\n */\\n function _pcValidateEvidence(\\n address _consensusAddr,\\n bytes calldata _header1,\\n bytes calldata _header2\\n ) internal view virtual returns (bool _validEvidence) {\\n address _smc = precompileValidateDoubleSignAddress();\\n bool _success = true;\\n\\n bytes memory _payload = abi.encodeWithSignature(\\n \\\"validatingDoubleSignProof(address,bytes,bytes)\\\",\\n _consensusAddr,\\n _header1,\\n _header2\\n );\\n uint _payloadLength = _payload.length;\\n uint[1] memory _output;\\n\\n assembly {\\n let _payloadStart := add(_payload, 0x20)\\n if iszero(staticcall(gas(), _smc, _payloadStart, _payloadLength, _output, 0x20)) {\\n _success := 0\\n }\\n\\n if iszero(returndatasize()) {\\n _success := 0\\n }\\n }\\n\\n if (!_success) revert ErrCallPrecompiled();\\n return (_output[0] != 0);\\n }\\n}\\n\",\"keccak256\":\"0x9df5b8272e1cd963d776b94e29a69ba1139f0df7404b67c213b3c5ebe19e527b\",\"license\":\"MIT\"},\"contracts/precompile-usages/PrecompiledUsage.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./PrecompiledUsage.sol\\\";\\n\\nabstract contract PrecompiledUsage {\\n /// @dev Error of call to precompile fails.\\n error ErrCallPrecompiled();\\n}\\n\",\"keccak256\":\"0x76facc3f3a8dd573c826bbbfedaa5cd8ef30963fbabd8c163c0c72b6efea5551\",\"license\":\"MIT\"},\"contracts/ronin/slash-indicator/CreditScore.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"../../interfaces/IMaintenance.sol\\\";\\nimport \\\"../../interfaces/validator/IRoninValidatorSet.sol\\\";\\nimport \\\"../../interfaces/slash-indicator/ICreditScore.sol\\\";\\nimport \\\"../../extensions/collections/HasContracts.sol\\\";\\nimport \\\"../../extensions/consumers/PercentageConsumer.sol\\\";\\nimport \\\"../../libraries/Math.sol\\\";\\nimport { HasValidatorDeprecated, HasMaintenanceDeprecated } from \\\"../../utils/DeprecatedSlots.sol\\\";\\nimport { ErrUnauthorized, RoleAccess } from \\\"../../utils/CommonErrors.sol\\\";\\n\\nabstract contract CreditScore is\\n ICreditScore,\\n HasContracts,\\n HasValidatorDeprecated,\\n HasMaintenanceDeprecated,\\n PercentageConsumer\\n{\\n /// @dev Mapping from validator address => period index => whether bailed out before\\n mapping(address => mapping(uint256 => bool)) internal _checkBailedOutAtPeriod;\\n /// @dev Mapping from validator address => credit score\\n mapping(address => uint256) internal _creditScore;\\n\\n /// @dev The max gained number of credit score per period.\\n uint256 internal _gainCreditScore;\\n /// @dev The max number of credit score that a validator can hold.\\n uint256 internal _maxCreditScore;\\n /// @dev The number that will be multiplied with the remaining jailed time to get the cost of bailing out.\\n uint256 internal _bailOutCostMultiplier;\\n /// @dev The percentage of reward to be cut off from the validator in the rest of the period after bailed out.\\n uint256 internal _cutOffPercentageAfterBailout;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n */\\n uint256[50] private ______gap;\\n\\n /**\\n * @inheritdoc ICreditScore\\n */\\n function updateCreditScores(\\n address[] calldata _validators,\\n uint256 _period\\n ) external override onlyContract(ContractType.VALIDATOR) {\\n IRoninValidatorSet _validatorContract = IRoninValidatorSet(msg.sender);\\n uint256 _periodStartAtBlock = _validatorContract.currentPeriodStartAtBlock();\\n\\n bool[] memory _jaileds = _validatorContract.checkManyJailed(_validators);\\n bool[] memory _maintaineds = IMaintenance(getContract(ContractType.MAINTENANCE)).checkManyMaintainedInBlockRange(\\n _validators,\\n _periodStartAtBlock,\\n block.number\\n );\\n uint256[] memory _updatedCreditScores = new uint256[](_validators.length);\\n\\n for (uint _i = 0; _i < _validators.length; ) {\\n address _validator = _validators[_i];\\n\\n uint256 _indicator = getUnavailabilityIndicator(_validator, _period);\\n bool _isJailedInPeriod = _jaileds[_i];\\n bool _isMaintainingInPeriod = _maintaineds[_i];\\n\\n uint256 _actualGain = (_isJailedInPeriod || _isMaintainingInPeriod)\\n ? 0\\n : Math.subNonNegative(_gainCreditScore, _indicator);\\n\\n _creditScore[_validator] = Math.addWithUpperbound(_creditScore[_validator], _actualGain, _maxCreditScore);\\n _updatedCreditScores[_i] = _creditScore[_validator];\\n unchecked {\\n ++_i;\\n }\\n }\\n\\n emit CreditScoresUpdated(_validators, _updatedCreditScores);\\n }\\n\\n function execResetCreditScores(\\n address[] calldata _validators\\n ) external override onlyContract(ContractType.VALIDATOR) {\\n uint256[] memory _updatedCreditScores = new uint256[](_validators.length);\\n for (uint _i = 0; _i < _validators.length; ) {\\n address _validator = _validators[_i];\\n delete _creditScore[_validator];\\n delete _updatedCreditScores[_i];\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n emit CreditScoresUpdated(_validators, _updatedCreditScores);\\n }\\n\\n /**\\n * @inheritdoc ICreditScore\\n */\\n function bailOut(address _consensusAddr) external override {\\n IRoninValidatorSet _validatorContract = IRoninValidatorSet(getContract(ContractType.VALIDATOR));\\n if (!_validatorContract.isValidatorCandidate(_consensusAddr))\\n revert ErrUnauthorized(msg.sig, RoleAccess.VALIDATOR_CANDIDATE);\\n\\n if (!_validatorContract.isCandidateAdmin(_consensusAddr, msg.sender))\\n revert ErrUnauthorized(msg.sig, RoleAccess.CANDIDATE_ADMIN);\\n\\n (bool _isJailed, , uint256 _jailedEpochLeft) = _validatorContract.getJailedTimeLeft(_consensusAddr);\\n if (!_isJailed) revert ErrCallerMustBeJailedInTheCurrentPeriod();\\n\\n uint256 _period = _validatorContract.currentPeriod();\\n if (_checkBailedOutAtPeriod[_consensusAddr][_period]) revert ErrValidatorHasBailedOutPreviously();\\n\\n uint256 _score = _creditScore[_consensusAddr];\\n uint256 _cost = _jailedEpochLeft * _bailOutCostMultiplier;\\n if (_score < _cost) revert ErrInsufficientCreditScoreToBailOut();\\n\\n _validatorContract.execBailOut(_consensusAddr, _period);\\n\\n _creditScore[_consensusAddr] -= _cost;\\n _setUnavailabilityIndicator(_consensusAddr, _period, 0);\\n _checkBailedOutAtPeriod[_consensusAddr][_period] = true;\\n emit BailedOut(_consensusAddr, _period, _cost);\\n }\\n\\n /**\\n * @inheritdoc ICreditScore\\n */\\n function setCreditScoreConfigs(\\n uint256 _gainScore,\\n uint256 _maxScore,\\n uint256 _bailOutMultiplier,\\n uint256 _cutOffPercentage\\n ) external override onlyAdmin {\\n _setCreditScoreConfigs(_gainScore, _maxScore, _bailOutMultiplier, _cutOffPercentage);\\n }\\n\\n /**\\n * @dev See `ISlashUnavailability`\\n */\\n function getUnavailabilityIndicator(address _validator, uint256 _period) public view virtual returns (uint256);\\n\\n /**\\n * @inheritdoc ICreditScore\\n */\\n function getCreditScoreConfigs()\\n external\\n view\\n override\\n returns (\\n uint256 gainCreditScore_,\\n uint256 maxCreditScore_,\\n uint256 bailOutCostMultiplier_,\\n uint256 cutOffPercentageAfterBailout_\\n )\\n {\\n return (_gainCreditScore, _maxCreditScore, _bailOutCostMultiplier, _cutOffPercentageAfterBailout);\\n }\\n\\n /**\\n * @inheritdoc ICreditScore\\n */\\n function getCreditScore(address _validator) external view override returns (uint256) {\\n return _creditScore[_validator];\\n }\\n\\n /**\\n * @inheritdoc ICreditScore\\n */\\n function getManyCreditScores(\\n address[] calldata _validators\\n ) public view override returns (uint256[] memory _resultList) {\\n _resultList = new uint256[](_validators.length);\\n\\n for (uint _i = 0; _i < _resultList.length; ) {\\n _resultList[_i] = _creditScore[_validators[_i]];\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @inheritdoc ICreditScore\\n */\\n function checkBailedOutAtPeriod(address _validator, uint256 _period) public view virtual override returns (bool) {\\n return _checkBailedOutAtPeriod[_validator][_period];\\n }\\n\\n /**\\n * @dev See `SlashUnavailability`.\\n */\\n function _setUnavailabilityIndicator(address _validator, uint256 _period, uint256 _indicator) internal virtual;\\n\\n /**\\n * @dev See `ICreditScore-setCreditScoreConfigs`.\\n */\\n function _setCreditScoreConfigs(\\n uint256 _gainScore,\\n uint256 _maxScore,\\n uint256 _bailOutMultiplier,\\n uint256 _cutOffPercentage\\n ) internal {\\n if (_gainScore > _maxScore) revert ErrInvalidCreditScoreConfig();\\n if (_cutOffPercentage > _MAX_PERCENTAGE) revert ErrInvalidCutOffPercentageConfig();\\n\\n _gainCreditScore = _gainScore;\\n _maxCreditScore = _maxScore;\\n _bailOutCostMultiplier = _bailOutMultiplier;\\n _cutOffPercentageAfterBailout = _cutOffPercentage;\\n emit CreditScoreConfigsUpdated(_gainScore, _maxScore, _bailOutMultiplier, _cutOffPercentage);\\n }\\n}\\n\",\"keccak256\":\"0xb4321e0140e8a0ceb0b41e8a65d6448fbb2a74c56233fb0aa4a7769016d2b5c6\",\"license\":\"MIT\"},\"contracts/ronin/slash-indicator/SlashBridgeOperator.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"../../extensions/consumers/PercentageConsumer.sol\\\";\\nimport \\\"../../extensions/collections/HasProxyAdmin.sol\\\";\\nimport \\\"../../interfaces/slash-indicator/ISlashBridgeOperator.sol\\\";\\nimport \\\"../../extensions/collections/HasContracts.sol\\\";\\nimport { HasValidatorDeprecated } from \\\"../../utils/DeprecatedSlots.sol\\\";\\n\\nabstract contract SlashBridgeOperator is\\n ISlashBridgeOperator,\\n HasProxyAdmin,\\n HasContracts,\\n HasValidatorDeprecated,\\n PercentageConsumer\\n{\\n /**\\n * @dev The bridge operators will be deprecated reward if (s)he missed more than the ratio.\\n * Values 0-10,000 map to 0%-100%.\\n */\\n uint256 internal _missingVotesRatioTier1;\\n /**\\n * @dev The bridge operators will be deprecated all rewards including bridge reward and mining reward if (s)he missed\\n * more than the ratio. Values 0-10,000 map to 0%-100%.\\n */\\n uint256 internal _missingVotesRatioTier2;\\n /// @dev The number of blocks to jail the corresponding block producer when its bridge operator is slashed tier-2.\\n uint256 internal _jailDurationForMissingVotesRatioTier2;\\n /// @dev The threshold to skip slashing the bridge operator in case the total number of votes in the bridge is too small.\\n uint256 internal _skipBridgeOperatorSlashingThreshold;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n */\\n uint256[50] private ______gap;\\n\\n /**\\n * @inheritdoc ISlashBridgeOperator\\n */\\n function getBridgeOperatorSlashingConfigs()\\n external\\n view\\n override\\n returns (\\n uint256 missingVotesRatioTier1_,\\n uint256 missingVotesRatioTier2_,\\n uint256 jailDurationForMissingVotesRatioTier2_,\\n uint256 skipBridgeOperatorSlashingThreshold_\\n )\\n {\\n return (\\n _missingVotesRatioTier1,\\n _missingVotesRatioTier2,\\n _jailDurationForMissingVotesRatioTier2,\\n _skipBridgeOperatorSlashingThreshold\\n );\\n }\\n\\n /**\\n * @inheritdoc ISlashBridgeOperator\\n */\\n function setBridgeOperatorSlashingConfigs(\\n uint256 _ratioTier1,\\n uint256 _ratioTier2,\\n uint256 _jailDurationTier2,\\n uint256 _skipSlashingThreshold\\n ) external override onlyAdmin {\\n _setBridgeOperatorSlashingConfigs(_ratioTier1, _ratioTier2, _jailDurationTier2, _skipSlashingThreshold);\\n }\\n\\n /**\\n * @inheritdoc ISlashBridgeOperator\\n */\\n function execSlashBridgeOperator(\\n address _consensusAddr,\\n uint256 _tier,\\n uint256 _period\\n ) external onlyContract(ContractType.VALIDATOR) {\\n if (_tier == 1) {\\n emit Slashed(_consensusAddr, SlashType.BRIDGE_OPERATOR_MISSING_VOTE_TIER_1, _period);\\n } else if (_tier == 2) {\\n emit Slashed(_consensusAddr, SlashType.BRIDGE_OPERATOR_MISSING_VOTE_TIER_2, _period);\\n }\\n }\\n\\n /**\\n * @dev See `ISlashBridgeOperator-setBridgeOperatorSlashingConfigs`.\\n */\\n function _setBridgeOperatorSlashingConfigs(\\n uint256 _ratioTier1,\\n uint256 _ratioTier2,\\n uint256 _jailDurationTier2,\\n uint256 _skipSlashingThreshold\\n ) internal {\\n if (_ratioTier1 > _ratioTier2 || _ratioTier1 > _MAX_PERCENTAGE || _ratioTier2 > _MAX_PERCENTAGE) {\\n revert ErrInvalidRatios();\\n }\\n\\n _missingVotesRatioTier1 = _ratioTier1;\\n _missingVotesRatioTier2 = _ratioTier2;\\n _jailDurationForMissingVotesRatioTier2 = _jailDurationTier2;\\n _skipBridgeOperatorSlashingThreshold = _skipSlashingThreshold;\\n emit BridgeOperatorSlashingConfigsUpdated(_ratioTier1, _ratioTier2, _jailDurationTier2, _skipSlashingThreshold);\\n }\\n}\\n\",\"keccak256\":\"0xb8125efc8cced5cd5e57be1e1ad25553439c6470545ef9eee79fb45d8774b18e\",\"license\":\"MIT\"},\"contracts/ronin/slash-indicator/SlashBridgeVoting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"../../libraries/Math.sol\\\";\\nimport { HasValidatorDeprecated, HasTrustedOrgDeprecated, HasGovernanceAdminDeprecated } from \\\"../../utils/DeprecatedSlots.sol\\\";\\nimport { IBridgeAdminProposal } from \\\"../../interfaces/IBridgeAdminProposal.sol\\\";\\nimport \\\"../../interfaces/slash-indicator/ISlashBridgeVoting.sol\\\";\\nimport \\\"../../interfaces/IRoninTrustedOrganization.sol\\\";\\nimport \\\"../../interfaces/validator/IRoninValidatorSet.sol\\\";\\nimport \\\"../../extensions/collections/HasContracts.sol\\\";\\n\\n// TODO: remove this from slashing logic of consensus contract\\nabstract contract SlashBridgeVoting is\\n ISlashBridgeVoting,\\n HasContracts,\\n HasValidatorDeprecated,\\n HasTrustedOrgDeprecated,\\n HasGovernanceAdminDeprecated\\n{\\n /// @dev Mapping from validator address => period index => bridge voting slashed\\n mapping(address => mapping(uint256 => bool)) internal _bridgeVotingSlashed;\\n /// @dev The threshold to slash when a trusted organization does not vote for bridge operators.\\n uint256 internal _bridgeVotingThreshold;\\n /// @dev The amount of RON to slash bridge voting.\\n uint256 internal _bridgeVotingSlashAmount;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n */\\n uint256[50] private ______gap;\\n\\n /**\\n * @inheritdoc ISlashBridgeVoting\\n */\\n function slashBridgeVoting(address _consensusAddr) external onlyAdmin {\\n IRoninTrustedOrganization.TrustedOrganization memory _org = IRoninTrustedOrganization(\\n getContract(ContractType.RONIN_TRUSTED_ORGANIZATION)\\n ).getTrustedOrganization(_consensusAddr);\\n uint256 _lastVotedBlock = Math.max(\\n IBridgeAdminProposal(getContract(ContractType.BRIDGE_MANAGER)).lastVotedBlock(_org.bridgeVoter),\\n _org.addedBlock\\n );\\n IRoninValidatorSet _validatorContract = IRoninValidatorSet(getContract(ContractType.VALIDATOR));\\n uint256 _period = _validatorContract.currentPeriod();\\n\\n if (block.number - _lastVotedBlock <= _bridgeVotingThreshold || _bridgeVotingSlashed[_consensusAddr][_period])\\n revert ErrInvalidSlash();\\n\\n _bridgeVotingSlashed[_consensusAddr][_period] = true;\\n emit Slashed(_consensusAddr, SlashType.BRIDGE_VOTING, _period);\\n _validatorContract.execSlash(_consensusAddr, 0, _bridgeVotingSlashAmount, false);\\n }\\n\\n /**\\n * @inheritdoc ISlashBridgeVoting\\n */\\n function getBridgeVotingSlashingConfigs()\\n external\\n view\\n override\\n returns (uint256 bridgeVotingThreshold_, uint256 bridgeVotingSlashAmount_)\\n {\\n return (_bridgeVotingThreshold, _bridgeVotingSlashAmount);\\n }\\n\\n /**\\n * @inheritdoc ISlashBridgeVoting\\n */\\n function setBridgeVotingSlashingConfigs(uint256 _threshold, uint256 _slashAmount) external override onlyAdmin {\\n _setBridgeVotingSlashingConfigs(_threshold, _slashAmount);\\n }\\n\\n /**\\n * @dev See `ISlashBridgeVoting-setBridgeVotingSlashingConfigs`.\\n */\\n function _setBridgeVotingSlashingConfigs(uint256 _threshold, uint256 _slashAmount) internal {\\n _bridgeVotingThreshold = _threshold;\\n _bridgeVotingSlashAmount = _slashAmount;\\n emit BridgeVotingSlashingConfigsUpdated(_threshold, _slashAmount);\\n }\\n}\\n\",\"keccak256\":\"0x807b11148e3db8b738dda824fa3c333d143cc9f3d5faf44297d81a8556dd14b7\",\"license\":\"MIT\"},\"contracts/ronin/slash-indicator/SlashDoubleSign.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"../../interfaces/slash-indicator/ISlashDoubleSign.sol\\\";\\nimport \\\"../../interfaces/validator/IRoninValidatorSet.sol\\\";\\nimport \\\"../../precompile-usages/PCUValidateDoubleSign.sol\\\";\\nimport \\\"../../extensions/collections/HasContracts.sol\\\";\\nimport { HasValidatorDeprecated } from \\\"../../utils/DeprecatedSlots.sol\\\";\\n\\nabstract contract SlashDoubleSign is ISlashDoubleSign, HasContracts, HasValidatorDeprecated, PCUValidateDoubleSign {\\n /// @dev The amount of RON to slash double sign.\\n uint256 internal _slashDoubleSignAmount;\\n /// @dev The block number that the punished validator will be jailed until, due to double signing.\\n uint256 internal _doubleSigningJailUntilBlock;\\n /** @dev The offset from the submitted block to the current block, from which double signing will be invalidated.\\n * This parameter is exposed for system transaction.\\n **/\\n uint256 internal _doubleSigningOffsetLimitBlock;\\n /// @dev Recording of submitted proof to prevent relay attack.\\n mapping(bytes32 => bool) _submittedEvidence;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n */\\n uint256[48] private ______gap;\\n\\n /**\\n * @inheritdoc ISlashDoubleSign\\n */\\n function slashDoubleSign(\\n address _consensusAddr,\\n bytes calldata _header1,\\n bytes calldata _header2\\n ) external override onlyAdmin {\\n bytes32 _header1Checksum = keccak256(_header1);\\n bytes32 _header2Checksum = keccak256(_header2);\\n\\n if (_submittedEvidence[_header1Checksum] || _submittedEvidence[_header2Checksum]) {\\n revert ErrEvidenceAlreadySubmitted();\\n }\\n\\n if (_pcValidateEvidence(_consensusAddr, _header1, _header2)) {\\n IRoninValidatorSet _validatorContract = IRoninValidatorSet(getContract(ContractType.VALIDATOR));\\n uint256 _period = _validatorContract.currentPeriod();\\n _submittedEvidence[_header1Checksum] = true;\\n _submittedEvidence[_header2Checksum] = true;\\n emit Slashed(_consensusAddr, SlashType.DOUBLE_SIGNING, _period);\\n _validatorContract.execSlash(_consensusAddr, _doubleSigningJailUntilBlock, _slashDoubleSignAmount, true);\\n }\\n }\\n\\n /**\\n * @inheritdoc ISlashDoubleSign\\n */\\n function getDoubleSignSlashingConfigs()\\n external\\n view\\n override\\n returns (\\n uint256 slashDoubleSignAmount_,\\n uint256 doubleSigningJailUntilBlock_,\\n uint256 doubleSigningOffsetLimitBlock_\\n )\\n {\\n return (_slashDoubleSignAmount, _doubleSigningJailUntilBlock, _doubleSigningOffsetLimitBlock);\\n }\\n\\n /**\\n * @inheritdoc ISlashDoubleSign\\n */\\n function setDoubleSignSlashingConfigs(\\n uint256 _slashAmount,\\n uint256 _jailUntilBlock,\\n uint256 _offsetLimitBlock\\n ) external override onlyAdmin {\\n _setDoubleSignSlashingConfigs(_slashAmount, _jailUntilBlock, _offsetLimitBlock);\\n }\\n\\n /**\\n * @dev See `ISlashDoubleSign-setDoubleSignSlashingConfigs`.\\n */\\n function _setDoubleSignSlashingConfigs(\\n uint256 _slashAmount,\\n uint256 _jailUntilBlock,\\n uint256 _offsetLimitBlock\\n ) internal {\\n _slashDoubleSignAmount = _slashAmount;\\n _doubleSigningJailUntilBlock = _jailUntilBlock;\\n _doubleSigningOffsetLimitBlock = _offsetLimitBlock;\\n emit DoubleSignSlashingConfigsUpdated(_slashAmount, _jailUntilBlock, _doubleSigningOffsetLimitBlock);\\n }\\n\\n /**\\n * @dev Returns whether the account `_addr` should be slashed or not.\\n */\\n function _shouldSlash(address _addr) internal view virtual returns (bool);\\n}\\n\",\"keccak256\":\"0x23e9c36b9fcd202323bd5b37753f577566077ad95f0275a5104f0c48fccee138\",\"license\":\"MIT\"},\"contracts/ronin/slash-indicator/SlashIndicator.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/proxy/utils/Initializable.sol\\\";\\nimport \\\"../../interfaces/slash-indicator/ISlashIndicator.sol\\\";\\nimport \\\"../../interfaces/validator/IRoninValidatorSet.sol\\\";\\nimport \\\"../../interfaces/IMaintenance.sol\\\";\\nimport \\\"./SlashDoubleSign.sol\\\";\\nimport \\\"./SlashBridgeVoting.sol\\\";\\nimport \\\"./SlashBridgeOperator.sol\\\";\\nimport \\\"./SlashUnavailability.sol\\\";\\nimport \\\"./CreditScore.sol\\\";\\n\\ncontract SlashIndicator is\\n ISlashIndicator,\\n SlashDoubleSign,\\n SlashBridgeVoting,\\n SlashBridgeOperator,\\n SlashUnavailability,\\n CreditScore,\\n Initializable\\n{\\n constructor() {\\n _disableInitializers();\\n }\\n\\n /**\\n * @dev Initializes the contract storage.\\n */\\n function initialize(\\n address __validatorContract,\\n address __maintenanceContract,\\n address __roninTrustedOrganizationContract,\\n address __roninGovernanceAdminContract,\\n // _bridgeOperatorSlashingConfigs[0]: _missingVotesRatioTier1\\n // _bridgeOperatorSlashingConfigs[1]: _missingVotesRatioTier2\\n // _bridgeOperatorSlashingConfigs[2]: _jailDurationForMissingVotesRatioTier2\\n // _bridgeOperatorSlashingConfigs[3]: _skipBridgeOperatorSlashingThreshold\\n uint256[4] calldata _bridgeOperatorSlashingConfigs,\\n // _bridgeVotingSlashingConfigs[0]: _bridgeVotingThreshold\\n // _bridgeVotingSlashingConfigs[1]: _bridgeVotingSlashAmount\\n uint256[2] calldata _bridgeVotingSlashingConfigs,\\n // _doubleSignSlashingConfigs[0]: _slashDoubleSignAmount\\n // _doubleSignSlashingConfigs[1]: _doubleSigningJailUntilBlock\\n // _doubleSignSlashingConfigs[2]: _doubleSigningOffsetLimitBlock\\n uint256[3] calldata _doubleSignSlashingConfigs,\\n // _unavailabilitySlashingConfigs[0]: _unavailabilityTier1Threshold\\n // _unavailabilitySlashingConfigs[1]: _unavailabilityTier2Threshold\\n // _unavailabilitySlashingConfigs[2]: _slashAmountForUnavailabilityTier2Threshold\\n // _unavailabilitySlashingConfigs[3]: _jailDurationForUnavailabilityTier2Threshold\\n uint256[4] calldata _unavailabilitySlashingConfigs,\\n // _creditScoreConfigs[0]: _gainCreditScore\\n // _creditScoreConfigs[1]: _maxCreditScore\\n // _creditScoreConfigs[2]: _bailOutCostMultiplier\\n // _creditScoreConfigs[3]: _cutOffPercentageAfterBailout\\n uint256[4] calldata _creditScoreConfigs\\n ) external initializer {\\n _setContract(ContractType.VALIDATOR, __validatorContract);\\n _setContract(ContractType.MAINTENANCE, __maintenanceContract);\\n _setContract(ContractType.GOVERNANCE_ADMIN, __roninGovernanceAdminContract);\\n _setContract(ContractType.RONIN_TRUSTED_ORGANIZATION, __roninTrustedOrganizationContract);\\n\\n _setBridgeOperatorSlashingConfigs(\\n _bridgeOperatorSlashingConfigs[0],\\n _bridgeOperatorSlashingConfigs[1],\\n _bridgeOperatorSlashingConfigs[2],\\n _bridgeOperatorSlashingConfigs[3]\\n );\\n _setBridgeVotingSlashingConfigs(_bridgeVotingSlashingConfigs[0], _bridgeVotingSlashingConfigs[1]);\\n _setDoubleSignSlashingConfigs(\\n _doubleSignSlashingConfigs[0],\\n _doubleSignSlashingConfigs[1],\\n _doubleSignSlashingConfigs[2]\\n );\\n _setUnavailabilitySlashingConfigs(\\n _unavailabilitySlashingConfigs[0],\\n _unavailabilitySlashingConfigs[1],\\n _unavailabilitySlashingConfigs[2],\\n _unavailabilitySlashingConfigs[3]\\n );\\n _setCreditScoreConfigs(\\n _creditScoreConfigs[0],\\n _creditScoreConfigs[1],\\n _creditScoreConfigs[2],\\n _creditScoreConfigs[3]\\n );\\n }\\n\\n function initializeV2(address roninGovernanceAdminContract) external reinitializer(2) {\\n _setContract(ContractType.VALIDATOR, ______deprecatedValidator);\\n _setContract(ContractType.MAINTENANCE, ______deprecatedMaintenance);\\n _setContract(ContractType.GOVERNANCE_ADMIN, roninGovernanceAdminContract);\\n _setContract(ContractType.RONIN_TRUSTED_ORGANIZATION, ______deprecatedTrustedOrg);\\n\\n delete ______deprecatedValidator;\\n delete ______deprecatedMaintenance;\\n delete ______deprecatedTrustedOrg;\\n delete ______deprecatedGovernanceAdmin;\\n }\\n\\n /**\\n * @dev Helper for CreditScore contract to reset the indicator of the validator after bailing out.\\n */\\n function _setUnavailabilityIndicator(\\n address _validator,\\n uint256 _period,\\n uint256 _indicator\\n ) internal override(CreditScore, SlashUnavailability) {\\n SlashUnavailability._setUnavailabilityIndicator(_validator, _period, _indicator);\\n }\\n\\n /**\\n * @dev Helper for CreditScore contract to query indicator of the validator.\\n */\\n function getUnavailabilityIndicator(\\n address _validator,\\n uint256 _period\\n ) public view override(CreditScore, ISlashUnavailability, SlashUnavailability) returns (uint256) {\\n return SlashUnavailability.getUnavailabilityIndicator(_validator, _period);\\n }\\n\\n /**\\n * @inheritdoc ICreditScore\\n */\\n function checkBailedOutAtPeriod(\\n address _validator,\\n uint256 _period\\n ) public view override(CreditScore, ICreditScore, SlashUnavailability) returns (bool) {\\n return CreditScore.checkBailedOutAtPeriod(_validator, _period);\\n }\\n\\n /**\\n * @dev Sanity check the address to be slashed\\n */\\n function _shouldSlash(address _addr) internal view override(SlashDoubleSign, SlashUnavailability) returns (bool) {\\n return\\n (msg.sender != _addr) &&\\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).isBlockProducer(_addr) &&\\n !IMaintenance(getContract(ContractType.MAINTENANCE)).checkMaintained(_addr, block.number);\\n }\\n}\\n\",\"keccak256\":\"0x0fa6ad414af5eddfa7125e8963aee9236c2500fc2b85524b9dbe0817edab5310\",\"license\":\"MIT\"},\"contracts/ronin/slash-indicator/SlashUnavailability.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./CreditScore.sol\\\";\\nimport \\\"../../interfaces/validator/IRoninValidatorSet.sol\\\";\\nimport \\\"../../interfaces/slash-indicator/ISlashUnavailability.sol\\\";\\nimport \\\"../../extensions/collections/HasContracts.sol\\\";\\nimport { HasValidatorDeprecated } from \\\"../../utils/DeprecatedSlots.sol\\\";\\nimport { ErrInvalidThreshold } from \\\"../../utils/CommonErrors.sol\\\";\\n\\nabstract contract SlashUnavailability is ISlashUnavailability, HasContracts, HasValidatorDeprecated {\\n /// @dev The last block that a validator is slashed for unavailability.\\n uint256 public lastUnavailabilitySlashedBlock;\\n /// @dev Mapping from validator address => period index => unavailability indicator.\\n mapping(address => mapping(uint256 => uint256)) internal _unavailabilityIndicator;\\n\\n /**\\n * @dev The mining reward will be deprecated, if (s)he missed more than this threshold.\\n * This threshold is applied for tier-1 and tier-3 of unavailability slash.\\n */\\n uint256 internal _unavailabilityTier1Threshold;\\n /**\\n * @dev The mining reward will be deprecated, (s)he will be put in jailed, and will be deducted\\n * self-staking if (s)he misses more than this threshold. This threshold is applied for tier-2 slash.\\n */\\n uint256 internal _unavailabilityTier2Threshold;\\n /**\\n * @dev The amount of RON to deduct from self-staking of a block producer when (s)he is slashed with\\n * tier-2 or tier-3.\\n **/\\n uint256 internal _slashAmountForUnavailabilityTier2Threshold;\\n /// @dev The number of blocks to jail a block producer when (s)he is slashed with tier-2 or tier-3.\\n uint256 internal _jailDurationForUnavailabilityTier2Threshold;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n */\\n uint256[50] private ______gap;\\n\\n modifier oncePerBlock() {\\n if (block.number <= lastUnavailabilitySlashedBlock) {\\n revert ErrCannotSlashAValidatorTwiceOrSlashMoreThanOneValidatorInOneBlock();\\n }\\n\\n lastUnavailabilitySlashedBlock = block.number;\\n _;\\n }\\n\\n /**\\n * @inheritdoc ISlashUnavailability\\n */\\n function slashUnavailability(address _validatorAddr) external override oncePerBlock {\\n if (msg.sender != block.coinbase) revert ErrUnauthorized(msg.sig, RoleAccess.COINBASE);\\n\\n if (!_shouldSlash(_validatorAddr)) {\\n // Should return instead of throwing error since this is a part of system transaction.\\n return;\\n }\\n\\n IRoninValidatorSet _validatorContract = IRoninValidatorSet(getContract(ContractType.VALIDATOR));\\n uint256 _period = _validatorContract.currentPeriod();\\n uint256 _count;\\n unchecked {\\n _count = ++_unavailabilityIndicator[_validatorAddr][_period];\\n }\\n uint256 _newJailedUntilBlock = Math.addIfNonZero(block.number, _jailDurationForUnavailabilityTier2Threshold);\\n\\n if (_count == _unavailabilityTier2Threshold) {\\n emit Slashed(_validatorAddr, SlashType.UNAVAILABILITY_TIER_2, _period);\\n _validatorContract.execSlash(\\n _validatorAddr,\\n _newJailedUntilBlock,\\n _slashAmountForUnavailabilityTier2Threshold,\\n false\\n );\\n } else if (_count == _unavailabilityTier1Threshold) {\\n bool _tier1SecondTime = checkBailedOutAtPeriod(_validatorAddr, _period);\\n if (!_tier1SecondTime) {\\n emit Slashed(_validatorAddr, SlashType.UNAVAILABILITY_TIER_1, _period);\\n _validatorContract.execSlash(_validatorAddr, 0, 0, false);\\n } else {\\n /// Handles tier-3\\n emit Slashed(_validatorAddr, SlashType.UNAVAILABILITY_TIER_3, _period);\\n _validatorContract.execSlash(\\n _validatorAddr,\\n _newJailedUntilBlock,\\n _slashAmountForUnavailabilityTier2Threshold,\\n true\\n );\\n }\\n }\\n }\\n\\n /**\\n * @inheritdoc ISlashUnavailability\\n */\\n function setUnavailabilitySlashingConfigs(\\n uint256 _tier1Threshold,\\n uint256 _tier2Threshold,\\n uint256 _slashAmountForTier2Threshold,\\n uint256 _jailDurationForTier2Threshold\\n ) external override onlyAdmin {\\n _setUnavailabilitySlashingConfigs(\\n _tier1Threshold,\\n _tier2Threshold,\\n _slashAmountForTier2Threshold,\\n _jailDurationForTier2Threshold\\n );\\n }\\n\\n /**\\n * @inheritdoc ISlashUnavailability\\n */\\n function getUnavailabilitySlashingConfigs()\\n external\\n view\\n override\\n returns (\\n uint256 unavailabilityTier1Threshold_,\\n uint256 unavailabilityTier2Threshold_,\\n uint256 slashAmountForUnavailabilityTier2Threshold_,\\n uint256 jailDurationForUnavailabilityTier2Threshold_\\n )\\n {\\n return (\\n _unavailabilityTier1Threshold,\\n _unavailabilityTier2Threshold,\\n _slashAmountForUnavailabilityTier2Threshold,\\n _jailDurationForUnavailabilityTier2Threshold\\n );\\n }\\n\\n /**\\n * @inheritdoc ISlashUnavailability\\n */\\n function currentUnavailabilityIndicator(address _validator) external view override returns (uint256) {\\n return\\n getUnavailabilityIndicator(_validator, IRoninValidatorSet(getContract(ContractType.VALIDATOR)).currentPeriod());\\n }\\n\\n /**\\n * @inheritdoc ISlashUnavailability\\n */\\n function getUnavailabilityIndicator(\\n address _validator,\\n uint256 _period\\n ) public view virtual override returns (uint256) {\\n return _unavailabilityIndicator[_validator][_period];\\n }\\n\\n /**\\n * @dev Sets the unavailability indicator of the `_validator` at `_period`.\\n */\\n function _setUnavailabilityIndicator(address _validator, uint256 _period, uint256 _indicator) internal virtual {\\n _unavailabilityIndicator[_validator][_period] = _indicator;\\n }\\n\\n /**\\n * @dev See `ISlashUnavailability-setUnavailabilitySlashingConfigs`.\\n */\\n function _setUnavailabilitySlashingConfigs(\\n uint256 _tier1Threshold,\\n uint256 _tier2Threshold,\\n uint256 _slashAmountForTier2Threshold,\\n uint256 _jailDurationForTier2Threshold\\n ) internal {\\n if (_unavailabilityTier1Threshold > _unavailabilityTier2Threshold) revert ErrInvalidThreshold(msg.sig);\\n\\n _unavailabilityTier1Threshold = _tier1Threshold;\\n _unavailabilityTier2Threshold = _tier2Threshold;\\n _slashAmountForUnavailabilityTier2Threshold = _slashAmountForTier2Threshold;\\n _jailDurationForUnavailabilityTier2Threshold = _jailDurationForTier2Threshold;\\n emit UnavailabilitySlashingConfigsUpdated(\\n _tier1Threshold,\\n _tier2Threshold,\\n _slashAmountForTier2Threshold,\\n _jailDurationForTier2Threshold\\n );\\n }\\n\\n /**\\n * @dev Returns whether the account `_addr` should be slashed or not.\\n */\\n function _shouldSlash(address _addr) internal view virtual returns (bool);\\n\\n /**\\n * @dev See `ICreditScore-checkBailedOutAtPeriod`\\n */\\n function checkBailedOutAtPeriod(address _validator, uint256 _period) public view virtual returns (bool);\\n}\\n\",\"keccak256\":\"0x77e1f62b033c810f9847fefeca1b7b4e3cf7b5dd754928fd765da57512a29b4d\",\"license\":\"MIT\"},\"contracts/utils/CommonErrors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { ContractType } from \\\"./ContractType.sol\\\";\\nimport { RoleAccess } from \\\"./RoleAccess.sol\\\";\\n\\nerror ErrSyncTooFarPeriod(uint256 period, uint256 latestRewardedPeriod);\\n/**\\n * @dev Error thrown when an address is expected to be an already created externally owned account (EOA).\\n * This error indicates that the provided address is invalid for certain contract operations that require already created EOA.\\n */\\nerror ErrAddressIsNotCreatedEOA(address addr, bytes32 codehash);\\n/**\\n * @dev Error raised when a bridge operator update operation fails.\\n * @param bridgeOperator The address of the bridge operator that failed to update.\\n */\\nerror ErrBridgeOperatorUpdateFailed(address bridgeOperator);\\n/**\\n * @dev Error thrown when attempting to add a bridge operator that already exists in the contract.\\n * This error indicates that the provided bridge operator address is already registered as a bridge operator in the contract.\\n */\\nerror ErrBridgeOperatorAlreadyExisted(address bridgeOperator);\\n/**\\n * @dev The error indicating an unsupported interface.\\n * @param interfaceId The bytes4 interface identifier that is not supported.\\n * @param addr The address where the unsupported interface was encountered.\\n */\\nerror ErrUnsupportedInterface(bytes4 interfaceId, address addr);\\n/**\\n * @dev Error thrown when the return data from a callback function is invalid.\\n * @param callbackFnSig The signature of the callback function that returned invalid data.\\n * @param register The address of the register where the callback function was invoked.\\n * @param returnData The invalid return data received from the callback function.\\n */\\nerror ErrInvalidReturnData(bytes4 callbackFnSig, address register, bytes returnData);\\n/**\\n * @dev Error of set to non-contract.\\n */\\nerror ErrZeroCodeContract(address addr);\\n/**\\n * @dev Error indicating that arguments are invalid.\\n */\\nerror ErrInvalidArguments(bytes4 msgSig);\\n/**\\n * @dev Error indicating that given address is null when it should not.\\n */\\nerror ErrZeroAddress(bytes4 msgSig);\\n/**\\n * @dev Error indicating that the provided threshold is invalid for a specific function signature.\\n * @param msgSig The function signature (bytes4) that the invalid threshold applies to.\\n */\\nerror ErrInvalidThreshold(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a function can only be called by the contract itself.\\n * @param msgSig The function signature (bytes4) that can only be called by the contract itself.\\n */\\nerror ErrOnlySelfCall(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\\n * @param msgSig The function signature (bytes4) that the caller is unauthorized to perform.\\n * @param expectedRole The role required to perform the function.\\n */\\nerror ErrUnauthorized(bytes4 msgSig, RoleAccess expectedRole);\\n\\n/**\\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\\n * @param msgSig The function signature (bytes4) that the caller is unauthorized to perform.\\n */\\nerror ErrUnauthorizedCall(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\\n * @param msgSig The function signature (bytes4).\\n * @param expectedContractType The contract type required to perform the function.\\n * @param actual The actual address that called to the function.\\n */\\nerror ErrUnexpectedInternalCall(bytes4 msgSig, ContractType expectedContractType, address actual);\\n\\n/**\\n * @dev Error indicating that an array is empty when it should contain elements.\\n */\\nerror ErrEmptyArray();\\n\\n/**\\n * @dev Error indicating a mismatch in the length of input parameters or arrays for a specific function.\\n * @param msgSig The function signature (bytes4) that has a length mismatch.\\n */\\nerror ErrLengthMismatch(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a proxy call to an external contract has failed.\\n * @param msgSig The function signature (bytes4) of the proxy call that failed.\\n * @param extCallSig The function signature (bytes4) of the external contract call that failed.\\n */\\nerror ErrProxyCallFailed(bytes4 msgSig, bytes4 extCallSig);\\n\\n/**\\n * @dev Error indicating that a function tried to call a precompiled contract that is not allowed.\\n * @param msgSig The function signature (bytes4) that attempted to call a precompiled contract.\\n */\\nerror ErrCallPrecompiled(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a native token transfer has failed.\\n * @param msgSig The function signature (bytes4) of the token transfer that failed.\\n */\\nerror ErrNativeTransferFailed(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that an order is invalid.\\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid order.\\n */\\nerror ErrInvalidOrder(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that the chain ID is invalid.\\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid chain ID.\\n * @param actual Current chain ID that executing function.\\n * @param expected Expected chain ID required for the tx to success.\\n */\\nerror ErrInvalidChainId(bytes4 msgSig, uint256 actual, uint256 expected);\\n\\n/**\\n * @dev Error indicating that a vote type is not supported.\\n * @param msgSig The function signature (bytes4) of the operation that encountered an unsupported vote type.\\n */\\nerror ErrUnsupportedVoteType(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that the proposal nonce is invalid.\\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid proposal nonce.\\n */\\nerror ErrInvalidProposalNonce(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a voter has already voted.\\n * @param voter The address of the voter who has already voted.\\n */\\nerror ErrAlreadyVoted(address voter);\\n\\n/**\\n * @dev Error indicating that a signature is invalid for a specific function signature.\\n * @param msgSig The function signature (bytes4) that encountered an invalid signature.\\n */\\nerror ErrInvalidSignatures(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a relay call has failed.\\n * @param msgSig The function signature (bytes4) of the relay call that failed.\\n */\\nerror ErrRelayFailed(bytes4 msgSig);\\n/**\\n * @dev Error indicating that a vote weight is invalid for a specific function signature.\\n * @param msgSig The function signature (bytes4) that encountered an invalid vote weight.\\n */\\nerror ErrInvalidVoteWeight(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a query was made for an outdated bridge operator set.\\n */\\nerror ErrQueryForOutdatedBridgeOperatorSet();\\n\\n/**\\n * @dev Error indicating that a request is invalid.\\n */\\nerror ErrInvalidRequest();\\n\\n/**\\n * @dev Error indicating that a token standard is invalid.\\n */\\nerror ErrInvalidTokenStandard();\\n\\n/**\\n * @dev Error indicating that a token is not supported.\\n */\\nerror ErrUnsupportedToken();\\n\\n/**\\n * @dev Error indicating that a receipt kind is invalid.\\n */\\nerror ErrInvalidReceiptKind();\\n\\n/**\\n * @dev Error indicating that a receipt is invalid.\\n */\\nerror ErrInvalidReceipt();\\n\\n/**\\n * @dev Error indicating that an address is not payable.\\n */\\nerror ErrNonpayableAddress(address);\\n\\n/**\\n * @dev Error indicating that the period is already processed, i.e. scattered reward.\\n */\\nerror ErrPeriodAlreadyProcessed(uint256 requestingPeriod, uint256 latestPeriod);\\n\\n/**\\n * @dev Error thrown when an invalid vote hash is provided.\\n */\\nerror ErrInvalidVoteHash();\\n\\n/**\\n * @dev Error thrown when querying for an empty vote.\\n */\\nerror ErrQueryForEmptyVote();\\n\\n/**\\n * @dev Error thrown when querying for an expired vote.\\n */\\nerror ErrQueryForExpiredVote();\\n\\n/**\\n * @dev Error thrown when querying for a non-existent vote.\\n */\\nerror ErrQueryForNonExistentVote();\\n\",\"keccak256\":\"0x3914292a405307cba9e93085edcaf5f1203ca2d55abf998bf1d2af1e86f5a4c6\",\"license\":\"MIT\"},\"contracts/utils/ContractType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum ContractType {\\n /* 0 */ UNKNOWN,\\n /* 1 */ PAUSE_ENFORCER,\\n /* 2 */ BRIDGE,\\n /* 3 */ BRIDGE_TRACKING,\\n /* 4 */ GOVERNANCE_ADMIN,\\n /* 5 */ MAINTENANCE,\\n /* 6 */ SLASH_INDICATOR,\\n /* 7 */ STAKING_VESTING,\\n /* 8 */ VALIDATOR,\\n /* 9 */ STAKING,\\n /* 10 */ RONIN_TRUSTED_ORGANIZATION,\\n /* 11 */ BRIDGE_MANAGER,\\n /* 12 */ BRIDGE_SLASH,\\n /* 13 */ BRIDGE_REWARD\\n}\\n\",\"keccak256\":\"0xf72feff9afafcb5cadc1b05c6e0b998ea5d66c7ece57c3e482e560d0a1bb4079\",\"license\":\"MIT\"},\"contracts/utils/DeprecatedSlots.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title Deprecated Contracts\\n * @dev These abstract contracts are deprecated and should not be used in new implementations.\\n * They provide functionality related to various aspects of a smart contract but have been marked\\n * as deprecated to indicate that they are no longer actively maintained or recommended for use.\\n * The purpose of these contracts is to preserve the slots for already deployed contracts.\\n */\\ncontract HasSlashIndicatorDeprecated {\\n /// @custom:deprecated Previously `_slashIndicatorContract` (non-zero value)\\n address internal ______deprecatedSlashIndicator;\\n}\\n\\ncontract HasStakingVestingDeprecated {\\n /// @custom:deprecated Previously `_stakingVestingContract` (non-zero value)\\n address internal ______deprecatedStakingVesting;\\n}\\n\\ncontract HasBridgeDeprecated {\\n /// @custom:deprecated Previously `_bridgeContract` (non-zero value)\\n address internal ______deprecatedBridge;\\n}\\n\\ncontract HasValidatorDeprecated {\\n /// @custom:deprecated Previously `_validatorContract` (non-zero value)\\n address internal ______deprecatedValidator;\\n}\\n\\ncontract HasStakingDeprecated {\\n /// @custom:deprecated Previously `_stakingContract` (non-zero value)\\n address internal ______deprecatedStakingContract;\\n}\\n\\ncontract HasMaintenanceDeprecated {\\n /// @custom:deprecated Previously `_maintenanceContract` (non-zero value)\\n address internal ______deprecatedMaintenance;\\n}\\n\\ncontract HasTrustedOrgDeprecated {\\n /// @custom:deprecated Previously `_trustedOrgContract` (non-zero value)\\n address internal ______deprecatedTrustedOrg;\\n}\\n\\ncontract HasGovernanceAdminDeprecated {\\n /// @custom:deprecated Previously `_governanceAdminContract` (non-zero value)\\n address internal ______deprecatedGovernanceAdmin;\\n}\\n\\ncontract HasBridgeTrackingDeprecated {\\n /// @custom:deprecated Previously `_bridgeTrackingContract` (non-zero value)\\n address internal ______deprecatedBridgeTracking;\\n}\\n\",\"keccak256\":\"0xe93504aed9f67a6d399475c7162560f2ac4f793fab5b67fe504fc694ac9a2892\",\"license\":\"MIT\"},\"contracts/utils/IdentityGuard.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { AddressArrayUtils } from \\\"../libraries/AddressArrayUtils.sol\\\";\\nimport { IERC165 } from \\\"@openzeppelin/contracts/utils/introspection/IERC165.sol\\\";\\nimport { TransparentUpgradeableProxyV2 } from \\\"../extensions/TransparentUpgradeableProxyV2.sol\\\";\\nimport { ErrAddressIsNotCreatedEOA, ErrZeroAddress, ErrOnlySelfCall, ErrZeroCodeContract, ErrUnsupportedInterface } from \\\"./CommonErrors.sol\\\";\\n\\nabstract contract IdentityGuard {\\n using AddressArrayUtils for address[];\\n\\n /// @dev value is equal to keccak256(abi.encode())\\n /// @dev see: https://eips.ethereum.org/EIPS/eip-1052\\n bytes32 internal constant CREATED_ACCOUNT_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\\n\\n /**\\n * @dev Modifier to restrict functions to only be called by this contract.\\n * @dev Reverts if the caller is not this contract.\\n */\\n modifier onlySelfCall() virtual {\\n _requireSelfCall();\\n _;\\n }\\n\\n /**\\n * @dev Modifier to ensure that the elements in the `arr` array are non-duplicates.\\n * It calls the internal `_checkDuplicate` function to perform the duplicate check.\\n *\\n * Requirements:\\n * - The elements in the `arr` array must not contain any duplicates.\\n */\\n modifier nonDuplicate(address[] memory arr) virtual {\\n _requireNonDuplicate(arr);\\n _;\\n }\\n\\n /**\\n * @dev Internal method to check the method caller.\\n * @dev Reverts if the method caller is not this contract.\\n */\\n function _requireSelfCall() internal view virtual {\\n if (msg.sender != address(this)) revert ErrOnlySelfCall(msg.sig);\\n }\\n\\n /**\\n * @dev Internal function to check if a contract address has code.\\n * @param addr The address of the contract to check.\\n * @dev Throws an error if the contract address has no code.\\n */\\n function _requireHasCode(address addr) internal view {\\n if (addr.code.length == 0) revert ErrZeroCodeContract(addr);\\n }\\n\\n /**\\n * @dev Checks if an address is zero and reverts if it is.\\n * @param addr The address to check.\\n */\\n function _requireNonZeroAddress(address addr) internal pure {\\n if (addr == address(0)) revert ErrZeroAddress(msg.sig);\\n }\\n\\n /**\\n * @dev Check if arr is empty and revert if it is.\\n * Checks if an array contains any duplicate addresses and reverts if duplicates are found.\\n * @param arr The array of addresses to check.\\n */\\n function _requireNonDuplicate(address[] memory arr) internal pure {\\n if (arr.hasDuplicate()) revert AddressArrayUtils.ErrDuplicated(msg.sig);\\n }\\n\\n /**\\n * @dev Internal function to require that the provided address is a created externally owned account (EOA).\\n * This internal function is used to ensure that the provided address is a valid externally owned account (EOA).\\n * It checks the codehash of the address against a predefined constant to confirm that the address is a created EOA.\\n * @notice This method only works with non-state EOA accounts\\n */\\n function _requireCreatedEOA(address addr) internal view {\\n _requireNonZeroAddress(addr);\\n bytes32 codehash = addr.codehash;\\n if (codehash != CREATED_ACCOUNT_HASH) revert ErrAddressIsNotCreatedEOA(addr, codehash);\\n }\\n\\n /**\\n * @dev Internal function to require that the specified contract supports the given interface. This method handle in\\n * both case that the callee is either or not the proxy admin of the caller. If the contract does not support the\\n * interface `interfaceId` or EIP165, a revert with the corresponding error message is triggered.\\n *\\n * @param contractAddr The address of the contract to check for interface support.\\n * @param interfaceId The interface ID to check for support.\\n */\\n function _requireSupportsInterface(address contractAddr, bytes4 interfaceId) internal view {\\n bytes memory supportsInterfaceParams = abi.encodeCall(IERC165.supportsInterface, (interfaceId));\\n (bool success, bytes memory returnOrRevertData) = contractAddr.staticcall(supportsInterfaceParams);\\n if (!success) {\\n (success, returnOrRevertData) = contractAddr.staticcall(\\n abi.encodeCall(TransparentUpgradeableProxyV2.functionDelegateCall, (supportsInterfaceParams))\\n );\\n if (!success) revert ErrUnsupportedInterface(interfaceId, contractAddr);\\n }\\n if (!abi.decode(returnOrRevertData, (bool))) revert ErrUnsupportedInterface(interfaceId, contractAddr);\\n }\\n}\\n\",\"keccak256\":\"0x2d0dfcef3636945bc1785c1fa5a05f5203c79cbb81b2eee92a3ac6a2378c2ce5\",\"license\":\"MIT\"},\"contracts/utils/RoleAccess.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum RoleAccess {\\n /* 0 */ UNKNOWN,\\n /* 1 */ ADMIN,\\n /* 2 */ COINBASE,\\n /* 3 */ GOVERNOR,\\n /* 4 */ CANDIDATE_ADMIN,\\n /* 5 */ WITHDRAWAL_MIGRATOR,\\n /* 6 */ __DEPRECATED_BRIDGE_OPERATOR,\\n /* 7 */ BLOCK_PRODUCER,\\n /* 8 */ VALIDATOR_CANDIDATE\\n}\\n\",\"keccak256\":\"0xa98cec38c640c4e37f475debbcd366226f1188c3f5ea6e29de768bd33e021873\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b506200001c62000022565b620000e7565b61011354610100900460ff1615620000905760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b6101135460ff9081161015620000e557610113805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b6128f080620000f76000396000f3fe608060405234801561001057600080fd5b50600436106101c45760003560e01c806399103f7b116100f9578063d1f992f711610097578063df4b6ee011610071578063df4b6ee0146103f2578063f1001e7814610416578063f562b3c414610436578063fd422cd01461043f57600080fd5b8063d1f992f7146103a3578063d3dd2bdf146103b6578063de981f1b146103df57600080fd5b8063c6391fa2116100d3578063c6391fa214610359578063ccbb72ed1461036a578063cf39d13c1461037d578063d1737e271461039057600080fd5b806399103f7b14610318578063c008ce391461032b578063c2e524dc1461033e57600080fd5b806329ddc3c0116101665780637680850c116101405780637680850c146102c45780637c2b55a0146102d7578063853af1b7146102f2578063865e6fd31461030557600080fd5b806329ddc3c01461027d5780633d48fd7d146102a057806362ffe6cb146102b157600080fd5b80631079402a116101a25780631079402a146102175780631a697341146102445780631e90b2a01461025757806329b6eca91461026a57600080fd5b806307c2d2f6146101c9578063082e7420146101de5780630e1512ac14610204575b600080fd5b6101dc6101d7366004612030565b610452565b005b6101f16101ec366004612087565b610560565b6040519081526020015b60405180910390f35b6101dc6102123660046120a4565b6105d7565b606d54606e54606f546070545b6040805194855260208501939093529183015260608201526080016101fb565b6101dc610252366004612087565b6105f1565b6101dc610265366004612118565b610892565b6101dc610278366004612087565b610a7a565b61029061028b36600461219b565b610b9e565b60405190151581526020016101fb565b60a55460a65460a75460a854610224565b6101f16102bf36600461219b565b610bcd565b6101dc6102d23660046121c7565b610bf6565b60675b6040516001600160a01b0390911681526020016101fb565b6101dc610300366004612213565b610f0d565b6101dc610313366004612244565b610f23565b6101dc61032636600461228c565b610f3e565b6101dc610339366004612350565b6110a9565b603854603954604080519283526020830191909152016101fb565b60dd5460de5460df5460e054610224565b6101dc6103783660046120a4565b611133565b6101dc61038b366004612385565b611147565b6101dc61039e3660046120a4565b61115f565b6101dc6103b1366004612087565b611173565b6101f16103c4366004612087565b6001600160a01b0316600090815260dc602052604090205490565b6102da6103ed3660046123b1565b611562565b600154600254600354604080519384526020840192909252908201526060016101fb565b610429610424366004612030565b6115dd565b6040516101fb9190612407565b6101f160a35481565b6101dc61044d366004612087565b6116a8565b600861045d816119bc565b60008267ffffffffffffffff8111156104785761047861241a565b6040519080825280602002602001820160405280156104a1578160200160208202803683370190505b50905060005b8381101561051e5760008585838181106104c3576104c3612430565b90506020020160208101906104d89190612087565b6001600160a01b038116600090815260dc6020526040812055835190915083908390811061050857610508612430565b60006020918202929092010152506001016104a7565b507f8c02b2ccee964dc50649a48bd0a0446f0f9e88ecdb72d099f4ace07c39c2348084848360405161055293929190612484565b60405180910390a150505050565b60006105d1826105706008611562565b6001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa1580156105ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102bf91906124b4565b92915050565b6105df611a08565b6105eb84848484611a64565b50505050565b6105f9611a08565b6000610605600a611562565b604051636db349d160e11b81526001600160a01b038481166004830152919091169063db6693a29060240160a060405180830381865afa15801561064d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067191906124fe565b905060006106fb610682600b611562565b6040808501519051632623bd4f60e21b81526001600160a01b03918216600482015291169063988ef53c90602401602060405180830381865afa1580156106cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f191906124b4565b8360800151611af6565b905060006107096008611562565b90506000816001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa15801561074b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076f91906124b4565b60385490915061077f844361259c565b1115806107af57506001600160a01b038516600090815260376020908152604080832084845290915290205460ff165b156107cd57604051632e308a0b60e11b815260040160405180910390fd5b6001600160a01b038516600081815260376020908152604080832085845290915290819020805460ff19166001179055516000805160206128c48339815191529061081c9060049085906125c5565b60405180910390a2603954604051630bde081360e21b81526001600160a01b03841691632f78204c916108599189916000919082906004016125e3565b600060405180830381600087803b15801561087357600080fd5b505af1158015610887573d6000803e3d6000fd5b505050505050505050565b61089a611a08565b600084846040516108ac92919061260b565b60405180910390209050600083836040516108c892919061260b565b604080519182900390912060008481526004602052919091205490915060ff1680610901575060008181526004602052604090205460ff165b1561091f5760405163f27b8ec960e01b815260040160405180910390fd5b61092c8787878787611b0d565b15610a7157600061093d6008611562565b90506000816001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa15801561097f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a391906124b4565b6000858152600460205260408082208054600160ff19918216811790925587845292829020805490931617909155519091506001600160a01b038a16906000805160206128c4833981519152906109fe9060039085906125c5565b60405180910390a260025460018054604051630bde081360e21b81526001600160a01b03861693632f78204c93610a3c938f939091906004016125e3565b600060405180830381600087803b158015610a5657600080fd5b505af1158015610a6a573d6000803e3d6000fd5b5050505050505b50505050505050565b61011354600290610100900460ff16158015610a9e57506101135460ff8083169116105b610ac35760405162461bcd60e51b8152600401610aba9061261b565b60405180910390fd5b610113805461ffff191660ff831617610100179055600054610af0906008906001600160a01b0316611bb7565b606c54610b08906005906001600160a01b0316611bb7565b610b13600483611bb7565b603554610b2b90600a906001600160a01b0316611bb7565b600080546001600160a01b0319908116909155606c8054821690556035805482169055603680549091169055610113805461ff001916905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15050565b6001600160a01b038216600090815260db6020908152604080832084845290915281205460ff165b9392505050565b6001600160a01b038216600090815260a460209081526040808320848452909152812054610bc6565b6008610c01816119bc565b60003390506000816001600160a01b031663297a8fca6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c46573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c6a91906124b4565b90506000826001600160a01b0316634de2b73588886040518363ffffffff1660e01b8152600401610c9c929190612669565b600060405180830381865afa158015610cb9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ce1919081019061268d565b90506000610cef6005611562565b6001600160a01b031663ba303755898986436040518563ffffffff1660e01b8152600401610d20949392919061273a565b600060405180830381865afa158015610d3d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d65919081019061268d565b905060008767ffffffffffffffff811115610d8257610d8261241a565b604051908082528060200260200182016040528015610dab578160200160208202803683370190505b50905060005b88811015610ec65760008a8a83818110610dcd57610dcd612430565b9050602002016020810190610de29190612087565b90506000610df0828b610bcd565b90506000868481518110610e0657610e06612430565b602002602001015190506000868581518110610e2457610e24612430565b6020026020010151905060008280610e395750815b610e4e57610e4960dd5485611c5b565b610e51565b60005b6001600160a01b038616600090815260dc602052604090205460de54919250610e7b918390611c75565b6001600160a01b038616600090815260dc602052604090208190558751889088908110610eaa57610eaa612430565b6020026020010181815250508560010195505050505050610db1565b507f8c02b2ccee964dc50649a48bd0a0446f0f9e88ecdb72d099f4ace07c39c23480898983604051610efa93929190612484565b60405180910390a1505050505050505050565b610f15611a08565b610f1f8282611c92565b5050565b610f2b611a08565b610f3481611cd2565b610f1f8282611bb7565b61011354610100900460ff1615808015610f60575061011354600160ff909116105b80610f7b5750303b158015610f7b57506101135460ff166001145b610f975760405162461bcd60e51b8152600401610aba9061261b565b610113805460ff191660011790558015610fbc57610113805461ff0019166101001790555b610fc760088b611bb7565b610fd260058a611bb7565b610fdd600488611bb7565b610fe8600a89611bb7565b61100186356020880135604089013560608a0135611a64565b61101085356020870135611c92565b611024843560208601356040870135611d08565b61103d8335602085013560408601356060870135611d5d565b6110568235602084013560408501356060860135611de9565b801561109d57610113805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050505050565b60086110b4816119bc565b826001036110f357836001600160a01b03166000805160206128c48339815191526005846040516110e69291906125c5565b60405180910390a26105eb565b826002036105eb57836001600160a01b03166000805160206128c48339815191526006846040516111259291906125c5565b60405180910390a250505050565b61113b611a08565b6105eb84848484611de9565b61114f611a08565b61115a838383611d08565b505050565b611167611a08565b6105eb84848484611d5d565b600061117f6008611562565b604051635061f96960e11b81526001600160a01b0384811660048301529192509082169063a0c3f2d290602401602060405180830381865afa1580156111c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ed9190612761565b61121a576000356001600160e01b0319166008604051620f948f60ea1b8152600401610aba92919061277c565b6040516304d971ab60e01b81526001600160a01b0383811660048301523360248301528216906304d971ab90604401602060405180830381865afa158015611266573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061128a9190612761565b6112b7576000356001600160e01b0319166004604051620f948f60ea1b8152600401610aba92919061277c565b604051634b2c2fe160e11b81526001600160a01b03838116600483015260009182918416906396585fc290602401606060405180830381865afa158015611302573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132691906127aa565b92505091508161134957604051636cd31b5960e01b815260040160405180910390fd5b6000836001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa158015611389573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ad91906124b4565b6001600160a01b038616600090815260db6020908152604080832084845290915290205490915060ff16156113f557604051637674d6a960e01b815260040160405180910390fd5b6001600160a01b038516600090815260dc602052604081205460df5490919061141e90856127df565b9050808210156114415760405163462e593760e11b815260040160405180910390fd5b604051630adaf5ef60e11b81526001600160a01b038881166004830152602482018590528716906315b5ebde90604401600060405180830381600087803b15801561148b57600080fd5b505af115801561149f573d6000803e3d6000fd5b505050506001600160a01b038716600090815260dc6020526040812080548392906114cb90849061259c565b90915550506001600160a01b038716600090815260a4602090815260408083208684529091528120556001600160a01b038716600081815260db60209081526040808320878452825291829020805460ff1916600117905581518681529081018490527f7ff9f7032d565c7e8919332964b2faa33c320b53604a65d9dd1f8112e12cd39d910160405180910390a250505050505050565b60007fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb600083600d811115611599576115996125af565b60ff1681526020810191909152604001600020546001600160a01b03169050806115d8578160405163409140df60e11b8152600401610aba919061280a565b919050565b60608167ffffffffffffffff8111156115f8576115f861241a565b604051908082528060200260200182016040528015611621578160200160208202803683370190505b50905060005b81518110156116a15760dc600085858481811061164657611646612430565b905060200201602081019061165b9190612087565b6001600160a01b03166001600160a01b031681526020019081526020016000205482828151811061168e5761168e612430565b6020908102919091010152600101611627565b5092915050565b60a35443116116ca5760405163557fd09160e01b815260040160405180910390fd5b4360a3553341146116fe576000356001600160e01b0319166002604051620f948f60ea1b8152600401610aba92919061277c565b61170781611e86565b156119b95760006117186008611562565b90506000816001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa15801561175a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061177e91906124b4565b6001600160a01b038416600090815260a460209081526040808320848452909152812080546001019081905560a854929350916117bc904390611f9c565b905060a654820361186557846001600160a01b03166000805160206128c48339815191526002856040516117f19291906125c5565b60405180910390a260a754604051630bde081360e21b81526001600160a01b03861691632f78204c9161182e9189918691906000906004016125e3565b600060405180830381600087803b15801561184857600080fd5b505af115801561185c573d6000803e3d6000fd5b505050506119b4565b60a55482036119b457600061187a8685610b9e565b90508061191d57856001600160a01b03166000805160206128c48339815191526001866040516118ab9291906125c5565b60405180910390a2604051630bde081360e21b81526001600160a01b03861690632f78204c906118e6908990600090819081906004016125e3565b600060405180830381600087803b15801561190057600080fd5b505af1158015611914573d6000803e3d6000fd5b505050506119b2565b856001600160a01b03166000805160206128c48339815191526007866040516119479291906125c5565b60405180910390a260a754604051630bde081360e21b81526001600160a01b03871691632f78204c91611984918a918791906001906004016125e3565b600060405180830381600087803b15801561199e57600080fd5b505af115801561109d573d6000803e3d6000fd5b505b505050505b50565b6119c581611562565b6001600160a01b0316336001600160a01b0316146119b9576000356001600160e01b03191681336040516320e0f98d60e21b8152600401610aba93929190612818565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b03163314611a62576000356001600160e01b0319166001604051620f948f60ea1b8152600401610aba92919061277c565b565b82841180611a73575061271084115b80611a7f575061271083115b15611a9d57604051631cbe1abf60e11b815260040160405180910390fd5b606d849055606e839055606f82905560708190556040805185815260208101859052908101839052606081018290527fd24c671da2227c139fe1a5b34de15e5a67bef9b46e912916b9e0d025d51b3e3b90608001610552565b600081831015611b065781610bc6565b5090919050565b6040516000906067906001908390611b31908a908a908a908a908a90602401612878565b60408051601f198184030181529190526020810180516001600160e01b0316637fc3567760e01b1790528051909150611b68611fc6565b602083016020828483895afa611b7d57600094505b503d611b8857600093505b83611ba657604051630fc2632160e01b815260040160405180910390fd5b5115159a9950505050505050505050565b807fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb600084600d811115611bed57611bed6125af565b60ff168152602081019190915260400160002080546001600160a01b0319166001600160a01b03928316179055811682600d811115611c2e57611c2e6125af565b6040517f865d1c228a8ea13709cfe61f346f7ff67f1bbd4a18ff31ad3e7147350d317c5990600090a35050565b6000818311611c6b576000610bc6565b610bc6828461259c565b6000611c8a611c8484866128b0565b83611fb7565b949350505050565b6038829055603981905560408051838152602081018390527fbda9ec2980d7468ba6a9f363696315affca9f9770016396bdea2ac39c3e5d61a9101610b92565b806001600160a01b03163b6000036119b957604051630bfc64a360e21b81526001600160a01b0382166004820152602401610aba565b60018390556002829055600381905560408051848152602081018490529081018290527f913da102149f952dde560cef3349db8e8002e9d580c41a7551d6d45329f4306b9060600160405180910390a1505050565b60a65460a5541115611d90576040516387f6f09560e01b81526001600160e01b0319600035166004820152602401610aba565b60a584905560a683905560a782905560a88190556040805185815260208101859052908101839052606081018290527f442862e6143ad95854e7c13ff4947ec6e43bc87160e3b193e7c1abaf6e3aaa9890608001610552565b82841115611e0a5760405163112af4d160e01b815260040160405180910390fd5b612710811115611e2d5760405163382c88a360e21b815260040160405180910390fd5b60dd84905560de83905560df82905560e08190556040805185815260208101859052908101839052606081018290527fe1f9c6c73554b5fa140eead3cfd4ec3e6d4824f3ed26fb25e38376f65b95470b90608001610552565b6000336001600160a01b03831614801590611f125750611ea66008611562565b604051633292276760e11b81526001600160a01b03848116600483015291909116906365244ece90602401602060405180830381865afa158015611eee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f129190612761565b80156105d15750611f236005611562565b604051630fbeb37f60e01b81526001600160a01b0384811660048301524360248301529190911690630fbeb37f90604401602060405180830381865afa158015611f71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f959190612761565b1592915050565b600081600003611fad576000610bc6565b610bc682846128b0565b6000818310611b065781610bc6565b60405180602001604052806001906020820280368337509192915050565b60008083601f840112611ff657600080fd5b50813567ffffffffffffffff81111561200e57600080fd5b6020830191508360208260051b850101111561202957600080fd5b9250929050565b6000806020838503121561204357600080fd5b823567ffffffffffffffff81111561205a57600080fd5b61206685828601611fe4565b90969095509350505050565b6001600160a01b03811681146119b957600080fd5b60006020828403121561209957600080fd5b8135610bc681612072565b600080600080608085870312156120ba57600080fd5b5050823594602084013594506040840135936060013592509050565b60008083601f8401126120e857600080fd5b50813567ffffffffffffffff81111561210057600080fd5b60208301915083602082850101111561202957600080fd5b60008060008060006060868803121561213057600080fd5b853561213b81612072565b9450602086013567ffffffffffffffff8082111561215857600080fd5b61216489838a016120d6565b9096509450604088013591508082111561217d57600080fd5b5061218a888289016120d6565b969995985093965092949392505050565b600080604083850312156121ae57600080fd5b82356121b981612072565b946020939093013593505050565b6000806000604084860312156121dc57600080fd5b833567ffffffffffffffff8111156121f357600080fd5b6121ff86828701611fe4565b909790965060209590950135949350505050565b6000806040838503121561222657600080fd5b50508035926020909101359150565b8035600e81106115d857600080fd5b6000806040838503121561225757600080fd5b61226083612235565b9150602083013561227081612072565b809150509250929050565b80608081018310156105d157600080fd5b60008060008060008060008060006102a08a8c0312156122ab57600080fd5b89356122b681612072565b985060208a01356122c681612072565b975060408a01356122d681612072565b965060608a01356122e681612072565b95506122f58b60808c0161227b565b94506101408a018b81111561230957600080fd5b6101008b0194506101a08b018c81111561232257600080fd5b81945061232f8d8261227b565b935050506123418b6102208c0161227b565b90509295985092959850929598565b60008060006060848603121561236557600080fd5b833561237081612072565b95602085013595506040909401359392505050565b60008060006060848603121561239a57600080fd5b505081359360208301359350604090920135919050565b6000602082840312156123c357600080fd5b610bc682612235565b600081518084526020808501945080840160005b838110156123fc578151875295820195908201906001016123e0565b509495945050505050565b602081526000610bc660208301846123cc565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b8183526000602080850194508260005b858110156123fc57813561246981612072565b6001600160a01b031687529582019590820190600101612456565b604081526000612498604083018587612446565b82810360208401526124aa81856123cc565b9695505050505050565b6000602082840312156124c657600080fd5b5051919050565b604051601f8201601f1916810167ffffffffffffffff811182821017156124f6576124f661241a565b604052919050565b600060a0828403121561251057600080fd5b60405160a0810181811067ffffffffffffffff821117156125335761253361241a565b604052825161254181612072565b8152602083015161255181612072565b6020820152604083015161256481612072565b6040820152606083810151908201526080928301519281019290925250919050565b634e487b7160e01b600052601160045260246000fd5b818103818111156105d1576105d1612586565b634e487b7160e01b600052602160045260246000fd5b60408101600884106125d9576125d96125af565b9281526020015290565b6001600160a01b03949094168452602084019290925260408301521515606082015260800190565b8183823760009101908152919050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b602081526000611c8a602083018486612446565b805180151581146115d857600080fd5b600060208083850312156126a057600080fd5b825167ffffffffffffffff808211156126b857600080fd5b818501915085601f8301126126cc57600080fd5b8151818111156126de576126de61241a565b8060051b91506126ef8483016124cd565b818152918301840191848101908884111561270957600080fd5b938501935b8385101561272e5761271f8561267d565b8252938501939085019061270e565b98975050505050505050565b60608152600061274e606083018688612446565b6020830194909452506040015292915050565b60006020828403121561277357600080fd5b610bc68261267d565b6001600160e01b031983168152604081016009831061279d5761279d6125af565b8260208301529392505050565b6000806000606084860312156127bf57600080fd5b6127c88461267d565b925060208401519150604084015190509250925092565b80820281158282048414176105d1576105d1612586565b600e8110612806576128066125af565b9052565b602081016105d182846127f6565b6001600160e01b0319841681526060810161283660208301856127f6565b6001600160a01b03929092166040919091015292915050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6001600160a01b038616815260606020820181905260009061289d908301868861284f565b828103604084015261272e81858761284f565b808201808211156105d1576105d161258656fe607adba66cff84b627e3537d1c17d088a98556bccd0536a2f3590c56329023d9a164736f6c6343000811000a", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101c45760003560e01c806399103f7b116100f9578063d1f992f711610097578063df4b6ee011610071578063df4b6ee0146103f2578063f1001e7814610416578063f562b3c414610436578063fd422cd01461043f57600080fd5b8063d1f992f7146103a3578063d3dd2bdf146103b6578063de981f1b146103df57600080fd5b8063c6391fa2116100d3578063c6391fa214610359578063ccbb72ed1461036a578063cf39d13c1461037d578063d1737e271461039057600080fd5b806399103f7b14610318578063c008ce391461032b578063c2e524dc1461033e57600080fd5b806329ddc3c0116101665780637680850c116101405780637680850c146102c45780637c2b55a0146102d7578063853af1b7146102f2578063865e6fd31461030557600080fd5b806329ddc3c01461027d5780633d48fd7d146102a057806362ffe6cb146102b157600080fd5b80631079402a116101a25780631079402a146102175780631a697341146102445780631e90b2a01461025757806329b6eca91461026a57600080fd5b806307c2d2f6146101c9578063082e7420146101de5780630e1512ac14610204575b600080fd5b6101dc6101d7366004612030565b610452565b005b6101f16101ec366004612087565b610560565b6040519081526020015b60405180910390f35b6101dc6102123660046120a4565b6105d7565b606d54606e54606f546070545b6040805194855260208501939093529183015260608201526080016101fb565b6101dc610252366004612087565b6105f1565b6101dc610265366004612118565b610892565b6101dc610278366004612087565b610a7a565b61029061028b36600461219b565b610b9e565b60405190151581526020016101fb565b60a55460a65460a75460a854610224565b6101f16102bf36600461219b565b610bcd565b6101dc6102d23660046121c7565b610bf6565b60675b6040516001600160a01b0390911681526020016101fb565b6101dc610300366004612213565b610f0d565b6101dc610313366004612244565b610f23565b6101dc61032636600461228c565b610f3e565b6101dc610339366004612350565b6110a9565b603854603954604080519283526020830191909152016101fb565b60dd5460de5460df5460e054610224565b6101dc6103783660046120a4565b611133565b6101dc61038b366004612385565b611147565b6101dc61039e3660046120a4565b61115f565b6101dc6103b1366004612087565b611173565b6101f16103c4366004612087565b6001600160a01b0316600090815260dc602052604090205490565b6102da6103ed3660046123b1565b611562565b600154600254600354604080519384526020840192909252908201526060016101fb565b610429610424366004612030565b6115dd565b6040516101fb9190612407565b6101f160a35481565b6101dc61044d366004612087565b6116a8565b600861045d816119bc565b60008267ffffffffffffffff8111156104785761047861241a565b6040519080825280602002602001820160405280156104a1578160200160208202803683370190505b50905060005b8381101561051e5760008585838181106104c3576104c3612430565b90506020020160208101906104d89190612087565b6001600160a01b038116600090815260dc6020526040812055835190915083908390811061050857610508612430565b60006020918202929092010152506001016104a7565b507f8c02b2ccee964dc50649a48bd0a0446f0f9e88ecdb72d099f4ace07c39c2348084848360405161055293929190612484565b60405180910390a150505050565b60006105d1826105706008611562565b6001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa1580156105ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102bf91906124b4565b92915050565b6105df611a08565b6105eb84848484611a64565b50505050565b6105f9611a08565b6000610605600a611562565b604051636db349d160e11b81526001600160a01b038481166004830152919091169063db6693a29060240160a060405180830381865afa15801561064d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067191906124fe565b905060006106fb610682600b611562565b6040808501519051632623bd4f60e21b81526001600160a01b03918216600482015291169063988ef53c90602401602060405180830381865afa1580156106cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f191906124b4565b8360800151611af6565b905060006107096008611562565b90506000816001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa15801561074b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076f91906124b4565b60385490915061077f844361259c565b1115806107af57506001600160a01b038516600090815260376020908152604080832084845290915290205460ff165b156107cd57604051632e308a0b60e11b815260040160405180910390fd5b6001600160a01b038516600081815260376020908152604080832085845290915290819020805460ff19166001179055516000805160206128c48339815191529061081c9060049085906125c5565b60405180910390a2603954604051630bde081360e21b81526001600160a01b03841691632f78204c916108599189916000919082906004016125e3565b600060405180830381600087803b15801561087357600080fd5b505af1158015610887573d6000803e3d6000fd5b505050505050505050565b61089a611a08565b600084846040516108ac92919061260b565b60405180910390209050600083836040516108c892919061260b565b604080519182900390912060008481526004602052919091205490915060ff1680610901575060008181526004602052604090205460ff165b1561091f5760405163f27b8ec960e01b815260040160405180910390fd5b61092c8787878787611b0d565b15610a7157600061093d6008611562565b90506000816001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa15801561097f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a391906124b4565b6000858152600460205260408082208054600160ff19918216811790925587845292829020805490931617909155519091506001600160a01b038a16906000805160206128c4833981519152906109fe9060039085906125c5565b60405180910390a260025460018054604051630bde081360e21b81526001600160a01b03861693632f78204c93610a3c938f939091906004016125e3565b600060405180830381600087803b158015610a5657600080fd5b505af1158015610a6a573d6000803e3d6000fd5b5050505050505b50505050505050565b61011354600290610100900460ff16158015610a9e57506101135460ff8083169116105b610ac35760405162461bcd60e51b8152600401610aba9061261b565b60405180910390fd5b610113805461ffff191660ff831617610100179055600054610af0906008906001600160a01b0316611bb7565b606c54610b08906005906001600160a01b0316611bb7565b610b13600483611bb7565b603554610b2b90600a906001600160a01b0316611bb7565b600080546001600160a01b0319908116909155606c8054821690556035805482169055603680549091169055610113805461ff001916905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15050565b6001600160a01b038216600090815260db6020908152604080832084845290915281205460ff165b9392505050565b6001600160a01b038216600090815260a460209081526040808320848452909152812054610bc6565b6008610c01816119bc565b60003390506000816001600160a01b031663297a8fca6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c46573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c6a91906124b4565b90506000826001600160a01b0316634de2b73588886040518363ffffffff1660e01b8152600401610c9c929190612669565b600060405180830381865afa158015610cb9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ce1919081019061268d565b90506000610cef6005611562565b6001600160a01b031663ba303755898986436040518563ffffffff1660e01b8152600401610d20949392919061273a565b600060405180830381865afa158015610d3d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d65919081019061268d565b905060008767ffffffffffffffff811115610d8257610d8261241a565b604051908082528060200260200182016040528015610dab578160200160208202803683370190505b50905060005b88811015610ec65760008a8a83818110610dcd57610dcd612430565b9050602002016020810190610de29190612087565b90506000610df0828b610bcd565b90506000868481518110610e0657610e06612430565b602002602001015190506000868581518110610e2457610e24612430565b6020026020010151905060008280610e395750815b610e4e57610e4960dd5485611c5b565b610e51565b60005b6001600160a01b038616600090815260dc602052604090205460de54919250610e7b918390611c75565b6001600160a01b038616600090815260dc602052604090208190558751889088908110610eaa57610eaa612430565b6020026020010181815250508560010195505050505050610db1565b507f8c02b2ccee964dc50649a48bd0a0446f0f9e88ecdb72d099f4ace07c39c23480898983604051610efa93929190612484565b60405180910390a1505050505050505050565b610f15611a08565b610f1f8282611c92565b5050565b610f2b611a08565b610f3481611cd2565b610f1f8282611bb7565b61011354610100900460ff1615808015610f60575061011354600160ff909116105b80610f7b5750303b158015610f7b57506101135460ff166001145b610f975760405162461bcd60e51b8152600401610aba9061261b565b610113805460ff191660011790558015610fbc57610113805461ff0019166101001790555b610fc760088b611bb7565b610fd260058a611bb7565b610fdd600488611bb7565b610fe8600a89611bb7565b61100186356020880135604089013560608a0135611a64565b61101085356020870135611c92565b611024843560208601356040870135611d08565b61103d8335602085013560408601356060870135611d5d565b6110568235602084013560408501356060860135611de9565b801561109d57610113805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050505050565b60086110b4816119bc565b826001036110f357836001600160a01b03166000805160206128c48339815191526005846040516110e69291906125c5565b60405180910390a26105eb565b826002036105eb57836001600160a01b03166000805160206128c48339815191526006846040516111259291906125c5565b60405180910390a250505050565b61113b611a08565b6105eb84848484611de9565b61114f611a08565b61115a838383611d08565b505050565b611167611a08565b6105eb84848484611d5d565b600061117f6008611562565b604051635061f96960e11b81526001600160a01b0384811660048301529192509082169063a0c3f2d290602401602060405180830381865afa1580156111c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ed9190612761565b61121a576000356001600160e01b0319166008604051620f948f60ea1b8152600401610aba92919061277c565b6040516304d971ab60e01b81526001600160a01b0383811660048301523360248301528216906304d971ab90604401602060405180830381865afa158015611266573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061128a9190612761565b6112b7576000356001600160e01b0319166004604051620f948f60ea1b8152600401610aba92919061277c565b604051634b2c2fe160e11b81526001600160a01b03838116600483015260009182918416906396585fc290602401606060405180830381865afa158015611302573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132691906127aa565b92505091508161134957604051636cd31b5960e01b815260040160405180910390fd5b6000836001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa158015611389573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ad91906124b4565b6001600160a01b038616600090815260db6020908152604080832084845290915290205490915060ff16156113f557604051637674d6a960e01b815260040160405180910390fd5b6001600160a01b038516600090815260dc602052604081205460df5490919061141e90856127df565b9050808210156114415760405163462e593760e11b815260040160405180910390fd5b604051630adaf5ef60e11b81526001600160a01b038881166004830152602482018590528716906315b5ebde90604401600060405180830381600087803b15801561148b57600080fd5b505af115801561149f573d6000803e3d6000fd5b505050506001600160a01b038716600090815260dc6020526040812080548392906114cb90849061259c565b90915550506001600160a01b038716600090815260a4602090815260408083208684529091528120556001600160a01b038716600081815260db60209081526040808320878452825291829020805460ff1916600117905581518681529081018490527f7ff9f7032d565c7e8919332964b2faa33c320b53604a65d9dd1f8112e12cd39d910160405180910390a250505050505050565b60007fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb600083600d811115611599576115996125af565b60ff1681526020810191909152604001600020546001600160a01b03169050806115d8578160405163409140df60e11b8152600401610aba919061280a565b919050565b60608167ffffffffffffffff8111156115f8576115f861241a565b604051908082528060200260200182016040528015611621578160200160208202803683370190505b50905060005b81518110156116a15760dc600085858481811061164657611646612430565b905060200201602081019061165b9190612087565b6001600160a01b03166001600160a01b031681526020019081526020016000205482828151811061168e5761168e612430565b6020908102919091010152600101611627565b5092915050565b60a35443116116ca5760405163557fd09160e01b815260040160405180910390fd5b4360a3553341146116fe576000356001600160e01b0319166002604051620f948f60ea1b8152600401610aba92919061277c565b61170781611e86565b156119b95760006117186008611562565b90506000816001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa15801561175a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061177e91906124b4565b6001600160a01b038416600090815260a460209081526040808320848452909152812080546001019081905560a854929350916117bc904390611f9c565b905060a654820361186557846001600160a01b03166000805160206128c48339815191526002856040516117f19291906125c5565b60405180910390a260a754604051630bde081360e21b81526001600160a01b03861691632f78204c9161182e9189918691906000906004016125e3565b600060405180830381600087803b15801561184857600080fd5b505af115801561185c573d6000803e3d6000fd5b505050506119b4565b60a55482036119b457600061187a8685610b9e565b90508061191d57856001600160a01b03166000805160206128c48339815191526001866040516118ab9291906125c5565b60405180910390a2604051630bde081360e21b81526001600160a01b03861690632f78204c906118e6908990600090819081906004016125e3565b600060405180830381600087803b15801561190057600080fd5b505af1158015611914573d6000803e3d6000fd5b505050506119b2565b856001600160a01b03166000805160206128c48339815191526007866040516119479291906125c5565b60405180910390a260a754604051630bde081360e21b81526001600160a01b03871691632f78204c91611984918a918791906001906004016125e3565b600060405180830381600087803b15801561199e57600080fd5b505af115801561109d573d6000803e3d6000fd5b505b505050505b50565b6119c581611562565b6001600160a01b0316336001600160a01b0316146119b9576000356001600160e01b03191681336040516320e0f98d60e21b8152600401610aba93929190612818565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b03163314611a62576000356001600160e01b0319166001604051620f948f60ea1b8152600401610aba92919061277c565b565b82841180611a73575061271084115b80611a7f575061271083115b15611a9d57604051631cbe1abf60e11b815260040160405180910390fd5b606d849055606e839055606f82905560708190556040805185815260208101859052908101839052606081018290527fd24c671da2227c139fe1a5b34de15e5a67bef9b46e912916b9e0d025d51b3e3b90608001610552565b600081831015611b065781610bc6565b5090919050565b6040516000906067906001908390611b31908a908a908a908a908a90602401612878565b60408051601f198184030181529190526020810180516001600160e01b0316637fc3567760e01b1790528051909150611b68611fc6565b602083016020828483895afa611b7d57600094505b503d611b8857600093505b83611ba657604051630fc2632160e01b815260040160405180910390fd5b5115159a9950505050505050505050565b807fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb600084600d811115611bed57611bed6125af565b60ff168152602081019190915260400160002080546001600160a01b0319166001600160a01b03928316179055811682600d811115611c2e57611c2e6125af565b6040517f865d1c228a8ea13709cfe61f346f7ff67f1bbd4a18ff31ad3e7147350d317c5990600090a35050565b6000818311611c6b576000610bc6565b610bc6828461259c565b6000611c8a611c8484866128b0565b83611fb7565b949350505050565b6038829055603981905560408051838152602081018390527fbda9ec2980d7468ba6a9f363696315affca9f9770016396bdea2ac39c3e5d61a9101610b92565b806001600160a01b03163b6000036119b957604051630bfc64a360e21b81526001600160a01b0382166004820152602401610aba565b60018390556002829055600381905560408051848152602081018490529081018290527f913da102149f952dde560cef3349db8e8002e9d580c41a7551d6d45329f4306b9060600160405180910390a1505050565b60a65460a5541115611d90576040516387f6f09560e01b81526001600160e01b0319600035166004820152602401610aba565b60a584905560a683905560a782905560a88190556040805185815260208101859052908101839052606081018290527f442862e6143ad95854e7c13ff4947ec6e43bc87160e3b193e7c1abaf6e3aaa9890608001610552565b82841115611e0a5760405163112af4d160e01b815260040160405180910390fd5b612710811115611e2d5760405163382c88a360e21b815260040160405180910390fd5b60dd84905560de83905560df82905560e08190556040805185815260208101859052908101839052606081018290527fe1f9c6c73554b5fa140eead3cfd4ec3e6d4824f3ed26fb25e38376f65b95470b90608001610552565b6000336001600160a01b03831614801590611f125750611ea66008611562565b604051633292276760e11b81526001600160a01b03848116600483015291909116906365244ece90602401602060405180830381865afa158015611eee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f129190612761565b80156105d15750611f236005611562565b604051630fbeb37f60e01b81526001600160a01b0384811660048301524360248301529190911690630fbeb37f90604401602060405180830381865afa158015611f71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f959190612761565b1592915050565b600081600003611fad576000610bc6565b610bc682846128b0565b6000818310611b065781610bc6565b60405180602001604052806001906020820280368337509192915050565b60008083601f840112611ff657600080fd5b50813567ffffffffffffffff81111561200e57600080fd5b6020830191508360208260051b850101111561202957600080fd5b9250929050565b6000806020838503121561204357600080fd5b823567ffffffffffffffff81111561205a57600080fd5b61206685828601611fe4565b90969095509350505050565b6001600160a01b03811681146119b957600080fd5b60006020828403121561209957600080fd5b8135610bc681612072565b600080600080608085870312156120ba57600080fd5b5050823594602084013594506040840135936060013592509050565b60008083601f8401126120e857600080fd5b50813567ffffffffffffffff81111561210057600080fd5b60208301915083602082850101111561202957600080fd5b60008060008060006060868803121561213057600080fd5b853561213b81612072565b9450602086013567ffffffffffffffff8082111561215857600080fd5b61216489838a016120d6565b9096509450604088013591508082111561217d57600080fd5b5061218a888289016120d6565b969995985093965092949392505050565b600080604083850312156121ae57600080fd5b82356121b981612072565b946020939093013593505050565b6000806000604084860312156121dc57600080fd5b833567ffffffffffffffff8111156121f357600080fd5b6121ff86828701611fe4565b909790965060209590950135949350505050565b6000806040838503121561222657600080fd5b50508035926020909101359150565b8035600e81106115d857600080fd5b6000806040838503121561225757600080fd5b61226083612235565b9150602083013561227081612072565b809150509250929050565b80608081018310156105d157600080fd5b60008060008060008060008060006102a08a8c0312156122ab57600080fd5b89356122b681612072565b985060208a01356122c681612072565b975060408a01356122d681612072565b965060608a01356122e681612072565b95506122f58b60808c0161227b565b94506101408a018b81111561230957600080fd5b6101008b0194506101a08b018c81111561232257600080fd5b81945061232f8d8261227b565b935050506123418b6102208c0161227b565b90509295985092959850929598565b60008060006060848603121561236557600080fd5b833561237081612072565b95602085013595506040909401359392505050565b60008060006060848603121561239a57600080fd5b505081359360208301359350604090920135919050565b6000602082840312156123c357600080fd5b610bc682612235565b600081518084526020808501945080840160005b838110156123fc578151875295820195908201906001016123e0565b509495945050505050565b602081526000610bc660208301846123cc565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b8183526000602080850194508260005b858110156123fc57813561246981612072565b6001600160a01b031687529582019590820190600101612456565b604081526000612498604083018587612446565b82810360208401526124aa81856123cc565b9695505050505050565b6000602082840312156124c657600080fd5b5051919050565b604051601f8201601f1916810167ffffffffffffffff811182821017156124f6576124f661241a565b604052919050565b600060a0828403121561251057600080fd5b60405160a0810181811067ffffffffffffffff821117156125335761253361241a565b604052825161254181612072565b8152602083015161255181612072565b6020820152604083015161256481612072565b6040820152606083810151908201526080928301519281019290925250919050565b634e487b7160e01b600052601160045260246000fd5b818103818111156105d1576105d1612586565b634e487b7160e01b600052602160045260246000fd5b60408101600884106125d9576125d96125af565b9281526020015290565b6001600160a01b03949094168452602084019290925260408301521515606082015260800190565b8183823760009101908152919050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b602081526000611c8a602083018486612446565b805180151581146115d857600080fd5b600060208083850312156126a057600080fd5b825167ffffffffffffffff808211156126b857600080fd5b818501915085601f8301126126cc57600080fd5b8151818111156126de576126de61241a565b8060051b91506126ef8483016124cd565b818152918301840191848101908884111561270957600080fd5b938501935b8385101561272e5761271f8561267d565b8252938501939085019061270e565b98975050505050505050565b60608152600061274e606083018688612446565b6020830194909452506040015292915050565b60006020828403121561277357600080fd5b610bc68261267d565b6001600160e01b031983168152604081016009831061279d5761279d6125af565b8260208301529392505050565b6000806000606084860312156127bf57600080fd5b6127c88461267d565b925060208401519150604084015190509250925092565b80820281158282048414176105d1576105d1612586565b600e8110612806576128066125af565b9052565b602081016105d182846127f6565b6001600160e01b0319841681526060810161283660208301856127f6565b6001600160a01b03929092166040919091015292915050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6001600160a01b038616815260606020820181905260009061289d908301868861284f565b828103604084015261272e81858761284f565b808201808211156105d1576105d161258656fe607adba66cff84b627e3537d1c17d088a98556bccd0536a2f3590c56329023d9a164736f6c6343000811000a", "devdoc": { "errors": { "ErrCallPrecompiled()": [ @@ -1250,7 +1250,7 @@ "storageLayout": { "storage": [ { - "astId": 35464, + "astId": 39807, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "______deprecatedValidator", "offset": 0, @@ -1258,7 +1258,7 @@ "type": "t_address" }, { - "astId": 27031, + "astId": 31454, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_slashDoubleSignAmount", "offset": 0, @@ -1266,7 +1266,7 @@ "type": "t_uint256" }, { - "astId": 27034, + "astId": 31457, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_doubleSigningJailUntilBlock", "offset": 0, @@ -1274,7 +1274,7 @@ "type": "t_uint256" }, { - "astId": 27037, + "astId": 31460, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_doubleSigningOffsetLimitBlock", "offset": 0, @@ -1282,7 +1282,7 @@ "type": "t_uint256" }, { - "astId": 27042, + "astId": 31465, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_submittedEvidence", "offset": 0, @@ -1290,7 +1290,7 @@ "type": "t_mapping(t_bytes32,t_bool)" }, { - "astId": 27047, + "astId": 31470, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "______gap", "offset": 0, @@ -1298,7 +1298,7 @@ "type": "t_array(t_uint256)48_storage" }, { - "astId": 35476, + "astId": 39819, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "______deprecatedTrustedOrg", "offset": 0, @@ -1306,7 +1306,7 @@ "type": "t_address" }, { - "astId": 35480, + "astId": 39823, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "______deprecatedGovernanceAdmin", "offset": 0, @@ -1314,7 +1314,7 @@ "type": "t_address" }, { - "astId": 26849, + "astId": 31272, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_bridgeVotingSlashed", "offset": 0, @@ -1322,7 +1322,7 @@ "type": "t_mapping(t_address,t_mapping(t_uint256,t_bool))" }, { - "astId": 26852, + "astId": 31275, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_bridgeVotingThreshold", "offset": 0, @@ -1330,7 +1330,7 @@ "type": "t_uint256" }, { - "astId": 26855, + "astId": 31278, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_bridgeVotingSlashAmount", "offset": 0, @@ -1338,7 +1338,7 @@ "type": "t_uint256" }, { - "astId": 26860, + "astId": 31283, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "______gap", "offset": 0, @@ -1346,7 +1346,7 @@ "type": "t_array(t_uint256)50_storage" }, { - "astId": 35472, + "astId": 39815, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "______deprecatedMaintenance", "offset": 0, @@ -1354,7 +1354,7 @@ "type": "t_address" }, { - "astId": 26671, + "astId": 31093, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_missingVotesRatioTier1", "offset": 0, @@ -1362,7 +1362,7 @@ "type": "t_uint256" }, { - "astId": 26674, + "astId": 31096, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_missingVotesRatioTier2", "offset": 0, @@ -1370,7 +1370,7 @@ "type": "t_uint256" }, { - "astId": 26677, + "astId": 31099, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_jailDurationForMissingVotesRatioTier2", "offset": 0, @@ -1378,7 +1378,7 @@ "type": "t_uint256" }, { - "astId": 26680, + "astId": 31102, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_skipBridgeOperatorSlashingThreshold", "offset": 0, @@ -1386,7 +1386,7 @@ "type": "t_uint256" }, { - "astId": 26685, + "astId": 31107, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "______gap", "offset": 0, @@ -1394,7 +1394,7 @@ "type": "t_array(t_uint256)50_storage" }, { - "astId": 27538, + "astId": 31961, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "lastUnavailabilitySlashedBlock", "offset": 0, @@ -1402,7 +1402,7 @@ "type": "t_uint256" }, { - "astId": 27545, + "astId": 31968, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_unavailabilityIndicator", "offset": 0, @@ -1410,7 +1410,7 @@ "type": "t_mapping(t_address,t_mapping(t_uint256,t_uint256))" }, { - "astId": 27548, + "astId": 31971, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_unavailabilityTier1Threshold", "offset": 0, @@ -1418,7 +1418,7 @@ "type": "t_uint256" }, { - "astId": 27551, + "astId": 31974, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_unavailabilityTier2Threshold", "offset": 0, @@ -1426,7 +1426,7 @@ "type": "t_uint256" }, { - "astId": 27554, + "astId": 31977, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_slashAmountForUnavailabilityTier2Threshold", "offset": 0, @@ -1434,7 +1434,7 @@ "type": "t_uint256" }, { - "astId": 27557, + "astId": 31980, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_jailDurationForUnavailabilityTier2Threshold", "offset": 0, @@ -1442,7 +1442,7 @@ "type": "t_uint256" }, { - "astId": 27562, + "astId": 31985, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "______gap", "offset": 0, @@ -1450,7 +1450,7 @@ "type": "t_array(t_uint256)50_storage" }, { - "astId": 26102, + "astId": 30524, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_checkBailedOutAtPeriod", "offset": 0, @@ -1458,7 +1458,7 @@ "type": "t_mapping(t_address,t_mapping(t_uint256,t_bool))" }, { - "astId": 26107, + "astId": 30529, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_creditScore", "offset": 0, @@ -1466,7 +1466,7 @@ "type": "t_mapping(t_address,t_uint256)" }, { - "astId": 26110, + "astId": 30532, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_gainCreditScore", "offset": 0, @@ -1474,7 +1474,7 @@ "type": "t_uint256" }, { - "astId": 26113, + "astId": 30535, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_maxCreditScore", "offset": 0, @@ -1482,7 +1482,7 @@ "type": "t_uint256" }, { - "astId": 26116, + "astId": 30538, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_bailOutCostMultiplier", "offset": 0, @@ -1490,7 +1490,7 @@ "type": "t_uint256" }, { - "astId": 26119, + "astId": 30541, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "_cutOffPercentageAfterBailout", "offset": 0, @@ -1498,7 +1498,7 @@ "type": "t_uint256" }, { - "astId": 26124, + "astId": 30546, "contract": "contracts/ronin/slash-indicator/SlashIndicator.sol:SlashIndicator", "label": "______gap", "offset": 0, diff --git a/deployments/ronin-testnet/StakingLogic.json b/deployments/ronin-testnet/StakingLogic.json index c5e44e8f1..038e09b95 100644 --- a/deployments/ronin-testnet/StakingLogic.json +++ b/deployments/ronin-testnet/StakingLogic.json @@ -1,5 +1,5 @@ { - "address": "0x0eFa0aD6D72088D903f2c8296E6eD9c364006176", + "address": "0x47FF1a3E1d8A43898Dd0BDd97e63Fe1B14087DdB", "abi": [ { "inputs": [], @@ -690,11 +690,6 @@ "name": "_treasuryAddr", "type": "address" }, - { - "internalType": "address", - "name": "_bridgeOperatorAddr", - "type": "address" - }, { "internalType": "uint256", "name": "_commissionRate", @@ -1328,6 +1323,34 @@ "stateMutability": "payable", "type": "function" }, + { + "inputs": [ + { + "internalType": "address", + "name": "_candidateAdmin", + "type": "address" + }, + { + "internalType": "address", + "name": "_consensusAddr", + "type": "address" + }, + { + "internalType": "address payable", + "name": "_treasuryAddr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_commissionRate", + "type": "uint256" + } + ], + "name": "tmp_re_applyValidatorCandidate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -1382,41 +1405,41 @@ "type": "receive" } ], - "transactionHash": "0x1fb7a10773437191ffff5dbda68a56fdb492b1bb1348931eae75eaf89924e729", + "transactionHash": "0x9c95ad9583c78bef5b822aa7636bc78a2aaa9572e82e911ffe69b0949a7cbf3e", "receipt": { "to": null, "from": "0x968D0Cd7343f711216817E617d3f92a23dC91c07", - "contractAddress": "0x0eFa0aD6D72088D903f2c8296E6eD9c364006176", + "contractAddress": "0x47FF1a3E1d8A43898Dd0BDd97e63Fe1B14087DdB", "transactionIndex": 0, - "gasUsed": "3254982", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000", - "blockHash": "0xad1697fc9ac3649b2c73a7077c78f3117dd30cf111f82727c18d52fee4e67ce0", - "transactionHash": "0x1fb7a10773437191ffff5dbda68a56fdb492b1bb1348931eae75eaf89924e729", + "gasUsed": "3282482", + "logsBloom": "0x00000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000002000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000", + "blockHash": "0xe17d483cd37c371e637ff64c780d24d5fd84ff4278a44ffea57e2011571e5320", + "transactionHash": "0x9c95ad9583c78bef5b822aa7636bc78a2aaa9572e82e911ffe69b0949a7cbf3e", "logs": [ { "transactionIndex": 0, - "blockNumber": 18032263, - "transactionHash": "0x1fb7a10773437191ffff5dbda68a56fdb492b1bb1348931eae75eaf89924e729", - "address": "0x0eFa0aD6D72088D903f2c8296E6eD9c364006176", + "blockNumber": 19430066, + "transactionHash": "0x9c95ad9583c78bef5b822aa7636bc78a2aaa9572e82e911ffe69b0949a7cbf3e", + "address": "0x47FF1a3E1d8A43898Dd0BDd97e63Fe1B14087DdB", "topics": [ "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" ], "data": "0x00000000000000000000000000000000000000000000000000000000000000ff", "logIndex": 0, - "blockHash": "0xad1697fc9ac3649b2c73a7077c78f3117dd30cf111f82727c18d52fee4e67ce0" + "blockHash": "0xe17d483cd37c371e637ff64c780d24d5fd84ff4278a44ffea57e2011571e5320" } ], - "blockNumber": 18032263, - "cumulativeGasUsed": "3254982", + "blockNumber": 19430066, + "cumulativeGasUsed": "3282482", "status": 1, "byzantium": true }, "args": [], - "numDeployments": 11, - "solcInputHash": "6bc16cc8f779fe2f1f4f2733e87f867e", - "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"name\":\"ErrAdminOfAnyActivePoolForbidden\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"extraInfo\",\"type\":\"string\"}],\"name\":\"ErrCannotInitTransferRON\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrCannotTransferRON\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"}],\"name\":\"ErrContractTypeNotFound\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"}],\"name\":\"ErrDuplicated\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"poolAddr\",\"type\":\"address\"}],\"name\":\"ErrInactivePool\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"},{\"internalType\":\"uint256\",\"name\":\"currentBalance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"sendAmount\",\"type\":\"uint256\"}],\"name\":\"ErrInsufficientBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInsufficientDelegatingAmount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInsufficientStakingAmount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidArrays\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidCommissionRate\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidPoolShare\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrOnlyPoolAdminAllowed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrPoolAdminForbidden\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"}],\"name\":\"ErrRecipientRevert\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrStakingAmountLeft\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrThreeInteractionAddrsNotEqual\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"},{\"internalType\":\"enum RoleAccess\",\"name\":\"expectedRole\",\"type\":\"uint8\"}],\"name\":\"ErrUnauthorized\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrUndelegateTooEarly\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrUndelegateZeroAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"},{\"internalType\":\"enum ContractType\",\"name\":\"expectedContractType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"actual\",\"type\":\"address\"}],\"name\":\"ErrUnexpectedInternalCall\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrUnstakeTooEarly\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrUnstakeZeroAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"ErrZeroCodeContract\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrZeroValue\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"minRate\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"maxRate\",\"type\":\"uint256\"}],\"name\":\"CommissionRateRangeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"ContractUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"minSecs\",\"type\":\"uint256\"}],\"name\":\"CooldownSecsToUndelegateUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensuAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Delegated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"threshold\",\"type\":\"uint256\"}],\"name\":\"MinValidatorStakingAmountUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"validator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"name\":\"PoolApproved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"poolAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"shares\",\"type\":\"uint256\"}],\"name\":\"PoolSharesUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"validator\",\"type\":\"address[]\"}],\"name\":\"PoolsDeprecated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"poolAddrs\",\"type\":\"address[]\"}],\"name\":\"PoolsUpdateConflicted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"poolAddrs\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"rewards\",\"type\":\"uint256[]\"}],\"name\":\"PoolsUpdateFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"poolAddrs\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"aRps\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"shares\",\"type\":\"uint256[]\"}],\"name\":\"PoolsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"poolAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"RewardClaimed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensuAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Staked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"validator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"contractBalance\",\"type\":\"uint256\"}],\"name\":\"StakingAmountDeductFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"validator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"contractBalance\",\"type\":\"uint256\"}],\"name\":\"StakingAmountTransferFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensuAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Undelegated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensuAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Unstaked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"poolAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"debited\",\"type\":\"uint256\"}],\"name\":\"UserRewardUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"secs\",\"type\":\"uint256\"}],\"name\":\"WaitingSecsToRevokeUpdated\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"DEFAULT_ADDITION_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"PERIOD_DURATION\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_candidateAdmin\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address payable\",\"name\":\"_treasuryAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_bridgeOperatorAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_commissionRate\",\"type\":\"uint256\"}],\"name\":\"applyValidatorCandidate\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_consensusAddrs\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_amounts\",\"type\":\"uint256[]\"}],\"name\":\"bulkUndelegate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_consensusAddrList\",\"type\":\"address[]\"}],\"name\":\"claimRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"cooldownSecsToUndelegate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"}],\"name\":\"delegate\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_consensusAddrList\",\"type\":\"address[]\"},{\"internalType\":\"address\",\"name\":\"_consensusAddrDst\",\"type\":\"address\"}],\"name\":\"delegateRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"execDeductStakingAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_actualDeductingAmount\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_pools\",\"type\":\"address[]\"},{\"internalType\":\"uint256\",\"name\":\"_newPeriod\",\"type\":\"uint256\"}],\"name\":\"execDeprecatePools\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_consensusAddrs\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_rewards\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256\",\"name\":\"_period\",\"type\":\"uint256\"}],\"name\":\"execRecordRewards\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCommissionRateRange\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"}],\"name\":\"getContract\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"contract_\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_pools\",\"type\":\"address[]\"}],\"name\":\"getManySelfStakings\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_selfStakings\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_poolAddrs\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"_userList\",\"type\":\"address[]\"}],\"name\":\"getManyStakingAmounts\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_stakingAmounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_poolList\",\"type\":\"address[]\"}],\"name\":\"getManyStakingTotals\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_stakingAmounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolAdminAddr\",\"type\":\"address\"}],\"name\":\"getPoolAddressOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolAddr\",\"type\":\"address\"}],\"name\":\"getPoolDetail\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"_admin\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_stakingAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_stakingTotal\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"}],\"name\":\"getReward\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"_poolAddrList\",\"type\":\"address[]\"}],\"name\":\"getRewards\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_rewards\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"}],\"name\":\"getStakingAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolAddr\",\"type\":\"address\"}],\"name\":\"getStakingTotal\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"__validatorContract\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"__minValidatorStakingAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"__maxCommissionRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"__cooldownSecsToUndelegate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"__waitingSecsToRevoke\",\"type\":\"uint256\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initializeV2\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolAdminAddr\",\"type\":\"address\"}],\"name\":\"isAdminOfActivePool\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minValidatorStakingAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddrSrc\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_consensusAddrDst\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"redelegate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"}],\"name\":\"requestEmergencyExit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"}],\"name\":\"requestRenounce\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_effectiveDaysOnwards\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_commissionRate\",\"type\":\"uint256\"}],\"name\":\"requestUpdateCommissionRate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_minRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_maxRate\",\"type\":\"uint256\"}],\"name\":\"setCommissionRateRange\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setContract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_cooldownSecs\",\"type\":\"uint256\"}],\"name\":\"setCooldownSecsToUndelegate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_threshold\",\"type\":\"uint256\"}],\"name\":\"setMinValidatorStakingAmount\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_secs\",\"type\":\"uint256\"}],\"name\":\"setWaitingSecsToRevoke\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"}],\"name\":\"stake\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"undelegate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"unstake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"waitingSecsToRevoke\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"errors\":{\"ErrAdminOfAnyActivePoolForbidden(address)\":[{\"details\":\"Error of admin of any active pool cannot delegate.\"}],\"ErrCannotInitTransferRON(address,string)\":[{\"details\":\"Error of cannot transfer RON to specified target.\"}],\"ErrCannotTransferRON()\":[{\"details\":\"Error of cannot transfer RON.\"}],\"ErrContractTypeNotFound(uint8)\":[{\"details\":\"Error of invalid role.\"}],\"ErrDuplicated(bytes4)\":[{\"details\":\"Error thrown when a duplicated element is detected in an array.\",\"params\":{\"msgSig\":\"The function signature that invoke the error.\"}}],\"ErrInactivePool(address)\":[{\"details\":\"Error of querying inactive pool.\"}],\"ErrInsufficientBalance(bytes4,uint256,uint256)\":[{\"details\":\"Error of sender has insufficient balance.\"}],\"ErrInsufficientDelegatingAmount()\":[{\"details\":\"Error of undelegating insufficient amount.\"}],\"ErrInsufficientStakingAmount()\":[{\"details\":\"Error of insufficient staking amount for unstaking.\"}],\"ErrInvalidArrays()\":[{\"details\":\"Error of length of input arrays are not of the same.\"}],\"ErrInvalidCommissionRate()\":[{\"details\":\"Error of setting commission rate exceeds max allowed.\"}],\"ErrInvalidPoolShare()\":[{\"details\":\"Error of invalid pool share.\"}],\"ErrOnlyPoolAdminAllowed()\":[{\"details\":\"Error of no one is allowed to call but the pool's admin.\"}],\"ErrPoolAdminForbidden()\":[{\"details\":\"Error of pool admin is not allowed to call.\"}],\"ErrRecipientRevert(bytes4)\":[{\"details\":\"Error of recipient not accepting RON when transfer RON.\"}],\"ErrStakingAmountLeft()\":[{\"details\":\"Error of invalid staking amount left after deducted.\"}],\"ErrThreeInteractionAddrsNotEqual()\":[{\"details\":\"Error of three interaction addresses must be of the same in applying for validator candidate.\"}],\"ErrUnauthorized(bytes4,uint8)\":[{\"details\":\"Error indicating that the caller is unauthorized to perform a specific function.\",\"params\":{\"expectedRole\":\"The role required to perform the function.\",\"msgSig\":\"The function signature (bytes4) that the caller is unauthorized to perform.\"}}],\"ErrUndelegateTooEarly()\":[{\"details\":\"Error of undelegating too early.\"}],\"ErrUndelegateZeroAmount()\":[{\"details\":\"Error of undelegating zero amount.\"}],\"ErrUnexpectedInternalCall(bytes4,uint8,address)\":[{\"details\":\"Error indicating that the caller is unauthorized to perform a specific function.\",\"params\":{\"actual\":\"The actual address that called to the function.\",\"expectedContractType\":\"The contract type required to perform the function.\",\"msgSig\":\"The function signature (bytes4).\"}}],\"ErrUnstakeTooEarly()\":[{\"details\":\"Error of unstaking too early.\"}],\"ErrUnstakeZeroAmount()\":[{\"details\":\"Error of unstaking zero amount.\"}],\"ErrZeroCodeContract(address)\":[{\"details\":\"Error of set to non-contract.\"}],\"ErrZeroValue()\":[{\"details\":\"Error of receiving zero message value.\"}]},\"kind\":\"dev\",\"methods\":{\"applyValidatorCandidate(address,address,address,address,uint256)\":{\"details\":\"Proposes a candidate to become a validator. Requirements: - The method caller is able to receive RON. - The treasury is able to receive RON. - The amount is larger than or equal to the minimum validator staking amount `minValidatorStakingAmount()`. Emits the event `PoolApproved`.\",\"params\":{\"_candidateAdmin\":\"the candidate admin will be stored in the validator contract, used for calling function that affects to its candidate, e.g. scheduling maintenance.\"}},\"bulkUndelegate(address[],uint256[])\":{\"details\":\"Bulk unstakes from a list of candidates. Requirements: - The method caller is not the pool admin. Emits the events `Undelegated`.\"},\"claimRewards(address[])\":{\"details\":\"Claims the reward of method caller. Emits the `RewardClaimed` event.\"},\"cooldownSecsToUndelegate()\":{\"details\":\"Returns The cooldown time in seconds to undelegate from the last timestamp (s)he delegated.\"},\"delegate(address)\":{\"details\":\"Stakes for a validator candidate `_consensusAddr`. Requirements: - The consensus address is a validator candidate. - The method caller is not the pool admin. Emits the `Delegated` event.\"},\"delegateRewards(address[],address)\":{\"details\":\"Claims the rewards and delegates them to the consensus address. Requirements: - The method caller is not the pool admin. - The consensus address `_consensusAddrDst` is a validator candidate. Emits the `RewardClaimed` event and the `Delegated` event.\"},\"execDeductStakingAmount(address,uint256)\":{\"details\":\"Deducts from staking amount of the validator `_consensusAddr` for `_amount`. Requirements: - The method caller must be validator contract. Emits the event `Unstaked`.\"},\"execDeprecatePools(address[],uint256)\":{\"details\":\"Deprecates the pool. - Deduct self-staking amount of the pool admin to zero. - Transfer the deducted amount to the pool admin. - Deactivate the pool admin address in the mapping of active pool admins Requirements: - The method caller is validator contract. Emits the event `PoolsDeprecated` and `Unstaked` events. Emits the event `StakingAmountTransferFailed` if the contract cannot transfer RON back to the pool admin.\"},\"execRecordRewards(address[],uint256[],uint256)\":{\"details\":\"Records the amount of rewards `_rewards` for the pools `_consensusAddrs`. Requirements: - The method caller must be validator contract. Emits the event `PoolsUpdated` once the contract recorded the rewards successfully. Emits the event `PoolsUpdateFailed` once the input array lengths are not equal. Emits the event `PoolsUpdateConflicted` when there are some pools which already updated in the period. Note: This method should be called once at the period ending.\"},\"getCommissionRateRange()\":{\"details\":\"Returns the commission rate range that the candidate can set.\"},\"getContract(uint8)\":{\"details\":\"Returns the address of a contract with a specific role. Throws an error if no contract is set for the specified role.\",\"params\":{\"contractType\":\"The role of the contract to retrieve.\"},\"returns\":{\"contract_\":\"The address of the contract with the specified role.\"}},\"getManySelfStakings(address[])\":{\"details\":\"Returns the self-staking amounts of the pools.\"},\"getManyStakingAmounts(address[],address[])\":{\"details\":\"Returns the staking amounts of the users.\"},\"getManyStakingTotals(address[])\":{\"details\":\"Returns the total staking amounts of all users for the pools `_poolAddrs`.\"},\"getPoolAddressOf(address)\":{\"details\":\"Returns the consensus address corresponding to the pool admin.\"},\"getPoolDetail(address)\":{\"details\":\"Returns the staking pool detail.\"},\"getReward(address,address)\":{\"details\":\"Returns the reward amount that user claimable.\"},\"getRewards(address,address[])\":{\"details\":\"Returns the claimable reward of the user `_user`.\"},\"getStakingAmount(address,address)\":{\"details\":\"Returns the staking amount of an user.\"},\"getStakingTotal(address)\":{\"details\":\"Returns the total staking amount of all users for a pool.\"},\"initialize(address,uint256,uint256,uint256,uint256)\":{\"details\":\"Initializes the contract storage.\"},\"isAdminOfActivePool(address)\":{\"details\":\"Returns whether the `_poolAdminAddr` is currently active.\"},\"minValidatorStakingAmount()\":{\"details\":\"Returns the minimum threshold for being a validator candidate.\"},\"redelegate(address,address,uint256)\":{\"details\":\"Unstakes an amount of RON from the `_consensusAddrSrc` and stake for `_consensusAddrDst`. Requirements: - The method caller is not the pool admin. - The consensus address `_consensusAddrDst` is a validator candidate. Emits the `Undelegated` event and the `Delegated` event.\"},\"requestEmergencyExit(address)\":{\"details\":\"Renounces being a validator candidate and takes back the delegating/staking amount. Requirements: - The consensus address is a validator candidate. - The method caller is the pool admin.\"},\"requestRenounce(address)\":{\"details\":\"Renounces being a validator candidate and takes back the delegating/staking amount. Requirements: - The consensus address is a validator candidate. - The method caller is the pool admin.\"},\"requestUpdateCommissionRate(address,uint256,uint256)\":{\"details\":\"Pool admin requests update validator commission rate. The request will be forwarded to the candidate manager contract, and the value is getting updated in {ICandidateManager-execRequestUpdateCommissionRate}. Requirements: - The consensus address is a validator candidate. - The method caller is the pool admin. - The `_effectiveDaysOnwards` must be equal to or larger than the {CandidateManager-_minEffectiveDaysOnwards}. - The `_rate` must be in range of [0_00; 100_00]. Emits the event `CommissionRateUpdated`.\"},\"setCommissionRateRange(uint256,uint256)\":{\"details\":\"Sets the commission rate range that a candidate can set. Requirements: - The method caller is admin. Emits the `CommissionRateRangeUpdated` event.\"},\"setContract(uint8,address)\":{\"details\":\"Sets the address of a contract with a specific role. Emits the event {ContractUpdated}.\",\"params\":{\"addr\":\"The address of the contract to set.\",\"contractType\":\"The role of the contract to set.\"}},\"setCooldownSecsToUndelegate(uint256)\":{\"details\":\"Sets the cooldown time in seconds to undelegate from the last timestamp (s)he delegated. Requirements: - The method caller is admin. Emits the event `CooldownSecsToUndelegateUpdated`.\"},\"setMinValidatorStakingAmount(uint256)\":{\"details\":\"Sets the minimum threshold for being a validator candidate. Requirements: - The method caller is admin. Emits the `MinValidatorStakingAmountUpdated` event.\"},\"setWaitingSecsToRevoke(uint256)\":{\"details\":\"Sets the number of seconds that a candidate must wait to be revoked. Requirements: - The method caller is admin. Emits the event `WaitingSecsToRevokeUpdated`.\"},\"stake(address)\":{\"details\":\"Self-delegates to the validator candidate `_consensusAddr`. Requirements: - The consensus address is a validator candidate. - The method caller is the pool admin. - The `msg.value` is larger than 0. Emits the event `Staked`.\"},\"undelegate(address,uint256)\":{\"details\":\"Unstakes from a validator candidate `_consensusAddr` for `_amount`. Requirements: - The method caller is not the pool admin. Emits the `Undelegated` event.\"},\"unstake(address,uint256)\":{\"details\":\"Unstakes from the validator candidate `_consensusAddr` for `_amount`. Requirements: - The consensus address is a validator candidate. - The method caller is the pool admin. Emits the event `Unstaked`.\"},\"waitingSecsToRevoke()\":{\"details\":\"Returns the number of seconds that a candidate must wait for the renounce request gets affected.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/ronin/staking/Staking.sol\":\"Staking\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"none\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[\":@ronin/contracts/=./contracts/\",\":bridge-operator-governance/=contracts/extensions/bridge-operator-governance/\",\":collections/=contracts/extensions/collections/\",\":consumers/=contracts/extensions/consumers/\",\":ds-test/=lib/forge-std/lib/ds-test/src/\",\":forge-std/=lib/forge-std/src/\",\":forwarder/=contracts/extensions/forwarder/\",\":sequential-governance/=contracts/extensions/sequential-governance/\",\":slash-indicator/=contracts/interfaces/slash-indicator/\",\":staking/=contracts/interfaces/staking/\",\":validator/=contracts/interfaces/validator/\",\":version-control/=contracts/extensions/version-control/\"]},\"sources\":{\"@openzeppelin/contracts/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/Address.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\\n * initialization step. This is essential to configure modules that are added through upgrades and that require\\n * initialization.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2a21b14ff90012878752f230d3ffd5c3405e5938d06c97a7d89c0a64561d0d66\",\"license\":\"MIT\"},\"@openzeppelin/contracts/security/ReentrancyGuard.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n */\\nabstract contract ReentrancyGuard {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n constructor() {\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and making it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n}\\n\",\"keccak256\":\"0x0e9621f60b2faabe65549f7ed0f24e8853a45c1b7990d47e8160e523683f3935\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd6153ce99bcdcce22b124f755e72553295be6abcd63804cfdffceb188b8bef10\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"contracts/extensions/RONTransferHelper.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nabstract contract RONTransferHelper {\\n /// @dev Error of sender has insufficient balance.\\n error ErrInsufficientBalance(bytes4 msgSig, uint256 currentBalance, uint256 sendAmount);\\n /// @dev Error of recipient not accepting RON when transfer RON.\\n error ErrRecipientRevert(bytes4 msgSig);\\n\\n /**\\n * @dev See `_sendRON`.\\n * Reverts if the recipient does not receive RON.\\n */\\n function _transferRON(address payable _recipient, uint256 _amount) internal {\\n if (!_sendRON(_recipient, _amount)) revert ErrRecipientRevert(msg.sig);\\n }\\n\\n /**\\n * @dev Send `_amount` RON to the address `_recipient`.\\n * Returns whether the recipient receives RON or not.\\n * Reverts once the contract balance is insufficient.\\n *\\n * Note: consider using `ReentrancyGuard` before calling this function.\\n *\\n */\\n function _sendRON(address payable _recipient, uint256 _amount) internal returns (bool _success) {\\n if (address(this).balance < _amount) revert ErrInsufficientBalance(msg.sig, address(this).balance, _amount);\\n return _unsafeSendRON(_recipient, _amount);\\n }\\n\\n /**\\n * @dev Unsafe send `_amount` RON to the address `_recipient`. If the sender's balance is insufficient,\\n * the call does not revert.\\n *\\n * Note:\\n * - Does not assert whether the balance of sender is sufficient.\\n * - Does not assert whether the recipient accepts RON.\\n * - Consider using `ReentrancyGuard` before calling this function.\\n *\\n */\\n function _unsafeSendRON(address payable _recipient, uint256 _amount) internal returns (bool _success) {\\n (_success, ) = _recipient.call{ value: _amount }(\\\"\\\");\\n }\\n\\n /**\\n * @dev Same purpose with {_unsafeSendRON(address,uin256)} but containing gas limit stipend forwarded in the call.\\n */\\n function _unsafeSendRON(address payable _recipient, uint256 _amount, uint256 _gas) internal returns (bool _success) {\\n (_success, ) = _recipient.call{ value: _amount, gas: _gas }(\\\"\\\");\\n }\\n}\\n\",\"keccak256\":\"0xf5cc672e96cd11640db34e1be785d5865c1d79abdbcf55df0926b0f6244db906\",\"license\":\"MIT\"},\"contracts/extensions/collections/HasContracts.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { HasProxyAdmin } from \\\"./HasProxyAdmin.sol\\\";\\nimport \\\"../../interfaces/collections/IHasContracts.sol\\\";\\nimport { ErrUnexpectedInternalCall } from \\\"../../utils/CommonErrors.sol\\\";\\n\\n/**\\n * @title HasContracts\\n * @dev A contract that provides functionality to manage multiple contracts with different roles.\\n */\\nabstract contract HasContracts is HasProxyAdmin, IHasContracts {\\n /// @dev value is equal to keccak256(\\\"@ronin.dpos.collections.HasContracts.slot\\\") - 1\\n bytes32 private constant _STORAGE_SLOT = 0xdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb;\\n\\n /**\\n * @dev Modifier to restrict access to functions only to contracts with a specific role.\\n * @param contractType The contract type that allowed to call\\n */\\n modifier onlyContract(ContractType contractType) virtual {\\n _requireContract(contractType);\\n _;\\n }\\n\\n /**\\n * @inheritdoc IHasContracts\\n */\\n function setContract(ContractType contractType, address addr) external virtual onlyAdmin {\\n _requireHasCode(addr);\\n _setContract(contractType, addr);\\n }\\n\\n /**\\n * @inheritdoc IHasContracts\\n */\\n function getContract(ContractType contractType) public view returns (address contract_) {\\n contract_ = _getContractMap()[uint8(contractType)];\\n if (contract_ == address(0)) revert ErrContractTypeNotFound(contractType);\\n }\\n\\n /**\\n * @dev Internal function to set the address of a contract with a specific role.\\n * @param contractType The contract type of the contract to set.\\n * @param addr The address of the contract to set.\\n */\\n function _setContract(ContractType contractType, address addr) internal virtual {\\n _getContractMap()[uint8(contractType)] = addr;\\n emit ContractUpdated(contractType, addr);\\n }\\n\\n /**\\n * @dev Internal function to check if a contract address has code.\\n * @param addr The address of the contract to check.\\n * @dev Throws an error if the contract address has no code.\\n */\\n function _requireHasCode(address addr) internal view {\\n if (addr.code.length == 0) revert ErrZeroCodeContract(addr);\\n }\\n\\n /**\\n * @dev Internal function to access the mapping of contract addresses with roles.\\n * @return contracts_ The mapping of contract addresses with roles.\\n */\\n function _getContractMap() private pure returns (mapping(uint8 => address) storage contracts_) {\\n assembly {\\n contracts_.slot := _STORAGE_SLOT\\n }\\n }\\n\\n /**\\n * @dev Internal function to check if the calling contract has a specific role.\\n * @param contractType The contract type that the calling contract must have.\\n * @dev Throws an error if the calling contract does not have the specified role.\\n */\\n function _requireContract(ContractType contractType) private view {\\n if (msg.sender != getContract(contractType)) {\\n revert ErrUnexpectedInternalCall(msg.sig, contractType, msg.sender);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0d5cda6bbab5672cc7983efd0cf1f9a4e4fb1a7a2c1cfb50d38aedd052230f91\",\"license\":\"MIT\"},\"contracts/extensions/collections/HasProxyAdmin.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/StorageSlot.sol\\\";\\nimport \\\"../../utils/CommonErrors.sol\\\";\\n\\nabstract contract HasProxyAdmin {\\n // bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n modifier onlyAdmin() {\\n _requireAdmin();\\n _;\\n }\\n\\n /**\\n * @dev Returns proxy admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n function _requireAdmin() internal view {\\n if (msg.sender != _getAdmin()) revert ErrUnauthorized(msg.sig, RoleAccess.ADMIN);\\n }\\n}\\n\",\"keccak256\":\"0x06e5962713a77abf6d5ba646e1cc1cfb6f9c50e7d52520dd82a10bf309534187\",\"license\":\"MIT\"},\"contracts/extensions/consumers/GlobalConfigConsumer.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nabstract contract GlobalConfigConsumer {\\n /// @dev The addition amount of gas sending along in external calls. Total gas stipend is added with default 2300 gas.\\n uint256 public constant DEFAULT_ADDITION_GAS = 1200;\\n /// @dev The length of a period in second.\\n uint256 public constant PERIOD_DURATION = 1 days;\\n}\\n\",\"keccak256\":\"0x96d6b1ea4c8e126a8c2468683e7513d195f8e05456d85dd8f259ab049347b527\",\"license\":\"MIT\"},\"contracts/extensions/consumers/PercentageConsumer.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nabstract contract PercentageConsumer {\\n uint256 internal constant _MAX_PERCENTAGE = 100_00;\\n}\\n\",\"keccak256\":\"0x5dc54a24348c5d614de1b4805dddeab4dda72f9f0636b27bf0ed295fee017dcf\",\"license\":\"MIT\"},\"contracts/interfaces/collections/IHasContracts.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport { ContractType } from \\\"../../utils/ContractType.sol\\\";\\n\\ninterface IHasContracts {\\n /// @dev Error of invalid role.\\n error ErrContractTypeNotFound(ContractType contractType);\\n /// @dev Error of set to non-contract.\\n error ErrZeroCodeContract(address addr);\\n\\n /// @dev Emitted when a contract is updated.\\n event ContractUpdated(ContractType indexed contractType, address indexed addr);\\n\\n /**\\n * @dev Returns the address of a contract with a specific role.\\n * Throws an error if no contract is set for the specified role.\\n *\\n * @param contractType The role of the contract to retrieve.\\n * @return contract_ The address of the contract with the specified role.\\n */\\n function getContract(ContractType contractType) external view returns (address contract_);\\n\\n /**\\n * @dev Sets the address of a contract with a specific role.\\n * Emits the event {ContractUpdated}.\\n * @param contractType The role of the contract to set.\\n * @param addr The address of the contract to set.\\n */\\n function setContract(ContractType contractType, address addr) external;\\n}\\n\",\"keccak256\":\"0x5947f7f706685ce9a692da732cc0f296fcf88d38a625708354180133b3451089\",\"license\":\"MIT\"},\"contracts/interfaces/consumers/PeriodWrapperConsumer.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\ninterface PeriodWrapperConsumer {\\n struct PeriodWrapper {\\n // Inner value.\\n uint256 inner;\\n // Last period number that the info updated.\\n uint256 lastPeriod;\\n }\\n}\\n\",\"keccak256\":\"0xb6777e3c364306eb8d5355583c1aca44de9d351cb40ddf1cea832206d4aad272\",\"license\":\"MIT\"},\"contracts/interfaces/staking/IBaseStaking.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface IBaseStaking {\\n struct PoolDetail {\\n // Address of the pool i.e. consensus address of the validator\\n address addr;\\n // Pool admin address\\n address admin;\\n // Self-staking amount\\n uint256 stakingAmount;\\n // Total number of RON staking for the pool\\n uint256 stakingTotal;\\n // Mapping from delegator => delegating amount\\n mapping(address => uint256) delegatingAmount;\\n // Mapping from delegator => the last timestamp that delegator staked\\n mapping(address => uint256) lastDelegatingTimestamp;\\n }\\n\\n /// @dev Emitted when the minium number of seconds to undelegate is updated.\\n event CooldownSecsToUndelegateUpdated(uint256 minSecs);\\n /// @dev Emitted when the number of seconds that a candidate must wait to be revoked.\\n event WaitingSecsToRevokeUpdated(uint256 secs);\\n\\n /// @dev Error of cannot transfer RON.\\n error ErrCannotTransferRON();\\n /// @dev Error of receiving zero message value.\\n error ErrZeroValue();\\n /// @dev Error of pool admin is not allowed to call.\\n error ErrPoolAdminForbidden();\\n /// @dev Error of no one is allowed to call but the pool's admin.\\n error ErrOnlyPoolAdminAllowed();\\n /// @dev Error of admin of any active pool cannot delegate.\\n error ErrAdminOfAnyActivePoolForbidden(address admin);\\n /// @dev Error of querying inactive pool.\\n error ErrInactivePool(address poolAddr);\\n /// @dev Error of length of input arrays are not of the same.\\n error ErrInvalidArrays();\\n\\n /**\\n * @dev Returns whether the `_poolAdminAddr` is currently active.\\n */\\n function isAdminOfActivePool(address _poolAdminAddr) external view returns (bool);\\n\\n /**\\n * @dev Returns the consensus address corresponding to the pool admin.\\n */\\n function getPoolAddressOf(address _poolAdminAddr) external view returns (address);\\n\\n /**\\n * @dev Returns the staking pool detail.\\n */\\n function getPoolDetail(address) external view returns (address _admin, uint256 _stakingAmount, uint256 _stakingTotal);\\n\\n /**\\n * @dev Returns the self-staking amounts of the pools.\\n */\\n function getManySelfStakings(address[] calldata) external view returns (uint256[] memory);\\n\\n /**\\n * @dev Returns The cooldown time in seconds to undelegate from the last timestamp (s)he delegated.\\n */\\n function cooldownSecsToUndelegate() external view returns (uint256);\\n\\n /**\\n * @dev Returns the number of seconds that a candidate must wait for the renounce request gets affected.\\n */\\n function waitingSecsToRevoke() external view returns (uint256);\\n\\n /**\\n * @dev Sets the cooldown time in seconds to undelegate from the last timestamp (s)he delegated.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `CooldownSecsToUndelegateUpdated`.\\n *\\n */\\n function setCooldownSecsToUndelegate(uint256 _cooldownSecs) external;\\n\\n /**\\n * @dev Sets the number of seconds that a candidate must wait to be revoked.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `WaitingSecsToRevokeUpdated`.\\n *\\n */\\n function setWaitingSecsToRevoke(uint256 _secs) external;\\n}\\n\",\"keccak256\":\"0x90517268a0e31147d97772c9ae518caa5eb8c03efe3b369e3c6d5166422f5962\",\"license\":\"MIT\"},\"contracts/interfaces/staking/ICandidateStaking.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IRewardPool.sol\\\";\\n\\ninterface ICandidateStaking is IRewardPool {\\n /// @dev Emitted when the minimum staking amount for being a validator is updated.\\n event MinValidatorStakingAmountUpdated(uint256 threshold);\\n /// @dev Emitted when the commission rate range is updated.\\n event CommissionRateRangeUpdated(uint256 minRate, uint256 maxRate);\\n\\n /// @dev Emitted when the pool admin staked for themself.\\n event Staked(address indexed consensuAddr, uint256 amount);\\n /// @dev Emitted when the pool admin unstaked the amount of RON from themself.\\n event Unstaked(address indexed consensuAddr, uint256 amount);\\n\\n /// @dev Emitted when the validator pool is approved.\\n event PoolApproved(address indexed validator, address indexed admin);\\n /// @dev Emitted when the validator pool is deprecated.\\n event PoolsDeprecated(address[] validator);\\n /// @dev Emitted when the staking amount transfer failed.\\n event StakingAmountTransferFailed(\\n address indexed validator,\\n address indexed admin,\\n uint256 amount,\\n uint256 contractBalance\\n );\\n /// @dev Emitted when the staking amount deducted failed, e.g. when the validator gets slashed.\\n event StakingAmountDeductFailed(\\n address indexed validator,\\n address indexed recipient,\\n uint256 amount,\\n uint256 contractBalance\\n );\\n\\n /// @dev Error of cannot transfer RON to specified target.\\n error ErrCannotInitTransferRON(address addr, string extraInfo);\\n /// @dev Error of three interaction addresses must be of the same in applying for validator candidate.\\n error ErrThreeInteractionAddrsNotEqual();\\n /// @dev Error of unstaking zero amount.\\n error ErrUnstakeZeroAmount();\\n /// @dev Error of invalid staking amount left after deducted.\\n error ErrStakingAmountLeft();\\n /// @dev Error of insufficient staking amount for unstaking.\\n error ErrInsufficientStakingAmount();\\n /// @dev Error of unstaking too early.\\n error ErrUnstakeTooEarly();\\n /// @dev Error of setting commission rate exceeds max allowed.\\n error ErrInvalidCommissionRate();\\n\\n /**\\n * @dev Returns the minimum threshold for being a validator candidate.\\n */\\n function minValidatorStakingAmount() external view returns (uint256);\\n\\n /**\\n * @dev Returns the commission rate range that the candidate can set.\\n */\\n function getCommissionRateRange() external view returns (uint256 _minRange, uint256 _maxRange);\\n\\n /**\\n * @dev Sets the minimum threshold for being a validator candidate.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the `MinValidatorStakingAmountUpdated` event.\\n *\\n */\\n function setMinValidatorStakingAmount(uint256) external;\\n\\n /**\\n * @dev Sets the commission rate range that a candidate can set.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the `CommissionRateRangeUpdated` event.\\n *\\n */\\n function setCommissionRateRange(uint256 _minRate, uint256 _maxRate) external;\\n\\n /**\\n * @dev Proposes a candidate to become a validator.\\n *\\n * Requirements:\\n * - The method caller is able to receive RON.\\n * - The treasury is able to receive RON.\\n * - The amount is larger than or equal to the minimum validator staking amount `minValidatorStakingAmount()`.\\n *\\n * Emits the event `PoolApproved`.\\n *\\n * @param _candidateAdmin the candidate admin will be stored in the validator contract, used for calling function that affects\\n * to its candidate, e.g. scheduling maintenance.\\n *\\n */\\n function applyValidatorCandidate(\\n address _candidateAdmin,\\n address _consensusAddr,\\n address payable _treasuryAddr,\\n address _bridgeOperatorAddr,\\n uint256 _commissionRate\\n ) external payable;\\n\\n /**\\n * @dev Deprecates the pool.\\n * - Deduct self-staking amount of the pool admin to zero.\\n * - Transfer the deducted amount to the pool admin.\\n * - Deactivate the pool admin address in the mapping of active pool admins\\n *\\n * Requirements:\\n * - The method caller is validator contract.\\n *\\n * Emits the event `PoolsDeprecated` and `Unstaked` events.\\n * Emits the event `StakingAmountTransferFailed` if the contract cannot transfer RON back to the pool admin.\\n *\\n */\\n function execDeprecatePools(address[] calldata _pools, uint256 _period) external;\\n\\n /**\\n * @dev Self-delegates to the validator candidate `_consensusAddr`.\\n *\\n * Requirements:\\n * - The consensus address is a validator candidate.\\n * - The method caller is the pool admin.\\n * - The `msg.value` is larger than 0.\\n *\\n * Emits the event `Staked`.\\n *\\n */\\n function stake(address _consensusAddr) external payable;\\n\\n /**\\n * @dev Unstakes from the validator candidate `_consensusAddr` for `_amount`.\\n *\\n * Requirements:\\n * - The consensus address is a validator candidate.\\n * - The method caller is the pool admin.\\n *\\n * Emits the event `Unstaked`.\\n *\\n */\\n function unstake(address _consensusAddr, uint256 _amount) external;\\n\\n /**\\n * @dev Pool admin requests update validator commission rate. The request will be forwarded to the candidate manager\\n * contract, and the value is getting updated in {ICandidateManager-execRequestUpdateCommissionRate}.\\n *\\n * Requirements:\\n * - The consensus address is a validator candidate.\\n * - The method caller is the pool admin.\\n * - The `_effectiveDaysOnwards` must be equal to or larger than the {CandidateManager-_minEffectiveDaysOnwards}.\\n * - The `_rate` must be in range of [0_00; 100_00].\\n *\\n * Emits the event `CommissionRateUpdated`.\\n *\\n */\\n function requestUpdateCommissionRate(\\n address _consensusAddr,\\n uint256 _effectiveDaysOnwards,\\n uint256 _commissionRate\\n ) external;\\n\\n /**\\n * @dev Renounces being a validator candidate and takes back the delegating/staking amount.\\n *\\n * Requirements:\\n * - The consensus address is a validator candidate.\\n * - The method caller is the pool admin.\\n *\\n */\\n function requestRenounce(address _consensusAddr) external;\\n\\n /**\\n * @dev Renounces being a validator candidate and takes back the delegating/staking amount.\\n *\\n * Requirements:\\n * - The consensus address is a validator candidate.\\n * - The method caller is the pool admin.\\n *\\n */\\n function requestEmergencyExit(address _consensusAddr) external;\\n}\\n\",\"keccak256\":\"0x8932608d94be6ab8c53ee9770f8702774bf38aa734d8d16902f2bb18c1749b81\",\"license\":\"MIT\"},\"contracts/interfaces/staking/IDelegatorStaking.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IRewardPool.sol\\\";\\n\\ninterface IDelegatorStaking is IRewardPool {\\n /// @dev Emitted when the delegator staked for a validator candidate.\\n event Delegated(address indexed delegator, address indexed consensuAddr, uint256 amount);\\n /// @dev Emitted when the delegator unstaked from a validator candidate.\\n event Undelegated(address indexed delegator, address indexed consensuAddr, uint256 amount);\\n\\n /// @dev Error of undelegating zero amount.\\n error ErrUndelegateZeroAmount();\\n /// @dev Error of undelegating insufficient amount.\\n error ErrInsufficientDelegatingAmount();\\n /// @dev Error of undelegating too early.\\n error ErrUndelegateTooEarly();\\n\\n /**\\n * @dev Stakes for a validator candidate `_consensusAddr`.\\n *\\n * Requirements:\\n * - The consensus address is a validator candidate.\\n * - The method caller is not the pool admin.\\n *\\n * Emits the `Delegated` event.\\n *\\n */\\n function delegate(address _consensusAddr) external payable;\\n\\n /**\\n * @dev Unstakes from a validator candidate `_consensusAddr` for `_amount`.\\n *\\n * Requirements:\\n * - The method caller is not the pool admin.\\n *\\n * Emits the `Undelegated` event.\\n *\\n */\\n function undelegate(address _consensusAddr, uint256 _amount) external;\\n\\n /**\\n * @dev Bulk unstakes from a list of candidates.\\n *\\n * Requirements:\\n * - The method caller is not the pool admin.\\n *\\n * Emits the events `Undelegated`.\\n *\\n */\\n function bulkUndelegate(address[] calldata _consensusAddrs, uint256[] calldata _amounts) external;\\n\\n /**\\n * @dev Unstakes an amount of RON from the `_consensusAddrSrc` and stake for `_consensusAddrDst`.\\n *\\n * Requirements:\\n * - The method caller is not the pool admin.\\n * - The consensus address `_consensusAddrDst` is a validator candidate.\\n *\\n * Emits the `Undelegated` event and the `Delegated` event.\\n *\\n */\\n function redelegate(address _consensusAddrSrc, address _consensusAddrDst, uint256 _amount) external;\\n\\n /**\\n * @dev Returns the claimable reward of the user `_user`.\\n */\\n function getRewards(\\n address _user,\\n address[] calldata _poolAddrList\\n ) external view returns (uint256[] memory _rewards);\\n\\n /**\\n * @dev Claims the reward of method caller.\\n *\\n * Emits the `RewardClaimed` event.\\n *\\n */\\n function claimRewards(address[] calldata _consensusAddrList) external returns (uint256 _amount);\\n\\n /**\\n * @dev Claims the rewards and delegates them to the consensus address.\\n *\\n * Requirements:\\n * - The method caller is not the pool admin.\\n * - The consensus address `_consensusAddrDst` is a validator candidate.\\n *\\n * Emits the `RewardClaimed` event and the `Delegated` event.\\n *\\n */\\n function delegateRewards(\\n address[] calldata _consensusAddrList,\\n address _consensusAddrDst\\n ) external returns (uint256 _amount);\\n}\\n\",\"keccak256\":\"0x6dd71bf0c17a65da0dee49b98e4b038c1dd0e74f5473d03570421ceebd5b7084\",\"license\":\"MIT\"},\"contracts/interfaces/staking/IRewardPool.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"../../interfaces/consumers/PeriodWrapperConsumer.sol\\\";\\n\\ninterface IRewardPool is PeriodWrapperConsumer {\\n struct UserRewardFields {\\n // Recorded reward amount.\\n uint256 debited;\\n // The last accumulated of the amount rewards per share (one unit staking) that the info updated.\\n uint256 aRps;\\n // Lowest staking amount in the period.\\n uint256 lowestAmount;\\n // Last period number that the info updated.\\n uint256 lastPeriod;\\n }\\n\\n struct PoolFields {\\n // Accumulated of the amount rewards per share (one unit staking).\\n uint256 aRps;\\n // The staking total to share reward of the current period.\\n PeriodWrapper shares;\\n }\\n\\n /// @dev Emitted when the fields to calculate pending reward for the user is updated.\\n event UserRewardUpdated(address indexed poolAddr, address indexed user, uint256 debited);\\n /// @dev Emitted when the user claimed their reward\\n event RewardClaimed(address indexed poolAddr, address indexed user, uint256 amount);\\n\\n /// @dev Emitted when the pool shares are updated\\n event PoolSharesUpdated(uint256 indexed period, address indexed poolAddr, uint256 shares);\\n /// @dev Emitted when the pools are updated\\n event PoolsUpdated(uint256 indexed period, address[] poolAddrs, uint256[] aRps, uint256[] shares);\\n /// @dev Emitted when the contract fails when updating the pools\\n event PoolsUpdateFailed(uint256 indexed period, address[] poolAddrs, uint256[] rewards);\\n /// @dev Emitted when the contract fails when updating the pools that already set\\n event PoolsUpdateConflicted(uint256 indexed period, address[] poolAddrs);\\n\\n /// @dev Error of invalid pool share.\\n error ErrInvalidPoolShare();\\n\\n /**\\n * @dev Returns the reward amount that user claimable.\\n */\\n function getReward(address _poolAddr, address _user) external view returns (uint256);\\n\\n /**\\n * @dev Returns the staking amount of an user.\\n */\\n function getStakingAmount(address _poolAddr, address _user) external view returns (uint256);\\n\\n /**\\n * @dev Returns the staking amounts of the users.\\n */\\n function getManyStakingAmounts(\\n address[] calldata _poolAddrs,\\n address[] calldata _userList\\n ) external view returns (uint256[] memory);\\n\\n /**\\n * @dev Returns the total staking amount of all users for a pool.\\n */\\n function getStakingTotal(address _poolAddr) external view returns (uint256);\\n\\n /**\\n * @dev Returns the total staking amounts of all users for the pools `_poolAddrs`.\\n */\\n function getManyStakingTotals(address[] calldata _poolAddrs) external view returns (uint256[] memory);\\n}\\n\",\"keccak256\":\"0x52349fecb897b3b8288d8732923551382822c0c5fb8db9c6b094d080a16a2129\",\"license\":\"MIT\"},\"contracts/interfaces/staking/IStaking.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IBaseStaking.sol\\\";\\nimport \\\"./ICandidateStaking.sol\\\";\\nimport \\\"./IDelegatorStaking.sol\\\";\\n\\ninterface IStaking is IRewardPool, IBaseStaking, ICandidateStaking, IDelegatorStaking {\\n /**\\n * @dev Records the amount of rewards `_rewards` for the pools `_consensusAddrs`.\\n *\\n * Requirements:\\n * - The method caller must be validator contract.\\n *\\n * Emits the event `PoolsUpdated` once the contract recorded the rewards successfully.\\n * Emits the event `PoolsUpdateFailed` once the input array lengths are not equal.\\n * Emits the event `PoolsUpdateConflicted` when there are some pools which already updated in the period.\\n *\\n * Note: This method should be called once at the period ending.\\n *\\n */\\n function execRecordRewards(\\n address[] calldata _consensusAddrs,\\n uint256[] calldata _rewards,\\n uint256 _period\\n ) external payable;\\n\\n /**\\n * @dev Deducts from staking amount of the validator `_consensusAddr` for `_amount`.\\n *\\n * Requirements:\\n * - The method caller must be validator contract.\\n *\\n * Emits the event `Unstaked`.\\n *\\n */\\n function execDeductStakingAmount(\\n address _consensusAddr,\\n uint256 _amount\\n ) external returns (uint256 _actualDeductingAmount);\\n}\\n\",\"keccak256\":\"0xd302d4a78203e277fb95a89de7ae32a3102129d3fbd64fc75f92d18be0443408\",\"license\":\"MIT\"},\"contracts/interfaces/validator/ICandidateManager.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface ICandidateManager {\\n struct ValidatorCandidate {\\n // Admin of the candidate\\n address admin;\\n // Address of the validator that produces block, e.g. block.coinbase. This is so-called validator address.\\n address consensusAddr;\\n // Address that receives mining reward of the validator\\n address payable treasuryAddr;\\n // Address of the bridge operator corresponding to the candidate\\n address bridgeOperatorAddr;\\n // The percentage of reward that validators can be received, the rest goes to the delegators.\\n // Values in range [0; 100_00] stands for 0-100%\\n uint256 commissionRate;\\n // The timestamp that scheduled to revoke the candidate (no schedule=0)\\n uint256 revokingTimestamp;\\n // The deadline that the candidate must top up staking amount to keep it larger than or equal to the threshold (no deadline=0)\\n uint256 topupDeadline;\\n }\\n\\n struct CommissionSchedule {\\n // The timestamp that the commission schedule gets affected (no schedule=0).\\n uint256 effectiveTimestamp;\\n // The new commission rate. Value is in range [0; 100_00], stands for 0-100%\\n uint256 commissionRate;\\n }\\n\\n /// @dev Emitted when the maximum number of validator candidates is updated.\\n event MaxValidatorCandidateUpdated(uint256 threshold);\\n /// @dev Emitted when the min offset to the effective date of commission rate change is updated.\\n event MinEffectiveDaysOnwardsUpdated(uint256 numOfDays);\\n /// @dev Emitted when the validator candidate is granted.\\n event CandidateGranted(\\n address indexed consensusAddr,\\n address indexed treasuryAddr,\\n address indexed admin,\\n address bridgeOperator\\n );\\n /// @dev Emitted when the revoking timestamp of a candidate is updated.\\n event CandidateRevokingTimestampUpdated(address indexed consensusAddr, uint256 revokingTimestamp);\\n /// @dev Emitted when the topup deadline of a candidate is updated.\\n event CandidateTopupDeadlineUpdated(address indexed consensusAddr, uint256 topupDeadline);\\n /// @dev Emitted when the validator candidate is revoked.\\n event CandidatesRevoked(address[] consensusAddrs);\\n\\n /// @dev Emitted when a schedule for updating commission rate is set.\\n event CommissionRateUpdateScheduled(address indexed consensusAddr, uint256 effectiveTimestamp, uint256 rate);\\n /// @dev Emitted when the commission rate of a validator is updated.\\n event CommissionRateUpdated(address indexed consensusAddr, uint256 rate);\\n\\n /// @dev Error of exceeding maximum number of candidates.\\n error ErrExceedsMaxNumberOfCandidate();\\n /// @dev Error of querying for already existent candidate.\\n error ErrExistentCandidate();\\n /// @dev Error of querying for non-existent candidate.\\n error ErrNonExistentCandidate();\\n /// @dev Error of candidate admin already exists.\\n error ErrExistentCandidateAdmin(address _candidateAdminAddr);\\n /// @dev Error of treasury already exists.\\n error ErrExistentTreasury(address _treasuryAddr);\\n /// @dev Error of bridge operator already exists.\\n error ErrExistentBridgeOperator(address _bridgeOperatorAddr);\\n /// @dev Error of invalid commission rate.\\n error ErrInvalidCommissionRate();\\n /// @dev Error of invalid effective days onwards.\\n error ErrInvalidEffectiveDaysOnwards();\\n /// @dev Error of invalid min effective days onwards.\\n error ErrInvalidMinEffectiveDaysOnwards();\\n /// @dev Error of already requested revoking candidate before.\\n error ErrAlreadyRequestedRevokingCandidate();\\n /// @dev Error of commission change schedule exists.\\n error ErrAlreadyRequestedUpdatingCommissionRate();\\n /// @dev Error of trusted org cannot renounce.\\n error ErrTrustedOrgCannotRenounce();\\n\\n /**\\n * @dev Returns the maximum number of validator candidate.\\n */\\n function maxValidatorCandidate() external view returns (uint256);\\n\\n /**\\n * @dev Returns the minimum number of days to the effective date of commission rate change.\\n */\\n function minEffectiveDaysOnwards() external view returns (uint256);\\n\\n /**\\n * @dev Sets the maximum number of validator candidate.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the `MaxValidatorCandidateUpdated` event.\\n *\\n */\\n function setMaxValidatorCandidate(uint256) external;\\n\\n /**\\n * @dev Sets the minimum number of days to the effective date of commision rate change.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the `MinEffectiveDaysOnwardsUpdated` event.\\n *\\n */\\n function setMinEffectiveDaysOnwards(uint256 _numOfDays) external;\\n\\n /**\\n * @dev Grants a validator candidate.\\n *\\n * Requirements:\\n * - The method caller is staking contract.\\n *\\n * Emits the event `CandidateGranted`.\\n *\\n */\\n function execApplyValidatorCandidate(\\n address _admin,\\n address _consensusAddr,\\n address payable _treasuryAddr,\\n address _bridgeOperatorAddr,\\n uint256 _commissionRate\\n ) external;\\n\\n /**\\n * @dev Requests to revoke a validator candidate in next `_secsLeft` seconds.\\n *\\n * Requirements:\\n * - The method caller is staking contract.\\n *\\n * Emits the event `CandidateRevokingTimestampUpdated`.\\n *\\n */\\n function execRequestRenounceCandidate(address, uint256 _secsLeft) external;\\n\\n /**\\n * @dev Fallback function of `CandidateStaking-requestUpdateCommissionRate`.\\n *\\n * Requirements:\\n * - The method caller is the staking contract.\\n * - The `_effectiveTimestamp` must be the beginning of a UTC day, and at least from 7 days onwards\\n * - The `_rate` must be in range of [0_00; 100_00].\\n *\\n * Emits the event `CommissionRateUpdateScheduled`.\\n *\\n */\\n function execRequestUpdateCommissionRate(address _consensusAddr, uint256 _effectiveTimestamp, uint256 _rate) external;\\n\\n /**\\n * @dev Returns whether the address is a validator (candidate).\\n */\\n function isValidatorCandidate(address _addr) external view returns (bool);\\n\\n /**\\n * @dev Returns the validator candidate.\\n */\\n function getValidatorCandidates() external view returns (address[] memory);\\n\\n /**\\n * @dev Returns all candidate info.\\n */\\n function getCandidateInfos() external view returns (ValidatorCandidate[] memory);\\n\\n /**\\n * @dev Returns the info of a candidate.\\n */\\n function getCandidateInfo(address _candidate) external view returns (ValidatorCandidate memory);\\n\\n /**\\n * @dev Returns whether the address is the candidate admin.\\n */\\n function isCandidateAdmin(address _candidate, address _admin) external view returns (bool);\\n\\n /**\\n * @dev Returns the schedule of changing commission rate of a candidate address.\\n */\\n function getCommissionChangeSchedule(address _candidate) external view returns (CommissionSchedule memory);\\n}\\n\",\"keccak256\":\"0x01bb0823588c4e6df855ec9962d3bbc10e179f1668d006946005a0af3e73114e\",\"license\":\"MIT\"},\"contracts/interfaces/validator/ICoinbaseExecution.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./ISlashingExecution.sol\\\";\\n\\ninterface ICoinbaseExecution is ISlashingExecution {\\n enum BlockRewardDeprecatedType {\\n UNKNOWN,\\n UNAVAILABILITY,\\n AFTER_BAILOUT\\n }\\n\\n /// @dev Emitted when the validator set is updated\\n event ValidatorSetUpdated(uint256 indexed period, address[] consensusAddrs);\\n /// @dev Emitted when the bridge operator set is updated, to mirror the in-jail and maintaining status of the validator.\\n event BlockProducerSetUpdated(uint256 indexed period, uint256 indexed epoch, address[] consensusAddrs);\\n /// @dev Emitted when the bridge operator set is updated.\\n event BridgeOperatorSetUpdated(uint256 indexed period, uint256 indexed epoch, address[] bridgeOperators);\\n\\n /// @dev Emitted when the reward of the block producer is deprecated.\\n event BlockRewardDeprecated(\\n address indexed coinbaseAddr,\\n uint256 rewardAmount,\\n BlockRewardDeprecatedType deprecatedType\\n );\\n /// @dev Emitted when the block reward is submitted.\\n event BlockRewardSubmitted(address indexed coinbaseAddr, uint256 submittedAmount, uint256 bonusAmount);\\n\\n /// @dev Emitted when the block producer reward is distributed.\\n event MiningRewardDistributed(address indexed consensusAddr, address indexed recipient, uint256 amount);\\n /// @dev Emitted when the contract fails when distributing the block producer reward.\\n event MiningRewardDistributionFailed(\\n address indexed consensusAddr,\\n address indexed recipient,\\n uint256 amount,\\n uint256 contractBalance\\n );\\n\\n /// @dev Emitted when the bridge operator reward is distributed.\\n event BridgeOperatorRewardDistributed(\\n address indexed consensusAddr,\\n address indexed bridgeOperator,\\n address indexed recipientAddr,\\n uint256 amount\\n );\\n /// @dev Emitted when the contract fails when distributing the bridge operator reward.\\n event BridgeOperatorRewardDistributionFailed(\\n address indexed consensusAddr,\\n address indexed bridgeOperator,\\n address indexed recipient,\\n uint256 amount,\\n uint256 contractBalance\\n );\\n\\n /// @dev Emitted when the amount of RON reward is distributed to staking contract.\\n event StakingRewardDistributed(uint256 totalAmount, address[] consensusAddrs, uint256[] amounts);\\n /// @dev Emitted when the contracts fails when distributing the amount of RON to the staking contract.\\n event StakingRewardDistributionFailed(\\n uint256 totalAmount,\\n address[] consensusAddrs,\\n uint256[] amounts,\\n uint256 contractBalance\\n );\\n\\n /// @dev Emitted when the epoch is wrapped up.\\n event WrappedUpEpoch(uint256 indexed periodNumber, uint256 indexed epochNumber, bool periodEnding);\\n /// @dev Emitted when the bridge tracking contract's response is incorrect\\n event BridgeTrackingIncorrectlyResponded();\\n\\n /// @dev Error of method caller must be coinbase\\n error ErrCallerMustBeCoinbase();\\n /// @dev Error of only allowed at the end of epoch\\n error ErrAtEndOfEpochOnly();\\n /// @dev Error of query for already wrapped up epoch\\n error ErrAlreadyWrappedEpoch();\\n\\n /**\\n * @dev Submits reward of the current block.\\n *\\n * Requirements:\\n * - The method caller is coinbase.\\n *\\n * Emits the event `MiningRewardDeprecated` if the coinbase is slashed or no longer be a block producer.\\n * Emits the event `BlockRewardSubmitted` for the valid call.\\n *\\n */\\n function submitBlockReward() external payable;\\n\\n /**\\n * @dev Wraps up the current epoch.\\n *\\n * Requirements:\\n * - The method must be called when the current epoch is ending.\\n * - The epoch is not wrapped yet.\\n * - The method caller is coinbase.\\n *\\n * Emits the event `MiningRewardDistributed` when some validator has reward distributed.\\n * Emits the event `StakingRewardDistributed` when some staking pool has reward distributed.\\n * Emits the event `BlockProducerSetUpdated` when the epoch is wrapped up.\\n * Emits the event `BridgeOperatorSetUpdated` when the epoch is wrapped up at period ending.\\n * Emits the event `ValidatorSetUpdated` when the epoch is wrapped up at period ending, and the validator set gets updated.\\n * Emits the event `WrappedUpEpoch`.\\n *\\n */\\n function wrapUpEpoch() external payable;\\n}\\n\",\"keccak256\":\"0x42ed0bff5f8233dc6de28bd3283f98a0c16df6abc26655fc777bdc07a83ff3f5\",\"license\":\"MIT\"},\"contracts/interfaces/validator/IEmergencyExit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface IEmergencyExit {\\n /// @dev Emitted when the fund is locked from an emergency exit request\\n event EmergencyExitRequested(address indexed consensusAddr, uint256 lockedAmount);\\n /// @dev Emitted when the fund that locked from an emergency exit request is transferred to the recipient.\\n event EmergencyExitLockedFundReleased(\\n address indexed consensusAddr,\\n address indexed recipient,\\n uint256 unlockedAmount\\n );\\n /// @dev Emitted when the fund that locked from an emergency exit request is failed to transferred back.\\n event EmergencyExitLockedFundReleasingFailed(\\n address indexed consensusAddr,\\n address indexed recipient,\\n uint256 unlockedAmount,\\n uint256 contractBalance\\n );\\n\\n /// @dev Emitted when the emergency exit locked amount is updated.\\n event EmergencyExitLockedAmountUpdated(uint256 amount);\\n /// @dev Emitted when the emergency expiry duration is updated.\\n event EmergencyExpiryDurationUpdated(uint256 amount);\\n\\n /// @dev Error of already requested emergency exit before.\\n error ErrAlreadyRequestedEmergencyExit();\\n\\n /**\\n * @dev Returns the amount of RON to lock from a consensus address.\\n */\\n function emergencyExitLockedAmount() external returns (uint256);\\n\\n /**\\n * @dev Returns the duration that an emergency request is expired and the fund will be recycled.\\n */\\n function emergencyExpiryDuration() external returns (uint256);\\n\\n /**\\n * @dev Sets the amount of RON to lock from a consensus address.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `EmergencyExitLockedAmountUpdated`.\\n *\\n */\\n function setEmergencyExitLockedAmount(uint256 _emergencyExitLockedAmount) external;\\n\\n /**\\n * @dev Sets the duration that an emergency request is expired and the fund will be recycled.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `EmergencyExpiryDurationUpdated`.\\n *\\n */\\n function setEmergencyExpiryDuration(uint256 _emergencyExpiryDuration) external;\\n\\n /**\\n * @dev Unlocks fund for emergency exit request.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `EmergencyExitLockedFundReleased` if the fund is successfully unlocked.\\n * Emits the event `EmergencyExitLockedFundReleasingFailed` if the fund is failed to unlock.\\n *\\n */\\n function execReleaseLockedFundForEmergencyExitRequest(address _consensusAddr, address payable _recipient) external;\\n\\n /**\\n * @dev Fallback function of `IStaking-requestEmergencyExit`.\\n *\\n * Requirements:\\n * - The method caller is staking contract.\\n *\\n */\\n function execEmergencyExit(address _consensusAddr, uint256 _secLeftToRevoke) external;\\n}\\n\",\"keccak256\":\"0x45161abd1e3db83052a06889a0e3a7a5e7ee3306478601d58ac4ed32ccaa75ad\",\"license\":\"MIT\"},\"contracts/interfaces/validator/IRoninValidatorSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./ICandidateManager.sol\\\";\\nimport \\\"./info-fragments/ICommonInfo.sol\\\";\\nimport \\\"./ICoinbaseExecution.sol\\\";\\nimport \\\"./ISlashingExecution.sol\\\";\\nimport \\\"./IEmergencyExit.sol\\\";\\n\\ninterface IRoninValidatorSet is\\n ICandidateManager,\\n ICommonInfo,\\n ISlashingExecution,\\n ICoinbaseExecution,\\n IEmergencyExit\\n{}\\n\",\"keccak256\":\"0x813f34747aea4dfb53bbc147abf8dbe5999ce73111c2db99bcb3efb4cf75bb3d\",\"license\":\"MIT\"},\"contracts/interfaces/validator/ISlashingExecution.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface ISlashingExecution {\\n /// @dev Emitted when the validator is punished.\\n event ValidatorPunished(\\n address indexed consensusAddr,\\n uint256 indexed period,\\n uint256 jailedUntil,\\n uint256 deductedStakingAmount,\\n bool blockProducerRewardDeprecated,\\n bool bridgeOperatorRewardDeprecated\\n );\\n /// @dev Emitted when the validator get out of jail by bailout.\\n event ValidatorUnjailed(address indexed validator, uint256 period);\\n\\n /// @dev Error of cannot bailout due to high tier slash.\\n error ErrCannotBailout(address validator);\\n\\n /**\\n * @dev Finalize the slash request from slash indicator contract.\\n *\\n * Requirements:\\n * - The method caller is slash indicator contract.\\n *\\n * Emits the event `ValidatorPunished`.\\n *\\n */\\n function execSlash(\\n address _validatorAddr,\\n uint256 _newJailedUntil,\\n uint256 _slashAmount,\\n bool _cannotBailout\\n ) external;\\n\\n /**\\n * @dev Finalize the bailout request from slash indicator contract.\\n *\\n * Requirements:\\n * - The method caller is slash indicator contract.\\n *\\n * Emits the event `ValidatorUnjailed`.\\n *\\n */\\n function execBailOut(address _validatorAddr, uint256 _period) external;\\n}\\n\",\"keccak256\":\"0x80362c42fdc0ee06543a2abbffee961fe51c15a7c5e18933a9c34897e50d07fe\",\"license\":\"MIT\"},\"contracts/interfaces/validator/info-fragments/ICommonInfo.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IJailingInfo.sol\\\";\\nimport \\\"./ITimingInfo.sol\\\";\\nimport \\\"./IValidatorInfo.sol\\\";\\n\\ninterface ICommonInfo is ITimingInfo, IJailingInfo, IValidatorInfo {\\n struct EmergencyExitInfo {\\n uint256 lockedAmount;\\n // The timestamp that this locked amount will be recycled to staking vesting contract\\n uint256 recyclingAt;\\n }\\n\\n /// @dev Emitted when the deprecated reward is withdrawn.\\n event DeprecatedRewardRecycled(address indexed recipientAddr, uint256 amount);\\n /// @dev Emitted when the deprecated reward withdrawal is failed\\n event DeprecatedRewardRecycleFailed(address indexed recipientAddr, uint256 amount, uint256 balance);\\n\\n /// @dev Error thrown when receives RON from neither staking vesting contract nor staking contract\\n error ErrUnauthorizedReceiveRON();\\n /// @dev Error thrown when queries for a non existent info.\\n error NonExistentRecyclingInfo();\\n\\n /**\\n * @dev Returns the total deprecated reward, which includes reward that is not sent for slashed validators and unsastified bridge operators\\n */\\n function totalDeprecatedReward() external view returns (uint256);\\n\\n /**\\n * @dev Returns the emergency exit request.\\n */\\n function getEmergencyExitInfo(address _consensusAddr) external view returns (EmergencyExitInfo memory);\\n}\\n\",\"keccak256\":\"0xc00b1bda0c6076c9aa0631dc0c01e849d8f42cc616fe4c036f73cda0a9afe9ef\",\"license\":\"MIT\"},\"contracts/interfaces/validator/info-fragments/IJailingInfo.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface IJailingInfo {\\n /**\\n * @dev Returns whether the validator are put in jail (cannot join the set of validators) during the current period.\\n */\\n function checkJailed(address) external view returns (bool);\\n\\n /**\\n * @dev Returns whether the validator are put in jail and the number of block and epoch that he still is in the jail.\\n */\\n function getJailedTimeLeft(\\n address _addr\\n ) external view returns (bool isJailed_, uint256 blockLeft_, uint256 epochLeft_);\\n\\n /**\\n * @dev Returns whether the validator are put in jail (cannot join the set of validators) at a specific block.\\n */\\n function checkJailedAtBlock(address _addr, uint256 _blockNum) external view returns (bool);\\n\\n /**\\n * @dev Returns whether the validator are put in jail at a specific block and the number of block and epoch that he still is in the jail.\\n */\\n function getJailedTimeLeftAtBlock(\\n address _addr,\\n uint256 _blockNum\\n ) external view returns (bool isJailed_, uint256 blockLeft_, uint256 epochLeft_);\\n\\n /**\\n * @dev Returns whether the validators are put in jail (cannot join the set of validators) during the current period.\\n */\\n function checkManyJailed(address[] calldata) external view returns (bool[] memory);\\n\\n /**\\n * @dev Returns whether the incoming reward of the block producer is deprecated during the current period.\\n */\\n function checkMiningRewardDeprecated(address _blockProducer) external view returns (bool);\\n\\n /**\\n * @dev Returns whether the incoming reward of the block producer is deprecated during a specific period.\\n */\\n function checkMiningRewardDeprecatedAtPeriod(address _blockProducer, uint256 _period) external view returns (bool);\\n\\n /**\\n * @dev Returns whether the incoming reward of the validator with `_consensusAddr` is deprecated in the latest wrapped up period.\\n */\\n function checkBridgeRewardDeprecatedAtLatestPeriod(address _consensusAddr) external view returns (bool _result);\\n\\n /**\\n * @dev Returns whether the incoming reward of the validator with `_consensusAddr` is deprecated in the `_period`.\\n */\\n function checkBridgeRewardDeprecatedAtPeriod(\\n address _consensusAddr,\\n uint256 _period\\n ) external view returns (bool _result);\\n}\\n\",\"keccak256\":\"0xc854f6deb26db9cae49e1cfa85aa94d64828251fcca394fed0dd67d554da749b\",\"license\":\"MIT\"},\"contracts/interfaces/validator/info-fragments/ITimingInfo.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface ITimingInfo {\\n /**\\n * @dev Returns the block that validator set was updated.\\n */\\n function getLastUpdatedBlock() external view returns (uint256);\\n\\n /**\\n * @dev Returns the number of blocks in a epoch.\\n */\\n function numberOfBlocksInEpoch() external view returns (uint256 _numberOfBlocks);\\n\\n /**\\n * @dev Returns the epoch index from the block number.\\n */\\n function epochOf(uint256 _block) external view returns (uint256);\\n\\n /**\\n * @dev Returns whether the epoch ending is at the block number `_block`.\\n */\\n function epochEndingAt(uint256 _block) external view returns (bool);\\n\\n /**\\n * @dev Tries to get the period index from the epoch number.\\n */\\n function tryGetPeriodOfEpoch(uint256 _epoch) external view returns (bool _filled, uint256 _periodNumber);\\n\\n /**\\n * @dev Returns whether the period ending at the current block number.\\n */\\n function isPeriodEnding() external view returns (bool);\\n\\n /**\\n * @dev Returns the period index from the current block.\\n */\\n function currentPeriod() external view returns (uint256);\\n\\n /**\\n * @dev Returns the block number that the current period starts at.\\n */\\n function currentPeriodStartAtBlock() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x77b86a68149389fed0eb0c5b8d56f278d3bd103ba64f504697d709b24c3212d5\",\"license\":\"MIT\"},\"contracts/interfaces/validator/info-fragments/IValidatorInfo.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"../../../libraries/EnumFlags.sol\\\";\\n\\ninterface IValidatorInfo {\\n /**\\n * @dev Error thrown when an invalid maximum prioritized validator number is provided.\\n */\\n error ErrInvalidMaxPrioritizedValidatorNumber();\\n\\n /// @dev Emitted when the number of max validator is updated.\\n event MaxValidatorNumberUpdated(uint256);\\n /// @dev Emitted when the number of reserved slots for prioritized validators is updated.\\n event MaxPrioritizedValidatorNumberUpdated(uint256);\\n\\n /**\\n * @dev Returns the maximum number of validators in the epoch.\\n */\\n function maxValidatorNumber() external view returns (uint256 _maximumValidatorNumber);\\n\\n /**\\n * @dev Returns the number of reserved slots for prioritized validators.\\n */\\n function maxPrioritizedValidatorNumber() external view returns (uint256 _maximumPrioritizedValidatorNumber);\\n\\n /**\\n * @dev Returns the current validator list.\\n */\\n function getValidators()\\n external\\n view\\n returns (\\n address[] memory _validatorList,\\n address[] memory _bridgeOperators,\\n EnumFlags.ValidatorFlag[] memory _flags\\n );\\n\\n /**\\n * @dev Returns whether the address is either a bridge operator or a block producer.\\n */\\n function isValidator(address _addr) external view returns (bool);\\n\\n /**\\n * @dev Returns the current block producer list.\\n */\\n function getBlockProducers() external view returns (address[] memory);\\n\\n /**\\n * @dev Returns whether the address is block producer or not.\\n */\\n function isBlockProducer(address _addr) external view returns (bool);\\n\\n /**\\n * @dev Returns total numbers of the block producers.\\n */\\n function totalBlockProducers() external view returns (uint256);\\n\\n /**\\n * @dev Returns the current on-working bridge operator list.\\n * @param bridgeOperatorList The list of working bridge operators.\\n * @param validatorList The list of corresponding validators.\\n */\\n function getBridgeOperators()\\n external\\n view\\n returns (address[] memory bridgeOperatorList, address[] memory validatorList);\\n\\n /**\\n * @dev Returns the bridge operator list corresponding to validator address list.\\n */\\n function getBridgeOperatorsOf(\\n address[] memory _validatorAddrs\\n ) external view returns (address[] memory bridgeOperatorList);\\n\\n /**\\n * @dev Returns whether the address is bridge operator.\\n */\\n function isBridgeOperator(address _addr) external view returns (bool isOperator);\\n\\n /**\\n * @dev Returns whether the consensus address is operating the bridge or not.\\n */\\n function isOperatingBridge(address _consensusAddr) external view returns (bool);\\n\\n /**\\n * @dev Returns total numbers of the bridge operators.\\n */\\n function totalBridgeOperators() external view returns (uint256);\\n\\n /**\\n * @dev Updates the max validator number\\n *\\n * Requirements:\\n * - The method caller is admin\\n *\\n * Emits the event `MaxValidatorNumberUpdated`\\n *\\n */\\n function setMaxValidatorNumber(uint256 _maxValidatorNumber) external;\\n\\n /**\\n * @dev Updates the number of reserved slots for prioritized validators\\n *\\n * Requirements:\\n * - The method caller is admin\\n *\\n * Emits the event `MaxPrioritizedValidatorNumberUpdated`\\n *\\n */\\n function setMaxPrioritizedValidatorNumber(uint256 _maxPrioritizedValidatorNumber) external;\\n}\\n\",\"keccak256\":\"0x3915e301358a793f14f6ecf6bca330311a9684e5144cd20d133b1905f8918f03\",\"license\":\"MIT\"},\"contracts/libraries/AddressArrayUtils.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\n\\npragma solidity ^0.8.0;\\n\\nlibrary AddressArrayUtils {\\n /**\\n * @dev Error thrown when a duplicated element is detected in an array.\\n * @param msgSig The function signature that invoke the error.\\n */\\n error ErrDuplicated(bytes4 msgSig);\\n\\n /**\\n * @dev Returns whether or not there's a duplicate. Runs in O(n^2).\\n * @param A Array to search\\n * @return Returns true if duplicate, false otherwise\\n */\\n function hasDuplicate(address[] memory A) internal pure returns (bool) {\\n if (A.length == 0) {\\n return false;\\n }\\n unchecked {\\n for (uint256 i = 0; i < A.length - 1; i++) {\\n for (uint256 j = i + 1; j < A.length; j++) {\\n if (A[i] == A[j]) {\\n return true;\\n }\\n }\\n }\\n }\\n return false;\\n }\\n\\n /**\\n * @dev Returns whether two arrays of addresses are equal or not.\\n */\\n function isEqual(address[] memory _this, address[] memory _other) internal pure returns (bool yes_) {\\n // Hashing two arrays and compare their hash\\n assembly {\\n let _thisHash := keccak256(add(_this, 32), mul(mload(_this), 32))\\n let _otherHash := keccak256(add(_other, 32), mul(mload(_other), 32))\\n yes_ := eq(_thisHash, _otherHash)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xad507377bb0f55ca4cb85a2306fca3b2b92a3b7246abfe79e85a0dfe1fb0d14c\",\"license\":\"UNLICENSED\"},\"contracts/libraries/EnumFlags.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This library implements checking flag of an enumerated value.\\n * The originated idea is inherited from [Enum.HashFlag(Enum)](https://learn.microsoft.com/en-us/dotnet/api/system.enum.hasflag?view=net-6.0) method of C#.\\n */\\nlibrary EnumFlags {\\n enum ValidatorFlag {\\n None, // bit(00)\\n BlockProducer, // bit(01)\\n BridgeOperator, // bit(10)\\n Both // bit(11)\\n }\\n\\n function isNone(ValidatorFlag _value) internal pure returns (bool) {\\n return uint8(_value) == 0;\\n }\\n\\n /**\\n * @dev Checks if `_value` has `_flag`.\\n */\\n function hasFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (bool) {\\n return (uint8(_value) & uint8(_flag)) != 0;\\n }\\n\\n /**\\n * @dev Calculate new value of `_value` after adding `_flag`.\\n */\\n function addFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (ValidatorFlag) {\\n return ValidatorFlag(uint8(_value) | uint8(_flag));\\n }\\n\\n /**\\n * @dev Calculate new value of `_value` after remove `_flag`.\\n */\\n function removeFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (ValidatorFlag) {\\n return ValidatorFlag(uint8(_value) & ~uint8(_flag));\\n }\\n}\\n\",\"keccak256\":\"0xa6c77f9d704c57854a30e57e16467a1b70b76be5331d9e53a3f9ec5e57542533\",\"license\":\"UNLICENSED\"},\"contracts/libraries/Math.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\n\\npragma solidity ^0.8.0;\\n\\nlibrary Math {\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a >= b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns whether the number `c` is in range of [a; b].\\n */\\n function inRange(uint256 c, uint256 a, uint256 b) internal pure returns (bool) {\\n return a <= c && c <= b;\\n }\\n\\n /**\\n * @dev Returns whether two inclusive ranges [x1;x2] and [y1;y2] overlap.\\n */\\n function twoRangeOverlap(uint256 x1, uint256 x2, uint256 y1, uint256 y2) internal pure returns (bool) {\\n return x1 <= y2 && y1 <= x2;\\n }\\n\\n /**\\n * @dev Returns value of a + b; in case result is larger than upperbound, upperbound is returned.\\n */\\n function addWithUpperbound(uint256 a, uint256 b, uint256 upperbound) internal pure returns (uint256) {\\n return min(a + b, upperbound);\\n }\\n\\n /**\\n * @dev Returns value of a - b; in case of negative result, 0 is returned.\\n */\\n function subNonNegative(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a - b : 0;\\n }\\n\\n /**\\n * @dev Returns value of `a + zeroable` if zerobale is not 0; otherwise, return 0.\\n */\\n function addIfNonZero(uint256 a, uint256 zeroable) internal pure returns (uint256) {\\n return zeroable != 0 ? a + zeroable : 0;\\n }\\n}\\n\",\"keccak256\":\"0xd73170f448c644a47024c7dbcf4afc3cc7ad27f61737c6ea4c3b543ec5cdb7e9\",\"license\":\"UNLICENSED\"},\"contracts/ronin/staking/BaseStaking.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/security/ReentrancyGuard.sol\\\";\\nimport \\\"../../extensions/RONTransferHelper.sol\\\";\\nimport \\\"../../extensions/collections/HasContracts.sol\\\";\\nimport \\\"../../interfaces/staking/IBaseStaking.sol\\\";\\nimport \\\"../../interfaces/validator/IRoninValidatorSet.sol\\\";\\nimport \\\"../../libraries/Math.sol\\\";\\nimport { HasValidatorDeprecated } from \\\"../../utils/DeprecatedSlots.sol\\\";\\nimport \\\"./RewardCalculation.sol\\\";\\n\\nabstract contract BaseStaking is\\n RONTransferHelper,\\n ReentrancyGuard,\\n RewardCalculation,\\n HasContracts,\\n IBaseStaking,\\n HasValidatorDeprecated\\n{\\n /// @dev Mapping from pool address => staking pool detail\\n mapping(address => PoolDetail) internal _stakingPool;\\n\\n /// @dev The cooldown time in seconds to undelegate from the last timestamp (s)he delegated.\\n uint256 internal _cooldownSecsToUndelegate;\\n /// @dev The number of seconds that a candidate must wait to be revoked and take the self-staking amount back.\\n uint256 internal _waitingSecsToRevoke;\\n\\n /// @dev Mapping from admin address of an active pool => consensus address.\\n mapping(address => address) internal _adminOfActivePoolMapping;\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n */\\n uint256[49] private ______gap;\\n\\n modifier noEmptyValue() {\\n _requireValue();\\n _;\\n }\\n\\n modifier anyExceptPoolAdmin(PoolDetail storage _pool, address _delegator) {\\n _anyExceptPoolAdmin(_pool, _delegator);\\n _;\\n }\\n\\n modifier onlyPoolAdmin(PoolDetail storage _pool, address _requester) {\\n _requirePoolAdmin(_pool, _requester);\\n _;\\n }\\n\\n modifier poolIsActive(address _poolAddr) {\\n _poolIsActive(_poolAddr);\\n _;\\n }\\n\\n function _requireValue() private view {\\n if (msg.value == 0) revert ErrZeroValue();\\n }\\n\\n function _requirePoolAdmin(PoolDetail storage _pool, address _requester) private view {\\n if (_pool.admin != _requester) revert ErrOnlyPoolAdminAllowed();\\n }\\n\\n function _anyExceptPoolAdmin(PoolDetail storage _pool, address _delegator) private view {\\n if (_pool.admin == _delegator) revert ErrPoolAdminForbidden();\\n }\\n\\n function _poolIsActive(address _poolAddr) private view {\\n if (!IRoninValidatorSet(getContract(ContractType.VALIDATOR)).isValidatorCandidate(_poolAddr))\\n revert ErrInactivePool(_poolAddr);\\n }\\n\\n /**\\n * @inheritdoc IBaseStaking\\n */\\n function isAdminOfActivePool(address _poolAdminAddr) public view override returns (bool) {\\n return _adminOfActivePoolMapping[_poolAdminAddr] != address(0);\\n }\\n\\n /**\\n * @inheritdoc IBaseStaking\\n */\\n function getPoolAddressOf(address _poolAdminAddr) external view override returns (address) {\\n return _adminOfActivePoolMapping[_poolAdminAddr];\\n }\\n\\n /**\\n * @inheritdoc IBaseStaking\\n */\\n function getPoolDetail(\\n address _poolAddr\\n ) external view returns (address _admin, uint256 _stakingAmount, uint256 _stakingTotal) {\\n PoolDetail storage _pool = _stakingPool[_poolAddr];\\n return (_pool.admin, _pool.stakingAmount, _pool.stakingTotal);\\n }\\n\\n /**\\n * @inheritdoc IBaseStaking\\n */\\n function getManySelfStakings(address[] calldata _pools) external view returns (uint256[] memory _selfStakings) {\\n _selfStakings = new uint256[](_pools.length);\\n for (uint _i = 0; _i < _pools.length; ) {\\n _selfStakings[_i] = _stakingPool[_pools[_i]].stakingAmount;\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @inheritdoc IRewardPool\\n */\\n function getStakingTotal(address _poolAddr) public view override returns (uint256) {\\n return _stakingPool[_poolAddr].stakingTotal;\\n }\\n\\n /**\\n * @inheritdoc IRewardPool\\n */\\n function getManyStakingTotals(\\n address[] calldata _poolList\\n ) public view override returns (uint256[] memory _stakingAmounts) {\\n _stakingAmounts = new uint256[](_poolList.length);\\n for (uint _i = 0; _i < _poolList.length; ) {\\n _stakingAmounts[_i] = getStakingTotal(_poolList[_i]);\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @inheritdoc IRewardPool\\n */\\n function getStakingAmount(address _poolAddr, address _user) public view override returns (uint256) {\\n return _stakingPool[_poolAddr].delegatingAmount[_user];\\n }\\n\\n /**\\n * @inheritdoc IRewardPool\\n */\\n function getManyStakingAmounts(\\n address[] calldata _poolAddrs,\\n address[] calldata _userList\\n ) external view override returns (uint256[] memory _stakingAmounts) {\\n if (_poolAddrs.length != _userList.length) revert ErrInvalidArrays();\\n _stakingAmounts = new uint256[](_poolAddrs.length);\\n for (uint _i = 0; _i < _stakingAmounts.length; ) {\\n _stakingAmounts[_i] = _stakingPool[_poolAddrs[_i]].delegatingAmount[_userList[_i]];\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @inheritdoc IBaseStaking\\n */\\n function cooldownSecsToUndelegate() external view returns (uint256) {\\n return _cooldownSecsToUndelegate;\\n }\\n\\n /**\\n * @inheritdoc IBaseStaking\\n */\\n function waitingSecsToRevoke() external view returns (uint256) {\\n return _waitingSecsToRevoke;\\n }\\n\\n /**\\n * @inheritdoc IBaseStaking\\n */\\n function setCooldownSecsToUndelegate(uint256 _cooldownSecs) external override onlyAdmin {\\n _setCooldownSecsToUndelegate(_cooldownSecs);\\n }\\n\\n /**\\n * @inheritdoc IBaseStaking\\n */\\n function setWaitingSecsToRevoke(uint256 _secs) external override onlyAdmin {\\n _setWaitingSecsToRevoke(_secs);\\n }\\n\\n /**\\n * @dev Sets the minium number of seconds to undelegate.\\n *\\n * Emits the event `CooldownSecsToUndelegateUpdated`.\\n *\\n */\\n function _setCooldownSecsToUndelegate(uint256 _cooldownSecs) internal {\\n _cooldownSecsToUndelegate = _cooldownSecs;\\n emit CooldownSecsToUndelegateUpdated(_cooldownSecs);\\n }\\n\\n /**\\n * @dev Sets the number of seconds that a candidate must wait to be revoked.\\n *\\n * Emits the event `WaitingSecsToRevokeUpdated`.\\n *\\n */\\n function _setWaitingSecsToRevoke(uint256 _secs) internal {\\n _waitingSecsToRevoke = _secs;\\n emit WaitingSecsToRevokeUpdated(_secs);\\n }\\n\\n /**\\n * @dev Changes the delegate amount.\\n */\\n function _changeDelegatingAmount(\\n PoolDetail storage _pool,\\n address _delegator,\\n uint256 _newDelegatingAmount,\\n uint256 _newStakingTotal\\n ) internal {\\n _syncUserReward(_pool.addr, _delegator, _newDelegatingAmount);\\n _pool.stakingTotal = _newStakingTotal;\\n _pool.delegatingAmount[_delegator] = _newDelegatingAmount;\\n }\\n}\\n\",\"keccak256\":\"0xa1a3e6edfc9d8da5c851de0647c58bc86b0ec2e4a1c041f1b2a73d91b3d69b8d\",\"license\":\"MIT\"},\"contracts/ronin/staking/CandidateStaking.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"../../extensions/consumers/GlobalConfigConsumer.sol\\\";\\nimport \\\"../../extensions/consumers/PercentageConsumer.sol\\\";\\nimport \\\"../../libraries/AddressArrayUtils.sol\\\";\\nimport \\\"../../interfaces/staking/ICandidateStaking.sol\\\";\\nimport \\\"./BaseStaking.sol\\\";\\n\\nabstract contract CandidateStaking is BaseStaking, ICandidateStaking, GlobalConfigConsumer, PercentageConsumer {\\n /// @dev The minimum threshold for being a validator candidate.\\n uint256 internal _minValidatorStakingAmount;\\n\\n /// @dev The max commission rate that the validator can set (in range of [0;100_00] means [0-100%])\\n uint256 internal _maxCommissionRate;\\n /// @dev The min commission rate that the validator can set (in range of [0;100_00] means [0-100%])\\n uint256 internal _minCommissionRate;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n */\\n uint256[48] ______gap;\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function minValidatorStakingAmount() public view override returns (uint256) {\\n return _minValidatorStakingAmount;\\n }\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function getCommissionRateRange() external view override returns (uint256, uint256) {\\n return (_minCommissionRate, _maxCommissionRate);\\n }\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function setMinValidatorStakingAmount(uint256 _threshold) external override onlyAdmin {\\n _setMinValidatorStakingAmount(_threshold);\\n }\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function setCommissionRateRange(uint256 _minRate, uint256 _maxRate) external override onlyAdmin {\\n _setCommissionRateRange(_minRate, _maxRate);\\n }\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function applyValidatorCandidate(\\n address _candidateAdmin,\\n address _consensusAddr,\\n address payable _treasuryAddr,\\n address _bridgeOperatorAddr,\\n uint256 _commissionRate\\n ) external payable override nonReentrant {\\n if (isAdminOfActivePool(msg.sender)) revert ErrAdminOfAnyActivePoolForbidden(msg.sender);\\n if (_commissionRate > _maxCommissionRate || _commissionRate < _minCommissionRate) revert ErrInvalidCommissionRate();\\n\\n uint256 _amount = msg.value;\\n address payable _poolAdmin = payable(msg.sender);\\n _applyValidatorCandidate(\\n _poolAdmin,\\n _candidateAdmin,\\n _consensusAddr,\\n _treasuryAddr,\\n _bridgeOperatorAddr,\\n _commissionRate,\\n _amount\\n );\\n\\n PoolDetail storage _pool = _stakingPool[_consensusAddr];\\n _pool.admin = _poolAdmin;\\n _pool.addr = _consensusAddr;\\n _adminOfActivePoolMapping[_poolAdmin] = _consensusAddr;\\n\\n _stake(_stakingPool[_consensusAddr], _poolAdmin, _amount);\\n emit PoolApproved(_consensusAddr, _poolAdmin);\\n }\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function requestUpdateCommissionRate(\\n address _consensusAddr,\\n uint256 _effectiveDaysOnwards,\\n uint256 _commissionRate\\n ) external override poolIsActive(_consensusAddr) onlyPoolAdmin(_stakingPool[_consensusAddr], msg.sender) {\\n if (_commissionRate > _maxCommissionRate || _commissionRate < _minCommissionRate) revert ErrInvalidCommissionRate();\\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execRequestUpdateCommissionRate(\\n _consensusAddr,\\n _effectiveDaysOnwards,\\n _commissionRate\\n );\\n }\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function execDeprecatePools(\\n address[] calldata _pools,\\n uint256 _newPeriod\\n ) external override onlyContract(ContractType.VALIDATOR) {\\n if (_pools.length == 0) {\\n return;\\n }\\n\\n for (uint _i = 0; _i < _pools.length; ) {\\n PoolDetail storage _pool = _stakingPool[_pools[_i]];\\n // Deactivate the pool admin in the active mapping.\\n delete _adminOfActivePoolMapping[_pool.admin];\\n\\n // Deduct and transfer the self staking amount to the pool admin.\\n uint256 _deductingAmount = _pool.stakingAmount;\\n if (_deductingAmount > 0) {\\n _deductStakingAmount(_pool, _deductingAmount);\\n if (!_unsafeSendRON(payable(_pool.admin), _deductingAmount, DEFAULT_ADDITION_GAS)) {\\n emit StakingAmountTransferFailed(_pool.addr, _pool.admin, _deductingAmount, address(this).balance);\\n }\\n }\\n\\n // Settle the unclaimed reward and transfer to the pool admin.\\n uint256 _lastRewardAmount = _claimReward(_pools[_i], _pool.admin, _newPeriod);\\n if (_lastRewardAmount > 0) {\\n _unsafeSendRON(payable(_pool.admin), _lastRewardAmount, DEFAULT_ADDITION_GAS);\\n }\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n\\n emit PoolsDeprecated(_pools);\\n }\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function stake(address _consensusAddr) external payable override noEmptyValue poolIsActive(_consensusAddr) {\\n _stake(_stakingPool[_consensusAddr], msg.sender, msg.value);\\n }\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function unstake(\\n address _consensusAddr,\\n uint256 _amount\\n ) external override nonReentrant poolIsActive(_consensusAddr) {\\n if (_amount == 0) revert ErrUnstakeZeroAmount();\\n address _requester = msg.sender;\\n PoolDetail storage _pool = _stakingPool[_consensusAddr];\\n uint256 _remainAmount = _pool.stakingAmount - _amount;\\n if (_remainAmount < _minValidatorStakingAmount) revert ErrStakingAmountLeft();\\n\\n _unstake(_pool, _requester, _amount);\\n if (!_unsafeSendRON(payable(_requester), _amount, DEFAULT_ADDITION_GAS)) revert ErrCannotTransferRON();\\n }\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function requestRenounce(\\n address _consensusAddr\\n ) external override poolIsActive(_consensusAddr) onlyPoolAdmin(_stakingPool[_consensusAddr], msg.sender) {\\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execRequestRenounceCandidate(\\n _consensusAddr,\\n _waitingSecsToRevoke\\n );\\n }\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function requestEmergencyExit(\\n address _consensusAddr\\n ) external override poolIsActive(_consensusAddr) onlyPoolAdmin(_stakingPool[_consensusAddr], msg.sender) {\\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execEmergencyExit(_consensusAddr, _waitingSecsToRevoke);\\n }\\n\\n /**\\n * @dev See `ICandidateStaking-applyValidatorCandidate`\\n */\\n function _applyValidatorCandidate(\\n address payable _poolAdmin,\\n address _candidateAdmin,\\n address _consensusAddr,\\n address payable _treasuryAddr,\\n address _bridgeOperatorAddr,\\n uint256 _commissionRate,\\n uint256 _amount\\n ) internal {\\n if (!_unsafeSendRON(_poolAdmin, 0, DEFAULT_ADDITION_GAS)) revert ErrCannotInitTransferRON(_poolAdmin, \\\"pool admin\\\");\\n if (!_unsafeSendRON(_treasuryAddr, 0, DEFAULT_ADDITION_GAS))\\n revert ErrCannotInitTransferRON(_treasuryAddr, \\\"treasury\\\");\\n if (_amount < _minValidatorStakingAmount) revert ErrInsufficientStakingAmount();\\n if (_poolAdmin != _candidateAdmin || _candidateAdmin != _treasuryAddr) revert ErrThreeInteractionAddrsNotEqual();\\n\\n {\\n address[] memory _diffAddrs = new address[](3);\\n _diffAddrs[0] = _poolAdmin;\\n _diffAddrs[1] = _consensusAddr;\\n _diffAddrs[2] = _bridgeOperatorAddr;\\n if (AddressArrayUtils.hasDuplicate(_diffAddrs)) revert AddressArrayUtils.ErrDuplicated(msg.sig);\\n }\\n\\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execApplyValidatorCandidate(\\n _candidateAdmin,\\n _consensusAddr,\\n _treasuryAddr,\\n _bridgeOperatorAddr,\\n _commissionRate\\n );\\n }\\n\\n /**\\n * @dev See `ICandidateStaking-stake`\\n */\\n function _stake(\\n PoolDetail storage _pool,\\n address _requester,\\n uint256 _amount\\n ) internal onlyPoolAdmin(_pool, _requester) {\\n _pool.stakingAmount += _amount;\\n _changeDelegatingAmount(_pool, _requester, _pool.stakingAmount, _pool.stakingTotal + _amount);\\n _pool.lastDelegatingTimestamp[_requester] = block.timestamp;\\n emit Staked(_pool.addr, _amount);\\n }\\n\\n /**\\n * @dev See `ICandidateStaking-unstake`\\n */\\n function _unstake(\\n PoolDetail storage _pool,\\n address _requester,\\n uint256 _amount\\n ) internal onlyPoolAdmin(_pool, _requester) {\\n if (_amount > _pool.stakingAmount) revert ErrInsufficientStakingAmount();\\n if (_pool.lastDelegatingTimestamp[_requester] + _cooldownSecsToUndelegate > block.timestamp) {\\n revert ErrUnstakeTooEarly();\\n }\\n\\n _pool.stakingAmount -= _amount;\\n _changeDelegatingAmount(_pool, _requester, _pool.stakingAmount, _pool.stakingTotal - _amount);\\n emit Unstaked(_pool.addr, _amount);\\n }\\n\\n /**\\n * @dev Deducts from staking amount of the validator `_consensusAddr` for `_amount`.\\n *\\n * Emits the event `Unstaked`.\\n *\\n * @return The actual deducted amount\\n */\\n function _deductStakingAmount(PoolDetail storage _pool, uint256 _amount) internal virtual returns (uint256);\\n\\n /**\\n * @dev Sets the minimum threshold for being a validator candidate.\\n *\\n * Emits the `MinValidatorStakingAmountUpdated` event.\\n *\\n */\\n function _setMinValidatorStakingAmount(uint256 _threshold) internal {\\n _minValidatorStakingAmount = _threshold;\\n emit MinValidatorStakingAmountUpdated(_threshold);\\n }\\n\\n /**\\n * @dev Sets the max commission rate that a candidate can set.\\n *\\n * Emits the `MaxCommissionRateUpdated` event.\\n *\\n */\\n function _setCommissionRateRange(uint256 _minRate, uint256 _maxRate) internal {\\n if (_maxRate > _MAX_PERCENTAGE || _minRate > _maxRate) revert ErrInvalidCommissionRate();\\n _maxCommissionRate = _maxRate;\\n _minCommissionRate = _minRate;\\n emit CommissionRateRangeUpdated(_minRate, _maxRate);\\n }\\n}\\n\",\"keccak256\":\"0x2d5d2b6fff08ac2754cf8dccc8c56757a916d83b25e0a657f898f87c5c28c17b\",\"license\":\"MIT\"},\"contracts/ronin/staking/DelegatorStaking.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"../../interfaces/staking/IDelegatorStaking.sol\\\";\\nimport \\\"./BaseStaking.sol\\\";\\n\\nabstract contract DelegatorStaking is BaseStaking, IDelegatorStaking {\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n */\\n uint256[50] private ______gap;\\n\\n /**\\n * @inheritdoc IDelegatorStaking\\n */\\n function delegate(address _consensusAddr) external payable noEmptyValue poolIsActive(_consensusAddr) {\\n if (isAdminOfActivePool(msg.sender)) revert ErrAdminOfAnyActivePoolForbidden(msg.sender);\\n _delegate(_stakingPool[_consensusAddr], msg.sender, msg.value);\\n }\\n\\n /**\\n * @inheritdoc IDelegatorStaking\\n */\\n function undelegate(address _consensusAddr, uint256 _amount) external nonReentrant {\\n address payable _delegator = payable(msg.sender);\\n _undelegate(_stakingPool[_consensusAddr], _delegator, _amount);\\n if (!_sendRON(_delegator, _amount)) revert ErrCannotTransferRON();\\n }\\n\\n /**\\n * @inheritdoc IDelegatorStaking\\n */\\n function bulkUndelegate(address[] calldata _consensusAddrs, uint256[] calldata _amounts) external nonReentrant {\\n if (_consensusAddrs.length == 0 || _consensusAddrs.length != _amounts.length) revert ErrInvalidArrays();\\n\\n address payable _delegator = payable(msg.sender);\\n uint256 _total;\\n\\n for (uint _i = 0; _i < _consensusAddrs.length; ) {\\n _total += _amounts[_i];\\n _undelegate(_stakingPool[_consensusAddrs[_i]], _delegator, _amounts[_i]);\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n\\n if (!_sendRON(_delegator, _total)) revert ErrCannotTransferRON();\\n }\\n\\n /**\\n * @inheritdoc IDelegatorStaking\\n */\\n function redelegate(\\n address _consensusAddrSrc,\\n address _consensusAddrDst,\\n uint256 _amount\\n ) external nonReentrant poolIsActive(_consensusAddrDst) {\\n address _delegator = msg.sender;\\n _undelegate(_stakingPool[_consensusAddrSrc], _delegator, _amount);\\n _delegate(_stakingPool[_consensusAddrDst], _delegator, _amount);\\n }\\n\\n /**\\n * @inheritdoc IDelegatorStaking\\n */\\n function claimRewards(\\n address[] calldata _consensusAddrList\\n ) external override nonReentrant returns (uint256 _amount) {\\n _amount = _claimRewards(msg.sender, _consensusAddrList);\\n _transferRON(payable(msg.sender), _amount);\\n }\\n\\n /**\\n * @inheritdoc IDelegatorStaking\\n */\\n function delegateRewards(\\n address[] calldata _consensusAddrList,\\n address _consensusAddrDst\\n ) external override nonReentrant poolIsActive(_consensusAddrDst) returns (uint256 _amount) {\\n if (isAdminOfActivePool(msg.sender)) revert ErrAdminOfAnyActivePoolForbidden(msg.sender);\\n return _delegateRewards(msg.sender, _consensusAddrList, _consensusAddrDst);\\n }\\n\\n /**\\n * @inheritdoc IDelegatorStaking\\n */\\n function getRewards(\\n address _user,\\n address[] calldata _poolAddrList\\n ) external view returns (uint256[] memory _rewards) {\\n address _consensusAddr;\\n uint256 _period = IRoninValidatorSet(getContract(ContractType.VALIDATOR)).currentPeriod();\\n _rewards = new uint256[](_poolAddrList.length);\\n\\n for (uint256 _i = 0; _i < _poolAddrList.length; ) {\\n _consensusAddr = _poolAddrList[_i];\\n _rewards[_i] = _getReward(_consensusAddr, _user, _period, getStakingAmount(_consensusAddr, _user));\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @dev Delegates from a validator address.\\n *\\n * Requirements:\\n * - The delegator is not the pool admin.\\n *\\n * Emits the `Delegated` event.\\n *\\n * Note: This function does not verify the `msg.value` with the amount.\\n *\\n */\\n function _delegate(\\n PoolDetail storage _pool,\\n address _delegator,\\n uint256 _amount\\n ) internal anyExceptPoolAdmin(_pool, _delegator) {\\n _changeDelegatingAmount(\\n _pool,\\n _delegator,\\n _pool.delegatingAmount[_delegator] + _amount,\\n _pool.stakingTotal + _amount\\n );\\n _pool.lastDelegatingTimestamp[_delegator] = block.timestamp;\\n emit Delegated(_delegator, _pool.addr, _amount);\\n }\\n\\n /**\\n * @dev Undelegates from a validator address.\\n *\\n * Requirements:\\n * - The delegator is not the pool admin.\\n * - The amount is larger than 0.\\n * - The delegating amount is larger than or equal to the undelegating amount.\\n *\\n * Emits the `Undelegated` event.\\n *\\n * Note: Consider transferring back the amount of RON after calling this function.\\n *\\n */\\n function _undelegate(\\n PoolDetail storage _pool,\\n address _delegator,\\n uint256 _amount\\n ) private anyExceptPoolAdmin(_pool, _delegator) {\\n if (_amount == 0) revert ErrUndelegateZeroAmount();\\n if (_pool.delegatingAmount[_delegator] < _amount) revert ErrInsufficientDelegatingAmount();\\n\\n IRoninValidatorSet _validatorContract = IRoninValidatorSet(getContract(ContractType.VALIDATOR));\\n if (\\n _validatorContract.isValidatorCandidate(_pool.addr) &&\\n _validatorContract.getCandidateInfo(_pool.addr).revokingTimestamp == 0 && // if candidate is not on renunciation\\n _pool.lastDelegatingTimestamp[_delegator] + _cooldownSecsToUndelegate >= block.timestamp // delegator is still in cooldown\\n ) revert ErrUndelegateTooEarly();\\n\\n _changeDelegatingAmount(\\n _pool,\\n _delegator,\\n _pool.delegatingAmount[_delegator] - _amount,\\n _pool.stakingTotal - _amount\\n );\\n emit Undelegated(_delegator, _pool.addr, _amount);\\n }\\n\\n /**\\n * @dev Claims rewards from the pools `_poolAddrList`.\\n * Note: This function does not transfer reward to user.\\n */\\n function _claimRewards(address _user, address[] memory _poolAddrList) internal returns (uint256 _amount) {\\n uint256 _period = _currentPeriod();\\n for (uint256 _i = 0; _i < _poolAddrList.length; ) {\\n _amount += _claimReward(_poolAddrList[_i], _user, _period);\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @dev Claims the rewards and delegates them to the consensus address.\\n */\\n function _delegateRewards(\\n address _user,\\n address[] calldata _poolAddrList,\\n address _poolAddrDst\\n ) internal returns (uint256 _amount) {\\n _amount = _claimRewards(_user, _poolAddrList);\\n _delegate(_stakingPool[_poolAddrDst], _user, _amount);\\n }\\n}\\n\",\"keccak256\":\"0x26d154ed736d57c1ecc6be99ac33274640039975374584bd4a12b8f53b68cb5e\",\"license\":\"MIT\"},\"contracts/ronin/staking/RewardCalculation.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"../../interfaces/staking/IRewardPool.sol\\\";\\nimport \\\"../../libraries/Math.sol\\\";\\n\\n/**\\n * @title RewardCalculation contract\\n * @dev This contract mainly contains the methods to calculate reward for staking contract.\\n */\\nabstract contract RewardCalculation is IRewardPool {\\n /// @dev Mapping from pool address => period number => accumulated rewards per share (one unit staking)\\n mapping(address => mapping(uint256 => PeriodWrapper)) private _accumulatedRps;\\n /// @dev Mapping from the pool address => user address => the reward info of the user\\n mapping(address => mapping(address => UserRewardFields)) private _userReward;\\n /// @dev Mapping from the pool address => reward pool fields\\n mapping(address => PoolFields) private _stakingPool;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n */\\n uint256[50] private ______gap;\\n\\n /**\\n * @inheritdoc IRewardPool\\n */\\n function getReward(address _poolAddr, address _user) external view returns (uint256) {\\n return _getReward(_poolAddr, _user, _currentPeriod(), getStakingAmount(_poolAddr, _user));\\n }\\n\\n /**\\n * @inheritdoc IRewardPool\\n */\\n function getStakingAmount(address _poolAddr, address _user) public view virtual returns (uint256);\\n\\n /**\\n * @inheritdoc IRewardPool\\n */\\n function getStakingTotal(address _poolAddr) public view virtual returns (uint256);\\n\\n /**\\n * @dev Returns the reward amount that user claimable.\\n */\\n function _getReward(\\n address _poolAddr,\\n address _user,\\n uint256 _latestPeriod,\\n uint256 _latestStakingAmount\\n ) internal view returns (uint256) {\\n UserRewardFields storage _reward = _userReward[_poolAddr][_user];\\n\\n if (_reward.lastPeriod == _latestPeriod) {\\n return _reward.debited;\\n }\\n\\n uint256 _aRps;\\n uint256 _lastPeriodReward;\\n PoolFields storage _pool = _stakingPool[_poolAddr];\\n PeriodWrapper storage _wrappedArps = _accumulatedRps[_poolAddr][_reward.lastPeriod];\\n\\n if (_wrappedArps.lastPeriod > 0) {\\n // Calculates the last period reward if the aRps at the period is set\\n _aRps = _wrappedArps.inner;\\n _lastPeriodReward = _reward.lowestAmount * (_aRps - _reward.aRps);\\n } else {\\n // Fallbacks to the previous aRps in case the aRps is not set\\n _aRps = _reward.aRps;\\n }\\n\\n uint256 _newPeriodsReward = _latestStakingAmount * (_pool.aRps - _aRps);\\n return _reward.debited + (_lastPeriodReward + _newPeriodsReward) / 1e18;\\n }\\n\\n /**\\n * @dev Syncs the user reward.\\n *\\n * Emits the event `UserRewardUpdated` once the debit amount is updated.\\n * Emits the event `PoolSharesUpdated` once the pool share is updated.\\n *\\n * Note: The method should be called whenever the user's staking amount changes.\\n *\\n */\\n function _syncUserReward(address _poolAddr, address _user, uint256 _newStakingAmount) internal {\\n uint256 _period = _currentPeriod();\\n PoolFields storage _pool = _stakingPool[_poolAddr];\\n uint256 _lastShares = _pool.shares.inner;\\n\\n // Updates the pool shares if it is outdated\\n if (_pool.shares.lastPeriod < _period) {\\n _pool.shares = PeriodWrapper(getStakingTotal(_poolAddr), _period);\\n }\\n\\n UserRewardFields storage _reward = _userReward[_poolAddr][_user];\\n uint256 _currentStakingAmount = getStakingAmount(_poolAddr, _user);\\n uint256 _debited = _getReward(_poolAddr, _user, _period, _currentStakingAmount);\\n\\n if (_reward.debited != _debited) {\\n _reward.debited = _debited;\\n emit UserRewardUpdated(_poolAddr, _user, _debited);\\n }\\n\\n _syncMinStakingAmount(_pool, _reward, _period, _newStakingAmount, _currentStakingAmount);\\n _reward.aRps = _pool.aRps;\\n _reward.lastPeriod = _period;\\n\\n if (_pool.shares.inner != _lastShares) {\\n emit PoolSharesUpdated(_period, _poolAddr, _pool.shares.inner);\\n }\\n }\\n\\n /**\\n * @dev Syncs the minimum staking amount of an user in the current period.\\n */\\n function _syncMinStakingAmount(\\n PoolFields storage _pool,\\n UserRewardFields storage _reward,\\n uint256 _latestPeriod,\\n uint256 _newStakingAmount,\\n uint256 _currentStakingAmount\\n ) internal {\\n if (_reward.lastPeriod < _latestPeriod) {\\n _reward.lowestAmount = _currentStakingAmount;\\n }\\n\\n uint256 _lowestAmount = Math.min(_reward.lowestAmount, _newStakingAmount);\\n uint256 _diffAmount = _reward.lowestAmount - _lowestAmount;\\n if (_diffAmount > 0) {\\n _reward.lowestAmount = _lowestAmount;\\n if (_pool.shares.inner < _diffAmount) revert ErrInvalidPoolShare();\\n _pool.shares.inner -= _diffAmount;\\n }\\n }\\n\\n /**\\n * @dev Claims the settled reward for a specific user.\\n *\\n * @param _lastPeriod Must be in two possible value: `_currentPeriod` in normal calculation, or\\n * `_currentPeriod + 1` in case of calculating the reward for revoked validators.\\n *\\n * Emits the `RewardClaimed` event and the `UserRewardUpdated` event.\\n *\\n * Note: This method should be called before transferring rewards for the user.\\n *\\n */\\n function _claimReward(address _poolAddr, address _user, uint256 _lastPeriod) internal returns (uint256 _amount) {\\n uint256 _currentStakingAmount = getStakingAmount(_poolAddr, _user);\\n _amount = _getReward(_poolAddr, _user, _lastPeriod, _currentStakingAmount);\\n emit RewardClaimed(_poolAddr, _user, _amount);\\n\\n UserRewardFields storage _reward = _userReward[_poolAddr][_user];\\n _reward.debited = 0;\\n _syncMinStakingAmount(_stakingPool[_poolAddr], _reward, _lastPeriod, _currentStakingAmount, _currentStakingAmount);\\n _reward.lastPeriod = _lastPeriod;\\n _reward.aRps = _stakingPool[_poolAddr].aRps;\\n emit UserRewardUpdated(_poolAddr, _user, 0);\\n }\\n\\n /**\\n * @dev Records the amount of rewards `_rewards` for the pools `_poolAddrs`.\\n *\\n * Emits the event `PoolsUpdated` once the contract recorded the rewards successfully.\\n * Emits the event `PoolsUpdateFailed` once the input array lengths are not equal.\\n * Emits the event `PoolUpdateConflicted` when the pool is already updated in the period.\\n *\\n * Note: This method should be called once at the period ending.\\n *\\n */\\n function _recordRewards(address[] memory _poolAddrs, uint256[] calldata _rewards, uint256 _period) internal {\\n if (_poolAddrs.length != _rewards.length) {\\n emit PoolsUpdateFailed(_period, _poolAddrs, _rewards);\\n return;\\n }\\n\\n uint256 _rps;\\n uint256 _count;\\n address _poolAddr;\\n uint256 _stakingTotal;\\n uint256[] memory _aRps = new uint256[](_poolAddrs.length);\\n uint256[] memory _shares = new uint256[](_poolAddrs.length);\\n address[] memory _conflicted = new address[](_poolAddrs.length);\\n\\n for (uint _i = 0; _i < _poolAddrs.length; _i++) {\\n _poolAddr = _poolAddrs[_i];\\n PoolFields storage _pool = _stakingPool[_poolAddr];\\n _stakingTotal = getStakingTotal(_poolAddr);\\n\\n if (_accumulatedRps[_poolAddr][_period].lastPeriod == _period) {\\n unchecked {\\n _conflicted[_count++] = _poolAddr;\\n }\\n continue;\\n }\\n\\n // Updates the pool shares if it is outdated\\n if (_pool.shares.lastPeriod < _period) {\\n _pool.shares = PeriodWrapper(_stakingTotal, _period);\\n }\\n\\n // The rps is 0 if no one stakes for the pool\\n _rps = _pool.shares.inner == 0 ? 0 : (_rewards[_i] * 1e18) / _pool.shares.inner;\\n _aRps[_i - _count] = _pool.aRps += _rps;\\n _accumulatedRps[_poolAddr][_period] = PeriodWrapper(_pool.aRps, _period);\\n _pool.shares.inner = _stakingTotal;\\n _shares[_i - _count] = _pool.shares.inner;\\n _poolAddrs[_i - _count] = _poolAddr;\\n }\\n\\n if (_count > 0) {\\n assembly {\\n mstore(_conflicted, _count)\\n mstore(_poolAddrs, sub(mload(_poolAddrs), _count))\\n }\\n emit PoolsUpdateConflicted(_period, _conflicted);\\n }\\n\\n if (_poolAddrs.length > 0) {\\n emit PoolsUpdated(_period, _poolAddrs, _aRps, _shares);\\n }\\n }\\n\\n /**\\n * @dev Returns the current period.\\n */\\n function _currentPeriod() internal view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x98f330685911b18730cf85223ecf30f4da2ec19dda5608b5d82c6b5e4f222fa1\",\"license\":\"MIT\"},\"contracts/ronin/staking/Staking.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/proxy/utils/Initializable.sol\\\";\\nimport \\\"../../libraries/Math.sol\\\";\\nimport \\\"../../interfaces/staking/IStaking.sol\\\";\\nimport \\\"../../interfaces/validator/IRoninValidatorSet.sol\\\";\\nimport \\\"./CandidateStaking.sol\\\";\\nimport \\\"./DelegatorStaking.sol\\\";\\n\\ncontract Staking is IStaking, CandidateStaking, DelegatorStaking, Initializable {\\n constructor() {\\n _disableInitializers();\\n }\\n\\n receive() external payable onlyContract(ContractType.VALIDATOR) {}\\n\\n fallback() external payable onlyContract(ContractType.VALIDATOR) {}\\n\\n /**\\n * @dev Initializes the contract storage.\\n */\\n function initialize(\\n address __validatorContract,\\n uint256 __minValidatorStakingAmount,\\n uint256 __maxCommissionRate,\\n uint256 __cooldownSecsToUndelegate,\\n uint256 __waitingSecsToRevoke\\n ) external initializer {\\n _setContract(ContractType.VALIDATOR, __validatorContract);\\n _setMinValidatorStakingAmount(__minValidatorStakingAmount);\\n _setCommissionRateRange(0, __maxCommissionRate);\\n _setCooldownSecsToUndelegate(__cooldownSecsToUndelegate);\\n _setWaitingSecsToRevoke(__waitingSecsToRevoke);\\n }\\n\\n function initializeV2() external reinitializer(2) {\\n _setContract(ContractType.VALIDATOR, ______deprecatedValidator);\\n delete ______deprecatedValidator;\\n }\\n\\n /**\\n * @inheritdoc IStaking\\n */\\n function execRecordRewards(\\n address[] calldata _consensusAddrs,\\n uint256[] calldata _rewards,\\n uint256 _period\\n ) external payable override onlyContract(ContractType.VALIDATOR) {\\n _recordRewards(_consensusAddrs, _rewards, _period);\\n }\\n\\n /**\\n * @inheritdoc IStaking\\n */\\n function execDeductStakingAmount(\\n address _consensusAddr,\\n uint256 _amount\\n ) external override onlyContract(ContractType.VALIDATOR) returns (uint256 _actualDeductingAmount) {\\n _actualDeductingAmount = _deductStakingAmount(_stakingPool[_consensusAddr], _amount);\\n address payable _validatorContractAddr = payable(msg.sender);\\n if (!_unsafeSendRON(_validatorContractAddr, _actualDeductingAmount)) {\\n emit StakingAmountDeductFailed(\\n _consensusAddr,\\n _validatorContractAddr,\\n _actualDeductingAmount,\\n address(this).balance\\n );\\n }\\n }\\n\\n /**\\n * @inheritdoc RewardCalculation\\n */\\n function _currentPeriod() internal view virtual override returns (uint256) {\\n return IRoninValidatorSet(getContract(ContractType.VALIDATOR)).currentPeriod();\\n }\\n\\n /**\\n * @inheritdoc CandidateStaking\\n */\\n function _deductStakingAmount(\\n PoolDetail storage _pool,\\n uint256 _amount\\n ) internal override returns (uint256 _actualDeductingAmount) {\\n _actualDeductingAmount = Math.min(_pool.stakingAmount, _amount);\\n\\n _pool.stakingAmount -= _actualDeductingAmount;\\n _changeDelegatingAmount(\\n _pool,\\n _pool.admin,\\n _pool.stakingAmount,\\n Math.subNonNegative(_pool.stakingTotal, _actualDeductingAmount)\\n );\\n emit Unstaked(_pool.addr, _actualDeductingAmount);\\n }\\n}\\n\",\"keccak256\":\"0x9ccdb181433c6e58de4684201bb1db1ae2b7f7b2def994a30457b3d08852e1a1\",\"license\":\"MIT\"},\"contracts/utils/CommonErrors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { ContractType } from \\\"./ContractType.sol\\\";\\nimport { RoleAccess } from \\\"./RoleAccess.sol\\\";\\n\\n/**\\n * @dev Error indicating that the provided threshold is invalid for a specific function signature.\\n * @param msgSig The function signature (bytes4) that the invalid threshold applies to.\\n */\\nerror ErrInvalidThreshold(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a function can only be called by the contract itself.\\n * @param msgSig The function signature (bytes4) that can only be called by the contract itself.\\n */\\nerror ErrOnlySelfCall(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\\n * @param msgSig The function signature (bytes4) that the caller is unauthorized to perform.\\n * @param expectedRole The role required to perform the function.\\n */\\nerror ErrUnauthorized(bytes4 msgSig, RoleAccess expectedRole);\\n\\n/**\\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\\n * @param msgSig The function signature (bytes4).\\n * @param expectedContractType The contract type required to perform the function.\\n * @param actual The actual address that called to the function.\\n */\\nerror ErrUnexpectedInternalCall(bytes4 msgSig, ContractType expectedContractType, address actual);\\n\\n/**\\n * @dev Error indicating that an array is empty when it should contain elements.\\n */\\nerror ErrEmptyArray();\\n\\n/**\\n * @dev Error indicating a mismatch in the length of input parameters or arrays for a specific function.\\n * @param msgSig The function signature (bytes4) that has a length mismatch.\\n */\\nerror ErrLengthMismatch(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a proxy call to an external contract has failed.\\n * @param msgSig The function signature (bytes4) of the proxy call that failed.\\n * @param extCallSig The function signature (bytes4) of the external contract call that failed.\\n */\\nerror ErrProxyCallFailed(bytes4 msgSig, bytes4 extCallSig);\\n\\n/**\\n * @dev Error indicating that a function tried to call a precompiled contract that is not allowed.\\n * @param msgSig The function signature (bytes4) that attempted to call a precompiled contract.\\n */\\nerror ErrCallPrecompiled(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a native token transfer has failed.\\n * @param msgSig The function signature (bytes4) of the token transfer that failed.\\n */\\nerror ErrNativeTransferFailed(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that an order is invalid.\\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid order.\\n */\\nerror ErrInvalidOrder(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that the chain ID is invalid.\\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid chain ID.\\n * @param actual Current chain ID that executing function.\\n * @param expected Expected chain ID required for the tx to success.\\n */\\nerror ErrInvalidChainId(bytes4 msgSig, uint256 actual, uint256 expected);\\n\\n/**\\n * @dev Error indicating that a vote type is not supported.\\n * @param msgSig The function signature (bytes4) of the operation that encountered an unsupported vote type.\\n */\\nerror ErrUnsupportedVoteType(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that the proposal nonce is invalid.\\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid proposal nonce.\\n */\\nerror ErrInvalidProposalNonce(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a voter has already voted.\\n * @param voter The address of the voter who has already voted.\\n */\\nerror ErrAlreadyVoted(address voter);\\n\\n/**\\n * @dev Error indicating that a signature is invalid for a specific function signature.\\n * @param msgSig The function signature (bytes4) that encountered an invalid signature.\\n */\\nerror ErrInvalidSignatures(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a relay call has failed.\\n * @param msgSig The function signature (bytes4) of the relay call that failed.\\n */\\nerror ErrRelayFailed(bytes4 msgSig);\\n/**\\n * @dev Error indicating that a vote weight is invalid for a specific function signature.\\n * @param msgSig The function signature (bytes4) that encountered an invalid vote weight.\\n */\\nerror ErrInvalidVoteWeight(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a query was made for an outdated bridge operator set.\\n */\\nerror ErrQueryForOutdatedBridgeOperatorSet();\\n\\n/**\\n * @dev Error indicating that a request is invalid.\\n */\\nerror ErrInvalidRequest();\\n\\n/**\\n * @dev Error indicating that a token standard is invalid.\\n */\\nerror ErrInvalidTokenStandard();\\n\\n/**\\n * @dev Error indicating that a token is not supported.\\n */\\nerror ErrUnsupportedToken();\\n\\n/**\\n * @dev Error indicating that a receipt kind is invalid.\\n */\\nerror ErrInvalidReceiptKind();\\n\\n/**\\n * @dev Error indicating that a receipt is invalid.\\n */\\nerror ErrInvalidReceipt();\\n\",\"keccak256\":\"0xe0c75a4a82f3dc7dcf89dd5cab9ae1ec93c136b7d8210b3f9e18f3215aa69ffb\",\"license\":\"MIT\"},\"contracts/utils/ContractType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum ContractType {\\n /* 0 */ UNKNOWN,\\n /* 1 */ PAUSE_ENFORCER,\\n /* 2 */ BRIDGE,\\n /* 3 */ BRIDGE_TRACKING,\\n /* 4 */ GOVERNANCE_ADMIN,\\n /* 5 */ MAINTENANCE,\\n /* 6 */ SLASH_INDICATOR,\\n /* 7 */ STAKING_VESTING,\\n /* 8 */ VALIDATOR,\\n /* 9 */ STAKING,\\n /* 10 */ RONIN_TRUSTED_ORGANIZATION\\n}\\n\",\"keccak256\":\"0x65a0b062c8f963b4679a128abb3840167de1b10b32a8528787f47915a7d9ccc3\",\"license\":\"MIT\"},\"contracts/utils/DeprecatedSlots.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title Deprecated Contracts\\n * @dev These abstract contracts are deprecated and should not be used in new implementations.\\n * They provide functionality related to various aspects of a smart contract but have been marked\\n * as deprecated to indicate that they are no longer actively maintained or recommended for use.\\n * The purpose of these contracts is to preserve the slots for already deployed contracts.\\n */\\ncontract HasSlashIndicatorDeprecated {\\n /// @custom:deprecated Previously `_slashIndicatorContract` (non-zero value)\\n address internal ______deprecatedSlashIndicator;\\n}\\n\\ncontract HasStakingVestingDeprecated {\\n /// @custom:deprecated Previously `_stakingVestingContract` (non-zero value)\\n address internal ______deprecatedStakingVesting;\\n}\\n\\ncontract HasBridgeDeprecated {\\n /// @custom:deprecated Previously `_bridgeContract` (non-zero value)\\n address internal ______deprecatedBridge;\\n}\\n\\ncontract HasValidatorDeprecated {\\n /// @custom:deprecated Previously `_validatorContract` (non-zero value)\\n address internal ______deprecatedValidator;\\n}\\n\\ncontract HasStakingDeprecated {\\n /// @custom:deprecated Previously `_stakingContract` (non-zero value)\\n address internal ______deprecatedStakingContract;\\n}\\n\\ncontract HasMaintenanceDeprecated {\\n /// @custom:deprecated Previously `_maintenanceContract` (non-zero value)\\n address internal ______deprecatedMaintenance;\\n}\\n\\ncontract HasTrustedOrgDeprecated {\\n /// @custom:deprecated Previously `_trustedOrgContract` (non-zero value)\\n address internal ______deprecatedTrustedOrg;\\n}\\n\\ncontract HasGovernanceAdminDeprecated {\\n /// @custom:deprecated Previously `_governanceAdminContract` (non-zero value)\\n address internal ______deprecatedGovernanceAdmin;\\n}\\n\\ncontract HasBridgeTrackingDeprecated {\\n /// @custom:deprecated Previously `_bridgeTrackingContract` (non-zero value)\\n address internal ______deprecatedBridgeTracking;\\n}\\n\",\"keccak256\":\"0xe93504aed9f67a6d399475c7162560f2ac4f793fab5b67fe504fc694ac9a2892\",\"license\":\"MIT\"},\"contracts/utils/RoleAccess.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum RoleAccess {\\n /* 0 */ UNKNOWN,\\n /* 1 */ ADMIN,\\n /* 2 */ COINBASE,\\n /* 3 */ GOVERNOR,\\n /* 4 */ CANDIDATE_ADMIN,\\n /* 5 */ WITHDRAWAL_MIGRATOR,\\n /* 6 */ BRIDGE_OPERATOR,\\n /* 7 */ BLOCK_PRODUCER,\\n /* 8 */ VALIDATOR_CANDIDATE\\n}\\n\",\"keccak256\":\"0xb3e242a9cb967a64e0ef6419a6b260b647b40082102ce3ab899ab690c84957fe\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x60806040523480156200001157600080fd5b5060016000556200002162000027565b620000e9565b60d154610100900460ff1615620000945760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60d15460ff9081161015620000e75760d1805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b61391080620000f96000396000f3fe6080604052600436106102345760003560e01c806376664b651161012e578063acd79c46116100ab578063de981f1b1161006f578063de981f1b14610719578063e22d1c9d14610739578063e5376f5414610759578063f92ad2191461076c578063f9f031df1461078c57610246565b8063acd79c461461060f578063af24542914610622578063c2a672e014610637578063c508700314610657578063d01b8eed146106a857610246565b806391f8723f116100f257806391f8723f1461056f578063924f081e1461058f5780639488e4e9146105af578063969ffc14146105cf578063aa15a6fd146105ef57610246565b806376664b65146104c1578063865e6fd3146104e1578063888b9ae914610501578063895ab74214610521578063909791dd1461055a57610246565b806342ef3c34116101bc5780635cd8a76b116101805780635cd8a76b146104355780636558954f1461044a578063679a6e43146104615780636b091695146104815780636bd8f804146104a157610246565b806342ef3c341461039a5780634530d202146103ba5780634d99dd16146103e257806357473447146104025780635c19a95c1461042257610246565b80631658c86e116102035780631658c86e146102dc57806326476204146102fc5780632715805e1461030f5780633d8e846e1461032f57806342e0c4081461034f57610246565b806303827884146102515780630682e8fa1461027a578063095f64751461028f578063097e4a9d146102bc57610246565b36610246576008610244816107ac565b005b6008610244816107ac565b34801561025d57600080fd5b506102676104b081565b6040519081526020015b60405180910390f35b34801561028657600080fd5b50603854610267565b34801561029b57600080fd5b506102af6102aa366004613070565b610804565b6040516102719190613116565b3480156102c857600080fd5b506102676102d736600461313e565b61093c565b3480156102e857600080fd5b506102446102f7366004613194565b6109c2565b61024461030a366004613194565b610a66565b34801561031b57600080fd5b5061026761032a3660046131b8565b610a9f565b34801561033b57600080fd5b506102af61034a3660046131e4565b610b30565b34801561035b57600080fd5b5061038a61036a366004613194565b6001600160a01b039081166000908152603a602052604090205416151590565b6040519015158152602001610271565b3480156103a657600080fd5b506102af6103b5366004613238565b610c5e565b3480156103c657600080fd5b50606e54606d5460408051928352602083019190915201610271565b3480156103ee57600080fd5b506102446103fd3660046131b8565b610d2a565b34801561040e57600080fd5b5061024461041d366004613279565b610da6565b610244610430366004613194565b610db8565b34801561044157600080fd5b50610244610e26565b34801561045657600080fd5b506102676201518081565b34801561046d57600080fd5b5061024461047c36600461329b565b610ee5565b34801561048d57600080fd5b5061026761049c3660046132b4565b610ef6565b3480156104ad57600080fd5b506102446104bc3660046132ed565b610f18565b3480156104cd57600080fd5b506102676104dc3660046132b4565b610f9d565b3480156104ed57600080fd5b506102446104fc36600461333d565b610fcc565b34801561050d57600080fd5b5061024461051c36600461329b565b610fe7565b34801561052d57600080fd5b5061026761053c366004613194565b6001600160a01b031660009081526037602052604090206003015490565b34801561056657600080fd5b50606c54610267565b34801561057b57600080fd5b506102af61058a366004613238565b610ff8565b34801561059b57600080fd5b506102446105aa366004613359565b611098565b3480156105bb57600080fd5b506102446105ca366004613070565b611171565b3480156105db57600080fd5b506102446105ea36600461329b565b6112a0565b3480156105fb57600080fd5b5061024461060a366004613194565b6112b1565b61024461061d36600461338e565b611321565b34801561062e57600080fd5b50603954610267565b34801561064357600080fd5b506102446106523660046131b8565b611375565b34801561066357600080fd5b50610690610672366004613194565b6001600160a01b039081166000908152603a60205260409020541690565b6040516001600160a01b039091168152602001610271565b3480156106b457600080fd5b506106f46106c3366004613194565b6001600160a01b03808216600090815260376020526040902060018101546002820154600390920154921693909250565b604080516001600160a01b039094168452602084019290925290820152606001610271565b34801561072557600080fd5b50610690610734366004613401565b61142f565b34801561074557600080fd5b5061024461075436600461341c565b6114aa565b610244610767366004613467565b61166e565b34801561077857600080fd5b506102446107873660046134cb565b6117be565b34801561079857600080fd5b506102676107a7366004613238565b6118b5565b6107b58161142f565b6001600160a01b0316336001600160a01b031614610801576000356001600160e01b03191681336040516320e0f98d60e21b81526004016107f893929190613539565b60405180910390fd5b50565b6060838214610826576040516376081a7b60e11b815260040160405180910390fd5b836001600160401b0381111561083e5761083e613570565b604051908082528060200260200182016040528015610867578160200160208202803683370190505b50905060005b8151811015610933576037600087878481811061088c5761088c613586565b90506020020160208101906108a19190613194565b6001600160a01b03166001600160a01b0316815260200190815260200160002060040160008585848181106108d8576108d8613586565b90506020020160208101906108ed9190613194565b6001600160a01b03166001600160a01b031681526020019081526020016000205482828151811061092057610920613586565b602090810291909101015260010161086d565b50949350505050565b60006002600054036109605760405162461bcd60e51b81526004016107f89061359c565b60026000558161096f81611935565b336000908152603a60205260409020546001600160a01b0316156109a857604051632fc6bfb160e21b81523360048201526024016107f8565b6109b4338686866119d3565b600160005595945050505050565b806109cc81611935565b6001600160a01b0382166000908152603760205260409020336109ef8282611a40565b6109f9600861142f565b60395460405163dd716ad360e01b81526001600160a01b038781166004830152602482019290925291169063dd716ad3906044015b600060405180830381600087803b158015610a4857600080fd5b505af1158015610a5c573d6000803e3d6000fd5b5050505050505050565b610a6e611a70565b80610a7881611935565b6001600160a01b0382166000908152603760205260409020610a9b903334611a93565b5050565b60006008610aac816107ac565b6001600160a01b0384166000908152603760205260409020610ace9084611b3e565b915033610adb8184611bdb565b610b2857604080518481524760208201526001600160a01b0380841692908816917f63701cd972aa3c7f87898aab145c972e52185beab07d6e39380a998d334cf6c8910160405180910390a35b505092915050565b6060600080610b3f600861142f565b6001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba091906135d3565b9050836001600160401b03811115610bba57610bba613570565b604051908082528060200260200182016040528015610be3578160200160208202803683370190505b50925060005b84811015610c5457858582818110610c0357610c03613586565b9050602002016020810190610c189190613194565b9250610c2f838884610c2a878c610f9d565b611c37565b848281518110610c4157610c41613586565b6020908102919091010152600101610be9565b5050509392505050565b6060816001600160401b03811115610c7857610c78613570565b604051908082528060200260200182016040528015610ca1578160200160208202803683370190505b50905060005b82811015610d235760376000858584818110610cc557610cc5613586565b9050602002016020810190610cda9190613194565b6001600160a01b03166001600160a01b0316815260200190815260200160002060020154828281518110610d1057610d10613586565b6020908102919091010152600101610ca7565b5092915050565b600260005403610d4c5760405162461bcd60e51b81526004016107f89061359c565b600260009081556001600160a01b03831681526037602052604090203390610d75908284611d33565b610d7f8183611f6b565b610d9c57604051635ff7115760e11b815260040160405180910390fd5b5050600160005550565b610dae611fb3565b610a9b828261200d565b610dc0611a70565b80610dca81611935565b336000908152603a60205260409020546001600160a01b031615610e0357604051632fc6bfb160e21b81523360048201526024016107f8565b6001600160a01b0382166000908152603760205260409020610a9b903334612081565b60d154600290610100900460ff16158015610e48575060d15460ff8083169116105b610e645760405162461bcd60e51b81526004016107f8906135ec565b60d1805461ffff191660ff831617610100179055603654610e90906008906001600160a01b0316612130565b603680546001600160a01b031916905560d1805461ff001916905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a150565b610eed611fb3565b610801816121d4565b6000610f0f8383610f05612209565b610c2a8787610f9d565b90505b92915050565b600260005403610f3a5760405162461bcd60e51b81526004016107f89061359c565b600260005581610f4981611935565b6001600160a01b03841660009081526037602052604090203390610f6e908285611d33565b6001600160a01b0384166000908152603760205260409020610f91908285612081565b50506001600055505050565b6001600160a01b0391821660009081526037602090815260408083209390941682526004909201909152205490565b610fd4611fb3565b610fdd8161227b565b610a9b8282612130565b610fef611fb3565b610801816122b1565b6060816001600160401b0381111561101257611012613570565b60405190808252806020026020018201604052801561103b578160200160208202803683370190505b50905060005b82811015610d235761107384848381811061105e5761105e613586565b905060200201602081019061053c9190613194565b82828151811061108557611085613586565b6020908102919091010152600101611041565b826110a281611935565b6001600160a01b0384166000908152603760205260409020336110c58282611a40565b606d548411806110d65750606e5484105b156110f457604051631b8454a360e21b815260040160405180910390fd5b6110fe600861142f565b60405163e5125a1d60e01b81526001600160a01b0388811660048301526024820188905260448201879052919091169063e5125a1d90606401600060405180830381600087803b15801561115157600080fd5b505af1158015611165573d6000803e3d6000fd5b50505050505050505050565b6002600054036111935760405162461bcd60e51b81526004016107f89061359c565b60026000558215806111a55750828114155b156111c3576040516376081a7b60e11b815260040160405180910390fd5b336000805b8581101561126b578484828181106111e2576111e2613586565b90506020020135826111f49190613650565b91506112636037600089898581811061120f5761120f613586565b90506020020160208101906112249190613194565b6001600160a01b03166001600160a01b031681526020019081526020016000208487878581811061125757611257613586565b90506020020135611d33565b6001016111c8565b506112768282611f6b565b61129357604051635ff7115760e11b815260040160405180910390fd5b5050600160005550505050565b6112a8611fb3565b610801816122e6565b806112bb81611935565b6001600160a01b0382166000908152603760205260409020336112de8282611a40565b6112e8600861142f565b60395460405163a7c2f11960e01b81526001600160a01b038781166004830152602482019290925291169063a7c2f11990604401610a2e565b600861132c816107ac565b61136d86868080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525088925087915086905061231b565b505050505050565b6002600054036113975760405162461bcd60e51b81526004016107f89061359c565b6002600055816113a681611935565b816000036113c7576040516331d9f7d760e01b815260040160405180910390fd5b6001600160a01b038316600090815260376020526040812060028101543392906113f2908690613663565b9050606c548110156114175760405163ef0a995760e01b815260040160405180910390fd5b611422828487612749565b61127683866104b0612835565b60007fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb600083600a8111156114665761146661350f565b60ff1681526020810191909152604001600020546001600160a01b03169050806114a5578160405163409140df60e11b81526004016107f89190613676565b919050565b60086114b5816107ac565b82156116685760005b8381101561162d576000603760008787858181106114de576114de613586565b90506020020160208101906114f39190613194565b6001600160a01b0390811682526020808301939093526040918201600090812060018101549092168152603a909352912080546001600160a01b0319169055600281015490915080156115ba5761154a8282611b3e565b506001820154611566906001600160a01b0316826104b0612835565b6115ba5760018201548254604080518481524760208201526001600160a01b0393841693909216917f7dc5115a5aba081f5a174f56a3d02eea582824783322a4ac03f7bd388f444194910160405180910390a35b60006115fa8888868181106115d1576115d1613586565b90506020020160208101906115e69190613194565b60018501546001600160a01b031688612895565b9050801561161f57600183015461161d906001600160a01b0316826104b0612835565b505b8360010193505050506114be565b507f4f257d3ba23679d338f1d94296086bba5724af341b7fa31aa0ff297bfcdc62d8848460405161165f929190613684565b60405180910390a15b50505050565b6002600054036116905760405162461bcd60e51b81526004016107f89061359c565b60026000908155338152603a60205260409020546001600160a01b0316156116cd57604051632fc6bfb160e21b81523360048201526024016107f8565b606d548111806116de5750606e5481105b156116fc57604051631b8454a360e21b815260040160405180910390fd5b343361170d818888888888886129a7565b6001600160a01b0380871660008181526037602081815260408084206001810180549789166001600160a01b0319988916811790915581548816871782558552603a83529084208054909616851790955592909152905261176f818385611a93565b816001600160a01b0316876001600160a01b03167ffc1f1e73948cbc47c5b7f90e5601b7daccd9ad7173218486ccc74bdd051d05e860405160405180910390a350506001600055505050505050565b60d154610100900460ff16158080156117de575060d154600160ff909116105b806117f85750303b1580156117f8575060d15460ff166001145b6118145760405162461bcd60e51b81526004016107f8906135ec565b60d1805460ff1916600117905580156118375760d1805461ff0019166101001790555b611842600887612130565b61184b856121d4565b61185660008561200d565b61185f836122b1565b611868826122e6565b801561136d5760d1805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050505050565b60006002600054036118d95760405162461bcd60e51b81526004016107f89061359c565b600260008190555061191e33848480806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250612c4292505050565b905061192a3382612c93565b600160005592915050565b61193f600861142f565b604051635061f96960e11b81526001600160a01b038381166004830152919091169063a0c3f2d290602401602060405180830381865afa158015611987573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ab91906136d2565b61080157604051630fd0c64560e11b81526001600160a01b03821660048201526024016107f8565b6000611a1285858580806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250612c4292505050565b6001600160a01b0383166000908152603760205260409020909150611a38908683612081565b949350505050565b60018201546001600160a01b03828116911614610a9b57604051637bc65bd760e11b815260040160405180910390fd5b34600003611a9157604051636dfcbde560e11b815260040160405180910390fd5b565b8282611a9f8282611a40565b82856002016000828254611ab39190613650565b92505081905550611ad985858760020154868960030154611ad49190613650565b612cc8565b6001600160a01b03808516600090815260058701602052604090819020429055865490519116907f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d90611b2f9086815260200190565b60405180910390a25050505050565b6000611b4e836002015483612d03565b905080836002016000828254611b649190613663565b9091555050600183015460028401546003850154611b949286926001600160a01b0390911691611ad49086612d19565b82546040518281526001600160a01b03909116907f0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f759060200160405180910390a292915050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611c28576040519150601f19603f3d011682016040523d82523d6000602084013e611c2d565b606091505b5090949350505050565b6001600160a01b03808516600090815260026020908152604080832093871683529290529081206003810154849003611c7257549050611a38565b6001600160a01b038616600090815260036020818152604080842060018084528286209487015486529390925283209182015483929015611cd75780546001860154909450611cc19085613663565b8560020154611cd091906136f4565b9250611cdf565b846001015493505b8154600090611cef908690613663565b611cf990896136f4565b9050670de0b6b3a7640000611d0e8286613650565b611d18919061370b565b8654611d249190613650565b9b9a5050505050505050505050565b8282611d3f8282612d33565b82600003611d6057604051637ab0c6ad60e11b815260040160405180910390fd5b6001600160a01b0384166000908152600486016020526040902054831115611d9b57604051630695534560e31b815260040160405180910390fd5b6000611da7600861142f565b8654604051635061f96960e11b81526001600160a01b03918216600482015291925082169063a0c3f2d290602401602060405180830381865afa158015611df2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e1691906136d2565b8015611e90575085546040516328bde1e160e01b81526001600160a01b039182166004820152908216906328bde1e19060240160e060405180830381865afa158015611e66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e8a9190613738565b60a00151155b8015611ec357506038546001600160a01b03861660009081526005880160205260409020544291611ec091613650565b10155b15611ee15760405163f19f52bd60e01b815260040160405180910390fd5b6001600160a01b0385166000908152600487016020526040902054611f1f9087908790611f0f908890613663565b878a60030154611ad49190613663565b85546040518581526001600160a01b03918216918716907f4d10bd049775c77bd7f255195afba5088028ecb3c7c277d393ccff7934f2f92c9060200160405180910390a3505050505050565b600081471015611fa9576040516302631c4f60e61b81526001600160e01b0319600035166004820152476024820152604481018390526064016107f8565b610f0f8383611bdb565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b03163314611a91576000356001600160e01b0319166001604051620f948f60ea1b81526004016107f89291906137e3565b61271081118061201c57508082115b1561203a57604051631b8454a360e21b815260040160405180910390fd5b606d819055606e82905560408051838152602081018390527f677752f5bf9541b14288833909e5ec5a478103131c1ec08c4638943be5826c14910160405180910390a15050565b828261208d8282612d33565b6001600160a01b03841660009081526004860160205260409020546120cb90869086906120bb908790613650565b868960030154611ad49190613650565b6001600160a01b03808516600081815260058801602052604090819020429055875490519216917fe5541a6b6103d4fa7e021ed54fad39c66f27a76bd13d374cf6240ae6bd0bb72b906121219087815260200190565b60405180910390a35050505050565b807fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb600084600a8111156121665761216661350f565b60ff168152602081019190915260400160002080546001600160a01b0319166001600160a01b03928316179055811682600a8111156121a7576121a761350f565b6040517f865d1c228a8ea13709cfe61f346f7ff67f1bbd4a18ff31ad3e7147350d317c5990600090a35050565b606c8190556040518181527f372bbdb8d72373b0012f84ee5a11671e5fb72b8bea902ebca93a19cb45d32be290602001610eda565b6000612215600861142f565b6001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa158015612252573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061227691906135d3565b905090565b806001600160a01b03163b60000361080157604051630bfc64a360e21b81526001600160a01b03821660048201526024016107f8565b60388190556040518181527f4956b65267b8f1e642284bcb5037116c69a9c78d9ca576beeae0974737a4872a90602001610eda565b60398190556040518181527f02be0b73b597f2c0f138aebee162b3b0e25d5b5a26854c15dcf79176e9a1c67890602001610eda565b8351821461236457807fae52c603227f64e4c6101dde593aa9790a16b3ac77546bd746d758511e9560a58585856040516123579392919061384a565b60405180910390a2611668565b600080600080600088516001600160401b0381111561238557612385613570565b6040519080825280602002602001820160405280156123ae578160200160208202803683370190505b509050600089516001600160401b038111156123cc576123cc613570565b6040519080825280602002602001820160405280156123f5578160200160208202803683370190505b50905060008a516001600160401b0381111561241357612413613570565b60405190808252806020026020018201604052801561243c578160200160208202803683370190505b50905060005b8b518110156126af578b818151811061245d5761245d613586565b6020908102919091018101516001600160a01b038116600090815260038084526040808320603790955290912001549097506001600160a01b03881660009081526001602081815260408084208f855290915290912001549096508a90036124fe57868389806001019a50815181106124d8576124d8613586565b60200260200101906001600160a01b031690816001600160a01b0316815250505061269d565b60028101548a111561252c57604080518082019091528681526020018a905260018101869055600281018a90555b6001810154156125765760018101548c8c8481811061254d5761254d613586565b90506020020135670de0b6b3a764000061256791906136f4565b612571919061370b565b612579565b60005b98508881600001600082825461258f9190613650565b91829055509050856125a18a85613663565b815181106125b1576125b1613586565b6020026020010181815250506040518060400160405280826000015481526020018b81525060016000896001600160a01b03166001600160a01b0316815260200190815260200160002060008c8152602001908152602001600020600082015181600001556020820151816001015590505085816001016000018190555080600101600001548489846126449190613663565b8151811061265457612654613586565b6020908102919091010152868d61266b8a85613663565b8151811061267b5761267b613586565b60200260200101906001600160a01b031690816001600160a01b031681525050505b806126a781613894565b915050612442565b5085156126f857858152858b51038b52877fee74f10cc50bf4b7e57fd36be7d46288795f3a9151dae97505b718b392ba14a3826040516126ef91906138ad565b60405180910390a25b8a511561273c57877f0e54e0485f70f0f63bc25889ddbf01ce1269ad6f07fdb2df573a0fbdb4d66f888c8585604051612733939291906138c0565b60405180910390a25b5050505050505050505050565b82826127558282611a40565b846002015483111561277a57604051630a8d7fa760e21b815260040160405180910390fd5b6038546001600160a01b038516600090815260058701602052604090205442916127a391613650565b11156127c2576040516303db082960e11b815260040160405180910390fd5b828560020160008282546127d69190613663565b925050819055506127f785858760020154868960030154611ad49190613663565b84546040518481526001600160a01b03909116907f0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f7590602001611b2f565b6000836001600160a01b0316838390604051600060405180830381858888f193505050503d8060008114612885576040519150601f19603f3d011682016040523d82523d6000602084013e61288a565b606091505b509095945050505050565b6000806128a28585610f9d565b90506128b085858584611c37565b9150836001600160a01b0316856001600160a01b03167f0aa4d283470c904c551d18bb894d37e17674920f3261a7f854be501e25f421b7846040516128f791815260200190565b60405180910390a36001600160a01b038086166000818152600260209081526040808320948916835293815283822082815592825260039052919091206129419082868580612d63565b60038181018590556001600160a01b03878116600081815260209384526040808220546001870155519081529188169290917faa7c29611027fd4be148712bb54960253b7a7d5998c17769bfc424c2f5f185ad910160405180910390a350509392505050565b6129b58760006104b0612835565b612a00576040805163338f030160e01b81526001600160a01b03891660048201526024810191909152600a6044820152693837b7b61030b236b4b760b11b60648201526084016107f8565b612a0e8460006104b0612835565b612a57576040805163338f030160e01b81526001600160a01b038616600482015260248101919091526008604482015267747265617375727960c01b60648201526084016107f8565b606c54811015612a7a57604051630a8d7fa760e21b815260040160405180910390fd5b856001600160a01b0316876001600160a01b0316141580612aad5750836001600160a01b0316866001600160a01b031614155b15612acb5760405163dc1d04ff60e01b815260040160405180910390fd5b60408051600380825260808201909252600091602082016060803683370190505090508781600081518110612b0257612b02613586565b60200260200101906001600160a01b031690816001600160a01b0316815250508581600181518110612b3657612b36613586565b60200260200101906001600160a01b031690816001600160a01b0316815250508381600281518110612b6a57612b6a613586565b60200260200101906001600160a01b031690816001600160a01b031681525050612b9381612df5565b15612bbf57604051630d697db160e11b81526001600160e01b03196000351660048201526024016107f8565b50612bca600861142f565b6040516302209ca560e31b81526001600160a01b038881166004830152878116602483015286811660448301528581166064830152608482018590529190911690631104e5289060a401600060405180830381600087803b158015612c2e57600080fd5b505af115801561273c573d6000803e3d6000fd5b600080612c4d612209565b905060005b8351811015610b2857612c7f848281518110612c7057612c70613586565b60200260200101518684612895565b612c899084613650565b9250600101612c52565b612c9d8282611f6b565b610a9b576040516303b97b7760e41b81526001600160e01b03196000351660048201526024016107f8565b8354612cde906001600160a01b03168484612e94565b60038401556001600160a01b0390911660009081526004909201602052604090912055565b6000818310612d125781610f0f565b5090919050565b6000818311612d29576000610f0f565b610f0f8284613663565b60018201546001600160a01b03808316911603610a9b57604051639feb934760e01b815260040160405180910390fd5b8284600301541015612d7757600284018190555b6000612d87856002015484612d03565b90506000818660020154612d9b9190613663565b90508015612dec57600286018290556001870154811115612dcf576040516352e521bf60e11b815260040160405180910390fd5b80876001016000016000828254612de69190613663565b90915550505b50505050505050565b60008151600003612e0857506000919050565b60005b6001835103811015612e8b57600181015b8351811015612e8257838181518110612e3757612e37613586565b60200260200101516001600160a01b0316848381518110612e5a57612e5a613586565b60200260200101516001600160a01b031603612e7a575060019392505050565b600101612e1c565b50600101612e0b565b50600092915050565b6000612e9e612209565b6001600160a01b0385166000908152600360205260409020600181015460028201549293509091831115612f12576040518060400160405280612ef9886001600160a01b031660009081526037602052604090206003015490565b8152602090810185905281516001850155015160028301555b6001600160a01b038087166000908152600260209081526040808320938916835292905290812090612f448888610f9d565b90506000612f5489898885611c37565b83549091508114612fa6578083556040518181526001600160a01b0389811691908b16907faa7c29611027fd4be148712bb54960253b7a7d5998c17769bfc424c2f5f185ad9060200160405180910390a35b612fb38584888a86612d63565b845460018085019190915560038401879055850154841461301a57886001600160a01b0316867f81faf50e2aaf52eaba2ab841071efb9f6f0850a3e7d008b1336e6001d3d4963c876001016000015460405161301191815260200190565b60405180910390a35b505050505050505050565b60008083601f84011261303757600080fd5b5081356001600160401b0381111561304e57600080fd5b6020830191508360208260051b850101111561306957600080fd5b9250929050565b6000806000806040858703121561308657600080fd5b84356001600160401b038082111561309d57600080fd5b6130a988838901613025565b909650945060208701359150808211156130c257600080fd5b506130cf87828801613025565b95989497509550505050565b600081518084526020808501945080840160005b8381101561310b578151875295820195908201906001016130ef565b509495945050505050565b602081526000610f0f60208301846130db565b6001600160a01b038116811461080157600080fd5b60008060006040848603121561315357600080fd5b83356001600160401b0381111561316957600080fd5b61317586828701613025565b909450925050602084013561318981613129565b809150509250925092565b6000602082840312156131a657600080fd5b81356131b181613129565b9392505050565b600080604083850312156131cb57600080fd5b82356131d681613129565b946020939093013593505050565b6000806000604084860312156131f957600080fd5b833561320481613129565b925060208401356001600160401b0381111561321f57600080fd5b61322b86828701613025565b9497909650939450505050565b6000806020838503121561324b57600080fd5b82356001600160401b0381111561326157600080fd5b61326d85828601613025565b90969095509350505050565b6000806040838503121561328c57600080fd5b50508035926020909101359150565b6000602082840312156132ad57600080fd5b5035919050565b600080604083850312156132c757600080fd5b82356132d281613129565b915060208301356132e281613129565b809150509250929050565b60008060006060848603121561330257600080fd5b833561330d81613129565b9250602084013561331d81613129565b929592945050506040919091013590565b8035600b81106114a557600080fd5b6000806040838503121561335057600080fd5b6132d28361332e565b60008060006060848603121561336e57600080fd5b833561337981613129565b95602085013595506040909401359392505050565b6000806000806000606086880312156133a657600080fd5b85356001600160401b03808211156133bd57600080fd5b6133c989838a01613025565b909750955060208801359150808211156133e257600080fd5b506133ef88828901613025565b96999598509660400135949350505050565b60006020828403121561341357600080fd5b610f0f8261332e565b60008060006040848603121561343157600080fd5b83356001600160401b0381111561344757600080fd5b61345386828701613025565b909790965060209590950135949350505050565b600080600080600060a0868803121561347f57600080fd5b853561348a81613129565b9450602086013561349a81613129565b935060408601356134aa81613129565b925060608601356134ba81613129565b949793965091946080013592915050565b600080600080600060a086880312156134e357600080fd5b85356134ee81613129565b97602087013597506040870135966060810135965060800135945092505050565b634e487b7160e01b600052602160045260246000fd5b600b81106135355761353561350f565b9052565b6001600160e01b031984168152606081016135576020830185613525565b6001600160a01b03929092166040919091015292915050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6000602082840312156135e557600080fd5b5051919050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b80820180821115610f1257610f1261363a565b81810381811115610f1257610f1261363a565b60208101610f128284613525565b60208082528181018390526000908460408401835b868110156136c75782356136ac81613129565b6001600160a01b031682529183019190830190600101613699565b509695505050505050565b6000602082840312156136e457600080fd5b815180151581146131b157600080fd5b8082028115828204841417610f1257610f1261363a565b60008261372857634e487b7160e01b600052601260045260246000fd5b500490565b80516114a581613129565b600060e0828403121561374a57600080fd5b60405160e081018181106001600160401b038211171561377a57634e487b7160e01b600052604160045260246000fd5b6040526137868361372d565b81526137946020840161372d565b60208201526137a56040840161372d565b60408201526137b66060840161372d565b60608201526080830151608082015260a083015160a082015260c083015160c08201528091505092915050565b6001600160e01b03198316815260408101600983106138045761380461350f565b8260208301529392505050565b600081518084526020808501945080840160005b8381101561310b5781516001600160a01b031687529582019590820190600101613825565b60408152600061385d6040830186613811565b82810360208401528381526001600160fb1b0384111561387c57600080fd5b8360051b808660208401370160200195945050505050565b6000600182016138a6576138a661363a565b5060010190565b602081526000610f0f6020830184613811565b6060815260006138d36060830186613811565b82810360208401526138e581866130db565b905082810360408401526138f981856130db565b969550505050505056fea164736f6c6343000811000a", - "deployedBytecode": "0x6080604052600436106102345760003560e01c806376664b651161012e578063acd79c46116100ab578063de981f1b1161006f578063de981f1b14610719578063e22d1c9d14610739578063e5376f5414610759578063f92ad2191461076c578063f9f031df1461078c57610246565b8063acd79c461461060f578063af24542914610622578063c2a672e014610637578063c508700314610657578063d01b8eed146106a857610246565b806391f8723f116100f257806391f8723f1461056f578063924f081e1461058f5780639488e4e9146105af578063969ffc14146105cf578063aa15a6fd146105ef57610246565b806376664b65146104c1578063865e6fd3146104e1578063888b9ae914610501578063895ab74214610521578063909791dd1461055a57610246565b806342ef3c34116101bc5780635cd8a76b116101805780635cd8a76b146104355780636558954f1461044a578063679a6e43146104615780636b091695146104815780636bd8f804146104a157610246565b806342ef3c341461039a5780634530d202146103ba5780634d99dd16146103e257806357473447146104025780635c19a95c1461042257610246565b80631658c86e116102035780631658c86e146102dc57806326476204146102fc5780632715805e1461030f5780633d8e846e1461032f57806342e0c4081461034f57610246565b806303827884146102515780630682e8fa1461027a578063095f64751461028f578063097e4a9d146102bc57610246565b36610246576008610244816107ac565b005b6008610244816107ac565b34801561025d57600080fd5b506102676104b081565b6040519081526020015b60405180910390f35b34801561028657600080fd5b50603854610267565b34801561029b57600080fd5b506102af6102aa366004613070565b610804565b6040516102719190613116565b3480156102c857600080fd5b506102676102d736600461313e565b61093c565b3480156102e857600080fd5b506102446102f7366004613194565b6109c2565b61024461030a366004613194565b610a66565b34801561031b57600080fd5b5061026761032a3660046131b8565b610a9f565b34801561033b57600080fd5b506102af61034a3660046131e4565b610b30565b34801561035b57600080fd5b5061038a61036a366004613194565b6001600160a01b039081166000908152603a602052604090205416151590565b6040519015158152602001610271565b3480156103a657600080fd5b506102af6103b5366004613238565b610c5e565b3480156103c657600080fd5b50606e54606d5460408051928352602083019190915201610271565b3480156103ee57600080fd5b506102446103fd3660046131b8565b610d2a565b34801561040e57600080fd5b5061024461041d366004613279565b610da6565b610244610430366004613194565b610db8565b34801561044157600080fd5b50610244610e26565b34801561045657600080fd5b506102676201518081565b34801561046d57600080fd5b5061024461047c36600461329b565b610ee5565b34801561048d57600080fd5b5061026761049c3660046132b4565b610ef6565b3480156104ad57600080fd5b506102446104bc3660046132ed565b610f18565b3480156104cd57600080fd5b506102676104dc3660046132b4565b610f9d565b3480156104ed57600080fd5b506102446104fc36600461333d565b610fcc565b34801561050d57600080fd5b5061024461051c36600461329b565b610fe7565b34801561052d57600080fd5b5061026761053c366004613194565b6001600160a01b031660009081526037602052604090206003015490565b34801561056657600080fd5b50606c54610267565b34801561057b57600080fd5b506102af61058a366004613238565b610ff8565b34801561059b57600080fd5b506102446105aa366004613359565b611098565b3480156105bb57600080fd5b506102446105ca366004613070565b611171565b3480156105db57600080fd5b506102446105ea36600461329b565b6112a0565b3480156105fb57600080fd5b5061024461060a366004613194565b6112b1565b61024461061d36600461338e565b611321565b34801561062e57600080fd5b50603954610267565b34801561064357600080fd5b506102446106523660046131b8565b611375565b34801561066357600080fd5b50610690610672366004613194565b6001600160a01b039081166000908152603a60205260409020541690565b6040516001600160a01b039091168152602001610271565b3480156106b457600080fd5b506106f46106c3366004613194565b6001600160a01b03808216600090815260376020526040902060018101546002820154600390920154921693909250565b604080516001600160a01b039094168452602084019290925290820152606001610271565b34801561072557600080fd5b50610690610734366004613401565b61142f565b34801561074557600080fd5b5061024461075436600461341c565b6114aa565b610244610767366004613467565b61166e565b34801561077857600080fd5b506102446107873660046134cb565b6117be565b34801561079857600080fd5b506102676107a7366004613238565b6118b5565b6107b58161142f565b6001600160a01b0316336001600160a01b031614610801576000356001600160e01b03191681336040516320e0f98d60e21b81526004016107f893929190613539565b60405180910390fd5b50565b6060838214610826576040516376081a7b60e11b815260040160405180910390fd5b836001600160401b0381111561083e5761083e613570565b604051908082528060200260200182016040528015610867578160200160208202803683370190505b50905060005b8151811015610933576037600087878481811061088c5761088c613586565b90506020020160208101906108a19190613194565b6001600160a01b03166001600160a01b0316815260200190815260200160002060040160008585848181106108d8576108d8613586565b90506020020160208101906108ed9190613194565b6001600160a01b03166001600160a01b031681526020019081526020016000205482828151811061092057610920613586565b602090810291909101015260010161086d565b50949350505050565b60006002600054036109605760405162461bcd60e51b81526004016107f89061359c565b60026000558161096f81611935565b336000908152603a60205260409020546001600160a01b0316156109a857604051632fc6bfb160e21b81523360048201526024016107f8565b6109b4338686866119d3565b600160005595945050505050565b806109cc81611935565b6001600160a01b0382166000908152603760205260409020336109ef8282611a40565b6109f9600861142f565b60395460405163dd716ad360e01b81526001600160a01b038781166004830152602482019290925291169063dd716ad3906044015b600060405180830381600087803b158015610a4857600080fd5b505af1158015610a5c573d6000803e3d6000fd5b5050505050505050565b610a6e611a70565b80610a7881611935565b6001600160a01b0382166000908152603760205260409020610a9b903334611a93565b5050565b60006008610aac816107ac565b6001600160a01b0384166000908152603760205260409020610ace9084611b3e565b915033610adb8184611bdb565b610b2857604080518481524760208201526001600160a01b0380841692908816917f63701cd972aa3c7f87898aab145c972e52185beab07d6e39380a998d334cf6c8910160405180910390a35b505092915050565b6060600080610b3f600861142f565b6001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba091906135d3565b9050836001600160401b03811115610bba57610bba613570565b604051908082528060200260200182016040528015610be3578160200160208202803683370190505b50925060005b84811015610c5457858582818110610c0357610c03613586565b9050602002016020810190610c189190613194565b9250610c2f838884610c2a878c610f9d565b611c37565b848281518110610c4157610c41613586565b6020908102919091010152600101610be9565b5050509392505050565b6060816001600160401b03811115610c7857610c78613570565b604051908082528060200260200182016040528015610ca1578160200160208202803683370190505b50905060005b82811015610d235760376000858584818110610cc557610cc5613586565b9050602002016020810190610cda9190613194565b6001600160a01b03166001600160a01b0316815260200190815260200160002060020154828281518110610d1057610d10613586565b6020908102919091010152600101610ca7565b5092915050565b600260005403610d4c5760405162461bcd60e51b81526004016107f89061359c565b600260009081556001600160a01b03831681526037602052604090203390610d75908284611d33565b610d7f8183611f6b565b610d9c57604051635ff7115760e11b815260040160405180910390fd5b5050600160005550565b610dae611fb3565b610a9b828261200d565b610dc0611a70565b80610dca81611935565b336000908152603a60205260409020546001600160a01b031615610e0357604051632fc6bfb160e21b81523360048201526024016107f8565b6001600160a01b0382166000908152603760205260409020610a9b903334612081565b60d154600290610100900460ff16158015610e48575060d15460ff8083169116105b610e645760405162461bcd60e51b81526004016107f8906135ec565b60d1805461ffff191660ff831617610100179055603654610e90906008906001600160a01b0316612130565b603680546001600160a01b031916905560d1805461ff001916905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a150565b610eed611fb3565b610801816121d4565b6000610f0f8383610f05612209565b610c2a8787610f9d565b90505b92915050565b600260005403610f3a5760405162461bcd60e51b81526004016107f89061359c565b600260005581610f4981611935565b6001600160a01b03841660009081526037602052604090203390610f6e908285611d33565b6001600160a01b0384166000908152603760205260409020610f91908285612081565b50506001600055505050565b6001600160a01b0391821660009081526037602090815260408083209390941682526004909201909152205490565b610fd4611fb3565b610fdd8161227b565b610a9b8282612130565b610fef611fb3565b610801816122b1565b6060816001600160401b0381111561101257611012613570565b60405190808252806020026020018201604052801561103b578160200160208202803683370190505b50905060005b82811015610d235761107384848381811061105e5761105e613586565b905060200201602081019061053c9190613194565b82828151811061108557611085613586565b6020908102919091010152600101611041565b826110a281611935565b6001600160a01b0384166000908152603760205260409020336110c58282611a40565b606d548411806110d65750606e5484105b156110f457604051631b8454a360e21b815260040160405180910390fd5b6110fe600861142f565b60405163e5125a1d60e01b81526001600160a01b0388811660048301526024820188905260448201879052919091169063e5125a1d90606401600060405180830381600087803b15801561115157600080fd5b505af1158015611165573d6000803e3d6000fd5b50505050505050505050565b6002600054036111935760405162461bcd60e51b81526004016107f89061359c565b60026000558215806111a55750828114155b156111c3576040516376081a7b60e11b815260040160405180910390fd5b336000805b8581101561126b578484828181106111e2576111e2613586565b90506020020135826111f49190613650565b91506112636037600089898581811061120f5761120f613586565b90506020020160208101906112249190613194565b6001600160a01b03166001600160a01b031681526020019081526020016000208487878581811061125757611257613586565b90506020020135611d33565b6001016111c8565b506112768282611f6b565b61129357604051635ff7115760e11b815260040160405180910390fd5b5050600160005550505050565b6112a8611fb3565b610801816122e6565b806112bb81611935565b6001600160a01b0382166000908152603760205260409020336112de8282611a40565b6112e8600861142f565b60395460405163a7c2f11960e01b81526001600160a01b038781166004830152602482019290925291169063a7c2f11990604401610a2e565b600861132c816107ac565b61136d86868080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525088925087915086905061231b565b505050505050565b6002600054036113975760405162461bcd60e51b81526004016107f89061359c565b6002600055816113a681611935565b816000036113c7576040516331d9f7d760e01b815260040160405180910390fd5b6001600160a01b038316600090815260376020526040812060028101543392906113f2908690613663565b9050606c548110156114175760405163ef0a995760e01b815260040160405180910390fd5b611422828487612749565b61127683866104b0612835565b60007fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb600083600a8111156114665761146661350f565b60ff1681526020810191909152604001600020546001600160a01b03169050806114a5578160405163409140df60e11b81526004016107f89190613676565b919050565b60086114b5816107ac565b82156116685760005b8381101561162d576000603760008787858181106114de576114de613586565b90506020020160208101906114f39190613194565b6001600160a01b0390811682526020808301939093526040918201600090812060018101549092168152603a909352912080546001600160a01b0319169055600281015490915080156115ba5761154a8282611b3e565b506001820154611566906001600160a01b0316826104b0612835565b6115ba5760018201548254604080518481524760208201526001600160a01b0393841693909216917f7dc5115a5aba081f5a174f56a3d02eea582824783322a4ac03f7bd388f444194910160405180910390a35b60006115fa8888868181106115d1576115d1613586565b90506020020160208101906115e69190613194565b60018501546001600160a01b031688612895565b9050801561161f57600183015461161d906001600160a01b0316826104b0612835565b505b8360010193505050506114be565b507f4f257d3ba23679d338f1d94296086bba5724af341b7fa31aa0ff297bfcdc62d8848460405161165f929190613684565b60405180910390a15b50505050565b6002600054036116905760405162461bcd60e51b81526004016107f89061359c565b60026000908155338152603a60205260409020546001600160a01b0316156116cd57604051632fc6bfb160e21b81523360048201526024016107f8565b606d548111806116de5750606e5481105b156116fc57604051631b8454a360e21b815260040160405180910390fd5b343361170d818888888888886129a7565b6001600160a01b0380871660008181526037602081815260408084206001810180549789166001600160a01b0319988916811790915581548816871782558552603a83529084208054909616851790955592909152905261176f818385611a93565b816001600160a01b0316876001600160a01b03167ffc1f1e73948cbc47c5b7f90e5601b7daccd9ad7173218486ccc74bdd051d05e860405160405180910390a350506001600055505050505050565b60d154610100900460ff16158080156117de575060d154600160ff909116105b806117f85750303b1580156117f8575060d15460ff166001145b6118145760405162461bcd60e51b81526004016107f8906135ec565b60d1805460ff1916600117905580156118375760d1805461ff0019166101001790555b611842600887612130565b61184b856121d4565b61185660008561200d565b61185f836122b1565b611868826122e6565b801561136d5760d1805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050505050565b60006002600054036118d95760405162461bcd60e51b81526004016107f89061359c565b600260008190555061191e33848480806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250612c4292505050565b905061192a3382612c93565b600160005592915050565b61193f600861142f565b604051635061f96960e11b81526001600160a01b038381166004830152919091169063a0c3f2d290602401602060405180830381865afa158015611987573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ab91906136d2565b61080157604051630fd0c64560e11b81526001600160a01b03821660048201526024016107f8565b6000611a1285858580806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250612c4292505050565b6001600160a01b0383166000908152603760205260409020909150611a38908683612081565b949350505050565b60018201546001600160a01b03828116911614610a9b57604051637bc65bd760e11b815260040160405180910390fd5b34600003611a9157604051636dfcbde560e11b815260040160405180910390fd5b565b8282611a9f8282611a40565b82856002016000828254611ab39190613650565b92505081905550611ad985858760020154868960030154611ad49190613650565b612cc8565b6001600160a01b03808516600090815260058701602052604090819020429055865490519116907f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d90611b2f9086815260200190565b60405180910390a25050505050565b6000611b4e836002015483612d03565b905080836002016000828254611b649190613663565b9091555050600183015460028401546003850154611b949286926001600160a01b0390911691611ad49086612d19565b82546040518281526001600160a01b03909116907f0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f759060200160405180910390a292915050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611c28576040519150601f19603f3d011682016040523d82523d6000602084013e611c2d565b606091505b5090949350505050565b6001600160a01b03808516600090815260026020908152604080832093871683529290529081206003810154849003611c7257549050611a38565b6001600160a01b038616600090815260036020818152604080842060018084528286209487015486529390925283209182015483929015611cd75780546001860154909450611cc19085613663565b8560020154611cd091906136f4565b9250611cdf565b846001015493505b8154600090611cef908690613663565b611cf990896136f4565b9050670de0b6b3a7640000611d0e8286613650565b611d18919061370b565b8654611d249190613650565b9b9a5050505050505050505050565b8282611d3f8282612d33565b82600003611d6057604051637ab0c6ad60e11b815260040160405180910390fd5b6001600160a01b0384166000908152600486016020526040902054831115611d9b57604051630695534560e31b815260040160405180910390fd5b6000611da7600861142f565b8654604051635061f96960e11b81526001600160a01b03918216600482015291925082169063a0c3f2d290602401602060405180830381865afa158015611df2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e1691906136d2565b8015611e90575085546040516328bde1e160e01b81526001600160a01b039182166004820152908216906328bde1e19060240160e060405180830381865afa158015611e66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e8a9190613738565b60a00151155b8015611ec357506038546001600160a01b03861660009081526005880160205260409020544291611ec091613650565b10155b15611ee15760405163f19f52bd60e01b815260040160405180910390fd5b6001600160a01b0385166000908152600487016020526040902054611f1f9087908790611f0f908890613663565b878a60030154611ad49190613663565b85546040518581526001600160a01b03918216918716907f4d10bd049775c77bd7f255195afba5088028ecb3c7c277d393ccff7934f2f92c9060200160405180910390a3505050505050565b600081471015611fa9576040516302631c4f60e61b81526001600160e01b0319600035166004820152476024820152604481018390526064016107f8565b610f0f8383611bdb565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b03163314611a91576000356001600160e01b0319166001604051620f948f60ea1b81526004016107f89291906137e3565b61271081118061201c57508082115b1561203a57604051631b8454a360e21b815260040160405180910390fd5b606d819055606e82905560408051838152602081018390527f677752f5bf9541b14288833909e5ec5a478103131c1ec08c4638943be5826c14910160405180910390a15050565b828261208d8282612d33565b6001600160a01b03841660009081526004860160205260409020546120cb90869086906120bb908790613650565b868960030154611ad49190613650565b6001600160a01b03808516600081815260058801602052604090819020429055875490519216917fe5541a6b6103d4fa7e021ed54fad39c66f27a76bd13d374cf6240ae6bd0bb72b906121219087815260200190565b60405180910390a35050505050565b807fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb600084600a8111156121665761216661350f565b60ff168152602081019190915260400160002080546001600160a01b0319166001600160a01b03928316179055811682600a8111156121a7576121a761350f565b6040517f865d1c228a8ea13709cfe61f346f7ff67f1bbd4a18ff31ad3e7147350d317c5990600090a35050565b606c8190556040518181527f372bbdb8d72373b0012f84ee5a11671e5fb72b8bea902ebca93a19cb45d32be290602001610eda565b6000612215600861142f565b6001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa158015612252573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061227691906135d3565b905090565b806001600160a01b03163b60000361080157604051630bfc64a360e21b81526001600160a01b03821660048201526024016107f8565b60388190556040518181527f4956b65267b8f1e642284bcb5037116c69a9c78d9ca576beeae0974737a4872a90602001610eda565b60398190556040518181527f02be0b73b597f2c0f138aebee162b3b0e25d5b5a26854c15dcf79176e9a1c67890602001610eda565b8351821461236457807fae52c603227f64e4c6101dde593aa9790a16b3ac77546bd746d758511e9560a58585856040516123579392919061384a565b60405180910390a2611668565b600080600080600088516001600160401b0381111561238557612385613570565b6040519080825280602002602001820160405280156123ae578160200160208202803683370190505b509050600089516001600160401b038111156123cc576123cc613570565b6040519080825280602002602001820160405280156123f5578160200160208202803683370190505b50905060008a516001600160401b0381111561241357612413613570565b60405190808252806020026020018201604052801561243c578160200160208202803683370190505b50905060005b8b518110156126af578b818151811061245d5761245d613586565b6020908102919091018101516001600160a01b038116600090815260038084526040808320603790955290912001549097506001600160a01b03881660009081526001602081815260408084208f855290915290912001549096508a90036124fe57868389806001019a50815181106124d8576124d8613586565b60200260200101906001600160a01b031690816001600160a01b0316815250505061269d565b60028101548a111561252c57604080518082019091528681526020018a905260018101869055600281018a90555b6001810154156125765760018101548c8c8481811061254d5761254d613586565b90506020020135670de0b6b3a764000061256791906136f4565b612571919061370b565b612579565b60005b98508881600001600082825461258f9190613650565b91829055509050856125a18a85613663565b815181106125b1576125b1613586565b6020026020010181815250506040518060400160405280826000015481526020018b81525060016000896001600160a01b03166001600160a01b0316815260200190815260200160002060008c8152602001908152602001600020600082015181600001556020820151816001015590505085816001016000018190555080600101600001548489846126449190613663565b8151811061265457612654613586565b6020908102919091010152868d61266b8a85613663565b8151811061267b5761267b613586565b60200260200101906001600160a01b031690816001600160a01b031681525050505b806126a781613894565b915050612442565b5085156126f857858152858b51038b52877fee74f10cc50bf4b7e57fd36be7d46288795f3a9151dae97505b718b392ba14a3826040516126ef91906138ad565b60405180910390a25b8a511561273c57877f0e54e0485f70f0f63bc25889ddbf01ce1269ad6f07fdb2df573a0fbdb4d66f888c8585604051612733939291906138c0565b60405180910390a25b5050505050505050505050565b82826127558282611a40565b846002015483111561277a57604051630a8d7fa760e21b815260040160405180910390fd5b6038546001600160a01b038516600090815260058701602052604090205442916127a391613650565b11156127c2576040516303db082960e11b815260040160405180910390fd5b828560020160008282546127d69190613663565b925050819055506127f785858760020154868960030154611ad49190613663565b84546040518481526001600160a01b03909116907f0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f7590602001611b2f565b6000836001600160a01b0316838390604051600060405180830381858888f193505050503d8060008114612885576040519150601f19603f3d011682016040523d82523d6000602084013e61288a565b606091505b509095945050505050565b6000806128a28585610f9d565b90506128b085858584611c37565b9150836001600160a01b0316856001600160a01b03167f0aa4d283470c904c551d18bb894d37e17674920f3261a7f854be501e25f421b7846040516128f791815260200190565b60405180910390a36001600160a01b038086166000818152600260209081526040808320948916835293815283822082815592825260039052919091206129419082868580612d63565b60038181018590556001600160a01b03878116600081815260209384526040808220546001870155519081529188169290917faa7c29611027fd4be148712bb54960253b7a7d5998c17769bfc424c2f5f185ad910160405180910390a350509392505050565b6129b58760006104b0612835565b612a00576040805163338f030160e01b81526001600160a01b03891660048201526024810191909152600a6044820152693837b7b61030b236b4b760b11b60648201526084016107f8565b612a0e8460006104b0612835565b612a57576040805163338f030160e01b81526001600160a01b038616600482015260248101919091526008604482015267747265617375727960c01b60648201526084016107f8565b606c54811015612a7a57604051630a8d7fa760e21b815260040160405180910390fd5b856001600160a01b0316876001600160a01b0316141580612aad5750836001600160a01b0316866001600160a01b031614155b15612acb5760405163dc1d04ff60e01b815260040160405180910390fd5b60408051600380825260808201909252600091602082016060803683370190505090508781600081518110612b0257612b02613586565b60200260200101906001600160a01b031690816001600160a01b0316815250508581600181518110612b3657612b36613586565b60200260200101906001600160a01b031690816001600160a01b0316815250508381600281518110612b6a57612b6a613586565b60200260200101906001600160a01b031690816001600160a01b031681525050612b9381612df5565b15612bbf57604051630d697db160e11b81526001600160e01b03196000351660048201526024016107f8565b50612bca600861142f565b6040516302209ca560e31b81526001600160a01b038881166004830152878116602483015286811660448301528581166064830152608482018590529190911690631104e5289060a401600060405180830381600087803b158015612c2e57600080fd5b505af115801561273c573d6000803e3d6000fd5b600080612c4d612209565b905060005b8351811015610b2857612c7f848281518110612c7057612c70613586565b60200260200101518684612895565b612c899084613650565b9250600101612c52565b612c9d8282611f6b565b610a9b576040516303b97b7760e41b81526001600160e01b03196000351660048201526024016107f8565b8354612cde906001600160a01b03168484612e94565b60038401556001600160a01b0390911660009081526004909201602052604090912055565b6000818310612d125781610f0f565b5090919050565b6000818311612d29576000610f0f565b610f0f8284613663565b60018201546001600160a01b03808316911603610a9b57604051639feb934760e01b815260040160405180910390fd5b8284600301541015612d7757600284018190555b6000612d87856002015484612d03565b90506000818660020154612d9b9190613663565b90508015612dec57600286018290556001870154811115612dcf576040516352e521bf60e11b815260040160405180910390fd5b80876001016000016000828254612de69190613663565b90915550505b50505050505050565b60008151600003612e0857506000919050565b60005b6001835103811015612e8b57600181015b8351811015612e8257838181518110612e3757612e37613586565b60200260200101516001600160a01b0316848381518110612e5a57612e5a613586565b60200260200101516001600160a01b031603612e7a575060019392505050565b600101612e1c565b50600101612e0b565b50600092915050565b6000612e9e612209565b6001600160a01b0385166000908152600360205260409020600181015460028201549293509091831115612f12576040518060400160405280612ef9886001600160a01b031660009081526037602052604090206003015490565b8152602090810185905281516001850155015160028301555b6001600160a01b038087166000908152600260209081526040808320938916835292905290812090612f448888610f9d565b90506000612f5489898885611c37565b83549091508114612fa6578083556040518181526001600160a01b0389811691908b16907faa7c29611027fd4be148712bb54960253b7a7d5998c17769bfc424c2f5f185ad9060200160405180910390a35b612fb38584888a86612d63565b845460018085019190915560038401879055850154841461301a57886001600160a01b0316867f81faf50e2aaf52eaba2ab841071efb9f6f0850a3e7d008b1336e6001d3d4963c876001016000015460405161301191815260200190565b60405180910390a35b505050505050505050565b60008083601f84011261303757600080fd5b5081356001600160401b0381111561304e57600080fd5b6020830191508360208260051b850101111561306957600080fd5b9250929050565b6000806000806040858703121561308657600080fd5b84356001600160401b038082111561309d57600080fd5b6130a988838901613025565b909650945060208701359150808211156130c257600080fd5b506130cf87828801613025565b95989497509550505050565b600081518084526020808501945080840160005b8381101561310b578151875295820195908201906001016130ef565b509495945050505050565b602081526000610f0f60208301846130db565b6001600160a01b038116811461080157600080fd5b60008060006040848603121561315357600080fd5b83356001600160401b0381111561316957600080fd5b61317586828701613025565b909450925050602084013561318981613129565b809150509250925092565b6000602082840312156131a657600080fd5b81356131b181613129565b9392505050565b600080604083850312156131cb57600080fd5b82356131d681613129565b946020939093013593505050565b6000806000604084860312156131f957600080fd5b833561320481613129565b925060208401356001600160401b0381111561321f57600080fd5b61322b86828701613025565b9497909650939450505050565b6000806020838503121561324b57600080fd5b82356001600160401b0381111561326157600080fd5b61326d85828601613025565b90969095509350505050565b6000806040838503121561328c57600080fd5b50508035926020909101359150565b6000602082840312156132ad57600080fd5b5035919050565b600080604083850312156132c757600080fd5b82356132d281613129565b915060208301356132e281613129565b809150509250929050565b60008060006060848603121561330257600080fd5b833561330d81613129565b9250602084013561331d81613129565b929592945050506040919091013590565b8035600b81106114a557600080fd5b6000806040838503121561335057600080fd5b6132d28361332e565b60008060006060848603121561336e57600080fd5b833561337981613129565b95602085013595506040909401359392505050565b6000806000806000606086880312156133a657600080fd5b85356001600160401b03808211156133bd57600080fd5b6133c989838a01613025565b909750955060208801359150808211156133e257600080fd5b506133ef88828901613025565b96999598509660400135949350505050565b60006020828403121561341357600080fd5b610f0f8261332e565b60008060006040848603121561343157600080fd5b83356001600160401b0381111561344757600080fd5b61345386828701613025565b909790965060209590950135949350505050565b600080600080600060a0868803121561347f57600080fd5b853561348a81613129565b9450602086013561349a81613129565b935060408601356134aa81613129565b925060608601356134ba81613129565b949793965091946080013592915050565b600080600080600060a086880312156134e357600080fd5b85356134ee81613129565b97602087013597506040870135966060810135965060800135945092505050565b634e487b7160e01b600052602160045260246000fd5b600b81106135355761353561350f565b9052565b6001600160e01b031984168152606081016135576020830185613525565b6001600160a01b03929092166040919091015292915050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6000602082840312156135e557600080fd5b5051919050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b80820180821115610f1257610f1261363a565b81810381811115610f1257610f1261363a565b60208101610f128284613525565b60208082528181018390526000908460408401835b868110156136c75782356136ac81613129565b6001600160a01b031682529183019190830190600101613699565b509695505050505050565b6000602082840312156136e457600080fd5b815180151581146131b157600080fd5b8082028115828204841417610f1257610f1261363a565b60008261372857634e487b7160e01b600052601260045260246000fd5b500490565b80516114a581613129565b600060e0828403121561374a57600080fd5b60405160e081018181106001600160401b038211171561377a57634e487b7160e01b600052604160045260246000fd5b6040526137868361372d565b81526137946020840161372d565b60208201526137a56040840161372d565b60408201526137b66060840161372d565b60608201526080830151608082015260a083015160a082015260c083015160c08201528091505092915050565b6001600160e01b03198316815260408101600983106138045761380461350f565b8260208301529392505050565b600081518084526020808501945080840160005b8381101561310b5781516001600160a01b031687529582019590820190600101613825565b60408152600061385d6040830186613811565b82810360208401528381526001600160fb1b0384111561387c57600080fd5b8360051b808660208401370160200195945050505050565b6000600182016138a6576138a661363a565b5060010190565b602081526000610f0f6020830184613811565b6060815260006138d36060830186613811565b82810360208401526138e581866130db565b905082810360408401526138f981856130db565b969550505050505056fea164736f6c6343000811000a", + "numDeployments": 13, + "solcInputHash": "6da162a003a00b6a8800b1f2bcac773f", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"name\":\"ErrAdminOfAnyActivePoolForbidden\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"extraInfo\",\"type\":\"string\"}],\"name\":\"ErrCannotInitTransferRON\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrCannotTransferRON\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"}],\"name\":\"ErrContractTypeNotFound\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"}],\"name\":\"ErrDuplicated\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"poolAddr\",\"type\":\"address\"}],\"name\":\"ErrInactivePool\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"},{\"internalType\":\"uint256\",\"name\":\"currentBalance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"sendAmount\",\"type\":\"uint256\"}],\"name\":\"ErrInsufficientBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInsufficientDelegatingAmount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInsufficientStakingAmount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidArrays\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidCommissionRate\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrInvalidPoolShare\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrOnlyPoolAdminAllowed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrPoolAdminForbidden\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"}],\"name\":\"ErrRecipientRevert\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrStakingAmountLeft\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrThreeInteractionAddrsNotEqual\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"},{\"internalType\":\"enum RoleAccess\",\"name\":\"expectedRole\",\"type\":\"uint8\"}],\"name\":\"ErrUnauthorized\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrUndelegateTooEarly\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrUndelegateZeroAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"},{\"internalType\":\"enum ContractType\",\"name\":\"expectedContractType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"actual\",\"type\":\"address\"}],\"name\":\"ErrUnexpectedInternalCall\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrUnstakeTooEarly\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrUnstakeZeroAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"ErrZeroCodeContract\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrZeroValue\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"minRate\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"maxRate\",\"type\":\"uint256\"}],\"name\":\"CommissionRateRangeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"ContractUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"minSecs\",\"type\":\"uint256\"}],\"name\":\"CooldownSecsToUndelegateUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensuAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Delegated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"threshold\",\"type\":\"uint256\"}],\"name\":\"MinValidatorStakingAmountUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"validator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"name\":\"PoolApproved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"poolAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"shares\",\"type\":\"uint256\"}],\"name\":\"PoolSharesUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"validator\",\"type\":\"address[]\"}],\"name\":\"PoolsDeprecated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"poolAddrs\",\"type\":\"address[]\"}],\"name\":\"PoolsUpdateConflicted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"poolAddrs\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"rewards\",\"type\":\"uint256[]\"}],\"name\":\"PoolsUpdateFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"poolAddrs\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"aRps\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"shares\",\"type\":\"uint256[]\"}],\"name\":\"PoolsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"poolAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"RewardClaimed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensuAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Staked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"validator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"contractBalance\",\"type\":\"uint256\"}],\"name\":\"StakingAmountDeductFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"validator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"contractBalance\",\"type\":\"uint256\"}],\"name\":\"StakingAmountTransferFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensuAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Undelegated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"consensuAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Unstaked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"poolAddr\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"debited\",\"type\":\"uint256\"}],\"name\":\"UserRewardUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"secs\",\"type\":\"uint256\"}],\"name\":\"WaitingSecsToRevokeUpdated\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"DEFAULT_ADDITION_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"PERIOD_DURATION\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_candidateAdmin\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address payable\",\"name\":\"_treasuryAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_commissionRate\",\"type\":\"uint256\"}],\"name\":\"applyValidatorCandidate\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_consensusAddrs\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_amounts\",\"type\":\"uint256[]\"}],\"name\":\"bulkUndelegate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_consensusAddrList\",\"type\":\"address[]\"}],\"name\":\"claimRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"cooldownSecsToUndelegate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"}],\"name\":\"delegate\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_consensusAddrList\",\"type\":\"address[]\"},{\"internalType\":\"address\",\"name\":\"_consensusAddrDst\",\"type\":\"address\"}],\"name\":\"delegateRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"execDeductStakingAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_actualDeductingAmount\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_pools\",\"type\":\"address[]\"},{\"internalType\":\"uint256\",\"name\":\"_newPeriod\",\"type\":\"uint256\"}],\"name\":\"execDeprecatePools\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_consensusAddrs\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_rewards\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256\",\"name\":\"_period\",\"type\":\"uint256\"}],\"name\":\"execRecordRewards\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCommissionRateRange\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"}],\"name\":\"getContract\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"contract_\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_pools\",\"type\":\"address[]\"}],\"name\":\"getManySelfStakings\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_selfStakings\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_poolAddrs\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"_userList\",\"type\":\"address[]\"}],\"name\":\"getManyStakingAmounts\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_stakingAmounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_poolList\",\"type\":\"address[]\"}],\"name\":\"getManyStakingTotals\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_stakingAmounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolAdminAddr\",\"type\":\"address\"}],\"name\":\"getPoolAddressOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolAddr\",\"type\":\"address\"}],\"name\":\"getPoolDetail\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"_admin\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_stakingAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_stakingTotal\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"}],\"name\":\"getReward\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"_poolAddrList\",\"type\":\"address[]\"}],\"name\":\"getRewards\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_rewards\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"}],\"name\":\"getStakingAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolAddr\",\"type\":\"address\"}],\"name\":\"getStakingTotal\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"__validatorContract\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"__minValidatorStakingAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"__maxCommissionRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"__cooldownSecsToUndelegate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"__waitingSecsToRevoke\",\"type\":\"uint256\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initializeV2\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolAdminAddr\",\"type\":\"address\"}],\"name\":\"isAdminOfActivePool\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minValidatorStakingAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddrSrc\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_consensusAddrDst\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"redelegate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"}],\"name\":\"requestEmergencyExit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"}],\"name\":\"requestRenounce\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_effectiveDaysOnwards\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_commissionRate\",\"type\":\"uint256\"}],\"name\":\"requestUpdateCommissionRate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_minRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_maxRate\",\"type\":\"uint256\"}],\"name\":\"setCommissionRateRange\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enum ContractType\",\"name\":\"contractType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setContract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_cooldownSecs\",\"type\":\"uint256\"}],\"name\":\"setCooldownSecsToUndelegate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_threshold\",\"type\":\"uint256\"}],\"name\":\"setMinValidatorStakingAmount\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_secs\",\"type\":\"uint256\"}],\"name\":\"setWaitingSecsToRevoke\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"}],\"name\":\"stake\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_candidateAdmin\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"address payable\",\"name\":\"_treasuryAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_commissionRate\",\"type\":\"uint256\"}],\"name\":\"tmp_re_applyValidatorCandidate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"undelegate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensusAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"unstake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"waitingSecsToRevoke\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"errors\":{\"ErrAdminOfAnyActivePoolForbidden(address)\":[{\"details\":\"Error of admin of any active pool cannot delegate.\"}],\"ErrCannotInitTransferRON(address,string)\":[{\"details\":\"Error of cannot transfer RON to specified target.\"}],\"ErrCannotTransferRON()\":[{\"details\":\"Error of cannot transfer RON.\"}],\"ErrContractTypeNotFound(uint8)\":[{\"details\":\"Error of invalid role.\"}],\"ErrDuplicated(bytes4)\":[{\"details\":\"Error thrown when a duplicated element is detected in an array.\",\"params\":{\"msgSig\":\"The function signature that invoke the error.\"}}],\"ErrInactivePool(address)\":[{\"details\":\"Error of querying inactive pool.\"}],\"ErrInsufficientBalance(bytes4,uint256,uint256)\":[{\"details\":\"Error of sender has insufficient balance.\"}],\"ErrInsufficientDelegatingAmount()\":[{\"details\":\"Error of undelegating insufficient amount.\"}],\"ErrInsufficientStakingAmount()\":[{\"details\":\"Error of insufficient staking amount for unstaking.\"}],\"ErrInvalidArrays()\":[{\"details\":\"Error of length of input arrays are not of the same.\"}],\"ErrInvalidCommissionRate()\":[{\"details\":\"Error of setting commission rate exceeds max allowed.\"}],\"ErrInvalidPoolShare()\":[{\"details\":\"Error of invalid pool share.\"}],\"ErrOnlyPoolAdminAllowed()\":[{\"details\":\"Error of no one is allowed to call but the pool's admin.\"}],\"ErrPoolAdminForbidden()\":[{\"details\":\"Error of pool admin is not allowed to call.\"}],\"ErrRecipientRevert(bytes4)\":[{\"details\":\"Error of recipient not accepting RON when transfer RON.\"}],\"ErrStakingAmountLeft()\":[{\"details\":\"Error of invalid staking amount left after deducted.\"}],\"ErrThreeInteractionAddrsNotEqual()\":[{\"details\":\"Error of three interaction addresses must be of the same in applying for validator candidate.\"}],\"ErrUnauthorized(bytes4,uint8)\":[{\"details\":\"Error indicating that the caller is unauthorized to perform a specific function.\",\"params\":{\"expectedRole\":\"The role required to perform the function.\",\"msgSig\":\"The function signature (bytes4) that the caller is unauthorized to perform.\"}}],\"ErrUndelegateTooEarly()\":[{\"details\":\"Error of undelegating too early.\"}],\"ErrUndelegateZeroAmount()\":[{\"details\":\"Error of undelegating zero amount.\"}],\"ErrUnexpectedInternalCall(bytes4,uint8,address)\":[{\"details\":\"Error indicating that the caller is unauthorized to perform a specific function.\",\"params\":{\"actual\":\"The actual address that called to the function.\",\"expectedContractType\":\"The contract type required to perform the function.\",\"msgSig\":\"The function signature (bytes4).\"}}],\"ErrUnstakeTooEarly()\":[{\"details\":\"Error of unstaking too early.\"}],\"ErrUnstakeZeroAmount()\":[{\"details\":\"Error of unstaking zero amount.\"}],\"ErrZeroCodeContract(address)\":[{\"details\":\"Error of set to non-contract.\"}],\"ErrZeroValue()\":[{\"details\":\"Error of receiving zero message value.\"}]},\"kind\":\"dev\",\"methods\":{\"applyValidatorCandidate(address,address,address,uint256)\":{\"details\":\"Proposes a candidate to become a validator. Requirements: - The method caller is able to receive RON. - The treasury is able to receive RON. - The amount is larger than or equal to the minimum validator staking amount `minValidatorStakingAmount()`. Emits the event `PoolApproved`.\",\"params\":{\"_candidateAdmin\":\"the candidate admin will be stored in the validator contract, used for calling function that affects to its candidate, e.g. scheduling maintenance.\"}},\"bulkUndelegate(address[],uint256[])\":{\"details\":\"Bulk unstakes from a list of candidates. Requirements: - The method caller is not the pool admin. Emits the events `Undelegated`.\"},\"claimRewards(address[])\":{\"details\":\"Claims the reward of method caller. Emits the `RewardClaimed` event.\"},\"cooldownSecsToUndelegate()\":{\"details\":\"Returns The cooldown time in seconds to undelegate from the last timestamp (s)he delegated.\"},\"delegate(address)\":{\"details\":\"Stakes for a validator candidate `_consensusAddr`. Requirements: - The consensus address is a validator candidate. - The method caller is not the pool admin. Emits the `Delegated` event.\"},\"delegateRewards(address[],address)\":{\"details\":\"Claims the rewards and delegates them to the consensus address. Requirements: - The method caller is not the pool admin. - The consensus address `_consensusAddrDst` is a validator candidate. Emits the `RewardClaimed` event and the `Delegated` event.\"},\"execDeductStakingAmount(address,uint256)\":{\"details\":\"Deducts from staking amount of the validator `_consensusAddr` for `_amount`. Requirements: - The method caller must be validator contract. Emits the event `Unstaked`.\"},\"execDeprecatePools(address[],uint256)\":{\"details\":\"Deprecates the pool. - Deduct self-staking amount of the pool admin to zero. - Transfer the deducted amount to the pool admin. - Deactivate the pool admin address in the mapping of active pool admins Requirements: - The method caller is validator contract. Emits the event `PoolsDeprecated` and `Unstaked` events. Emits the event `StakingAmountTransferFailed` if the contract cannot transfer RON back to the pool admin.\"},\"execRecordRewards(address[],uint256[],uint256)\":{\"details\":\"Records the amount of rewards `_rewards` for the pools `_consensusAddrs`. Requirements: - The method caller must be validator contract. Emits the event `PoolsUpdated` once the contract recorded the rewards successfully. Emits the event `PoolsUpdateFailed` once the input array lengths are not equal. Emits the event `PoolsUpdateConflicted` when there are some pools which already updated in the period. Note: This method should be called once at the period ending.\"},\"getCommissionRateRange()\":{\"details\":\"Returns the commission rate range that the candidate can set.\"},\"getContract(uint8)\":{\"details\":\"Returns the address of a contract with a specific role. Throws an error if no contract is set for the specified role.\",\"params\":{\"contractType\":\"The role of the contract to retrieve.\"},\"returns\":{\"contract_\":\"The address of the contract with the specified role.\"}},\"getManySelfStakings(address[])\":{\"details\":\"Returns the self-staking amounts of the pools.\"},\"getManyStakingAmounts(address[],address[])\":{\"details\":\"Returns the staking amounts of the users.\"},\"getManyStakingTotals(address[])\":{\"details\":\"Returns the total staking amounts of all users for the pools `_poolAddrs`.\"},\"getPoolAddressOf(address)\":{\"details\":\"Returns the consensus address corresponding to the pool admin.\"},\"getPoolDetail(address)\":{\"details\":\"Returns the staking pool detail.\"},\"getReward(address,address)\":{\"details\":\"Returns the reward amount that user claimable.\"},\"getRewards(address,address[])\":{\"details\":\"Returns the claimable reward of the user `_user`.\"},\"getStakingAmount(address,address)\":{\"details\":\"Returns the staking amount of an user.\"},\"getStakingTotal(address)\":{\"details\":\"Returns the total staking amount of all users for a pool.\"},\"initialize(address,uint256,uint256,uint256,uint256)\":{\"details\":\"Initializes the contract storage.\"},\"isAdminOfActivePool(address)\":{\"details\":\"Returns whether the `_poolAdminAddr` is currently active.\"},\"minValidatorStakingAmount()\":{\"details\":\"Returns the minimum threshold for being a validator candidate.\"},\"redelegate(address,address,uint256)\":{\"details\":\"Unstakes an amount of RON from the `_consensusAddrSrc` and stake for `_consensusAddrDst`. Requirements: - The method caller is not the pool admin. - The consensus address `_consensusAddrDst` is a validator candidate. Emits the `Undelegated` event and the `Delegated` event.\"},\"requestEmergencyExit(address)\":{\"details\":\"Renounces being a validator candidate and takes back the delegating/staking amount. Requirements: - The consensus address is a validator candidate. - The method caller is the pool admin.\"},\"requestRenounce(address)\":{\"details\":\"Renounces being a validator candidate and takes back the delegating/staking amount. Requirements: - The consensus address is a validator candidate. - The method caller is the pool admin.\"},\"requestUpdateCommissionRate(address,uint256,uint256)\":{\"details\":\"Pool admin requests update validator commission rate. The request will be forwarded to the candidate manager contract, and the value is getting updated in {ICandidateManager-execRequestUpdateCommissionRate}. Requirements: - The consensus address is a validator candidate. - The method caller is the pool admin. - The `_effectiveDaysOnwards` must be equal to or larger than the {CandidateManager-_minEffectiveDaysOnwards}. - The `_rate` must be in range of [0_00; 100_00]. Emits the event `CommissionRateUpdated`.\"},\"setCommissionRateRange(uint256,uint256)\":{\"details\":\"Sets the commission rate range that a candidate can set. Requirements: - The method caller is admin. Emits the `CommissionRateRangeUpdated` event.\"},\"setContract(uint8,address)\":{\"details\":\"Sets the address of a contract with a specific role. Emits the event {ContractUpdated}.\",\"params\":{\"addr\":\"The address of the contract to set.\",\"contractType\":\"The role of the contract to set.\"}},\"setCooldownSecsToUndelegate(uint256)\":{\"details\":\"Sets the cooldown time in seconds to undelegate from the last timestamp (s)he delegated. Requirements: - The method caller is admin. Emits the event `CooldownSecsToUndelegateUpdated`.\"},\"setMinValidatorStakingAmount(uint256)\":{\"details\":\"Sets the minimum threshold for being a validator candidate. Requirements: - The method caller is admin. Emits the `MinValidatorStakingAmountUpdated` event.\"},\"setWaitingSecsToRevoke(uint256)\":{\"details\":\"Sets the number of seconds that a candidate must wait to be revoked. Requirements: - The method caller is admin. Emits the event `WaitingSecsToRevokeUpdated`.\"},\"stake(address)\":{\"details\":\"Self-delegates to the validator candidate `_consensusAddr`. Requirements: - The consensus address is a validator candidate. - The method caller is the pool admin. - The `msg.value` is larger than 0. Emits the event `Staked`.\"},\"tmp_re_applyValidatorCandidate(address,address,address,uint256)\":{\"details\":\"This method only work on testnet, to hotfix the applied validator candidate that is failed. Should remove this method before deploying it on mainnet.\"},\"undelegate(address,uint256)\":{\"details\":\"Unstakes from a validator candidate `_consensusAddr` for `_amount`. Requirements: - The method caller is not the pool admin. Emits the `Undelegated` event.\"},\"unstake(address,uint256)\":{\"details\":\"Unstakes from the validator candidate `_consensusAddr` for `_amount`. Requirements: - The consensus address is a validator candidate. - The method caller is the pool admin. Emits the event `Unstaked`.\"},\"waitingSecsToRevoke()\":{\"details\":\"Returns the number of seconds that a candidate must wait for the renounce request gets affected.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/ronin/staking/Staking.sol\":\"Staking\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"none\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/Address.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\\n * initialization step. This is essential to configure modules that are added through upgrades and that require\\n * initialization.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2a21b14ff90012878752f230d3ffd5c3405e5938d06c97a7d89c0a64561d0d66\",\"license\":\"MIT\"},\"@openzeppelin/contracts/security/ReentrancyGuard.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n */\\nabstract contract ReentrancyGuard {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n constructor() {\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and making it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n}\\n\",\"keccak256\":\"0x0e9621f60b2faabe65549f7ed0f24e8853a45c1b7990d47e8160e523683f3935\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd6153ce99bcdcce22b124f755e72553295be6abcd63804cfdffceb188b8bef10\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"contracts/extensions/RONTransferHelper.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nabstract contract RONTransferHelper {\\n /// @dev Error of sender has insufficient balance.\\n error ErrInsufficientBalance(bytes4 msgSig, uint256 currentBalance, uint256 sendAmount);\\n /// @dev Error of recipient not accepting RON when transfer RON.\\n error ErrRecipientRevert(bytes4 msgSig);\\n\\n /**\\n * @dev See `_sendRON`.\\n * Reverts if the recipient does not receive RON.\\n */\\n function _transferRON(address payable recipient, uint256 amount) internal {\\n if (!_sendRON(recipient, amount)) revert ErrRecipientRevert(msg.sig);\\n }\\n\\n /**\\n * @dev Send `amount` RON to the address `recipient`.\\n * Returns whether the recipient receives RON or not.\\n * Reverts once the contract balance is insufficient.\\n *\\n * Note: consider using `ReentrancyGuard` before calling this function.\\n *\\n */\\n function _sendRON(address payable recipient, uint256 amount) internal returns (bool success) {\\n if (address(this).balance < amount) revert ErrInsufficientBalance(msg.sig, address(this).balance, amount);\\n return _unsafeSendRON(recipient, amount);\\n }\\n\\n /**\\n * @dev Unsafe send `amount` RON to the address `recipient`. If the sender's balance is insufficient,\\n * the call does not revert.\\n *\\n * Note:\\n * - Does not assert whether the balance of sender is sufficient.\\n * - Does not assert whether the recipient accepts RON.\\n * - Consider using `ReentrancyGuard` before calling this function.\\n *\\n */\\n function _unsafeSendRON(address payable recipient, uint256 amount) internal returns (bool success) {\\n (success, ) = recipient.call{ value: amount }(\\\"\\\");\\n }\\n\\n /**\\n * @dev Same purpose with {_unsafeSendRONLimitGas(address,uin256)} but containing gas limit stipend forwarded in the call.\\n */\\n function _unsafeSendRONLimitGas(\\n address payable recipient,\\n uint256 amount,\\n uint256 gas\\n ) internal returns (bool success) {\\n (success, ) = recipient.call{ value: amount, gas: gas }(\\\"\\\");\\n }\\n}\\n\",\"keccak256\":\"0xdece837caa8da00fe031b8139ada009330b8bef149af12b535913c021ab94d0e\",\"license\":\"MIT\"},\"contracts/extensions/TransparentUpgradeableProxyV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract TransparentUpgradeableProxyV2 is TransparentUpgradeableProxy {\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable TransparentUpgradeableProxy(_logic, admin_, _data) {}\\n\\n /**\\n * @dev Calls a function from the current implementation as specified by `_data`, which should be an encoded function call.\\n *\\n * Requirements:\\n * - Only the admin can call this function.\\n *\\n * Note: The proxy admin is not allowed to interact with the proxy logic through the fallback function to avoid\\n * triggering some unexpected logic. This is to allow the administrator to explicitly call the proxy, please consider\\n * reviewing the encoded data `_data` and the method which is called before using this.\\n *\\n */\\n function functionDelegateCall(bytes memory _data) public payable ifAdmin {\\n address _addr = _implementation();\\n assembly {\\n let _result := delegatecall(gas(), _addr, add(_data, 32), mload(_data), 0, 0)\\n returndatacopy(0, 0, returndatasize())\\n switch _result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x6609392ea7d3174439b5715100bee82528fe6e4aff28927d48c27db8475e88c5\",\"license\":\"MIT\"},\"contracts/extensions/collections/HasContracts.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { HasProxyAdmin } from \\\"./HasProxyAdmin.sol\\\";\\nimport \\\"../../interfaces/collections/IHasContracts.sol\\\";\\nimport { IdentityGuard } from \\\"../../utils/IdentityGuard.sol\\\";\\nimport { ErrUnexpectedInternalCall } from \\\"../../utils/CommonErrors.sol\\\";\\n\\n/**\\n * @title HasContracts\\n * @dev A contract that provides functionality to manage multiple contracts with different roles.\\n */\\nabstract contract HasContracts is HasProxyAdmin, IHasContracts, IdentityGuard {\\n /// @dev value is equal to keccak256(\\\"@ronin.dpos.collections.HasContracts.slot\\\") - 1\\n bytes32 private constant _STORAGE_SLOT = 0xdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb;\\n\\n /**\\n * @dev Modifier to restrict access to functions only to contracts with a specific role.\\n * @param contractType The contract type that allowed to call\\n */\\n modifier onlyContract(ContractType contractType) virtual {\\n _requireContract(contractType);\\n _;\\n }\\n\\n /**\\n * @inheritdoc IHasContracts\\n */\\n function setContract(ContractType contractType, address addr) external virtual onlyAdmin {\\n _requireHasCode(addr);\\n _setContract(contractType, addr);\\n }\\n\\n /**\\n * @inheritdoc IHasContracts\\n */\\n function getContract(ContractType contractType) public view returns (address contract_) {\\n contract_ = _getContractMap()[uint8(contractType)];\\n if (contract_ == address(0)) revert ErrContractTypeNotFound(contractType);\\n }\\n\\n /**\\n * @dev Internal function to set the address of a contract with a specific role.\\n * @param contractType The contract type of the contract to set.\\n * @param addr The address of the contract to set.\\n */\\n function _setContract(ContractType contractType, address addr) internal virtual {\\n _getContractMap()[uint8(contractType)] = addr;\\n emit ContractUpdated(contractType, addr);\\n }\\n\\n /**\\n * @dev Internal function to access the mapping of contract addresses with roles.\\n * @return contracts_ The mapping of contract addresses with roles.\\n */\\n function _getContractMap() private pure returns (mapping(uint8 => address) storage contracts_) {\\n assembly {\\n contracts_.slot := _STORAGE_SLOT\\n }\\n }\\n\\n /**\\n * @dev Internal function to check if the calling contract has a specific role.\\n * @param contractType The contract type that the calling contract must have.\\n * @dev Throws an error if the calling contract does not have the specified role.\\n */\\n function _requireContract(ContractType contractType) private view {\\n if (msg.sender != getContract(contractType)) {\\n revert ErrUnexpectedInternalCall(msg.sig, contractType, msg.sender);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9e1dceb68827adfb8c8184662f29ab5fe14e292a632878150e3b0b6c61bc1dce\",\"license\":\"MIT\"},\"contracts/extensions/collections/HasProxyAdmin.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/StorageSlot.sol\\\";\\nimport \\\"../../utils/CommonErrors.sol\\\";\\n\\nabstract contract HasProxyAdmin {\\n // bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n modifier onlyAdmin() {\\n _requireAdmin();\\n _;\\n }\\n\\n /**\\n * @dev Returns proxy admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n function _requireAdmin() internal view {\\n if (msg.sender != _getAdmin()) revert ErrUnauthorized(msg.sig, RoleAccess.ADMIN);\\n }\\n}\\n\",\"keccak256\":\"0x06e5962713a77abf6d5ba646e1cc1cfb6f9c50e7d52520dd82a10bf309534187\",\"license\":\"MIT\"},\"contracts/extensions/consumers/GlobalConfigConsumer.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nabstract contract GlobalConfigConsumer {\\n /// @dev The addition amount of gas sending along in external calls. Total gas stipend is added with default 2300 gas.\\n uint256 public constant DEFAULT_ADDITION_GAS = 1200;\\n /// @dev The length of a period in second.\\n uint256 public constant PERIOD_DURATION = 1 days;\\n}\\n\",\"keccak256\":\"0x96d6b1ea4c8e126a8c2468683e7513d195f8e05456d85dd8f259ab049347b527\",\"license\":\"MIT\"},\"contracts/extensions/consumers/PercentageConsumer.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nabstract contract PercentageConsumer {\\n uint256 internal constant _MAX_PERCENTAGE = 100_00;\\n}\\n\",\"keccak256\":\"0x5dc54a24348c5d614de1b4805dddeab4dda72f9f0636b27bf0ed295fee017dcf\",\"license\":\"MIT\"},\"contracts/interfaces/collections/IHasContracts.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport { ContractType } from \\\"../../utils/ContractType.sol\\\";\\n\\ninterface IHasContracts {\\n /// @dev Error of invalid role.\\n error ErrContractTypeNotFound(ContractType contractType);\\n\\n /// @dev Emitted when a contract is updated.\\n event ContractUpdated(ContractType indexed contractType, address indexed addr);\\n\\n /**\\n * @dev Returns the address of a contract with a specific role.\\n * Throws an error if no contract is set for the specified role.\\n *\\n * @param contractType The role of the contract to retrieve.\\n * @return contract_ The address of the contract with the specified role.\\n */\\n function getContract(ContractType contractType) external view returns (address contract_);\\n\\n /**\\n * @dev Sets the address of a contract with a specific role.\\n * Emits the event {ContractUpdated}.\\n * @param contractType The role of the contract to set.\\n * @param addr The address of the contract to set.\\n */\\n function setContract(ContractType contractType, address addr) external;\\n}\\n\",\"keccak256\":\"0x99d8213d857e30d367155abd15dc42730afdfbbac3a22dfb3b95ffea2083a92e\",\"license\":\"MIT\"},\"contracts/interfaces/consumers/PeriodWrapperConsumer.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\ninterface PeriodWrapperConsumer {\\n struct PeriodWrapper {\\n // Inner value.\\n uint256 inner;\\n // Last period number that the info updated.\\n uint256 lastPeriod;\\n }\\n}\\n\",\"keccak256\":\"0xb6777e3c364306eb8d5355583c1aca44de9d351cb40ddf1cea832206d4aad272\",\"license\":\"MIT\"},\"contracts/interfaces/staking/IBaseStaking.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface IBaseStaking {\\n struct PoolDetail {\\n // Address of the pool i.e. consensus address of the validator\\n address addr;\\n // Pool admin address\\n address admin;\\n // Self-staking amount\\n uint256 stakingAmount;\\n // Total number of RON staking for the pool\\n uint256 stakingTotal;\\n // Mapping from delegator => delegating amount\\n mapping(address => uint256) delegatingAmount;\\n // Mapping from delegator => the last timestamp that delegator staked\\n mapping(address => uint256) lastDelegatingTimestamp;\\n }\\n\\n /// @dev Emitted when the minium number of seconds to undelegate is updated.\\n event CooldownSecsToUndelegateUpdated(uint256 minSecs);\\n /// @dev Emitted when the number of seconds that a candidate must wait to be revoked.\\n event WaitingSecsToRevokeUpdated(uint256 secs);\\n\\n /// @dev Error of cannot transfer RON.\\n error ErrCannotTransferRON();\\n /// @dev Error of receiving zero message value.\\n error ErrZeroValue();\\n /// @dev Error of pool admin is not allowed to call.\\n error ErrPoolAdminForbidden();\\n /// @dev Error of no one is allowed to call but the pool's admin.\\n error ErrOnlyPoolAdminAllowed();\\n /// @dev Error of admin of any active pool cannot delegate.\\n error ErrAdminOfAnyActivePoolForbidden(address admin);\\n /// @dev Error of querying inactive pool.\\n error ErrInactivePool(address poolAddr);\\n /// @dev Error of length of input arrays are not of the same.\\n error ErrInvalidArrays();\\n\\n /**\\n * @dev Returns whether the `_poolAdminAddr` is currently active.\\n */\\n function isAdminOfActivePool(address _poolAdminAddr) external view returns (bool);\\n\\n /**\\n * @dev Returns the consensus address corresponding to the pool admin.\\n */\\n function getPoolAddressOf(address _poolAdminAddr) external view returns (address);\\n\\n /**\\n * @dev Returns the staking pool detail.\\n */\\n function getPoolDetail(address) external view returns (address _admin, uint256 _stakingAmount, uint256 _stakingTotal);\\n\\n /**\\n * @dev Returns the self-staking amounts of the pools.\\n */\\n function getManySelfStakings(address[] calldata) external view returns (uint256[] memory);\\n\\n /**\\n * @dev Returns The cooldown time in seconds to undelegate from the last timestamp (s)he delegated.\\n */\\n function cooldownSecsToUndelegate() external view returns (uint256);\\n\\n /**\\n * @dev Returns the number of seconds that a candidate must wait for the renounce request gets affected.\\n */\\n function waitingSecsToRevoke() external view returns (uint256);\\n\\n /**\\n * @dev Sets the cooldown time in seconds to undelegate from the last timestamp (s)he delegated.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `CooldownSecsToUndelegateUpdated`.\\n *\\n */\\n function setCooldownSecsToUndelegate(uint256 _cooldownSecs) external;\\n\\n /**\\n * @dev Sets the number of seconds that a candidate must wait to be revoked.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `WaitingSecsToRevokeUpdated`.\\n *\\n */\\n function setWaitingSecsToRevoke(uint256 _secs) external;\\n}\\n\",\"keccak256\":\"0x90517268a0e31147d97772c9ae518caa5eb8c03efe3b369e3c6d5166422f5962\",\"license\":\"MIT\"},\"contracts/interfaces/staking/ICandidateStaking.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IRewardPool.sol\\\";\\n\\ninterface ICandidateStaking is IRewardPool {\\n /// @dev Emitted when the minimum staking amount for being a validator is updated.\\n event MinValidatorStakingAmountUpdated(uint256 threshold);\\n /// @dev Emitted when the commission rate range is updated.\\n event CommissionRateRangeUpdated(uint256 minRate, uint256 maxRate);\\n\\n /// @dev Emitted when the pool admin staked for themself.\\n event Staked(address indexed consensuAddr, uint256 amount);\\n /// @dev Emitted when the pool admin unstaked the amount of RON from themself.\\n event Unstaked(address indexed consensuAddr, uint256 amount);\\n\\n /// @dev Emitted when the validator pool is approved.\\n event PoolApproved(address indexed validator, address indexed admin);\\n /// @dev Emitted when the validator pool is deprecated.\\n event PoolsDeprecated(address[] validator);\\n /// @dev Emitted when the staking amount transfer failed.\\n event StakingAmountTransferFailed(\\n address indexed validator,\\n address indexed admin,\\n uint256 amount,\\n uint256 contractBalance\\n );\\n /// @dev Emitted when the staking amount deducted failed, e.g. when the validator gets slashed.\\n event StakingAmountDeductFailed(\\n address indexed validator,\\n address indexed recipient,\\n uint256 amount,\\n uint256 contractBalance\\n );\\n\\n /// @dev Error of cannot transfer RON to specified target.\\n error ErrCannotInitTransferRON(address addr, string extraInfo);\\n /// @dev Error of three interaction addresses must be of the same in applying for validator candidate.\\n error ErrThreeInteractionAddrsNotEqual();\\n /// @dev Error of unstaking zero amount.\\n error ErrUnstakeZeroAmount();\\n /// @dev Error of invalid staking amount left after deducted.\\n error ErrStakingAmountLeft();\\n /// @dev Error of insufficient staking amount for unstaking.\\n error ErrInsufficientStakingAmount();\\n /// @dev Error of unstaking too early.\\n error ErrUnstakeTooEarly();\\n /// @dev Error of setting commission rate exceeds max allowed.\\n error ErrInvalidCommissionRate();\\n\\n /**\\n * @dev Returns the minimum threshold for being a validator candidate.\\n */\\n function minValidatorStakingAmount() external view returns (uint256);\\n\\n /**\\n * @dev Returns the commission rate range that the candidate can set.\\n */\\n function getCommissionRateRange() external view returns (uint256 _minRange, uint256 _maxRange);\\n\\n /**\\n * @dev Sets the minimum threshold for being a validator candidate.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the `MinValidatorStakingAmountUpdated` event.\\n *\\n */\\n function setMinValidatorStakingAmount(uint256) external;\\n\\n /**\\n * @dev Sets the commission rate range that a candidate can set.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the `CommissionRateRangeUpdated` event.\\n *\\n */\\n function setCommissionRateRange(uint256 _minRate, uint256 _maxRate) external;\\n\\n /**\\n * @dev Proposes a candidate to become a validator.\\n *\\n * Requirements:\\n * - The method caller is able to receive RON.\\n * - The treasury is able to receive RON.\\n * - The amount is larger than or equal to the minimum validator staking amount `minValidatorStakingAmount()`.\\n *\\n * Emits the event `PoolApproved`.\\n *\\n * @param _candidateAdmin the candidate admin will be stored in the validator contract, used for calling function that affects\\n * to its candidate, e.g. scheduling maintenance.\\n *\\n */\\n function applyValidatorCandidate(\\n address _candidateAdmin,\\n address _consensusAddr,\\n address payable _treasuryAddr,\\n uint256 _commissionRate\\n ) external payable;\\n\\n /**\\n * @dev Deprecates the pool.\\n * - Deduct self-staking amount of the pool admin to zero.\\n * - Transfer the deducted amount to the pool admin.\\n * - Deactivate the pool admin address in the mapping of active pool admins\\n *\\n * Requirements:\\n * - The method caller is validator contract.\\n *\\n * Emits the event `PoolsDeprecated` and `Unstaked` events.\\n * Emits the event `StakingAmountTransferFailed` if the contract cannot transfer RON back to the pool admin.\\n *\\n */\\n function execDeprecatePools(address[] calldata _pools, uint256 _period) external;\\n\\n /**\\n * @dev Self-delegates to the validator candidate `_consensusAddr`.\\n *\\n * Requirements:\\n * - The consensus address is a validator candidate.\\n * - The method caller is the pool admin.\\n * - The `msg.value` is larger than 0.\\n *\\n * Emits the event `Staked`.\\n *\\n */\\n function stake(address _consensusAddr) external payable;\\n\\n /**\\n * @dev Unstakes from the validator candidate `_consensusAddr` for `_amount`.\\n *\\n * Requirements:\\n * - The consensus address is a validator candidate.\\n * - The method caller is the pool admin.\\n *\\n * Emits the event `Unstaked`.\\n *\\n */\\n function unstake(address _consensusAddr, uint256 _amount) external;\\n\\n /**\\n * @dev Pool admin requests update validator commission rate. The request will be forwarded to the candidate manager\\n * contract, and the value is getting updated in {ICandidateManager-execRequestUpdateCommissionRate}.\\n *\\n * Requirements:\\n * - The consensus address is a validator candidate.\\n * - The method caller is the pool admin.\\n * - The `_effectiveDaysOnwards` must be equal to or larger than the {CandidateManager-_minEffectiveDaysOnwards}.\\n * - The `_rate` must be in range of [0_00; 100_00].\\n *\\n * Emits the event `CommissionRateUpdated`.\\n *\\n */\\n function requestUpdateCommissionRate(\\n address _consensusAddr,\\n uint256 _effectiveDaysOnwards,\\n uint256 _commissionRate\\n ) external;\\n\\n /**\\n * @dev Renounces being a validator candidate and takes back the delegating/staking amount.\\n *\\n * Requirements:\\n * - The consensus address is a validator candidate.\\n * - The method caller is the pool admin.\\n *\\n */\\n function requestRenounce(address _consensusAddr) external;\\n\\n /**\\n * @dev Renounces being a validator candidate and takes back the delegating/staking amount.\\n *\\n * Requirements:\\n * - The consensus address is a validator candidate.\\n * - The method caller is the pool admin.\\n *\\n */\\n function requestEmergencyExit(address _consensusAddr) external;\\n}\\n\",\"keccak256\":\"0x9bc6ba6d13f00d9928c0add35ee6406906e16ed86207d373460930c0a75e5938\",\"license\":\"MIT\"},\"contracts/interfaces/staking/IDelegatorStaking.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IRewardPool.sol\\\";\\n\\ninterface IDelegatorStaking is IRewardPool {\\n /// @dev Emitted when the delegator staked for a validator candidate.\\n event Delegated(address indexed delegator, address indexed consensuAddr, uint256 amount);\\n /// @dev Emitted when the delegator unstaked from a validator candidate.\\n event Undelegated(address indexed delegator, address indexed consensuAddr, uint256 amount);\\n\\n /// @dev Error of undelegating zero amount.\\n error ErrUndelegateZeroAmount();\\n /// @dev Error of undelegating insufficient amount.\\n error ErrInsufficientDelegatingAmount();\\n /// @dev Error of undelegating too early.\\n error ErrUndelegateTooEarly();\\n\\n /**\\n * @dev Stakes for a validator candidate `_consensusAddr`.\\n *\\n * Requirements:\\n * - The consensus address is a validator candidate.\\n * - The method caller is not the pool admin.\\n *\\n * Emits the `Delegated` event.\\n *\\n */\\n function delegate(address _consensusAddr) external payable;\\n\\n /**\\n * @dev Unstakes from a validator candidate `_consensusAddr` for `_amount`.\\n *\\n * Requirements:\\n * - The method caller is not the pool admin.\\n *\\n * Emits the `Undelegated` event.\\n *\\n */\\n function undelegate(address _consensusAddr, uint256 _amount) external;\\n\\n /**\\n * @dev Bulk unstakes from a list of candidates.\\n *\\n * Requirements:\\n * - The method caller is not the pool admin.\\n *\\n * Emits the events `Undelegated`.\\n *\\n */\\n function bulkUndelegate(address[] calldata _consensusAddrs, uint256[] calldata _amounts) external;\\n\\n /**\\n * @dev Unstakes an amount of RON from the `_consensusAddrSrc` and stake for `_consensusAddrDst`.\\n *\\n * Requirements:\\n * - The method caller is not the pool admin.\\n * - The consensus address `_consensusAddrDst` is a validator candidate.\\n *\\n * Emits the `Undelegated` event and the `Delegated` event.\\n *\\n */\\n function redelegate(address _consensusAddrSrc, address _consensusAddrDst, uint256 _amount) external;\\n\\n /**\\n * @dev Returns the claimable reward of the user `_user`.\\n */\\n function getRewards(\\n address _user,\\n address[] calldata _poolAddrList\\n ) external view returns (uint256[] memory _rewards);\\n\\n /**\\n * @dev Claims the reward of method caller.\\n *\\n * Emits the `RewardClaimed` event.\\n *\\n */\\n function claimRewards(address[] calldata _consensusAddrList) external returns (uint256 _amount);\\n\\n /**\\n * @dev Claims the rewards and delegates them to the consensus address.\\n *\\n * Requirements:\\n * - The method caller is not the pool admin.\\n * - The consensus address `_consensusAddrDst` is a validator candidate.\\n *\\n * Emits the `RewardClaimed` event and the `Delegated` event.\\n *\\n */\\n function delegateRewards(\\n address[] calldata _consensusAddrList,\\n address _consensusAddrDst\\n ) external returns (uint256 _amount);\\n}\\n\",\"keccak256\":\"0x6dd71bf0c17a65da0dee49b98e4b038c1dd0e74f5473d03570421ceebd5b7084\",\"license\":\"MIT\"},\"contracts/interfaces/staking/IRewardPool.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"../../interfaces/consumers/PeriodWrapperConsumer.sol\\\";\\n\\ninterface IRewardPool is PeriodWrapperConsumer {\\n struct UserRewardFields {\\n // Recorded reward amount.\\n uint256 debited;\\n // The last accumulated of the amount rewards per share (one unit staking) that the info updated.\\n uint256 aRps;\\n // Lowest staking amount in the period.\\n uint256 lowestAmount;\\n // Last period number that the info updated.\\n uint256 lastPeriod;\\n }\\n\\n struct PoolFields {\\n // Accumulated of the amount rewards per share (one unit staking).\\n uint256 aRps;\\n // The staking total to share reward of the current period.\\n PeriodWrapper shares;\\n }\\n\\n /// @dev Emitted when the fields to calculate pending reward for the user is updated.\\n event UserRewardUpdated(address indexed poolAddr, address indexed user, uint256 debited);\\n /// @dev Emitted when the user claimed their reward\\n event RewardClaimed(address indexed poolAddr, address indexed user, uint256 amount);\\n\\n /// @dev Emitted when the pool shares are updated\\n event PoolSharesUpdated(uint256 indexed period, address indexed poolAddr, uint256 shares);\\n /// @dev Emitted when the pools are updated\\n event PoolsUpdated(uint256 indexed period, address[] poolAddrs, uint256[] aRps, uint256[] shares);\\n /// @dev Emitted when the contract fails when updating the pools\\n event PoolsUpdateFailed(uint256 indexed period, address[] poolAddrs, uint256[] rewards);\\n /// @dev Emitted when the contract fails when updating the pools that already set\\n event PoolsUpdateConflicted(uint256 indexed period, address[] poolAddrs);\\n\\n /// @dev Error of invalid pool share.\\n error ErrInvalidPoolShare();\\n\\n /**\\n * @dev Returns the reward amount that user claimable.\\n */\\n function getReward(address _poolAddr, address _user) external view returns (uint256);\\n\\n /**\\n * @dev Returns the staking amount of an user.\\n */\\n function getStakingAmount(address _poolAddr, address _user) external view returns (uint256);\\n\\n /**\\n * @dev Returns the staking amounts of the users.\\n */\\n function getManyStakingAmounts(\\n address[] calldata _poolAddrs,\\n address[] calldata _userList\\n ) external view returns (uint256[] memory);\\n\\n /**\\n * @dev Returns the total staking amount of all users for a pool.\\n */\\n function getStakingTotal(address _poolAddr) external view returns (uint256);\\n\\n /**\\n * @dev Returns the total staking amounts of all users for the pools `_poolAddrs`.\\n */\\n function getManyStakingTotals(address[] calldata _poolAddrs) external view returns (uint256[] memory);\\n}\\n\",\"keccak256\":\"0x52349fecb897b3b8288d8732923551382822c0c5fb8db9c6b094d080a16a2129\",\"license\":\"MIT\"},\"contracts/interfaces/staking/IStaking.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IBaseStaking.sol\\\";\\nimport \\\"./ICandidateStaking.sol\\\";\\nimport \\\"./IDelegatorStaking.sol\\\";\\n\\ninterface IStaking is IRewardPool, IBaseStaking, ICandidateStaking, IDelegatorStaking {\\n /**\\n * @dev Records the amount of rewards `_rewards` for the pools `_consensusAddrs`.\\n *\\n * Requirements:\\n * - The method caller must be validator contract.\\n *\\n * Emits the event `PoolsUpdated` once the contract recorded the rewards successfully.\\n * Emits the event `PoolsUpdateFailed` once the input array lengths are not equal.\\n * Emits the event `PoolsUpdateConflicted` when there are some pools which already updated in the period.\\n *\\n * Note: This method should be called once at the period ending.\\n *\\n */\\n function execRecordRewards(\\n address[] calldata _consensusAddrs,\\n uint256[] calldata _rewards,\\n uint256 _period\\n ) external payable;\\n\\n /**\\n * @dev Deducts from staking amount of the validator `_consensusAddr` for `_amount`.\\n *\\n * Requirements:\\n * - The method caller must be validator contract.\\n *\\n * Emits the event `Unstaked`.\\n *\\n */\\n function execDeductStakingAmount(\\n address _consensusAddr,\\n uint256 _amount\\n ) external returns (uint256 _actualDeductingAmount);\\n}\\n\",\"keccak256\":\"0xd302d4a78203e277fb95a89de7ae32a3102129d3fbd64fc75f92d18be0443408\",\"license\":\"MIT\"},\"contracts/interfaces/validator/ICandidateManager.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface ICandidateManager {\\n struct ValidatorCandidate {\\n // Admin of the candidate\\n address admin;\\n // Address of the validator that produces block, e.g. block.coinbase. This is so-called validator address.\\n address consensusAddr;\\n // Address that receives mining reward of the validator\\n address payable treasuryAddr;\\n // Address of the bridge operator corresponding to the candidate\\n address ______deprecatedbridgeOperatorAddr;\\n // The percentage of reward that validators can be received, the rest goes to the delegators.\\n // Values in range [0; 100_00] stands for 0-100%\\n uint256 commissionRate;\\n // The timestamp that scheduled to revoke the candidate (no schedule=0)\\n uint256 revokingTimestamp;\\n // The deadline that the candidate must top up staking amount to keep it larger than or equal to the threshold (no deadline=0)\\n uint256 topupDeadline;\\n }\\n\\n struct CommissionSchedule {\\n // The timestamp that the commission schedule gets affected (no schedule=0).\\n uint256 effectiveTimestamp;\\n // The new commission rate. Value is in range [0; 100_00], stands for 0-100%\\n uint256 commissionRate;\\n }\\n\\n /// @dev Emitted when the maximum number of validator candidates is updated.\\n event MaxValidatorCandidateUpdated(uint256 threshold);\\n /// @dev Emitted when the min offset to the effective date of commission rate change is updated.\\n event MinEffectiveDaysOnwardsUpdated(uint256 numOfDays);\\n /// @dev Emitted when the validator candidate is granted.\\n event CandidateGranted(address indexed consensusAddr, address indexed treasuryAddr, address indexed admin);\\n /// @dev Emitted when the revoking timestamp of a candidate is updated.\\n event CandidateRevokingTimestampUpdated(address indexed consensusAddr, uint256 revokingTimestamp);\\n /// @dev Emitted when the topup deadline of a candidate is updated.\\n event CandidateTopupDeadlineUpdated(address indexed consensusAddr, uint256 topupDeadline);\\n /// @dev Emitted when the validator candidate is revoked.\\n event CandidatesRevoked(address[] consensusAddrs);\\n\\n /// @dev Emitted when a schedule for updating commission rate is set.\\n event CommissionRateUpdateScheduled(address indexed consensusAddr, uint256 effectiveTimestamp, uint256 rate);\\n /// @dev Emitted when the commission rate of a validator is updated.\\n event CommissionRateUpdated(address indexed consensusAddr, uint256 rate);\\n\\n /// @dev Error of exceeding maximum number of candidates.\\n error ErrExceedsMaxNumberOfCandidate();\\n /// @dev Error of querying for already existent candidate.\\n error ErrExistentCandidate();\\n /// @dev Error of querying for non-existent candidate.\\n error ErrNonExistentCandidate();\\n /// @dev Error of candidate admin already exists.\\n error ErrExistentCandidateAdmin(address _candidateAdminAddr);\\n /// @dev Error of treasury already exists.\\n error ErrExistentTreasury(address _treasuryAddr);\\n /// @dev Error of invalid commission rate.\\n error ErrInvalidCommissionRate();\\n /// @dev Error of invalid effective days onwards.\\n error ErrInvalidEffectiveDaysOnwards();\\n /// @dev Error of invalid min effective days onwards.\\n error ErrInvalidMinEffectiveDaysOnwards();\\n /// @dev Error of already requested revoking candidate before.\\n error ErrAlreadyRequestedRevokingCandidate();\\n /// @dev Error of commission change schedule exists.\\n error ErrAlreadyRequestedUpdatingCommissionRate();\\n /// @dev Error of trusted org cannot renounce.\\n error ErrTrustedOrgCannotRenounce();\\n\\n /**\\n * @dev Returns the maximum number of validator candidate.\\n */\\n function maxValidatorCandidate() external view returns (uint256);\\n\\n /**\\n * @dev Returns the minimum number of days to the effective date of commission rate change.\\n */\\n function minEffectiveDaysOnwards() external view returns (uint256);\\n\\n /**\\n * @dev Sets the maximum number of validator candidate.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the `MaxValidatorCandidateUpdated` event.\\n *\\n */\\n function setMaxValidatorCandidate(uint256) external;\\n\\n /**\\n * @dev Sets the minimum number of days to the effective date of commision rate change.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the `MinEffectiveDaysOnwardsUpdated` event.\\n *\\n */\\n function setMinEffectiveDaysOnwards(uint256 _numOfDays) external;\\n\\n /**\\n * @dev Grants a validator candidate.\\n *\\n * Requirements:\\n * - The method caller is staking contract.\\n *\\n * Emits the event `CandidateGranted`.\\n *\\n */\\n function execApplyValidatorCandidate(\\n address _admin,\\n address _consensusAddr,\\n address payable _treasuryAddr,\\n uint256 _commissionRate\\n ) external;\\n\\n /**\\n * @dev Requests to revoke a validator candidate in next `_secsLeft` seconds.\\n *\\n * Requirements:\\n * - The method caller is staking contract.\\n *\\n * Emits the event `CandidateRevokingTimestampUpdated`.\\n *\\n */\\n function execRequestRenounceCandidate(address, uint256 _secsLeft) external;\\n\\n /**\\n * @dev Fallback function of `CandidateStaking-requestUpdateCommissionRate`.\\n *\\n * Requirements:\\n * - The method caller is the staking contract.\\n * - The `_effectiveTimestamp` must be the beginning of a UTC day, and at least from 7 days onwards\\n * - The `_rate` must be in range of [0_00; 100_00].\\n *\\n * Emits the event `CommissionRateUpdateScheduled`.\\n *\\n */\\n function execRequestUpdateCommissionRate(address _consensusAddr, uint256 _effectiveTimestamp, uint256 _rate) external;\\n\\n /**\\n * @dev Returns whether the address is a validator (candidate).\\n */\\n function isValidatorCandidate(address _addr) external view returns (bool);\\n\\n /**\\n * @dev Returns the validator candidate.\\n */\\n function getValidatorCandidates() external view returns (address[] memory);\\n\\n /**\\n * @dev Returns all candidate info.\\n */\\n function getCandidateInfos() external view returns (ValidatorCandidate[] memory);\\n\\n /**\\n * @dev Returns the info of a candidate.\\n */\\n function getCandidateInfo(address _candidate) external view returns (ValidatorCandidate memory);\\n\\n /**\\n * @dev Returns whether the address is the candidate admin.\\n */\\n function isCandidateAdmin(address _candidate, address _admin) external view returns (bool);\\n\\n /**\\n * @dev Returns the schedule of changing commission rate of a candidate address.\\n */\\n function getCommissionChangeSchedule(address _candidate) external view returns (CommissionSchedule memory);\\n}\\n\",\"keccak256\":\"0x9ab205c736f1bcc9a3debe06e08d829f4857141d940e6f608236f136193a7f49\",\"license\":\"MIT\"},\"contracts/interfaces/validator/ICoinbaseExecution.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./ISlashingExecution.sol\\\";\\n\\ninterface ICoinbaseExecution is ISlashingExecution {\\n enum BlockRewardDeprecatedType {\\n UNKNOWN,\\n UNAVAILABILITY,\\n AFTER_BAILOUT\\n }\\n\\n /// @dev Emitted when the validator set is updated\\n event ValidatorSetUpdated(uint256 indexed period, address[] consensusAddrs);\\n /// @dev Emitted when the bridge operator set is updated, to mirror the in-jail and maintaining status of the validator.\\n event BlockProducerSetUpdated(uint256 indexed period, uint256 indexed epoch, address[] consensusAddrs);\\n /// @dev Emitted when the bridge operator set is updated.\\n event BridgeOperatorSetUpdated(uint256 indexed period, uint256 indexed epoch, address[] bridgeOperators);\\n\\n /// @dev Emitted when the reward of the block producer is deprecated.\\n event BlockRewardDeprecated(\\n address indexed coinbaseAddr,\\n uint256 rewardAmount,\\n BlockRewardDeprecatedType deprecatedType\\n );\\n /// @dev Emitted when the block reward is submitted.\\n event BlockRewardSubmitted(address indexed coinbaseAddr, uint256 submittedAmount, uint256 bonusAmount);\\n\\n /// @dev Emitted when the block producer reward is distributed.\\n event MiningRewardDistributed(address indexed consensusAddr, address indexed recipient, uint256 amount);\\n /// @dev Emitted when the contract fails when distributing the block producer reward.\\n event MiningRewardDistributionFailed(\\n address indexed consensusAddr,\\n address indexed recipient,\\n uint256 amount,\\n uint256 contractBalance\\n );\\n\\n /// @dev Emitted when the bridge operator reward is distributed.\\n event BridgeOperatorRewardDistributed(\\n address indexed consensusAddr,\\n address indexed bridgeOperator,\\n address indexed recipientAddr,\\n uint256 amount\\n );\\n /// @dev Emitted when the contract fails when distributing the bridge operator reward.\\n event BridgeOperatorRewardDistributionFailed(\\n address indexed consensusAddr,\\n address indexed bridgeOperator,\\n address indexed recipient,\\n uint256 amount,\\n uint256 contractBalance\\n );\\n\\n /// @dev Emitted when the amount of RON reward is distributed to staking contract.\\n event StakingRewardDistributed(uint256 totalAmount, address[] consensusAddrs, uint256[] amounts);\\n /// @dev Emitted when the contracts fails when distributing the amount of RON to the staking contract.\\n event StakingRewardDistributionFailed(\\n uint256 totalAmount,\\n address[] consensusAddrs,\\n uint256[] amounts,\\n uint256 contractBalance\\n );\\n\\n /// @dev Emitted when the epoch is wrapped up.\\n event WrappedUpEpoch(uint256 indexed periodNumber, uint256 indexed epochNumber, bool periodEnding);\\n\\n /// @dev Error of method caller must be coinbase\\n error ErrCallerMustBeCoinbase();\\n /// @dev Error of only allowed at the end of epoch\\n error ErrAtEndOfEpochOnly();\\n /// @dev Error of query for already wrapped up epoch\\n error ErrAlreadyWrappedEpoch();\\n\\n /**\\n * @dev Submits reward of the current block.\\n *\\n * Requirements:\\n * - The method caller is coinbase.\\n *\\n * Emits the event `MiningRewardDeprecated` if the coinbase is slashed or no longer be a block producer.\\n * Emits the event `BlockRewardSubmitted` for the valid call.\\n *\\n */\\n function submitBlockReward() external payable;\\n\\n /**\\n * @dev Wraps up the current epoch.\\n *\\n * Requirements:\\n * - The method must be called when the current epoch is ending.\\n * - The epoch is not wrapped yet.\\n * - The method caller is coinbase.\\n *\\n * Emits the event `MiningRewardDistributed` when some validator has reward distributed.\\n * Emits the event `StakingRewardDistributed` when some staking pool has reward distributed.\\n * Emits the event `BlockProducerSetUpdated` when the epoch is wrapped up.\\n * Emits the event `BridgeOperatorSetUpdated` when the epoch is wrapped up at period ending.\\n * Emits the event `ValidatorSetUpdated` when the epoch is wrapped up at period ending, and the validator set gets updated.\\n * Emits the event `WrappedUpEpoch`.\\n *\\n */\\n function wrapUpEpoch() external payable;\\n}\\n\",\"keccak256\":\"0xe4060b7e3b04a0043bd334011fe4ba67c990b0484dad52d7f14b35040989b6ab\",\"license\":\"MIT\"},\"contracts/interfaces/validator/IEmergencyExit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface IEmergencyExit {\\n /// @dev Emitted when the fund is locked from an emergency exit request\\n event EmergencyExitRequested(address indexed consensusAddr, uint256 lockedAmount);\\n /// @dev Emitted when the fund that locked from an emergency exit request is transferred to the recipient.\\n event EmergencyExitLockedFundReleased(\\n address indexed consensusAddr,\\n address indexed recipient,\\n uint256 unlockedAmount\\n );\\n /// @dev Emitted when the fund that locked from an emergency exit request is failed to transferred back.\\n event EmergencyExitLockedFundReleasingFailed(\\n address indexed consensusAddr,\\n address indexed recipient,\\n uint256 unlockedAmount,\\n uint256 contractBalance\\n );\\n\\n /// @dev Emitted when the emergency exit locked amount is updated.\\n event EmergencyExitLockedAmountUpdated(uint256 amount);\\n /// @dev Emitted when the emergency expiry duration is updated.\\n event EmergencyExpiryDurationUpdated(uint256 amount);\\n\\n /// @dev Error of already requested emergency exit before.\\n error ErrAlreadyRequestedEmergencyExit();\\n\\n /**\\n * @dev Returns the amount of RON to lock from a consensus address.\\n */\\n function emergencyExitLockedAmount() external returns (uint256);\\n\\n /**\\n * @dev Returns the duration that an emergency request is expired and the fund will be recycled.\\n */\\n function emergencyExpiryDuration() external returns (uint256);\\n\\n /**\\n * @dev Sets the amount of RON to lock from a consensus address.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `EmergencyExitLockedAmountUpdated`.\\n *\\n */\\n function setEmergencyExitLockedAmount(uint256 _emergencyExitLockedAmount) external;\\n\\n /**\\n * @dev Sets the duration that an emergency request is expired and the fund will be recycled.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `EmergencyExpiryDurationUpdated`.\\n *\\n */\\n function setEmergencyExpiryDuration(uint256 _emergencyExpiryDuration) external;\\n\\n /**\\n * @dev Unlocks fund for emergency exit request.\\n *\\n * Requirements:\\n * - The method caller is admin.\\n *\\n * Emits the event `EmergencyExitLockedFundReleased` if the fund is successfully unlocked.\\n * Emits the event `EmergencyExitLockedFundReleasingFailed` if the fund is failed to unlock.\\n *\\n */\\n function execReleaseLockedFundForEmergencyExitRequest(address _consensusAddr, address payable _recipient) external;\\n\\n /**\\n * @dev Fallback function of `IStaking-requestEmergencyExit`.\\n *\\n * Requirements:\\n * - The method caller is staking contract.\\n *\\n */\\n function execEmergencyExit(address _consensusAddr, uint256 _secLeftToRevoke) external;\\n}\\n\",\"keccak256\":\"0x45161abd1e3db83052a06889a0e3a7a5e7ee3306478601d58ac4ed32ccaa75ad\",\"license\":\"MIT\"},\"contracts/interfaces/validator/IRoninValidatorSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./ICandidateManager.sol\\\";\\nimport \\\"./info-fragments/ICommonInfo.sol\\\";\\nimport \\\"./ICoinbaseExecution.sol\\\";\\nimport \\\"./ISlashingExecution.sol\\\";\\nimport \\\"./IEmergencyExit.sol\\\";\\n\\ninterface IRoninValidatorSet is\\n ICandidateManager,\\n ICommonInfo,\\n ISlashingExecution,\\n ICoinbaseExecution,\\n IEmergencyExit\\n{}\\n\",\"keccak256\":\"0x813f34747aea4dfb53bbc147abf8dbe5999ce73111c2db99bcb3efb4cf75bb3d\",\"license\":\"MIT\"},\"contracts/interfaces/validator/ISlashingExecution.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface ISlashingExecution {\\n /// @dev Emitted when the validator is punished.\\n event ValidatorPunished(\\n address indexed consensusAddr,\\n uint256 indexed period,\\n uint256 jailedUntil,\\n uint256 deductedStakingAmount,\\n bool blockProducerRewardDeprecated,\\n bool bridgeOperatorRewardDeprecated\\n );\\n /// @dev Emitted when the validator get out of jail by bailout.\\n event ValidatorUnjailed(address indexed validator, uint256 period);\\n\\n /// @dev Error of cannot bailout due to high tier slash.\\n error ErrCannotBailout(address validator);\\n\\n /**\\n * @dev Finalize the slash request from slash indicator contract.\\n *\\n * Requirements:\\n * - The method caller is slash indicator contract.\\n *\\n * Emits the event `ValidatorPunished`.\\n *\\n */\\n function execSlash(\\n address _validatorAddr,\\n uint256 _newJailedUntil,\\n uint256 _slashAmount,\\n bool _cannotBailout\\n ) external;\\n\\n /**\\n * @dev Finalize the bailout request from slash indicator contract.\\n *\\n * Requirements:\\n * - The method caller is slash indicator contract.\\n *\\n * Emits the event `ValidatorUnjailed`.\\n *\\n */\\n function execBailOut(address _validatorAddr, uint256 _period) external;\\n}\\n\",\"keccak256\":\"0x80362c42fdc0ee06543a2abbffee961fe51c15a7c5e18933a9c34897e50d07fe\",\"license\":\"MIT\"},\"contracts/interfaces/validator/info-fragments/ICommonInfo.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"./IJailingInfo.sol\\\";\\nimport \\\"./ITimingInfo.sol\\\";\\nimport \\\"./IValidatorInfoV2.sol\\\";\\n\\ninterface ICommonInfo is ITimingInfo, IJailingInfo, IValidatorInfoV2 {\\n struct EmergencyExitInfo {\\n uint256 lockedAmount;\\n // The timestamp that this locked amount will be recycled to staking vesting contract\\n uint256 recyclingAt;\\n }\\n\\n /// @dev Emitted when the deprecated reward is withdrawn.\\n event DeprecatedRewardRecycled(address indexed recipientAddr, uint256 amount);\\n /// @dev Emitted when the deprecated reward withdrawal is failed\\n event DeprecatedRewardRecycleFailed(address indexed recipientAddr, uint256 amount, uint256 balance);\\n\\n /// @dev Error thrown when receives RON from neither staking vesting contract nor staking contract\\n error ErrUnauthorizedReceiveRON();\\n /// @dev Error thrown when queries for a non existent info.\\n error NonExistentRecyclingInfo();\\n\\n /**\\n * @dev Returns the total deprecated reward, which includes reward that is not sent for slashed validators and unsastified bridge operators\\n */\\n function totalDeprecatedReward() external view returns (uint256);\\n\\n /**\\n * @dev Returns the emergency exit request.\\n */\\n function getEmergencyExitInfo(address _consensusAddr) external view returns (EmergencyExitInfo memory);\\n}\\n\",\"keccak256\":\"0x3fdfa86da33b889e5153075ffc028d6b0c607480a96b532fbbbc48ac7bbf27c9\",\"license\":\"MIT\"},\"contracts/interfaces/validator/info-fragments/IJailingInfo.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface IJailingInfo {\\n /**\\n * @dev Returns whether the validator are put in jail (cannot join the set of validators) during the current period.\\n */\\n function checkJailed(address) external view returns (bool);\\n\\n /**\\n * @dev Returns whether the validator are put in jail and the number of block and epoch that he still is in the jail.\\n */\\n function getJailedTimeLeft(\\n address _addr\\n ) external view returns (bool isJailed_, uint256 blockLeft_, uint256 epochLeft_);\\n\\n /**\\n * @dev Returns whether the validator are put in jail (cannot join the set of validators) at a specific block.\\n */\\n function checkJailedAtBlock(address _addr, uint256 _blockNum) external view returns (bool);\\n\\n /**\\n * @dev Returns whether the validator are put in jail at a specific block and the number of block and epoch that he still is in the jail.\\n */\\n function getJailedTimeLeftAtBlock(\\n address _addr,\\n uint256 _blockNum\\n ) external view returns (bool isJailed_, uint256 blockLeft_, uint256 epochLeft_);\\n\\n /**\\n * @dev Returns whether the validators are put in jail (cannot join the set of validators) during the current period.\\n */\\n function checkManyJailed(address[] calldata) external view returns (bool[] memory);\\n\\n /**\\n * @dev Returns whether the incoming reward of the block producer is deprecated during the current period.\\n */\\n function checkMiningRewardDeprecated(address _blockProducer) external view returns (bool);\\n\\n /**\\n * @dev Returns whether the incoming reward of the block producer is deprecated during a specific period.\\n */\\n function checkMiningRewardDeprecatedAtPeriod(address _blockProducer, uint256 _period) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x2b1846b05ca1d636299fb929c1bd7b392b236f5e3f7aa3e7eea2c6d57b8836fb\",\"license\":\"MIT\"},\"contracts/interfaces/validator/info-fragments/ITimingInfo.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\ninterface ITimingInfo {\\n /**\\n * @dev Returns the block that validator set was updated.\\n */\\n function getLastUpdatedBlock() external view returns (uint256);\\n\\n /**\\n * @dev Returns the number of blocks in a epoch.\\n */\\n function numberOfBlocksInEpoch() external view returns (uint256 _numberOfBlocks);\\n\\n /**\\n * @dev Returns the epoch index from the block number.\\n */\\n function epochOf(uint256 _block) external view returns (uint256);\\n\\n /**\\n * @dev Returns whether the epoch ending is at the block number `_block`.\\n */\\n function epochEndingAt(uint256 _block) external view returns (bool);\\n\\n /**\\n * @dev Tries to get the period index from the epoch number.\\n */\\n function tryGetPeriodOfEpoch(uint256 _epoch) external view returns (bool _filled, uint256 _periodNumber);\\n\\n /**\\n * @dev Returns whether the period ending at the current block number.\\n */\\n function isPeriodEnding() external view returns (bool);\\n\\n /**\\n * @dev Returns the period index from the current block.\\n */\\n function currentPeriod() external view returns (uint256);\\n\\n /**\\n * @dev Returns the block number that the current period starts at.\\n */\\n function currentPeriodStartAtBlock() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x77b86a68149389fed0eb0c5b8d56f278d3bd103ba64f504697d709b24c3212d5\",\"license\":\"MIT\"},\"contracts/interfaces/validator/info-fragments/IValidatorInfoV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"../../../libraries/EnumFlags.sol\\\";\\n\\ninterface IValidatorInfoV2 {\\n /**\\n * @dev Error thrown when an invalid maximum prioritized validator number is provided.\\n */\\n error ErrInvalidMaxPrioritizedValidatorNumber();\\n\\n /// @dev Emitted when the number of max validator is updated.\\n event MaxValidatorNumberUpdated(uint256);\\n /// @dev Emitted when the number of reserved slots for prioritized validators is updated.\\n event MaxPrioritizedValidatorNumberUpdated(uint256);\\n\\n /**\\n * @dev Returns the maximum number of validators in the epoch.\\n */\\n function maxValidatorNumber() external view returns (uint256 _maximumValidatorNumber);\\n\\n /**\\n * @dev Returns the number of reserved slots for prioritized validators.\\n */\\n function maxPrioritizedValidatorNumber() external view returns (uint256 _maximumPrioritizedValidatorNumber);\\n\\n /**\\n * @dev Returns the current validator list.\\n */\\n function getValidators() external view returns (address[] memory _validatorList);\\n\\n /**\\n * @dev Returns the current block producer list.\\n */\\n function getBlockProducers() external view returns (address[] memory);\\n\\n /**\\n * @dev Returns whether the address is block producer or not.\\n */\\n function isBlockProducer(address _addr) external view returns (bool);\\n\\n /**\\n * @dev Returns total numbers of the block producers.\\n */\\n function totalBlockProducers() external view returns (uint256);\\n\\n /**\\n * @dev Updates the max validator number\\n *\\n * Requirements:\\n * - The method caller is admin\\n *\\n * Emits the event `MaxValidatorNumberUpdated`\\n *\\n */\\n function setMaxValidatorNumber(uint256 _maxValidatorNumber) external;\\n\\n /**\\n * @dev Updates the number of reserved slots for prioritized validators\\n *\\n * Requirements:\\n * - The method caller is admin\\n *\\n * Emits the event `MaxPrioritizedValidatorNumberUpdated`\\n *\\n */\\n function setMaxPrioritizedValidatorNumber(uint256 _maxPrioritizedValidatorNumber) external;\\n}\\n\",\"keccak256\":\"0x6213c188a1323b242a098394b91caf9481e257bd57a0804cb2aa890377a993ed\",\"license\":\"MIT\"},\"contracts/libraries/AddressArrayUtils.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\n\\npragma solidity ^0.8.0;\\n\\nlibrary AddressArrayUtils {\\n /**\\n * @dev Error thrown when a duplicated element is detected in an array.\\n * @param msgSig The function signature that invoke the error.\\n */\\n error ErrDuplicated(bytes4 msgSig);\\n\\n /**\\n * @dev Returns whether or not there's a duplicate. Runs in O(n^2).\\n * @param A Array to search\\n * @return Returns true if duplicate, false otherwise\\n */\\n function hasDuplicate(address[] memory A) internal pure returns (bool) {\\n if (A.length == 0) {\\n return false;\\n }\\n unchecked {\\n for (uint256 i = 0; i < A.length - 1; i++) {\\n for (uint256 j = i + 1; j < A.length; j++) {\\n if (A[i] == A[j]) {\\n return true;\\n }\\n }\\n }\\n }\\n return false;\\n }\\n\\n /**\\n * @dev Returns whether two arrays of addresses are equal or not.\\n */\\n function isEqual(address[] memory _this, address[] memory _other) internal pure returns (bool yes_) {\\n // Hashing two arrays and compare their hash\\n assembly {\\n let _thisHash := keccak256(add(_this, 32), mul(mload(_this), 32))\\n let _otherHash := keccak256(add(_other, 32), mul(mload(_other), 32))\\n yes_ := eq(_thisHash, _otherHash)\\n }\\n }\\n\\n /**\\n * @dev Return the concatenated array from a and b.\\n */\\n function extend(address[] memory a, address[] memory b) internal pure returns (address[] memory c) {\\n uint256 lengthA = a.length;\\n uint256 lengthB = b.length;\\n unchecked {\\n c = new address[](lengthA + lengthB);\\n }\\n uint256 i;\\n for (; i < lengthA; ) {\\n c[i] = a[i];\\n unchecked {\\n ++i;\\n }\\n }\\n for (uint256 j; j < lengthB; ) {\\n c[i] = b[j];\\n unchecked {\\n ++i;\\n ++j;\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xaf760162653a85d6e1b24df4d33c74076f778470112f421a02050fb981242001\",\"license\":\"UNLICENSED\"},\"contracts/libraries/EnumFlags.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This library implements checking flag of an enumerated value.\\n * The originated idea is inherited from [Enum.HashFlag(Enum)](https://learn.microsoft.com/en-us/dotnet/api/system.enum.hasflag?view=net-6.0) method of C#.\\n */\\nlibrary EnumFlags {\\n enum ValidatorFlag {\\n None, // bit(00)\\n BlockProducer, // bit(01)\\n DeprecatedBridgeOperator, // bit(10)\\n Both // bit(11)\\n }\\n\\n function isNone(ValidatorFlag _value) internal pure returns (bool) {\\n return uint8(_value) == 0;\\n }\\n\\n /**\\n * @dev Checks if `_value` has `_flag`.\\n */\\n function hasFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (bool) {\\n return (uint8(_value) & uint8(_flag)) != 0;\\n }\\n\\n /**\\n * @dev Calculate new value of `_value` after adding `_flag`.\\n */\\n function addFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (ValidatorFlag) {\\n return ValidatorFlag(uint8(_value) | uint8(_flag));\\n }\\n\\n /**\\n * @dev Calculate new value of `_value` after remove `_flag`.\\n */\\n function removeFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (ValidatorFlag) {\\n return ValidatorFlag(uint8(_value) & ~uint8(_flag));\\n }\\n}\\n\",\"keccak256\":\"0xa712f0d1a323ee39f23eb3ee3278b4ec25fe2e536b1ccc629578c66f277c088d\",\"license\":\"UNLICENSED\"},\"contracts/libraries/Math.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\n\\npragma solidity ^0.8.0;\\n\\nlibrary Math {\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a >= b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns whether the number `c` is in range of [a; b].\\n */\\n function inRange(uint256 c, uint256 a, uint256 b) internal pure returns (bool) {\\n return a <= c && c <= b;\\n }\\n\\n /**\\n * @dev Returns whether two inclusive ranges [x1;x2] and [y1;y2] overlap.\\n */\\n function twoRangeOverlap(uint256 x1, uint256 x2, uint256 y1, uint256 y2) internal pure returns (bool) {\\n return x1 <= y2 && y1 <= x2;\\n }\\n\\n /**\\n * @dev Returns value of a + b; in case result is larger than upperbound, upperbound is returned.\\n */\\n function addWithUpperbound(uint256 a, uint256 b, uint256 upperbound) internal pure returns (uint256) {\\n return min(a + b, upperbound);\\n }\\n\\n /**\\n * @dev Returns value of a - b; in case of negative result, 0 is returned.\\n */\\n function subNonNegative(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a - b : 0;\\n }\\n\\n /**\\n * @dev Returns value of `a + zeroable` if zerobale is not 0; otherwise, return 0.\\n */\\n function addIfNonZero(uint256 a, uint256 zeroable) internal pure returns (uint256) {\\n return zeroable != 0 ? a + zeroable : 0;\\n }\\n}\\n\",\"keccak256\":\"0xd73170f448c644a47024c7dbcf4afc3cc7ad27f61737c6ea4c3b543ec5cdb7e9\",\"license\":\"UNLICENSED\"},\"contracts/ronin/staking/BaseStaking.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/security/ReentrancyGuard.sol\\\";\\nimport \\\"../../extensions/RONTransferHelper.sol\\\";\\nimport \\\"../../extensions/collections/HasContracts.sol\\\";\\nimport \\\"../../interfaces/staking/IBaseStaking.sol\\\";\\nimport \\\"../../interfaces/validator/IRoninValidatorSet.sol\\\";\\nimport \\\"../../libraries/Math.sol\\\";\\nimport { HasValidatorDeprecated } from \\\"../../utils/DeprecatedSlots.sol\\\";\\nimport \\\"./RewardCalculation.sol\\\";\\n\\nabstract contract BaseStaking is\\n RONTransferHelper,\\n ReentrancyGuard,\\n RewardCalculation,\\n HasContracts,\\n IBaseStaking,\\n HasValidatorDeprecated\\n{\\n /// @dev Mapping from pool address => staking pool detail\\n mapping(address => PoolDetail) internal _stakingPool;\\n\\n /// @dev The cooldown time in seconds to undelegate from the last timestamp (s)he delegated.\\n uint256 internal _cooldownSecsToUndelegate;\\n /// @dev The number of seconds that a candidate must wait to be revoked and take the self-staking amount back.\\n uint256 internal _waitingSecsToRevoke;\\n\\n /// @dev Mapping from admin address of an active pool => consensus address.\\n mapping(address => address) internal _adminOfActivePoolMapping;\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n */\\n uint256[49] private ______gap;\\n\\n modifier noEmptyValue() {\\n _requireValue();\\n _;\\n }\\n\\n modifier anyExceptPoolAdmin(PoolDetail storage _pool, address _delegator) {\\n _anyExceptPoolAdmin(_pool, _delegator);\\n _;\\n }\\n\\n modifier onlyPoolAdmin(PoolDetail storage _pool, address _requester) {\\n _requirePoolAdmin(_pool, _requester);\\n _;\\n }\\n\\n modifier poolIsActive(address _poolAddr) {\\n _poolIsActive(_poolAddr);\\n _;\\n }\\n\\n function _requireValue() private view {\\n if (msg.value == 0) revert ErrZeroValue();\\n }\\n\\n function _requirePoolAdmin(PoolDetail storage _pool, address _requester) private view {\\n if (_pool.admin != _requester) revert ErrOnlyPoolAdminAllowed();\\n }\\n\\n function _anyExceptPoolAdmin(PoolDetail storage _pool, address _delegator) private view {\\n if (_pool.admin == _delegator) revert ErrPoolAdminForbidden();\\n }\\n\\n function _poolIsActive(address _poolAddr) private view {\\n if (!IRoninValidatorSet(getContract(ContractType.VALIDATOR)).isValidatorCandidate(_poolAddr))\\n revert ErrInactivePool(_poolAddr);\\n }\\n\\n /**\\n * @inheritdoc IBaseStaking\\n */\\n function isAdminOfActivePool(address _poolAdminAddr) public view override returns (bool) {\\n return _adminOfActivePoolMapping[_poolAdminAddr] != address(0);\\n }\\n\\n /**\\n * @inheritdoc IBaseStaking\\n */\\n function getPoolAddressOf(address _poolAdminAddr) external view override returns (address) {\\n return _adminOfActivePoolMapping[_poolAdminAddr];\\n }\\n\\n /**\\n * @inheritdoc IBaseStaking\\n */\\n function getPoolDetail(\\n address _poolAddr\\n ) external view returns (address _admin, uint256 _stakingAmount, uint256 _stakingTotal) {\\n PoolDetail storage _pool = _stakingPool[_poolAddr];\\n return (_pool.admin, _pool.stakingAmount, _pool.stakingTotal);\\n }\\n\\n /**\\n * @inheritdoc IBaseStaking\\n */\\n function getManySelfStakings(address[] calldata _pools) external view returns (uint256[] memory _selfStakings) {\\n _selfStakings = new uint256[](_pools.length);\\n for (uint _i = 0; _i < _pools.length; ) {\\n _selfStakings[_i] = _stakingPool[_pools[_i]].stakingAmount;\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @inheritdoc IRewardPool\\n */\\n function getStakingTotal(address _poolAddr) public view override returns (uint256) {\\n return _stakingPool[_poolAddr].stakingTotal;\\n }\\n\\n /**\\n * @inheritdoc IRewardPool\\n */\\n function getManyStakingTotals(\\n address[] calldata _poolList\\n ) public view override returns (uint256[] memory _stakingAmounts) {\\n _stakingAmounts = new uint256[](_poolList.length);\\n for (uint _i = 0; _i < _poolList.length; ) {\\n _stakingAmounts[_i] = getStakingTotal(_poolList[_i]);\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @inheritdoc IRewardPool\\n */\\n function getStakingAmount(address _poolAddr, address _user) public view override returns (uint256) {\\n return _stakingPool[_poolAddr].delegatingAmount[_user];\\n }\\n\\n /**\\n * @inheritdoc IRewardPool\\n */\\n function getManyStakingAmounts(\\n address[] calldata _poolAddrs,\\n address[] calldata _userList\\n ) external view override returns (uint256[] memory _stakingAmounts) {\\n if (_poolAddrs.length != _userList.length) revert ErrInvalidArrays();\\n _stakingAmounts = new uint256[](_poolAddrs.length);\\n for (uint _i = 0; _i < _stakingAmounts.length; ) {\\n _stakingAmounts[_i] = _stakingPool[_poolAddrs[_i]].delegatingAmount[_userList[_i]];\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @inheritdoc IBaseStaking\\n */\\n function cooldownSecsToUndelegate() external view returns (uint256) {\\n return _cooldownSecsToUndelegate;\\n }\\n\\n /**\\n * @inheritdoc IBaseStaking\\n */\\n function waitingSecsToRevoke() external view returns (uint256) {\\n return _waitingSecsToRevoke;\\n }\\n\\n /**\\n * @inheritdoc IBaseStaking\\n */\\n function setCooldownSecsToUndelegate(uint256 _cooldownSecs) external override onlyAdmin {\\n _setCooldownSecsToUndelegate(_cooldownSecs);\\n }\\n\\n /**\\n * @inheritdoc IBaseStaking\\n */\\n function setWaitingSecsToRevoke(uint256 _secs) external override onlyAdmin {\\n _setWaitingSecsToRevoke(_secs);\\n }\\n\\n /**\\n * @dev Sets the minium number of seconds to undelegate.\\n *\\n * Emits the event `CooldownSecsToUndelegateUpdated`.\\n *\\n */\\n function _setCooldownSecsToUndelegate(uint256 _cooldownSecs) internal {\\n _cooldownSecsToUndelegate = _cooldownSecs;\\n emit CooldownSecsToUndelegateUpdated(_cooldownSecs);\\n }\\n\\n /**\\n * @dev Sets the number of seconds that a candidate must wait to be revoked.\\n *\\n * Emits the event `WaitingSecsToRevokeUpdated`.\\n *\\n */\\n function _setWaitingSecsToRevoke(uint256 _secs) internal {\\n _waitingSecsToRevoke = _secs;\\n emit WaitingSecsToRevokeUpdated(_secs);\\n }\\n\\n /**\\n * @dev Changes the delegate amount.\\n */\\n function _changeDelegatingAmount(\\n PoolDetail storage _pool,\\n address _delegator,\\n uint256 _newDelegatingAmount,\\n uint256 _newStakingTotal\\n ) internal {\\n _syncUserReward(_pool.addr, _delegator, _newDelegatingAmount);\\n _pool.stakingTotal = _newStakingTotal;\\n _pool.delegatingAmount[_delegator] = _newDelegatingAmount;\\n }\\n}\\n\",\"keccak256\":\"0xa1a3e6edfc9d8da5c851de0647c58bc86b0ec2e4a1c041f1b2a73d91b3d69b8d\",\"license\":\"MIT\"},\"contracts/ronin/staking/CandidateStaking.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"../../extensions/consumers/GlobalConfigConsumer.sol\\\";\\nimport \\\"../../extensions/consumers/PercentageConsumer.sol\\\";\\nimport \\\"../../libraries/AddressArrayUtils.sol\\\";\\nimport \\\"../../interfaces/staking/ICandidateStaking.sol\\\";\\nimport \\\"./BaseStaking.sol\\\";\\n\\nabstract contract CandidateStaking is BaseStaking, ICandidateStaking, GlobalConfigConsumer, PercentageConsumer {\\n /// @dev The minimum threshold for being a validator candidate.\\n uint256 internal _minValidatorStakingAmount;\\n\\n /// @dev The max commission rate that the validator can set (in range of [0;100_00] means [0-100%])\\n uint256 internal _maxCommissionRate;\\n /// @dev The min commission rate that the validator can set (in range of [0;100_00] means [0-100%])\\n uint256 internal _minCommissionRate;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n */\\n uint256[48] ______gap;\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function minValidatorStakingAmount() public view override returns (uint256) {\\n return _minValidatorStakingAmount;\\n }\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function getCommissionRateRange() external view override returns (uint256, uint256) {\\n return (_minCommissionRate, _maxCommissionRate);\\n }\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function setMinValidatorStakingAmount(uint256 _threshold) external override onlyAdmin {\\n _setMinValidatorStakingAmount(_threshold);\\n }\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function setCommissionRateRange(uint256 _minRate, uint256 _maxRate) external override onlyAdmin {\\n _setCommissionRateRange(_minRate, _maxRate);\\n }\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function applyValidatorCandidate(\\n address _candidateAdmin,\\n address _consensusAddr,\\n address payable _treasuryAddr,\\n uint256 _commissionRate\\n ) external payable override nonReentrant {\\n if (isAdminOfActivePool(msg.sender)) revert ErrAdminOfAnyActivePoolForbidden(msg.sender);\\n if (_commissionRate > _maxCommissionRate || _commissionRate < _minCommissionRate) revert ErrInvalidCommissionRate();\\n\\n uint256 _amount = msg.value;\\n address payable _poolAdmin = payable(msg.sender);\\n _applyValidatorCandidate({\\n _poolAdmin: _poolAdmin,\\n _candidateAdmin: _candidateAdmin,\\n _consensusAddr: _consensusAddr,\\n _treasuryAddr: _treasuryAddr,\\n _commissionRate: _commissionRate,\\n _amount: _amount\\n });\\n\\n PoolDetail storage _pool = _stakingPool[_consensusAddr];\\n _pool.admin = _poolAdmin;\\n _pool.addr = _consensusAddr;\\n _adminOfActivePoolMapping[_poolAdmin] = _consensusAddr;\\n\\n _stake(_stakingPool[_consensusAddr], _poolAdmin, _amount);\\n emit PoolApproved(_consensusAddr, _poolAdmin);\\n }\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function requestUpdateCommissionRate(\\n address _consensusAddr,\\n uint256 _effectiveDaysOnwards,\\n uint256 _commissionRate\\n ) external override poolIsActive(_consensusAddr) onlyPoolAdmin(_stakingPool[_consensusAddr], msg.sender) {\\n if (_commissionRate > _maxCommissionRate || _commissionRate < _minCommissionRate) revert ErrInvalidCommissionRate();\\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execRequestUpdateCommissionRate(\\n _consensusAddr,\\n _effectiveDaysOnwards,\\n _commissionRate\\n );\\n }\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function execDeprecatePools(\\n address[] calldata _pools,\\n uint256 _newPeriod\\n ) external override onlyContract(ContractType.VALIDATOR) {\\n if (_pools.length == 0) {\\n return;\\n }\\n\\n for (uint _i = 0; _i < _pools.length; ) {\\n PoolDetail storage _pool = _stakingPool[_pools[_i]];\\n // Deactivate the pool admin in the active mapping.\\n delete _adminOfActivePoolMapping[_pool.admin];\\n\\n // Deduct and transfer the self staking amount to the pool admin.\\n uint256 _deductingAmount = _pool.stakingAmount;\\n if (_deductingAmount > 0) {\\n _deductStakingAmount(_pool, _deductingAmount);\\n if (!_unsafeSendRONLimitGas(payable(_pool.admin), _deductingAmount, DEFAULT_ADDITION_GAS)) {\\n emit StakingAmountTransferFailed(_pool.addr, _pool.admin, _deductingAmount, address(this).balance);\\n }\\n }\\n\\n // Settle the unclaimed reward and transfer to the pool admin.\\n uint256 _lastRewardAmount = _claimReward(_pools[_i], _pool.admin, _newPeriod);\\n if (_lastRewardAmount > 0) {\\n _unsafeSendRONLimitGas(payable(_pool.admin), _lastRewardAmount, DEFAULT_ADDITION_GAS);\\n }\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n\\n emit PoolsDeprecated(_pools);\\n }\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function stake(address _consensusAddr) external payable override noEmptyValue poolIsActive(_consensusAddr) {\\n _stake(_stakingPool[_consensusAddr], msg.sender, msg.value);\\n }\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function unstake(\\n address _consensusAddr,\\n uint256 _amount\\n ) external override nonReentrant poolIsActive(_consensusAddr) {\\n if (_amount == 0) revert ErrUnstakeZeroAmount();\\n address _requester = msg.sender;\\n PoolDetail storage _pool = _stakingPool[_consensusAddr];\\n uint256 _remainAmount = _pool.stakingAmount - _amount;\\n if (_remainAmount < _minValidatorStakingAmount) revert ErrStakingAmountLeft();\\n\\n _unstake(_pool, _requester, _amount);\\n if (!_unsafeSendRONLimitGas(payable(_requester), _amount, DEFAULT_ADDITION_GAS)) revert ErrCannotTransferRON();\\n }\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function requestRenounce(\\n address _consensusAddr\\n ) external override poolIsActive(_consensusAddr) onlyPoolAdmin(_stakingPool[_consensusAddr], msg.sender) {\\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execRequestRenounceCandidate(\\n _consensusAddr,\\n _waitingSecsToRevoke\\n );\\n }\\n\\n /**\\n * @inheritdoc ICandidateStaking\\n */\\n function requestEmergencyExit(\\n address _consensusAddr\\n ) external override poolIsActive(_consensusAddr) onlyPoolAdmin(_stakingPool[_consensusAddr], msg.sender) {\\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execEmergencyExit(_consensusAddr, _waitingSecsToRevoke);\\n }\\n\\n /**\\n * @dev See `ICandidateStaking-applyValidatorCandidate`\\n */\\n function _applyValidatorCandidate(\\n address payable _poolAdmin,\\n address _candidateAdmin,\\n address _consensusAddr,\\n address payable _treasuryAddr,\\n uint256 _commissionRate,\\n uint256 _amount\\n ) internal {\\n if (!_unsafeSendRONLimitGas(_poolAdmin, 0, DEFAULT_ADDITION_GAS))\\n revert ErrCannotInitTransferRON(_poolAdmin, \\\"pool admin\\\");\\n if (!_unsafeSendRONLimitGas(_treasuryAddr, 0, DEFAULT_ADDITION_GAS))\\n revert ErrCannotInitTransferRON(_treasuryAddr, \\\"treasury\\\");\\n if (_amount < _minValidatorStakingAmount) revert ErrInsufficientStakingAmount();\\n if (_poolAdmin != _candidateAdmin || _candidateAdmin != _treasuryAddr) revert ErrThreeInteractionAddrsNotEqual();\\n\\n {\\n address[] memory _diffAddrs = new address[](2);\\n _diffAddrs[0] = _poolAdmin;\\n _diffAddrs[1] = _consensusAddr;\\n if (AddressArrayUtils.hasDuplicate(_diffAddrs)) revert AddressArrayUtils.ErrDuplicated(msg.sig);\\n }\\n\\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execApplyValidatorCandidate(\\n _candidateAdmin,\\n _consensusAddr,\\n _treasuryAddr,\\n _commissionRate\\n );\\n }\\n\\n /**\\n * @dev See `ICandidateStaking-stake`\\n */\\n function _stake(\\n PoolDetail storage _pool,\\n address _requester,\\n uint256 _amount\\n ) internal onlyPoolAdmin(_pool, _requester) {\\n _pool.stakingAmount += _amount;\\n _changeDelegatingAmount(_pool, _requester, _pool.stakingAmount, _pool.stakingTotal + _amount);\\n _pool.lastDelegatingTimestamp[_requester] = block.timestamp;\\n emit Staked(_pool.addr, _amount);\\n }\\n\\n /**\\n * @dev See `ICandidateStaking-unstake`\\n */\\n function _unstake(\\n PoolDetail storage _pool,\\n address _requester,\\n uint256 _amount\\n ) internal onlyPoolAdmin(_pool, _requester) {\\n if (_amount > _pool.stakingAmount) revert ErrInsufficientStakingAmount();\\n if (_pool.lastDelegatingTimestamp[_requester] + _cooldownSecsToUndelegate > block.timestamp) {\\n revert ErrUnstakeTooEarly();\\n }\\n\\n _pool.stakingAmount -= _amount;\\n _changeDelegatingAmount(_pool, _requester, _pool.stakingAmount, _pool.stakingTotal - _amount);\\n emit Unstaked(_pool.addr, _amount);\\n }\\n\\n /**\\n * @dev Deducts from staking amount of the validator `_consensusAddr` for `_amount`.\\n *\\n * Emits the event `Unstaked`.\\n *\\n * @return The actual deducted amount\\n */\\n function _deductStakingAmount(PoolDetail storage _pool, uint256 _amount) internal virtual returns (uint256);\\n\\n /**\\n * @dev Sets the minimum threshold for being a validator candidate.\\n *\\n * Emits the `MinValidatorStakingAmountUpdated` event.\\n *\\n */\\n function _setMinValidatorStakingAmount(uint256 _threshold) internal {\\n _minValidatorStakingAmount = _threshold;\\n emit MinValidatorStakingAmountUpdated(_threshold);\\n }\\n\\n /**\\n * @dev Sets the max commission rate that a candidate can set.\\n *\\n * Emits the `MaxCommissionRateUpdated` event.\\n *\\n */\\n function _setCommissionRateRange(uint256 _minRate, uint256 _maxRate) internal {\\n if (_maxRate > _MAX_PERCENTAGE || _minRate > _maxRate) revert ErrInvalidCommissionRate();\\n _maxCommissionRate = _maxRate;\\n _minCommissionRate = _minRate;\\n emit CommissionRateRangeUpdated(_minRate, _maxRate);\\n }\\n}\\n\",\"keccak256\":\"0x4859f479e8659e7c1005ae9dad4e5efc80869e8a87ee0794e90de7bffdde7a2b\",\"license\":\"MIT\"},\"contracts/ronin/staking/DelegatorStaking.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"../../interfaces/staking/IDelegatorStaking.sol\\\";\\nimport \\\"./BaseStaking.sol\\\";\\n\\nabstract contract DelegatorStaking is BaseStaking, IDelegatorStaking {\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n */\\n uint256[50] private ______gap;\\n\\n /**\\n * @inheritdoc IDelegatorStaking\\n */\\n function delegate(address _consensusAddr) external payable noEmptyValue poolIsActive(_consensusAddr) {\\n if (isAdminOfActivePool(msg.sender)) revert ErrAdminOfAnyActivePoolForbidden(msg.sender);\\n _delegate(_stakingPool[_consensusAddr], msg.sender, msg.value);\\n }\\n\\n /**\\n * @inheritdoc IDelegatorStaking\\n */\\n function undelegate(address _consensusAddr, uint256 _amount) external nonReentrant {\\n address payable _delegator = payable(msg.sender);\\n _undelegate(_stakingPool[_consensusAddr], _delegator, _amount);\\n if (!_sendRON(_delegator, _amount)) revert ErrCannotTransferRON();\\n }\\n\\n /**\\n * @inheritdoc IDelegatorStaking\\n */\\n function bulkUndelegate(address[] calldata _consensusAddrs, uint256[] calldata _amounts) external nonReentrant {\\n if (_consensusAddrs.length == 0 || _consensusAddrs.length != _amounts.length) revert ErrInvalidArrays();\\n\\n address payable _delegator = payable(msg.sender);\\n uint256 _total;\\n\\n for (uint _i = 0; _i < _consensusAddrs.length; ) {\\n _total += _amounts[_i];\\n _undelegate(_stakingPool[_consensusAddrs[_i]], _delegator, _amounts[_i]);\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n\\n if (!_sendRON(_delegator, _total)) revert ErrCannotTransferRON();\\n }\\n\\n /**\\n * @inheritdoc IDelegatorStaking\\n */\\n function redelegate(\\n address _consensusAddrSrc,\\n address _consensusAddrDst,\\n uint256 _amount\\n ) external nonReentrant poolIsActive(_consensusAddrDst) {\\n address _delegator = msg.sender;\\n _undelegate(_stakingPool[_consensusAddrSrc], _delegator, _amount);\\n _delegate(_stakingPool[_consensusAddrDst], _delegator, _amount);\\n }\\n\\n /**\\n * @inheritdoc IDelegatorStaking\\n */\\n function claimRewards(\\n address[] calldata _consensusAddrList\\n ) external override nonReentrant returns (uint256 _amount) {\\n _amount = _claimRewards(msg.sender, _consensusAddrList);\\n _transferRON(payable(msg.sender), _amount);\\n }\\n\\n /**\\n * @inheritdoc IDelegatorStaking\\n */\\n function delegateRewards(\\n address[] calldata _consensusAddrList,\\n address _consensusAddrDst\\n ) external override nonReentrant poolIsActive(_consensusAddrDst) returns (uint256 _amount) {\\n if (isAdminOfActivePool(msg.sender)) revert ErrAdminOfAnyActivePoolForbidden(msg.sender);\\n return _delegateRewards(msg.sender, _consensusAddrList, _consensusAddrDst);\\n }\\n\\n /**\\n * @inheritdoc IDelegatorStaking\\n */\\n function getRewards(\\n address _user,\\n address[] calldata _poolAddrList\\n ) external view returns (uint256[] memory _rewards) {\\n address _consensusAddr;\\n uint256 _period = IRoninValidatorSet(getContract(ContractType.VALIDATOR)).currentPeriod();\\n _rewards = new uint256[](_poolAddrList.length);\\n\\n for (uint256 _i = 0; _i < _poolAddrList.length; ) {\\n _consensusAddr = _poolAddrList[_i];\\n _rewards[_i] = _getReward(_consensusAddr, _user, _period, getStakingAmount(_consensusAddr, _user));\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @dev Delegates from a validator address.\\n *\\n * Requirements:\\n * - The delegator is not the pool admin.\\n *\\n * Emits the `Delegated` event.\\n *\\n * Note: This function does not verify the `msg.value` with the amount.\\n *\\n */\\n function _delegate(\\n PoolDetail storage _pool,\\n address _delegator,\\n uint256 _amount\\n ) internal anyExceptPoolAdmin(_pool, _delegator) {\\n _changeDelegatingAmount(\\n _pool,\\n _delegator,\\n _pool.delegatingAmount[_delegator] + _amount,\\n _pool.stakingTotal + _amount\\n );\\n _pool.lastDelegatingTimestamp[_delegator] = block.timestamp;\\n emit Delegated(_delegator, _pool.addr, _amount);\\n }\\n\\n /**\\n * @dev Undelegates from a validator address.\\n *\\n * Requirements:\\n * - The delegator is not the pool admin.\\n * - The amount is larger than 0.\\n * - The delegating amount is larger than or equal to the undelegating amount.\\n *\\n * Emits the `Undelegated` event.\\n *\\n * Note: Consider transferring back the amount of RON after calling this function.\\n *\\n */\\n function _undelegate(\\n PoolDetail storage _pool,\\n address _delegator,\\n uint256 _amount\\n ) private anyExceptPoolAdmin(_pool, _delegator) {\\n if (_amount == 0) revert ErrUndelegateZeroAmount();\\n if (_pool.delegatingAmount[_delegator] < _amount) revert ErrInsufficientDelegatingAmount();\\n\\n IRoninValidatorSet _validatorContract = IRoninValidatorSet(getContract(ContractType.VALIDATOR));\\n if (\\n _validatorContract.isValidatorCandidate(_pool.addr) &&\\n _validatorContract.getCandidateInfo(_pool.addr).revokingTimestamp == 0 && // if candidate is not on renunciation\\n _pool.lastDelegatingTimestamp[_delegator] + _cooldownSecsToUndelegate >= block.timestamp // delegator is still in cooldown\\n ) revert ErrUndelegateTooEarly();\\n\\n _changeDelegatingAmount(\\n _pool,\\n _delegator,\\n _pool.delegatingAmount[_delegator] - _amount,\\n _pool.stakingTotal - _amount\\n );\\n emit Undelegated(_delegator, _pool.addr, _amount);\\n }\\n\\n /**\\n * @dev Claims rewards from the pools `_poolAddrList`.\\n * Note: This function does not transfer reward to user.\\n */\\n function _claimRewards(address _user, address[] memory _poolAddrList) internal returns (uint256 _amount) {\\n uint256 _period = _currentPeriod();\\n for (uint256 _i = 0; _i < _poolAddrList.length; ) {\\n _amount += _claimReward(_poolAddrList[_i], _user, _period);\\n\\n unchecked {\\n ++_i;\\n }\\n }\\n }\\n\\n /**\\n * @dev Claims the rewards and delegates them to the consensus address.\\n */\\n function _delegateRewards(\\n address _user,\\n address[] calldata _poolAddrList,\\n address _poolAddrDst\\n ) internal returns (uint256 _amount) {\\n _amount = _claimRewards(_user, _poolAddrList);\\n _delegate(_stakingPool[_poolAddrDst], _user, _amount);\\n }\\n}\\n\",\"keccak256\":\"0x26d154ed736d57c1ecc6be99ac33274640039975374584bd4a12b8f53b68cb5e\",\"license\":\"MIT\"},\"contracts/ronin/staking/RewardCalculation.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"../../interfaces/staking/IRewardPool.sol\\\";\\nimport \\\"../../libraries/Math.sol\\\";\\n\\n/**\\n * @title RewardCalculation contract\\n * @dev This contract mainly contains the methods to calculate reward for staking contract.\\n */\\nabstract contract RewardCalculation is IRewardPool {\\n /// @dev Mapping from pool address => period number => accumulated rewards per share (one unit staking)\\n mapping(address => mapping(uint256 => PeriodWrapper)) private _accumulatedRps;\\n /// @dev Mapping from the pool address => user address => the reward info of the user\\n mapping(address => mapping(address => UserRewardFields)) private _userReward;\\n /// @dev Mapping from the pool address => reward pool fields\\n mapping(address => PoolFields) private _stakingPool;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n */\\n uint256[50] private ______gap;\\n\\n /**\\n * @inheritdoc IRewardPool\\n */\\n function getReward(address _poolAddr, address _user) external view returns (uint256) {\\n return _getReward(_poolAddr, _user, _currentPeriod(), getStakingAmount(_poolAddr, _user));\\n }\\n\\n /**\\n * @inheritdoc IRewardPool\\n */\\n function getStakingAmount(address _poolAddr, address _user) public view virtual returns (uint256);\\n\\n /**\\n * @inheritdoc IRewardPool\\n */\\n function getStakingTotal(address _poolAddr) public view virtual returns (uint256);\\n\\n /**\\n * @dev Returns the reward amount that user claimable.\\n */\\n function _getReward(\\n address _poolAddr,\\n address _user,\\n uint256 _latestPeriod,\\n uint256 _latestStakingAmount\\n ) internal view returns (uint256) {\\n UserRewardFields storage _reward = _userReward[_poolAddr][_user];\\n\\n if (_reward.lastPeriod == _latestPeriod) {\\n return _reward.debited;\\n }\\n\\n uint256 _aRps;\\n uint256 _lastPeriodReward;\\n PoolFields storage _pool = _stakingPool[_poolAddr];\\n PeriodWrapper storage _wrappedArps = _accumulatedRps[_poolAddr][_reward.lastPeriod];\\n\\n if (_wrappedArps.lastPeriod > 0) {\\n // Calculates the last period reward if the aRps at the period is set\\n _aRps = _wrappedArps.inner;\\n _lastPeriodReward = _reward.lowestAmount * (_aRps - _reward.aRps);\\n } else {\\n // Fallbacks to the previous aRps in case the aRps is not set\\n _aRps = _reward.aRps;\\n }\\n\\n uint256 _newPeriodsReward = _latestStakingAmount * (_pool.aRps - _aRps);\\n return _reward.debited + (_lastPeriodReward + _newPeriodsReward) / 1e18;\\n }\\n\\n /**\\n * @dev Syncs the user reward.\\n *\\n * Emits the event `UserRewardUpdated` once the debit amount is updated.\\n * Emits the event `PoolSharesUpdated` once the pool share is updated.\\n *\\n * Note: The method should be called whenever the user's staking amount changes.\\n *\\n */\\n function _syncUserReward(address _poolAddr, address _user, uint256 _newStakingAmount) internal {\\n uint256 _period = _currentPeriod();\\n PoolFields storage _pool = _stakingPool[_poolAddr];\\n uint256 _lastShares = _pool.shares.inner;\\n\\n // Updates the pool shares if it is outdated\\n if (_pool.shares.lastPeriod < _period) {\\n _pool.shares = PeriodWrapper(getStakingTotal(_poolAddr), _period);\\n }\\n\\n UserRewardFields storage _reward = _userReward[_poolAddr][_user];\\n uint256 _currentStakingAmount = getStakingAmount(_poolAddr, _user);\\n uint256 _debited = _getReward(_poolAddr, _user, _period, _currentStakingAmount);\\n\\n if (_reward.debited != _debited) {\\n _reward.debited = _debited;\\n emit UserRewardUpdated(_poolAddr, _user, _debited);\\n }\\n\\n _syncMinStakingAmount(_pool, _reward, _period, _newStakingAmount, _currentStakingAmount);\\n _reward.aRps = _pool.aRps;\\n _reward.lastPeriod = _period;\\n\\n if (_pool.shares.inner != _lastShares) {\\n emit PoolSharesUpdated(_period, _poolAddr, _pool.shares.inner);\\n }\\n }\\n\\n /**\\n * @dev Syncs the minimum staking amount of an user in the current period.\\n */\\n function _syncMinStakingAmount(\\n PoolFields storage _pool,\\n UserRewardFields storage _reward,\\n uint256 _latestPeriod,\\n uint256 _newStakingAmount,\\n uint256 _currentStakingAmount\\n ) internal {\\n if (_reward.lastPeriod < _latestPeriod) {\\n _reward.lowestAmount = _currentStakingAmount;\\n }\\n\\n uint256 _lowestAmount = Math.min(_reward.lowestAmount, _newStakingAmount);\\n uint256 _diffAmount = _reward.lowestAmount - _lowestAmount;\\n if (_diffAmount > 0) {\\n _reward.lowestAmount = _lowestAmount;\\n if (_pool.shares.inner < _diffAmount) revert ErrInvalidPoolShare();\\n _pool.shares.inner -= _diffAmount;\\n }\\n }\\n\\n /**\\n * @dev Claims the settled reward for a specific user.\\n *\\n * @param _lastPeriod Must be in two possible value: `_currentPeriod` in normal calculation, or\\n * `_currentPeriod + 1` in case of calculating the reward for revoked validators.\\n *\\n * Emits the `RewardClaimed` event and the `UserRewardUpdated` event.\\n *\\n * Note: This method should be called before transferring rewards for the user.\\n *\\n */\\n function _claimReward(address _poolAddr, address _user, uint256 _lastPeriod) internal returns (uint256 _amount) {\\n uint256 _currentStakingAmount = getStakingAmount(_poolAddr, _user);\\n _amount = _getReward(_poolAddr, _user, _lastPeriod, _currentStakingAmount);\\n emit RewardClaimed(_poolAddr, _user, _amount);\\n\\n UserRewardFields storage _reward = _userReward[_poolAddr][_user];\\n _reward.debited = 0;\\n _syncMinStakingAmount(_stakingPool[_poolAddr], _reward, _lastPeriod, _currentStakingAmount, _currentStakingAmount);\\n _reward.lastPeriod = _lastPeriod;\\n _reward.aRps = _stakingPool[_poolAddr].aRps;\\n emit UserRewardUpdated(_poolAddr, _user, 0);\\n }\\n\\n /**\\n * @dev Records the amount of rewards `_rewards` for the pools `_poolAddrs`.\\n *\\n * Emits the event `PoolsUpdated` once the contract recorded the rewards successfully.\\n * Emits the event `PoolsUpdateFailed` once the input array lengths are not equal.\\n * Emits the event `PoolUpdateConflicted` when the pool is already updated in the period.\\n *\\n * Note: This method should be called once at the period ending.\\n *\\n */\\n function _recordRewards(address[] memory _poolAddrs, uint256[] calldata _rewards, uint256 _period) internal {\\n if (_poolAddrs.length != _rewards.length) {\\n emit PoolsUpdateFailed(_period, _poolAddrs, _rewards);\\n return;\\n }\\n\\n uint256 _rps;\\n uint256 _count;\\n address _poolAddr;\\n uint256 _stakingTotal;\\n uint256[] memory _aRps = new uint256[](_poolAddrs.length);\\n uint256[] memory _shares = new uint256[](_poolAddrs.length);\\n address[] memory _conflicted = new address[](_poolAddrs.length);\\n\\n for (uint _i = 0; _i < _poolAddrs.length; _i++) {\\n _poolAddr = _poolAddrs[_i];\\n PoolFields storage _pool = _stakingPool[_poolAddr];\\n _stakingTotal = getStakingTotal(_poolAddr);\\n\\n if (_accumulatedRps[_poolAddr][_period].lastPeriod == _period) {\\n unchecked {\\n _conflicted[_count++] = _poolAddr;\\n }\\n continue;\\n }\\n\\n // Updates the pool shares if it is outdated\\n if (_pool.shares.lastPeriod < _period) {\\n _pool.shares = PeriodWrapper(_stakingTotal, _period);\\n }\\n\\n // The rps is 0 if no one stakes for the pool\\n _rps = _pool.shares.inner == 0 ? 0 : (_rewards[_i] * 1e18) / _pool.shares.inner;\\n _aRps[_i - _count] = _pool.aRps += _rps;\\n _accumulatedRps[_poolAddr][_period] = PeriodWrapper(_pool.aRps, _period);\\n _pool.shares.inner = _stakingTotal;\\n _shares[_i - _count] = _pool.shares.inner;\\n _poolAddrs[_i - _count] = _poolAddr;\\n }\\n\\n if (_count > 0) {\\n assembly {\\n mstore(_conflicted, _count)\\n mstore(_poolAddrs, sub(mload(_poolAddrs), _count))\\n }\\n emit PoolsUpdateConflicted(_period, _conflicted);\\n }\\n\\n if (_poolAddrs.length > 0) {\\n emit PoolsUpdated(_period, _poolAddrs, _aRps, _shares);\\n }\\n }\\n\\n /**\\n * @dev Returns the current period.\\n */\\n function _currentPeriod() internal view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x98f330685911b18730cf85223ecf30f4da2ec19dda5608b5d82c6b5e4f222fa1\",\"license\":\"MIT\"},\"contracts/ronin/staking/Staking.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/proxy/utils/Initializable.sol\\\";\\nimport \\\"../../libraries/Math.sol\\\";\\nimport \\\"../../interfaces/staking/IStaking.sol\\\";\\nimport \\\"../../interfaces/validator/IRoninValidatorSet.sol\\\";\\nimport \\\"./CandidateStaking.sol\\\";\\nimport \\\"./DelegatorStaking.sol\\\";\\n\\ncontract Staking is IStaking, CandidateStaking, DelegatorStaking, Initializable {\\n constructor() {\\n _disableInitializers();\\n }\\n\\n receive() external payable onlyContract(ContractType.VALIDATOR) {}\\n\\n fallback() external payable onlyContract(ContractType.VALIDATOR) {}\\n\\n /**\\n * @dev Initializes the contract storage.\\n */\\n function initialize(\\n address __validatorContract,\\n uint256 __minValidatorStakingAmount,\\n uint256 __maxCommissionRate,\\n uint256 __cooldownSecsToUndelegate,\\n uint256 __waitingSecsToRevoke\\n ) external initializer {\\n _setContract(ContractType.VALIDATOR, __validatorContract);\\n _setMinValidatorStakingAmount(__minValidatorStakingAmount);\\n _setCommissionRateRange(0, __maxCommissionRate);\\n _setCooldownSecsToUndelegate(__cooldownSecsToUndelegate);\\n _setWaitingSecsToRevoke(__waitingSecsToRevoke);\\n }\\n\\n function initializeV2() external reinitializer(2) {\\n _setContract(ContractType.VALIDATOR, ______deprecatedValidator);\\n delete ______deprecatedValidator;\\n }\\n\\n /**\\n * @dev This method only work on testnet, to hotfix the applied validator candidate that is failed.\\n * Should remove this method before deploying it on mainnet.\\n */\\n function tmp_re_applyValidatorCandidate(\\n address _candidateAdmin,\\n address _consensusAddr,\\n address payable _treasuryAddr,\\n uint256 _commissionRate\\n ) external {\\n require(block.chainid == 2021, \\\"E1\\\");\\n require(msg.sender == 0x57832A94810E18c84a5A5E2c4dD67D012ade574F, \\\"E2\\\");\\n\\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execApplyValidatorCandidate(\\n _candidateAdmin,\\n _consensusAddr,\\n _treasuryAddr,\\n _commissionRate\\n );\\n }\\n\\n /**\\n * @inheritdoc IStaking\\n */\\n function execRecordRewards(\\n address[] calldata _consensusAddrs,\\n uint256[] calldata _rewards,\\n uint256 _period\\n ) external payable override onlyContract(ContractType.VALIDATOR) {\\n _recordRewards(_consensusAddrs, _rewards, _period);\\n }\\n\\n /**\\n * @inheritdoc IStaking\\n */\\n function execDeductStakingAmount(\\n address _consensusAddr,\\n uint256 _amount\\n ) external override onlyContract(ContractType.VALIDATOR) returns (uint256 _actualDeductingAmount) {\\n _actualDeductingAmount = _deductStakingAmount(_stakingPool[_consensusAddr], _amount);\\n address payable _validatorContractAddr = payable(msg.sender);\\n if (!_unsafeSendRON(_validatorContractAddr, _actualDeductingAmount)) {\\n emit StakingAmountDeductFailed(\\n _consensusAddr,\\n _validatorContractAddr,\\n _actualDeductingAmount,\\n address(this).balance\\n );\\n }\\n }\\n\\n /**\\n * @inheritdoc RewardCalculation\\n */\\n function _currentPeriod() internal view virtual override returns (uint256) {\\n return IRoninValidatorSet(getContract(ContractType.VALIDATOR)).currentPeriod();\\n }\\n\\n /**\\n * @inheritdoc CandidateStaking\\n */\\n function _deductStakingAmount(\\n PoolDetail storage _pool,\\n uint256 _amount\\n ) internal override returns (uint256 _actualDeductingAmount) {\\n _actualDeductingAmount = Math.min(_pool.stakingAmount, _amount);\\n\\n _pool.stakingAmount -= _actualDeductingAmount;\\n _changeDelegatingAmount(\\n _pool,\\n _pool.admin,\\n _pool.stakingAmount,\\n Math.subNonNegative(_pool.stakingTotal, _actualDeductingAmount)\\n );\\n emit Unstaked(_pool.addr, _actualDeductingAmount);\\n }\\n}\\n\",\"keccak256\":\"0x41e527efa72cfde0b60112adc6bbc631539521370d1cc9a12a7d17336ddf3829\",\"license\":\"MIT\"},\"contracts/utils/CommonErrors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { ContractType } from \\\"./ContractType.sol\\\";\\nimport { RoleAccess } from \\\"./RoleAccess.sol\\\";\\n\\nerror ErrSyncTooFarPeriod(uint256 period, uint256 latestRewardedPeriod);\\n/**\\n * @dev Error thrown when an address is expected to be an already created externally owned account (EOA).\\n * This error indicates that the provided address is invalid for certain contract operations that require already created EOA.\\n */\\nerror ErrAddressIsNotCreatedEOA(address addr, bytes32 codehash);\\n/**\\n * @dev Error raised when a bridge operator update operation fails.\\n * @param bridgeOperator The address of the bridge operator that failed to update.\\n */\\nerror ErrBridgeOperatorUpdateFailed(address bridgeOperator);\\n/**\\n * @dev Error thrown when attempting to add a bridge operator that already exists in the contract.\\n * This error indicates that the provided bridge operator address is already registered as a bridge operator in the contract.\\n */\\nerror ErrBridgeOperatorAlreadyExisted(address bridgeOperator);\\n/**\\n * @dev The error indicating an unsupported interface.\\n * @param interfaceId The bytes4 interface identifier that is not supported.\\n * @param addr The address where the unsupported interface was encountered.\\n */\\nerror ErrUnsupportedInterface(bytes4 interfaceId, address addr);\\n/**\\n * @dev Error thrown when the return data from a callback function is invalid.\\n * @param callbackFnSig The signature of the callback function that returned invalid data.\\n * @param register The address of the register where the callback function was invoked.\\n * @param returnData The invalid return data received from the callback function.\\n */\\nerror ErrInvalidReturnData(bytes4 callbackFnSig, address register, bytes returnData);\\n/**\\n * @dev Error of set to non-contract.\\n */\\nerror ErrZeroCodeContract(address addr);\\n/**\\n * @dev Error indicating that arguments are invalid.\\n */\\nerror ErrInvalidArguments(bytes4 msgSig);\\n/**\\n * @dev Error indicating that given address is null when it should not.\\n */\\nerror ErrZeroAddress(bytes4 msgSig);\\n/**\\n * @dev Error indicating that the provided threshold is invalid for a specific function signature.\\n * @param msgSig The function signature (bytes4) that the invalid threshold applies to.\\n */\\nerror ErrInvalidThreshold(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a function can only be called by the contract itself.\\n * @param msgSig The function signature (bytes4) that can only be called by the contract itself.\\n */\\nerror ErrOnlySelfCall(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\\n * @param msgSig The function signature (bytes4) that the caller is unauthorized to perform.\\n * @param expectedRole The role required to perform the function.\\n */\\nerror ErrUnauthorized(bytes4 msgSig, RoleAccess expectedRole);\\n\\n/**\\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\\n * @param msgSig The function signature (bytes4) that the caller is unauthorized to perform.\\n */\\nerror ErrUnauthorizedCall(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\\n * @param msgSig The function signature (bytes4).\\n * @param expectedContractType The contract type required to perform the function.\\n * @param actual The actual address that called to the function.\\n */\\nerror ErrUnexpectedInternalCall(bytes4 msgSig, ContractType expectedContractType, address actual);\\n\\n/**\\n * @dev Error indicating that an array is empty when it should contain elements.\\n */\\nerror ErrEmptyArray();\\n\\n/**\\n * @dev Error indicating a mismatch in the length of input parameters or arrays for a specific function.\\n * @param msgSig The function signature (bytes4) that has a length mismatch.\\n */\\nerror ErrLengthMismatch(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a proxy call to an external contract has failed.\\n * @param msgSig The function signature (bytes4) of the proxy call that failed.\\n * @param extCallSig The function signature (bytes4) of the external contract call that failed.\\n */\\nerror ErrProxyCallFailed(bytes4 msgSig, bytes4 extCallSig);\\n\\n/**\\n * @dev Error indicating that a function tried to call a precompiled contract that is not allowed.\\n * @param msgSig The function signature (bytes4) that attempted to call a precompiled contract.\\n */\\nerror ErrCallPrecompiled(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a native token transfer has failed.\\n * @param msgSig The function signature (bytes4) of the token transfer that failed.\\n */\\nerror ErrNativeTransferFailed(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that an order is invalid.\\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid order.\\n */\\nerror ErrInvalidOrder(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that the chain ID is invalid.\\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid chain ID.\\n * @param actual Current chain ID that executing function.\\n * @param expected Expected chain ID required for the tx to success.\\n */\\nerror ErrInvalidChainId(bytes4 msgSig, uint256 actual, uint256 expected);\\n\\n/**\\n * @dev Error indicating that a vote type is not supported.\\n * @param msgSig The function signature (bytes4) of the operation that encountered an unsupported vote type.\\n */\\nerror ErrUnsupportedVoteType(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that the proposal nonce is invalid.\\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid proposal nonce.\\n */\\nerror ErrInvalidProposalNonce(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a voter has already voted.\\n * @param voter The address of the voter who has already voted.\\n */\\nerror ErrAlreadyVoted(address voter);\\n\\n/**\\n * @dev Error indicating that a signature is invalid for a specific function signature.\\n * @param msgSig The function signature (bytes4) that encountered an invalid signature.\\n */\\nerror ErrInvalidSignatures(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a relay call has failed.\\n * @param msgSig The function signature (bytes4) of the relay call that failed.\\n */\\nerror ErrRelayFailed(bytes4 msgSig);\\n/**\\n * @dev Error indicating that a vote weight is invalid for a specific function signature.\\n * @param msgSig The function signature (bytes4) that encountered an invalid vote weight.\\n */\\nerror ErrInvalidVoteWeight(bytes4 msgSig);\\n\\n/**\\n * @dev Error indicating that a query was made for an outdated bridge operator set.\\n */\\nerror ErrQueryForOutdatedBridgeOperatorSet();\\n\\n/**\\n * @dev Error indicating that a request is invalid.\\n */\\nerror ErrInvalidRequest();\\n\\n/**\\n * @dev Error indicating that a token standard is invalid.\\n */\\nerror ErrInvalidTokenStandard();\\n\\n/**\\n * @dev Error indicating that a token is not supported.\\n */\\nerror ErrUnsupportedToken();\\n\\n/**\\n * @dev Error indicating that a receipt kind is invalid.\\n */\\nerror ErrInvalidReceiptKind();\\n\\n/**\\n * @dev Error indicating that a receipt is invalid.\\n */\\nerror ErrInvalidReceipt();\\n\\n/**\\n * @dev Error indicating that an address is not payable.\\n */\\nerror ErrNonpayableAddress(address);\\n\\n/**\\n * @dev Error indicating that the period is already processed, i.e. scattered reward.\\n */\\nerror ErrPeriodAlreadyProcessed(uint256 requestingPeriod, uint256 latestPeriod);\\n\\n/**\\n * @dev Error thrown when an invalid vote hash is provided.\\n */\\nerror ErrInvalidVoteHash();\\n\\n/**\\n * @dev Error thrown when querying for an empty vote.\\n */\\nerror ErrQueryForEmptyVote();\\n\\n/**\\n * @dev Error thrown when querying for an expired vote.\\n */\\nerror ErrQueryForExpiredVote();\\n\\n/**\\n * @dev Error thrown when querying for a non-existent vote.\\n */\\nerror ErrQueryForNonExistentVote();\\n\",\"keccak256\":\"0x3914292a405307cba9e93085edcaf5f1203ca2d55abf998bf1d2af1e86f5a4c6\",\"license\":\"MIT\"},\"contracts/utils/ContractType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum ContractType {\\n /* 0 */ UNKNOWN,\\n /* 1 */ PAUSE_ENFORCER,\\n /* 2 */ BRIDGE,\\n /* 3 */ BRIDGE_TRACKING,\\n /* 4 */ GOVERNANCE_ADMIN,\\n /* 5 */ MAINTENANCE,\\n /* 6 */ SLASH_INDICATOR,\\n /* 7 */ STAKING_VESTING,\\n /* 8 */ VALIDATOR,\\n /* 9 */ STAKING,\\n /* 10 */ RONIN_TRUSTED_ORGANIZATION,\\n /* 11 */ BRIDGE_MANAGER,\\n /* 12 */ BRIDGE_SLASH,\\n /* 13 */ BRIDGE_REWARD\\n}\\n\",\"keccak256\":\"0xf72feff9afafcb5cadc1b05c6e0b998ea5d66c7ece57c3e482e560d0a1bb4079\",\"license\":\"MIT\"},\"contracts/utils/DeprecatedSlots.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title Deprecated Contracts\\n * @dev These abstract contracts are deprecated and should not be used in new implementations.\\n * They provide functionality related to various aspects of a smart contract but have been marked\\n * as deprecated to indicate that they are no longer actively maintained or recommended for use.\\n * The purpose of these contracts is to preserve the slots for already deployed contracts.\\n */\\ncontract HasSlashIndicatorDeprecated {\\n /// @custom:deprecated Previously `_slashIndicatorContract` (non-zero value)\\n address internal ______deprecatedSlashIndicator;\\n}\\n\\ncontract HasStakingVestingDeprecated {\\n /// @custom:deprecated Previously `_stakingVestingContract` (non-zero value)\\n address internal ______deprecatedStakingVesting;\\n}\\n\\ncontract HasBridgeDeprecated {\\n /// @custom:deprecated Previously `_bridgeContract` (non-zero value)\\n address internal ______deprecatedBridge;\\n}\\n\\ncontract HasValidatorDeprecated {\\n /// @custom:deprecated Previously `_validatorContract` (non-zero value)\\n address internal ______deprecatedValidator;\\n}\\n\\ncontract HasStakingDeprecated {\\n /// @custom:deprecated Previously `_stakingContract` (non-zero value)\\n address internal ______deprecatedStakingContract;\\n}\\n\\ncontract HasMaintenanceDeprecated {\\n /// @custom:deprecated Previously `_maintenanceContract` (non-zero value)\\n address internal ______deprecatedMaintenance;\\n}\\n\\ncontract HasTrustedOrgDeprecated {\\n /// @custom:deprecated Previously `_trustedOrgContract` (non-zero value)\\n address internal ______deprecatedTrustedOrg;\\n}\\n\\ncontract HasGovernanceAdminDeprecated {\\n /// @custom:deprecated Previously `_governanceAdminContract` (non-zero value)\\n address internal ______deprecatedGovernanceAdmin;\\n}\\n\\ncontract HasBridgeTrackingDeprecated {\\n /// @custom:deprecated Previously `_bridgeTrackingContract` (non-zero value)\\n address internal ______deprecatedBridgeTracking;\\n}\\n\",\"keccak256\":\"0xe93504aed9f67a6d399475c7162560f2ac4f793fab5b67fe504fc694ac9a2892\",\"license\":\"MIT\"},\"contracts/utils/IdentityGuard.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { AddressArrayUtils } from \\\"../libraries/AddressArrayUtils.sol\\\";\\nimport { IERC165 } from \\\"@openzeppelin/contracts/utils/introspection/IERC165.sol\\\";\\nimport { TransparentUpgradeableProxyV2 } from \\\"../extensions/TransparentUpgradeableProxyV2.sol\\\";\\nimport { ErrAddressIsNotCreatedEOA, ErrZeroAddress, ErrOnlySelfCall, ErrZeroCodeContract, ErrUnsupportedInterface } from \\\"./CommonErrors.sol\\\";\\n\\nabstract contract IdentityGuard {\\n using AddressArrayUtils for address[];\\n\\n /// @dev value is equal to keccak256(abi.encode())\\n /// @dev see: https://eips.ethereum.org/EIPS/eip-1052\\n bytes32 internal constant CREATED_ACCOUNT_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\\n\\n /**\\n * @dev Modifier to restrict functions to only be called by this contract.\\n * @dev Reverts if the caller is not this contract.\\n */\\n modifier onlySelfCall() virtual {\\n _requireSelfCall();\\n _;\\n }\\n\\n /**\\n * @dev Modifier to ensure that the elements in the `arr` array are non-duplicates.\\n * It calls the internal `_checkDuplicate` function to perform the duplicate check.\\n *\\n * Requirements:\\n * - The elements in the `arr` array must not contain any duplicates.\\n */\\n modifier nonDuplicate(address[] memory arr) virtual {\\n _requireNonDuplicate(arr);\\n _;\\n }\\n\\n /**\\n * @dev Internal method to check the method caller.\\n * @dev Reverts if the method caller is not this contract.\\n */\\n function _requireSelfCall() internal view virtual {\\n if (msg.sender != address(this)) revert ErrOnlySelfCall(msg.sig);\\n }\\n\\n /**\\n * @dev Internal function to check if a contract address has code.\\n * @param addr The address of the contract to check.\\n * @dev Throws an error if the contract address has no code.\\n */\\n function _requireHasCode(address addr) internal view {\\n if (addr.code.length == 0) revert ErrZeroCodeContract(addr);\\n }\\n\\n /**\\n * @dev Checks if an address is zero and reverts if it is.\\n * @param addr The address to check.\\n */\\n function _requireNonZeroAddress(address addr) internal pure {\\n if (addr == address(0)) revert ErrZeroAddress(msg.sig);\\n }\\n\\n /**\\n * @dev Check if arr is empty and revert if it is.\\n * Checks if an array contains any duplicate addresses and reverts if duplicates are found.\\n * @param arr The array of addresses to check.\\n */\\n function _requireNonDuplicate(address[] memory arr) internal pure {\\n if (arr.hasDuplicate()) revert AddressArrayUtils.ErrDuplicated(msg.sig);\\n }\\n\\n /**\\n * @dev Internal function to require that the provided address is a created externally owned account (EOA).\\n * This internal function is used to ensure that the provided address is a valid externally owned account (EOA).\\n * It checks the codehash of the address against a predefined constant to confirm that the address is a created EOA.\\n * @notice This method only works with non-state EOA accounts\\n */\\n function _requireCreatedEOA(address addr) internal view {\\n _requireNonZeroAddress(addr);\\n bytes32 codehash = addr.codehash;\\n if (codehash != CREATED_ACCOUNT_HASH) revert ErrAddressIsNotCreatedEOA(addr, codehash);\\n }\\n\\n /**\\n * @dev Internal function to require that the specified contract supports the given interface. This method handle in\\n * both case that the callee is either or not the proxy admin of the caller. If the contract does not support the\\n * interface `interfaceId` or EIP165, a revert with the corresponding error message is triggered.\\n *\\n * @param contractAddr The address of the contract to check for interface support.\\n * @param interfaceId The interface ID to check for support.\\n */\\n function _requireSupportsInterface(address contractAddr, bytes4 interfaceId) internal view {\\n bytes memory supportsInterfaceParams = abi.encodeCall(IERC165.supportsInterface, (interfaceId));\\n (bool success, bytes memory returnOrRevertData) = contractAddr.staticcall(supportsInterfaceParams);\\n if (!success) {\\n (success, returnOrRevertData) = contractAddr.staticcall(\\n abi.encodeCall(TransparentUpgradeableProxyV2.functionDelegateCall, (supportsInterfaceParams))\\n );\\n if (!success) revert ErrUnsupportedInterface(interfaceId, contractAddr);\\n }\\n if (!abi.decode(returnOrRevertData, (bool))) revert ErrUnsupportedInterface(interfaceId, contractAddr);\\n }\\n}\\n\",\"keccak256\":\"0x2d0dfcef3636945bc1785c1fa5a05f5203c79cbb81b2eee92a3ac6a2378c2ce5\",\"license\":\"MIT\"},\"contracts/utils/RoleAccess.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum RoleAccess {\\n /* 0 */ UNKNOWN,\\n /* 1 */ ADMIN,\\n /* 2 */ COINBASE,\\n /* 3 */ GOVERNOR,\\n /* 4 */ CANDIDATE_ADMIN,\\n /* 5 */ WITHDRAWAL_MIGRATOR,\\n /* 6 */ __DEPRECATED_BRIDGE_OPERATOR,\\n /* 7 */ BLOCK_PRODUCER,\\n /* 8 */ VALIDATOR_CANDIDATE\\n}\\n\",\"keccak256\":\"0xa98cec38c640c4e37f475debbcd366226f1188c3f5ea6e29de768bd33e021873\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b5060016000556200002162000027565b620000e9565b60d154610100900460ff1615620000945760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60d15460ff9081161015620000e75760d1805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b61398f80620000f96000396000f3fe60806040526004361061023f5760003560e01c80636bd8f8041161012e578063aa15a6fd116100ab578063d01b8eed1161006f578063d01b8eed146106e6578063de981f1b14610757578063e22d1c9d14610777578063f92ad21914610797578063f9f031df146107b757610251565b8063aa15a6fd1461062d578063acd79c461461064d578063af24542914610660578063c2a672e014610675578063c50870031461069557610251565b8063909791dd116100f2578063909791dd1461059857806391f8723f146105ad578063924f081e146105cd5780639488e4e9146105ed578063969ffc141461060d57610251565b80636bd8f804146104df57806376664b65146104ff578063865e6fd31461051f578063888b9ae91461053f578063895ab7421461055f57610251565b806342e0c408116101bc5780635c19a95c116101805780635c19a95c146104605780635cd8a76b146104735780636558954f14610488578063679a6e431461049f5780636b091695146104bf57610251565b806342e0c4081461038d57806342ef3c34146103d85780634530d202146103f85780634d99dd1614610420578063574734471461044057610251565b80631658c86e116102035780631658c86e1461030757806326476204146103275780632715805e1461033a5780632baae1251461035a5780633d8e846e1461036d57610251565b8063038278841461025c5780630682e8fa14610285578063095f64751461029a578063097e4a9d146102c75780630dccaf46146102e757610251565b3661025157600861024f816107d7565b005b600861024f816107d7565b34801561026857600080fd5b506102726104b081565b6040519081526020015b60405180910390f35b34801561029157600080fd5b50603854610272565b3480156102a657600080fd5b506102ba6102b5366004613102565b61082f565b60405161027c91906131a8565b3480156102d357600080fd5b506102726102e23660046131d0565b610967565b3480156102f357600080fd5b5061024f610302366004613226565b6109ed565b34801561031357600080fd5b5061024f610322366004613277565b610af0565b61024f610335366004613277565b610b60565b34801561034657600080fd5b5061027261035536600461329b565b610b99565b61024f610368366004613226565b610c2a565b34801561037957600080fd5b506102ba6103883660046132c7565b610d78565b34801561039957600080fd5b506103c86103a8366004613277565b6001600160a01b039081166000908152603a602052604090205416151590565b604051901515815260200161027c565b3480156103e457600080fd5b506102ba6103f336600461331b565b610ea6565b34801561040457600080fd5b50606e54606d546040805192835260208301919091520161027c565b34801561042c57600080fd5b5061024f61043b36600461329b565b610f72565b34801561044c57600080fd5b5061024f61045b36600461335c565b610fee565b61024f61046e366004613277565b611000565b34801561047f57600080fd5b5061024f61106e565b34801561049457600080fd5b506102726201518081565b3480156104ab57600080fd5b5061024f6104ba36600461337e565b61112d565b3480156104cb57600080fd5b506102726104da366004613397565b61113e565b3480156104eb57600080fd5b5061024f6104fa3660046133d0565b611160565b34801561050b57600080fd5b5061027261051a366004613397565b6111e5565b34801561052b57600080fd5b5061024f61053a366004613420565b611214565b34801561054b57600080fd5b5061024f61055a36600461337e565b61122f565b34801561056b57600080fd5b5061027261057a366004613277565b6001600160a01b031660009081526037602052604090206003015490565b3480156105a457600080fd5b50606c54610272565b3480156105b957600080fd5b506102ba6105c836600461331b565b611240565b3480156105d957600080fd5b5061024f6105e836600461343c565b6112e0565b3480156105f957600080fd5b5061024f610608366004613102565b6113ba565b34801561061957600080fd5b5061024f61062836600461337e565b6114e9565b34801561063957600080fd5b5061024f610648366004613277565b6114fa565b61024f61065b366004613471565b61156a565b34801561066c57600080fd5b50603954610272565b34801561068157600080fd5b5061024f61069036600461329b565b6115be565b3480156106a157600080fd5b506106ce6106b0366004613277565b6001600160a01b039081166000908152603a60205260409020541690565b6040516001600160a01b03909116815260200161027c565b3480156106f257600080fd5b50610732610701366004613277565b6001600160a01b03808216600090815260376020526040902060018101546002820154600390920154921693909250565b604080516001600160a01b03909416845260208401929092529082015260600161027c565b34801561076357600080fd5b506106ce6107723660046134e4565b611678565b34801561078357600080fd5b5061024f6107923660046134ff565b6116f3565b3480156107a357600080fd5b5061024f6107b236600461354a565b6118b7565b3480156107c357600080fd5b506102726107d236600461331b565b6119ae565b6107e081611678565b6001600160a01b0316336001600160a01b03161461082c576000356001600160e01b03191681336040516320e0f98d60e21b8152600401610823939291906135b8565b60405180910390fd5b50565b6060838214610851576040516376081a7b60e11b815260040160405180910390fd5b836001600160401b03811115610869576108696135ef565b604051908082528060200260200182016040528015610892578160200160208202803683370190505b50905060005b815181101561095e57603760008787848181106108b7576108b7613605565b90506020020160208101906108cc9190613277565b6001600160a01b03166001600160a01b03168152602001908152602001600020600401600085858481811061090357610903613605565b90506020020160208101906109189190613277565b6001600160a01b03166001600160a01b031681526020019081526020016000205482828151811061094b5761094b613605565b6020908102919091010152600101610898565b50949350505050565b600060026000540361098b5760405162461bcd60e51b81526004016108239061361b565b60026000558161099a81611a2e565b336000908152603a60205260409020546001600160a01b0316156109d357604051632fc6bfb160e21b8152336004820152602401610823565b6109df33868686611acc565b600160005595945050505050565b466107e514610a235760405162461bcd60e51b8152602060048201526002602482015261453160f01b6044820152606401610823565b7357832a94810e18c84a5a5e2c4dd67d012ade574f3314610a6b5760405162461bcd60e51b8152602060048201526002602482015261229960f11b6044820152606401610823565b610a756008611678565b60405163f883afaf60e01b81526001600160a01b0386811660048301528581166024830152848116604483015260648201849052919091169063f883afaf906084015b600060405180830381600087803b158015610ad257600080fd5b505af1158015610ae6573d6000803e3d6000fd5b5050505050505050565b80610afa81611a2e565b6001600160a01b038216600090815260376020526040902033610b1d8282611b39565b610b276008611678565b60395460405163dd716ad360e01b81526001600160a01b038781166004830152602482019290925291169063dd716ad390604401610ab8565b610b68611b69565b80610b7281611a2e565b6001600160a01b0382166000908152603760205260409020610b95903334611b8c565b5050565b60006008610ba6816107d7565b6001600160a01b0384166000908152603760205260409020610bc89084611c37565b915033610bd58184611cd4565b610c2257604080518481524760208201526001600160a01b0380841692908816917f63701cd972aa3c7f87898aab145c972e52185beab07d6e39380a998d334cf6c8910160405180910390a35b505092915050565b600260005403610c4c5760405162461bcd60e51b81526004016108239061361b565b60026000908155338152603a60205260409020546001600160a01b031615610c8957604051632fc6bfb160e21b8152336004820152602401610823565b606d54811180610c9a5750606e5481105b15610cb857604051631b8454a360e21b815260040160405180910390fd5b3433610cc8818787878787611d30565b6001600160a01b0380861660008181526037602081815260408084206001810180549789166001600160a01b0319988916811790915581548816871782558552603a835290842080549096168517909555929091529052610d2a818385611b8c565b816001600160a01b0316866001600160a01b03167ffc1f1e73948cbc47c5b7f90e5601b7daccd9ad7173218486ccc74bdd051d05e860405160405180910390a3505060016000555050505050565b6060600080610d876008611678565b6001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa158015610dc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610de89190613652565b9050836001600160401b03811115610e0257610e026135ef565b604051908082528060200260200182016040528015610e2b578160200160208202803683370190505b50925060005b84811015610e9c57858582818110610e4b57610e4b613605565b9050602002016020810190610e609190613277565b9250610e77838884610e72878c6111e5565b611f64565b848281518110610e8957610e89613605565b6020908102919091010152600101610e31565b5050509392505050565b6060816001600160401b03811115610ec057610ec06135ef565b604051908082528060200260200182016040528015610ee9578160200160208202803683370190505b50905060005b82811015610f6b5760376000858584818110610f0d57610f0d613605565b9050602002016020810190610f229190613277565b6001600160a01b03166001600160a01b0316815260200190815260200160002060020154828281518110610f5857610f58613605565b6020908102919091010152600101610eef565b5092915050565b600260005403610f945760405162461bcd60e51b81526004016108239061361b565b600260009081556001600160a01b03831681526037602052604090203390610fbd908284612060565b610fc78183612298565b610fe457604051635ff7115760e11b815260040160405180910390fd5b5050600160005550565b610ff66122e0565b610b95828261233a565b611008611b69565b8061101281611a2e565b336000908152603a60205260409020546001600160a01b03161561104b57604051632fc6bfb160e21b8152336004820152602401610823565b6001600160a01b0382166000908152603760205260409020610b959033346123ae565b60d154600290610100900460ff16158015611090575060d15460ff8083169116105b6110ac5760405162461bcd60e51b81526004016108239061366b565b60d1805461ffff191660ff8316176101001790556036546110d8906008906001600160a01b031661245d565b603680546001600160a01b031916905560d1805461ff001916905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a150565b6111356122e0565b61082c81612501565b6000611157838361114d612536565b610e7287876111e5565b90505b92915050565b6002600054036111825760405162461bcd60e51b81526004016108239061361b565b60026000558161119181611a2e565b6001600160a01b038416600090815260376020526040902033906111b6908285612060565b6001600160a01b03841660009081526037602052604090206111d99082856123ae565b50506001600055505050565b6001600160a01b0391821660009081526037602090815260408083209390941682526004909201909152205490565b61121c6122e0565b611225816125a8565b610b95828261245d565b6112376122e0565b61082c816125de565b6060816001600160401b0381111561125a5761125a6135ef565b604051908082528060200260200182016040528015611283578160200160208202803683370190505b50905060005b82811015610f6b576112bb8484838181106112a6576112a6613605565b905060200201602081019061057a9190613277565b8282815181106112cd576112cd613605565b6020908102919091010152600101611289565b826112ea81611a2e565b6001600160a01b03841660009081526037602052604090203361130d8282611b39565b606d5484118061131e5750606e5484105b1561133c57604051631b8454a360e21b815260040160405180910390fd5b6113466008611678565b60405163e5125a1d60e01b81526001600160a01b0388811660048301526024820188905260448201879052919091169063e5125a1d906064015b600060405180830381600087803b15801561139a57600080fd5b505af11580156113ae573d6000803e3d6000fd5b50505050505050505050565b6002600054036113dc5760405162461bcd60e51b81526004016108239061361b565b60026000558215806113ee5750828114155b1561140c576040516376081a7b60e11b815260040160405180910390fd5b336000805b858110156114b45784848281811061142b5761142b613605565b905060200201358261143d91906136cf565b91506114ac6037600089898581811061145857611458613605565b905060200201602081019061146d9190613277565b6001600160a01b03166001600160a01b03168152602001908152602001600020848787858181106114a0576114a0613605565b90506020020135612060565b600101611411565b506114bf8282612298565b6114dc57604051635ff7115760e11b815260040160405180910390fd5b5050600160005550505050565b6114f16122e0565b61082c81612613565b8061150481611a2e565b6001600160a01b0382166000908152603760205260409020336115278282611b39565b6115316008611678565b60395460405163a7c2f11960e01b81526001600160a01b038781166004830152602482019290925291169063a7c2f11990604401610ab8565b6008611575816107d7565b6115b6868680806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250889250879150869050612648565b505050505050565b6002600054036115e05760405162461bcd60e51b81526004016108239061361b565b6002600055816115ef81611a2e565b81600003611610576040516331d9f7d760e01b815260040160405180910390fd5b6001600160a01b0383166000908152603760205260408120600281015433929061163b9086906136e2565b9050606c548110156116605760405163ef0a995760e01b815260040160405180910390fd5b61166b828487612a76565b6114bf83866104b0612b62565b60007fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb600083600d8111156116af576116af61358e565b60ff1681526020810191909152604001600020546001600160a01b03169050806116ee578160405163409140df60e11b815260040161082391906136f5565b919050565b60086116fe816107d7565b82156118b15760005b838110156118765760006037600087878581811061172757611727613605565b905060200201602081019061173c9190613277565b6001600160a01b0390811682526020808301939093526040918201600090812060018101549092168152603a909352912080546001600160a01b031916905560028101549091508015611803576117938282611c37565b5060018201546117af906001600160a01b0316826104b0612b62565b6118035760018201548254604080518481524760208201526001600160a01b0393841693909216917f7dc5115a5aba081f5a174f56a3d02eea582824783322a4ac03f7bd388f444194910160405180910390a35b600061184388888681811061181a5761181a613605565b905060200201602081019061182f9190613277565b60018501546001600160a01b031688612bc2565b90508015611868576001830154611866906001600160a01b0316826104b0612b62565b505b836001019350505050611707565b507f4f257d3ba23679d338f1d94296086bba5724af341b7fa31aa0ff297bfcdc62d884846040516118a8929190613703565b60405180910390a15b50505050565b60d154610100900460ff16158080156118d7575060d154600160ff909116105b806118f15750303b1580156118f1575060d15460ff166001145b61190d5760405162461bcd60e51b81526004016108239061366b565b60d1805460ff1916600117905580156119305760d1805461ff0019166101001790555b61193b60088761245d565b61194485612501565b61194f60008561233a565b611958836125de565b61196182612613565b80156115b65760d1805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050505050565b60006002600054036119d25760405162461bcd60e51b81526004016108239061361b565b6002600081905550611a1733848480806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250612cd492505050565b9050611a233382612d25565b600160005592915050565b611a386008611678565b604051635061f96960e11b81526001600160a01b038381166004830152919091169063a0c3f2d290602401602060405180830381865afa158015611a80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aa49190613751565b61082c57604051630fd0c64560e11b81526001600160a01b0382166004820152602401610823565b6000611b0b85858580806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250612cd492505050565b6001600160a01b0383166000908152603760205260409020909150611b319086836123ae565b949350505050565b60018201546001600160a01b03828116911614610b9557604051637bc65bd760e11b815260040160405180910390fd5b34600003611b8a57604051636dfcbde560e11b815260040160405180910390fd5b565b8282611b988282611b39565b82856002016000828254611bac91906136cf565b92505081905550611bd285858760020154868960030154611bcd91906136cf565b612d5a565b6001600160a01b03808516600090815260058701602052604090819020429055865490519116907f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d90611c289086815260200190565b60405180910390a25050505050565b6000611c47836002015483612d95565b905080836002016000828254611c5d91906136e2565b9091555050600183015460028401546003850154611c8d9286926001600160a01b0390911691611bcd9086612dab565b82546040518281526001600160a01b03909116907f0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f759060200160405180910390a292915050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611d21576040519150601f19603f3d011682016040523d82523d6000602084013e611d26565b606091505b5090949350505050565b611d3e8660006104b0612b62565b611d89576040805163338f030160e01b81526001600160a01b03881660048201526024810191909152600a6044820152693837b7b61030b236b4b760b11b6064820152608401610823565b611d978360006104b0612b62565b611de0576040805163338f030160e01b81526001600160a01b038516600482015260248101919091526008604482015267747265617375727960c01b6064820152608401610823565b606c54811015611e0357604051630a8d7fa760e21b815260040160405180910390fd5b846001600160a01b0316866001600160a01b0316141580611e365750826001600160a01b0316856001600160a01b031614155b15611e545760405163dc1d04ff60e01b815260040160405180910390fd5b6040805160028082526060820183526000926020830190803683370190505090508681600081518110611e8957611e89613605565b60200260200101906001600160a01b031690816001600160a01b0316815250508481600181518110611ebd57611ebd613605565b60200260200101906001600160a01b031690816001600160a01b031681525050611ee681612dc5565b15611f1257604051630d697db160e11b81526001600160e01b0319600035166004820152602401610823565b50611f1d6008611678565b60405163f883afaf60e01b81526001600160a01b0387811660048301528681166024830152858116604483015260648201859052919091169063f883afaf90608401611380565b6001600160a01b03808516600090815260026020908152604080832093871683529290529081206003810154849003611f9f57549050611b31565b6001600160a01b0386166000908152600360208181526040808420600180845282862094870154865293909252832091820154839290156120045780546001860154909450611fee90856136e2565b8560020154611ffd9190613773565b925061200c565b846001015493505b815460009061201c9086906136e2565b6120269089613773565b9050670de0b6b3a764000061203b82866136cf565b612045919061378a565b865461205191906136cf565b9b9a5050505050505050505050565b828261206c8282612e64565b8260000361208d57604051637ab0c6ad60e11b815260040160405180910390fd5b6001600160a01b03841660009081526004860160205260409020548311156120c857604051630695534560e31b815260040160405180910390fd5b60006120d46008611678565b8654604051635061f96960e11b81526001600160a01b03918216600482015291925082169063a0c3f2d290602401602060405180830381865afa15801561211f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121439190613751565b80156121bd575085546040516328bde1e160e01b81526001600160a01b039182166004820152908216906328bde1e19060240160e060405180830381865afa158015612193573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121b791906137b7565b60a00151155b80156121f057506038546001600160a01b038616600090815260058801602052604090205442916121ed916136cf565b10155b1561220e5760405163f19f52bd60e01b815260040160405180910390fd5b6001600160a01b038516600090815260048701602052604090205461224c908790879061223c9088906136e2565b878a60030154611bcd91906136e2565b85546040518581526001600160a01b03918216918716907f4d10bd049775c77bd7f255195afba5088028ecb3c7c277d393ccff7934f2f92c9060200160405180910390a3505050505050565b6000814710156122d6576040516302631c4f60e61b81526001600160e01b031960003516600482015247602482015260448101839052606401610823565b6111578383611cd4565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b03163314611b8a576000356001600160e01b0319166001604051620f948f60ea1b8152600401610823929190613862565b61271081118061234957508082115b1561236757604051631b8454a360e21b815260040160405180910390fd5b606d819055606e82905560408051838152602081018390527f677752f5bf9541b14288833909e5ec5a478103131c1ec08c4638943be5826c14910160405180910390a15050565b82826123ba8282612e64565b6001600160a01b03841660009081526004860160205260409020546123f890869086906123e89087906136cf565b868960030154611bcd91906136cf565b6001600160a01b03808516600081815260058801602052604090819020429055875490519216917fe5541a6b6103d4fa7e021ed54fad39c66f27a76bd13d374cf6240ae6bd0bb72b9061244e9087815260200190565b60405180910390a35050505050565b807fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb600084600d8111156124935761249361358e565b60ff168152602081019190915260400160002080546001600160a01b0319166001600160a01b03928316179055811682600d8111156124d4576124d461358e565b6040517f865d1c228a8ea13709cfe61f346f7ff67f1bbd4a18ff31ad3e7147350d317c5990600090a35050565b606c8190556040518181527f372bbdb8d72373b0012f84ee5a11671e5fb72b8bea902ebca93a19cb45d32be290602001611122565b60006125426008611678565b6001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa15801561257f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125a39190613652565b905090565b806001600160a01b03163b60000361082c57604051630bfc64a360e21b81526001600160a01b0382166004820152602401610823565b60388190556040518181527f4956b65267b8f1e642284bcb5037116c69a9c78d9ca576beeae0974737a4872a90602001611122565b60398190556040518181527f02be0b73b597f2c0f138aebee162b3b0e25d5b5a26854c15dcf79176e9a1c67890602001611122565b8351821461269157807fae52c603227f64e4c6101dde593aa9790a16b3ac77546bd746d758511e9560a5858585604051612684939291906138c9565b60405180910390a26118b1565b600080600080600088516001600160401b038111156126b2576126b26135ef565b6040519080825280602002602001820160405280156126db578160200160208202803683370190505b509050600089516001600160401b038111156126f9576126f96135ef565b604051908082528060200260200182016040528015612722578160200160208202803683370190505b50905060008a516001600160401b03811115612740576127406135ef565b604051908082528060200260200182016040528015612769578160200160208202803683370190505b50905060005b8b518110156129dc578b818151811061278a5761278a613605565b6020908102919091018101516001600160a01b038116600090815260038084526040808320603790955290912001549097506001600160a01b03881660009081526001602081815260408084208f855290915290912001549096508a900361282b57868389806001019a508151811061280557612805613605565b60200260200101906001600160a01b031690816001600160a01b031681525050506129ca565b60028101548a111561285957604080518082019091528681526020018a905260018101869055600281018a90555b6001810154156128a35760018101548c8c8481811061287a5761287a613605565b90506020020135670de0b6b3a76400006128949190613773565b61289e919061378a565b6128a6565b60005b9850888160000160008282546128bc91906136cf565b91829055509050856128ce8a856136e2565b815181106128de576128de613605565b6020026020010181815250506040518060400160405280826000015481526020018b81525060016000896001600160a01b03166001600160a01b0316815260200190815260200160002060008c81526020019081526020016000206000820151816000015560208201518160010155905050858160010160000181905550806001016000015484898461297191906136e2565b8151811061298157612981613605565b6020908102919091010152868d6129988a856136e2565b815181106129a8576129a8613605565b60200260200101906001600160a01b031690816001600160a01b031681525050505b806129d481613913565b91505061276f565b508515612a2557858152858b51038b52877fee74f10cc50bf4b7e57fd36be7d46288795f3a9151dae97505b718b392ba14a382604051612a1c919061392c565b60405180910390a25b8a5115612a6957877f0e54e0485f70f0f63bc25889ddbf01ce1269ad6f07fdb2df573a0fbdb4d66f888c8585604051612a609392919061393f565b60405180910390a25b5050505050505050505050565b8282612a828282611b39565b8460020154831115612aa757604051630a8d7fa760e21b815260040160405180910390fd5b6038546001600160a01b03851660009081526005870160205260409020544291612ad0916136cf565b1115612aef576040516303db082960e11b815260040160405180910390fd5b82856002016000828254612b0391906136e2565b92505081905550612b2485858760020154868960030154611bcd91906136e2565b84546040518481526001600160a01b03909116907f0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f7590602001611c28565b6000836001600160a01b0316838390604051600060405180830381858888f193505050503d8060008114612bb2576040519150601f19603f3d011682016040523d82523d6000602084013e612bb7565b606091505b509095945050505050565b600080612bcf85856111e5565b9050612bdd85858584611f64565b9150836001600160a01b0316856001600160a01b03167f0aa4d283470c904c551d18bb894d37e17674920f3261a7f854be501e25f421b784604051612c2491815260200190565b60405180910390a36001600160a01b03808616600081815260026020908152604080832094891683529381528382208281559282526003905291909120612c6e9082868580612e94565b60038181018590556001600160a01b03878116600081815260209384526040808220546001870155519081529188169290917faa7c29611027fd4be148712bb54960253b7a7d5998c17769bfc424c2f5f185ad910160405180910390a350509392505050565b600080612cdf612536565b905060005b8351811015610c2257612d11848281518110612d0257612d02613605565b60200260200101518684612bc2565b612d1b90846136cf565b9250600101612ce4565b612d2f8282612298565b610b95576040516303b97b7760e41b81526001600160e01b0319600035166004820152602401610823565b8354612d70906001600160a01b03168484612f26565b60038401556001600160a01b0390911660009081526004909201602052604090912055565b6000818310612da45781611157565b5090919050565b6000818311612dbb576000611157565b61115782846136e2565b60008151600003612dd857506000919050565b60005b6001835103811015612e5b57600181015b8351811015612e5257838181518110612e0757612e07613605565b60200260200101516001600160a01b0316848381518110612e2a57612e2a613605565b60200260200101516001600160a01b031603612e4a575060019392505050565b600101612dec565b50600101612ddb565b50600092915050565b60018201546001600160a01b03808316911603610b9557604051639feb934760e01b815260040160405180910390fd5b8284600301541015612ea857600284018190555b6000612eb8856002015484612d95565b90506000818660020154612ecc91906136e2565b90508015612f1d57600286018290556001870154811115612f00576040516352e521bf60e11b815260040160405180910390fd5b80876001016000016000828254612f1791906136e2565b90915550505b50505050505050565b6000612f30612536565b6001600160a01b0385166000908152600360205260409020600181015460028201549293509091831115612fa4576040518060400160405280612f8b886001600160a01b031660009081526037602052604090206003015490565b8152602090810185905281516001850155015160028301555b6001600160a01b038087166000908152600260209081526040808320938916835292905290812090612fd688886111e5565b90506000612fe689898885611f64565b83549091508114613038578083556040518181526001600160a01b0389811691908b16907faa7c29611027fd4be148712bb54960253b7a7d5998c17769bfc424c2f5f185ad9060200160405180910390a35b6130458584888a86612e94565b84546001808501919091556003840187905585015484146130ac57886001600160a01b0316867f81faf50e2aaf52eaba2ab841071efb9f6f0850a3e7d008b1336e6001d3d4963c87600101600001546040516130a391815260200190565b60405180910390a35b505050505050505050565b60008083601f8401126130c957600080fd5b5081356001600160401b038111156130e057600080fd5b6020830191508360208260051b85010111156130fb57600080fd5b9250929050565b6000806000806040858703121561311857600080fd5b84356001600160401b038082111561312f57600080fd5b61313b888389016130b7565b9096509450602087013591508082111561315457600080fd5b50613161878288016130b7565b95989497509550505050565b600081518084526020808501945080840160005b8381101561319d57815187529582019590820190600101613181565b509495945050505050565b602081526000611157602083018461316d565b6001600160a01b038116811461082c57600080fd5b6000806000604084860312156131e557600080fd5b83356001600160401b038111156131fb57600080fd5b613207868287016130b7565b909450925050602084013561321b816131bb565b809150509250925092565b6000806000806080858703121561323c57600080fd5b8435613247816131bb565b93506020850135613257816131bb565b92506040850135613267816131bb565b9396929550929360600135925050565b60006020828403121561328957600080fd5b8135613294816131bb565b9392505050565b600080604083850312156132ae57600080fd5b82356132b9816131bb565b946020939093013593505050565b6000806000604084860312156132dc57600080fd5b83356132e7816131bb565b925060208401356001600160401b0381111561330257600080fd5b61330e868287016130b7565b9497909650939450505050565b6000806020838503121561332e57600080fd5b82356001600160401b0381111561334457600080fd5b613350858286016130b7565b90969095509350505050565b6000806040838503121561336f57600080fd5b50508035926020909101359150565b60006020828403121561339057600080fd5b5035919050565b600080604083850312156133aa57600080fd5b82356133b5816131bb565b915060208301356133c5816131bb565b809150509250929050565b6000806000606084860312156133e557600080fd5b83356133f0816131bb565b92506020840135613400816131bb565b929592945050506040919091013590565b8035600e81106116ee57600080fd5b6000806040838503121561343357600080fd5b6133b583613411565b60008060006060848603121561345157600080fd5b833561345c816131bb565b95602085013595506040909401359392505050565b60008060008060006060868803121561348957600080fd5b85356001600160401b03808211156134a057600080fd5b6134ac89838a016130b7565b909750955060208801359150808211156134c557600080fd5b506134d2888289016130b7565b96999598509660400135949350505050565b6000602082840312156134f657600080fd5b61115782613411565b60008060006040848603121561351457600080fd5b83356001600160401b0381111561352a57600080fd5b613536868287016130b7565b909790965060209590950135949350505050565b600080600080600060a0868803121561356257600080fd5b853561356d816131bb565b97602087013597506040870135966060810135965060800135945092505050565b634e487b7160e01b600052602160045260246000fd5b600e81106135b4576135b461358e565b9052565b6001600160e01b031984168152606081016135d660208301856135a4565b6001600160a01b03929092166040919091015292915050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60006020828403121561366457600080fd5b5051919050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b8082018082111561115a5761115a6136b9565b8181038181111561115a5761115a6136b9565b6020810161115a82846135a4565b60208082528181018390526000908460408401835b8681101561374657823561372b816131bb565b6001600160a01b031682529183019190830190600101613718565b509695505050505050565b60006020828403121561376357600080fd5b8151801515811461329457600080fd5b808202811582820484141761115a5761115a6136b9565b6000826137a757634e487b7160e01b600052601260045260246000fd5b500490565b80516116ee816131bb565b600060e082840312156137c957600080fd5b60405160e081018181106001600160401b03821117156137f957634e487b7160e01b600052604160045260246000fd5b604052613805836137ac565b8152613813602084016137ac565b6020820152613824604084016137ac565b6040820152613835606084016137ac565b60608201526080830151608082015260a083015160a082015260c083015160c08201528091505092915050565b6001600160e01b03198316815260408101600983106138835761388361358e565b8260208301529392505050565b600081518084526020808501945080840160005b8381101561319d5781516001600160a01b0316875295820195908201906001016138a4565b6040815260006138dc6040830186613890565b82810360208401528381526001600160fb1b038411156138fb57600080fd5b8360051b808660208401370160200195945050505050565b600060018201613925576139256136b9565b5060010190565b6020815260006111576020830184613890565b6060815260006139526060830186613890565b8281036020840152613964818661316d565b90508281036040840152613978818561316d565b969550505050505056fea164736f6c6343000811000a", + "deployedBytecode": "0x60806040526004361061023f5760003560e01c80636bd8f8041161012e578063aa15a6fd116100ab578063d01b8eed1161006f578063d01b8eed146106e6578063de981f1b14610757578063e22d1c9d14610777578063f92ad21914610797578063f9f031df146107b757610251565b8063aa15a6fd1461062d578063acd79c461461064d578063af24542914610660578063c2a672e014610675578063c50870031461069557610251565b8063909791dd116100f2578063909791dd1461059857806391f8723f146105ad578063924f081e146105cd5780639488e4e9146105ed578063969ffc141461060d57610251565b80636bd8f804146104df57806376664b65146104ff578063865e6fd31461051f578063888b9ae91461053f578063895ab7421461055f57610251565b806342e0c408116101bc5780635c19a95c116101805780635c19a95c146104605780635cd8a76b146104735780636558954f14610488578063679a6e431461049f5780636b091695146104bf57610251565b806342e0c4081461038d57806342ef3c34146103d85780634530d202146103f85780634d99dd1614610420578063574734471461044057610251565b80631658c86e116102035780631658c86e1461030757806326476204146103275780632715805e1461033a5780632baae1251461035a5780633d8e846e1461036d57610251565b8063038278841461025c5780630682e8fa14610285578063095f64751461029a578063097e4a9d146102c75780630dccaf46146102e757610251565b3661025157600861024f816107d7565b005b600861024f816107d7565b34801561026857600080fd5b506102726104b081565b6040519081526020015b60405180910390f35b34801561029157600080fd5b50603854610272565b3480156102a657600080fd5b506102ba6102b5366004613102565b61082f565b60405161027c91906131a8565b3480156102d357600080fd5b506102726102e23660046131d0565b610967565b3480156102f357600080fd5b5061024f610302366004613226565b6109ed565b34801561031357600080fd5b5061024f610322366004613277565b610af0565b61024f610335366004613277565b610b60565b34801561034657600080fd5b5061027261035536600461329b565b610b99565b61024f610368366004613226565b610c2a565b34801561037957600080fd5b506102ba6103883660046132c7565b610d78565b34801561039957600080fd5b506103c86103a8366004613277565b6001600160a01b039081166000908152603a602052604090205416151590565b604051901515815260200161027c565b3480156103e457600080fd5b506102ba6103f336600461331b565b610ea6565b34801561040457600080fd5b50606e54606d546040805192835260208301919091520161027c565b34801561042c57600080fd5b5061024f61043b36600461329b565b610f72565b34801561044c57600080fd5b5061024f61045b36600461335c565b610fee565b61024f61046e366004613277565b611000565b34801561047f57600080fd5b5061024f61106e565b34801561049457600080fd5b506102726201518081565b3480156104ab57600080fd5b5061024f6104ba36600461337e565b61112d565b3480156104cb57600080fd5b506102726104da366004613397565b61113e565b3480156104eb57600080fd5b5061024f6104fa3660046133d0565b611160565b34801561050b57600080fd5b5061027261051a366004613397565b6111e5565b34801561052b57600080fd5b5061024f61053a366004613420565b611214565b34801561054b57600080fd5b5061024f61055a36600461337e565b61122f565b34801561056b57600080fd5b5061027261057a366004613277565b6001600160a01b031660009081526037602052604090206003015490565b3480156105a457600080fd5b50606c54610272565b3480156105b957600080fd5b506102ba6105c836600461331b565b611240565b3480156105d957600080fd5b5061024f6105e836600461343c565b6112e0565b3480156105f957600080fd5b5061024f610608366004613102565b6113ba565b34801561061957600080fd5b5061024f61062836600461337e565b6114e9565b34801561063957600080fd5b5061024f610648366004613277565b6114fa565b61024f61065b366004613471565b61156a565b34801561066c57600080fd5b50603954610272565b34801561068157600080fd5b5061024f61069036600461329b565b6115be565b3480156106a157600080fd5b506106ce6106b0366004613277565b6001600160a01b039081166000908152603a60205260409020541690565b6040516001600160a01b03909116815260200161027c565b3480156106f257600080fd5b50610732610701366004613277565b6001600160a01b03808216600090815260376020526040902060018101546002820154600390920154921693909250565b604080516001600160a01b03909416845260208401929092529082015260600161027c565b34801561076357600080fd5b506106ce6107723660046134e4565b611678565b34801561078357600080fd5b5061024f6107923660046134ff565b6116f3565b3480156107a357600080fd5b5061024f6107b236600461354a565b6118b7565b3480156107c357600080fd5b506102726107d236600461331b565b6119ae565b6107e081611678565b6001600160a01b0316336001600160a01b03161461082c576000356001600160e01b03191681336040516320e0f98d60e21b8152600401610823939291906135b8565b60405180910390fd5b50565b6060838214610851576040516376081a7b60e11b815260040160405180910390fd5b836001600160401b03811115610869576108696135ef565b604051908082528060200260200182016040528015610892578160200160208202803683370190505b50905060005b815181101561095e57603760008787848181106108b7576108b7613605565b90506020020160208101906108cc9190613277565b6001600160a01b03166001600160a01b03168152602001908152602001600020600401600085858481811061090357610903613605565b90506020020160208101906109189190613277565b6001600160a01b03166001600160a01b031681526020019081526020016000205482828151811061094b5761094b613605565b6020908102919091010152600101610898565b50949350505050565b600060026000540361098b5760405162461bcd60e51b81526004016108239061361b565b60026000558161099a81611a2e565b336000908152603a60205260409020546001600160a01b0316156109d357604051632fc6bfb160e21b8152336004820152602401610823565b6109df33868686611acc565b600160005595945050505050565b466107e514610a235760405162461bcd60e51b8152602060048201526002602482015261453160f01b6044820152606401610823565b7357832a94810e18c84a5a5e2c4dd67d012ade574f3314610a6b5760405162461bcd60e51b8152602060048201526002602482015261229960f11b6044820152606401610823565b610a756008611678565b60405163f883afaf60e01b81526001600160a01b0386811660048301528581166024830152848116604483015260648201849052919091169063f883afaf906084015b600060405180830381600087803b158015610ad257600080fd5b505af1158015610ae6573d6000803e3d6000fd5b5050505050505050565b80610afa81611a2e565b6001600160a01b038216600090815260376020526040902033610b1d8282611b39565b610b276008611678565b60395460405163dd716ad360e01b81526001600160a01b038781166004830152602482019290925291169063dd716ad390604401610ab8565b610b68611b69565b80610b7281611a2e565b6001600160a01b0382166000908152603760205260409020610b95903334611b8c565b5050565b60006008610ba6816107d7565b6001600160a01b0384166000908152603760205260409020610bc89084611c37565b915033610bd58184611cd4565b610c2257604080518481524760208201526001600160a01b0380841692908816917f63701cd972aa3c7f87898aab145c972e52185beab07d6e39380a998d334cf6c8910160405180910390a35b505092915050565b600260005403610c4c5760405162461bcd60e51b81526004016108239061361b565b60026000908155338152603a60205260409020546001600160a01b031615610c8957604051632fc6bfb160e21b8152336004820152602401610823565b606d54811180610c9a5750606e5481105b15610cb857604051631b8454a360e21b815260040160405180910390fd5b3433610cc8818787878787611d30565b6001600160a01b0380861660008181526037602081815260408084206001810180549789166001600160a01b0319988916811790915581548816871782558552603a835290842080549096168517909555929091529052610d2a818385611b8c565b816001600160a01b0316866001600160a01b03167ffc1f1e73948cbc47c5b7f90e5601b7daccd9ad7173218486ccc74bdd051d05e860405160405180910390a3505060016000555050505050565b6060600080610d876008611678565b6001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa158015610dc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610de89190613652565b9050836001600160401b03811115610e0257610e026135ef565b604051908082528060200260200182016040528015610e2b578160200160208202803683370190505b50925060005b84811015610e9c57858582818110610e4b57610e4b613605565b9050602002016020810190610e609190613277565b9250610e77838884610e72878c6111e5565b611f64565b848281518110610e8957610e89613605565b6020908102919091010152600101610e31565b5050509392505050565b6060816001600160401b03811115610ec057610ec06135ef565b604051908082528060200260200182016040528015610ee9578160200160208202803683370190505b50905060005b82811015610f6b5760376000858584818110610f0d57610f0d613605565b9050602002016020810190610f229190613277565b6001600160a01b03166001600160a01b0316815260200190815260200160002060020154828281518110610f5857610f58613605565b6020908102919091010152600101610eef565b5092915050565b600260005403610f945760405162461bcd60e51b81526004016108239061361b565b600260009081556001600160a01b03831681526037602052604090203390610fbd908284612060565b610fc78183612298565b610fe457604051635ff7115760e11b815260040160405180910390fd5b5050600160005550565b610ff66122e0565b610b95828261233a565b611008611b69565b8061101281611a2e565b336000908152603a60205260409020546001600160a01b03161561104b57604051632fc6bfb160e21b8152336004820152602401610823565b6001600160a01b0382166000908152603760205260409020610b959033346123ae565b60d154600290610100900460ff16158015611090575060d15460ff8083169116105b6110ac5760405162461bcd60e51b81526004016108239061366b565b60d1805461ffff191660ff8316176101001790556036546110d8906008906001600160a01b031661245d565b603680546001600160a01b031916905560d1805461ff001916905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a150565b6111356122e0565b61082c81612501565b6000611157838361114d612536565b610e7287876111e5565b90505b92915050565b6002600054036111825760405162461bcd60e51b81526004016108239061361b565b60026000558161119181611a2e565b6001600160a01b038416600090815260376020526040902033906111b6908285612060565b6001600160a01b03841660009081526037602052604090206111d99082856123ae565b50506001600055505050565b6001600160a01b0391821660009081526037602090815260408083209390941682526004909201909152205490565b61121c6122e0565b611225816125a8565b610b95828261245d565b6112376122e0565b61082c816125de565b6060816001600160401b0381111561125a5761125a6135ef565b604051908082528060200260200182016040528015611283578160200160208202803683370190505b50905060005b82811015610f6b576112bb8484838181106112a6576112a6613605565b905060200201602081019061057a9190613277565b8282815181106112cd576112cd613605565b6020908102919091010152600101611289565b826112ea81611a2e565b6001600160a01b03841660009081526037602052604090203361130d8282611b39565b606d5484118061131e5750606e5484105b1561133c57604051631b8454a360e21b815260040160405180910390fd5b6113466008611678565b60405163e5125a1d60e01b81526001600160a01b0388811660048301526024820188905260448201879052919091169063e5125a1d906064015b600060405180830381600087803b15801561139a57600080fd5b505af11580156113ae573d6000803e3d6000fd5b50505050505050505050565b6002600054036113dc5760405162461bcd60e51b81526004016108239061361b565b60026000558215806113ee5750828114155b1561140c576040516376081a7b60e11b815260040160405180910390fd5b336000805b858110156114b45784848281811061142b5761142b613605565b905060200201358261143d91906136cf565b91506114ac6037600089898581811061145857611458613605565b905060200201602081019061146d9190613277565b6001600160a01b03166001600160a01b03168152602001908152602001600020848787858181106114a0576114a0613605565b90506020020135612060565b600101611411565b506114bf8282612298565b6114dc57604051635ff7115760e11b815260040160405180910390fd5b5050600160005550505050565b6114f16122e0565b61082c81612613565b8061150481611a2e565b6001600160a01b0382166000908152603760205260409020336115278282611b39565b6115316008611678565b60395460405163a7c2f11960e01b81526001600160a01b038781166004830152602482019290925291169063a7c2f11990604401610ab8565b6008611575816107d7565b6115b6868680806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250889250879150869050612648565b505050505050565b6002600054036115e05760405162461bcd60e51b81526004016108239061361b565b6002600055816115ef81611a2e565b81600003611610576040516331d9f7d760e01b815260040160405180910390fd5b6001600160a01b0383166000908152603760205260408120600281015433929061163b9086906136e2565b9050606c548110156116605760405163ef0a995760e01b815260040160405180910390fd5b61166b828487612a76565b6114bf83866104b0612b62565b60007fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb600083600d8111156116af576116af61358e565b60ff1681526020810191909152604001600020546001600160a01b03169050806116ee578160405163409140df60e11b815260040161082391906136f5565b919050565b60086116fe816107d7565b82156118b15760005b838110156118765760006037600087878581811061172757611727613605565b905060200201602081019061173c9190613277565b6001600160a01b0390811682526020808301939093526040918201600090812060018101549092168152603a909352912080546001600160a01b031916905560028101549091508015611803576117938282611c37565b5060018201546117af906001600160a01b0316826104b0612b62565b6118035760018201548254604080518481524760208201526001600160a01b0393841693909216917f7dc5115a5aba081f5a174f56a3d02eea582824783322a4ac03f7bd388f444194910160405180910390a35b600061184388888681811061181a5761181a613605565b905060200201602081019061182f9190613277565b60018501546001600160a01b031688612bc2565b90508015611868576001830154611866906001600160a01b0316826104b0612b62565b505b836001019350505050611707565b507f4f257d3ba23679d338f1d94296086bba5724af341b7fa31aa0ff297bfcdc62d884846040516118a8929190613703565b60405180910390a15b50505050565b60d154610100900460ff16158080156118d7575060d154600160ff909116105b806118f15750303b1580156118f1575060d15460ff166001145b61190d5760405162461bcd60e51b81526004016108239061366b565b60d1805460ff1916600117905580156119305760d1805461ff0019166101001790555b61193b60088761245d565b61194485612501565b61194f60008561233a565b611958836125de565b61196182612613565b80156115b65760d1805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050505050565b60006002600054036119d25760405162461bcd60e51b81526004016108239061361b565b6002600081905550611a1733848480806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250612cd492505050565b9050611a233382612d25565b600160005592915050565b611a386008611678565b604051635061f96960e11b81526001600160a01b038381166004830152919091169063a0c3f2d290602401602060405180830381865afa158015611a80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aa49190613751565b61082c57604051630fd0c64560e11b81526001600160a01b0382166004820152602401610823565b6000611b0b85858580806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250612cd492505050565b6001600160a01b0383166000908152603760205260409020909150611b319086836123ae565b949350505050565b60018201546001600160a01b03828116911614610b9557604051637bc65bd760e11b815260040160405180910390fd5b34600003611b8a57604051636dfcbde560e11b815260040160405180910390fd5b565b8282611b988282611b39565b82856002016000828254611bac91906136cf565b92505081905550611bd285858760020154868960030154611bcd91906136cf565b612d5a565b6001600160a01b03808516600090815260058701602052604090819020429055865490519116907f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d90611c289086815260200190565b60405180910390a25050505050565b6000611c47836002015483612d95565b905080836002016000828254611c5d91906136e2565b9091555050600183015460028401546003850154611c8d9286926001600160a01b0390911691611bcd9086612dab565b82546040518281526001600160a01b03909116907f0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f759060200160405180910390a292915050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611d21576040519150601f19603f3d011682016040523d82523d6000602084013e611d26565b606091505b5090949350505050565b611d3e8660006104b0612b62565b611d89576040805163338f030160e01b81526001600160a01b03881660048201526024810191909152600a6044820152693837b7b61030b236b4b760b11b6064820152608401610823565b611d978360006104b0612b62565b611de0576040805163338f030160e01b81526001600160a01b038516600482015260248101919091526008604482015267747265617375727960c01b6064820152608401610823565b606c54811015611e0357604051630a8d7fa760e21b815260040160405180910390fd5b846001600160a01b0316866001600160a01b0316141580611e365750826001600160a01b0316856001600160a01b031614155b15611e545760405163dc1d04ff60e01b815260040160405180910390fd5b6040805160028082526060820183526000926020830190803683370190505090508681600081518110611e8957611e89613605565b60200260200101906001600160a01b031690816001600160a01b0316815250508481600181518110611ebd57611ebd613605565b60200260200101906001600160a01b031690816001600160a01b031681525050611ee681612dc5565b15611f1257604051630d697db160e11b81526001600160e01b0319600035166004820152602401610823565b50611f1d6008611678565b60405163f883afaf60e01b81526001600160a01b0387811660048301528681166024830152858116604483015260648201859052919091169063f883afaf90608401611380565b6001600160a01b03808516600090815260026020908152604080832093871683529290529081206003810154849003611f9f57549050611b31565b6001600160a01b0386166000908152600360208181526040808420600180845282862094870154865293909252832091820154839290156120045780546001860154909450611fee90856136e2565b8560020154611ffd9190613773565b925061200c565b846001015493505b815460009061201c9086906136e2565b6120269089613773565b9050670de0b6b3a764000061203b82866136cf565b612045919061378a565b865461205191906136cf565b9b9a5050505050505050505050565b828261206c8282612e64565b8260000361208d57604051637ab0c6ad60e11b815260040160405180910390fd5b6001600160a01b03841660009081526004860160205260409020548311156120c857604051630695534560e31b815260040160405180910390fd5b60006120d46008611678565b8654604051635061f96960e11b81526001600160a01b03918216600482015291925082169063a0c3f2d290602401602060405180830381865afa15801561211f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121439190613751565b80156121bd575085546040516328bde1e160e01b81526001600160a01b039182166004820152908216906328bde1e19060240160e060405180830381865afa158015612193573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121b791906137b7565b60a00151155b80156121f057506038546001600160a01b038616600090815260058801602052604090205442916121ed916136cf565b10155b1561220e5760405163f19f52bd60e01b815260040160405180910390fd5b6001600160a01b038516600090815260048701602052604090205461224c908790879061223c9088906136e2565b878a60030154611bcd91906136e2565b85546040518581526001600160a01b03918216918716907f4d10bd049775c77bd7f255195afba5088028ecb3c7c277d393ccff7934f2f92c9060200160405180910390a3505050505050565b6000814710156122d6576040516302631c4f60e61b81526001600160e01b031960003516600482015247602482015260448101839052606401610823565b6111578383611cd4565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b03163314611b8a576000356001600160e01b0319166001604051620f948f60ea1b8152600401610823929190613862565b61271081118061234957508082115b1561236757604051631b8454a360e21b815260040160405180910390fd5b606d819055606e82905560408051838152602081018390527f677752f5bf9541b14288833909e5ec5a478103131c1ec08c4638943be5826c14910160405180910390a15050565b82826123ba8282612e64565b6001600160a01b03841660009081526004860160205260409020546123f890869086906123e89087906136cf565b868960030154611bcd91906136cf565b6001600160a01b03808516600081815260058801602052604090819020429055875490519216917fe5541a6b6103d4fa7e021ed54fad39c66f27a76bd13d374cf6240ae6bd0bb72b9061244e9087815260200190565b60405180910390a35050505050565b807fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb600084600d8111156124935761249361358e565b60ff168152602081019190915260400160002080546001600160a01b0319166001600160a01b03928316179055811682600d8111156124d4576124d461358e565b6040517f865d1c228a8ea13709cfe61f346f7ff67f1bbd4a18ff31ad3e7147350d317c5990600090a35050565b606c8190556040518181527f372bbdb8d72373b0012f84ee5a11671e5fb72b8bea902ebca93a19cb45d32be290602001611122565b60006125426008611678565b6001600160a01b031663060406186040518163ffffffff1660e01b8152600401602060405180830381865afa15801561257f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125a39190613652565b905090565b806001600160a01b03163b60000361082c57604051630bfc64a360e21b81526001600160a01b0382166004820152602401610823565b60388190556040518181527f4956b65267b8f1e642284bcb5037116c69a9c78d9ca576beeae0974737a4872a90602001611122565b60398190556040518181527f02be0b73b597f2c0f138aebee162b3b0e25d5b5a26854c15dcf79176e9a1c67890602001611122565b8351821461269157807fae52c603227f64e4c6101dde593aa9790a16b3ac77546bd746d758511e9560a5858585604051612684939291906138c9565b60405180910390a26118b1565b600080600080600088516001600160401b038111156126b2576126b26135ef565b6040519080825280602002602001820160405280156126db578160200160208202803683370190505b509050600089516001600160401b038111156126f9576126f96135ef565b604051908082528060200260200182016040528015612722578160200160208202803683370190505b50905060008a516001600160401b03811115612740576127406135ef565b604051908082528060200260200182016040528015612769578160200160208202803683370190505b50905060005b8b518110156129dc578b818151811061278a5761278a613605565b6020908102919091018101516001600160a01b038116600090815260038084526040808320603790955290912001549097506001600160a01b03881660009081526001602081815260408084208f855290915290912001549096508a900361282b57868389806001019a508151811061280557612805613605565b60200260200101906001600160a01b031690816001600160a01b031681525050506129ca565b60028101548a111561285957604080518082019091528681526020018a905260018101869055600281018a90555b6001810154156128a35760018101548c8c8481811061287a5761287a613605565b90506020020135670de0b6b3a76400006128949190613773565b61289e919061378a565b6128a6565b60005b9850888160000160008282546128bc91906136cf565b91829055509050856128ce8a856136e2565b815181106128de576128de613605565b6020026020010181815250506040518060400160405280826000015481526020018b81525060016000896001600160a01b03166001600160a01b0316815260200190815260200160002060008c81526020019081526020016000206000820151816000015560208201518160010155905050858160010160000181905550806001016000015484898461297191906136e2565b8151811061298157612981613605565b6020908102919091010152868d6129988a856136e2565b815181106129a8576129a8613605565b60200260200101906001600160a01b031690816001600160a01b031681525050505b806129d481613913565b91505061276f565b508515612a2557858152858b51038b52877fee74f10cc50bf4b7e57fd36be7d46288795f3a9151dae97505b718b392ba14a382604051612a1c919061392c565b60405180910390a25b8a5115612a6957877f0e54e0485f70f0f63bc25889ddbf01ce1269ad6f07fdb2df573a0fbdb4d66f888c8585604051612a609392919061393f565b60405180910390a25b5050505050505050505050565b8282612a828282611b39565b8460020154831115612aa757604051630a8d7fa760e21b815260040160405180910390fd5b6038546001600160a01b03851660009081526005870160205260409020544291612ad0916136cf565b1115612aef576040516303db082960e11b815260040160405180910390fd5b82856002016000828254612b0391906136e2565b92505081905550612b2485858760020154868960030154611bcd91906136e2565b84546040518481526001600160a01b03909116907f0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f7590602001611c28565b6000836001600160a01b0316838390604051600060405180830381858888f193505050503d8060008114612bb2576040519150601f19603f3d011682016040523d82523d6000602084013e612bb7565b606091505b509095945050505050565b600080612bcf85856111e5565b9050612bdd85858584611f64565b9150836001600160a01b0316856001600160a01b03167f0aa4d283470c904c551d18bb894d37e17674920f3261a7f854be501e25f421b784604051612c2491815260200190565b60405180910390a36001600160a01b03808616600081815260026020908152604080832094891683529381528382208281559282526003905291909120612c6e9082868580612e94565b60038181018590556001600160a01b03878116600081815260209384526040808220546001870155519081529188169290917faa7c29611027fd4be148712bb54960253b7a7d5998c17769bfc424c2f5f185ad910160405180910390a350509392505050565b600080612cdf612536565b905060005b8351811015610c2257612d11848281518110612d0257612d02613605565b60200260200101518684612bc2565b612d1b90846136cf565b9250600101612ce4565b612d2f8282612298565b610b95576040516303b97b7760e41b81526001600160e01b0319600035166004820152602401610823565b8354612d70906001600160a01b03168484612f26565b60038401556001600160a01b0390911660009081526004909201602052604090912055565b6000818310612da45781611157565b5090919050565b6000818311612dbb576000611157565b61115782846136e2565b60008151600003612dd857506000919050565b60005b6001835103811015612e5b57600181015b8351811015612e5257838181518110612e0757612e07613605565b60200260200101516001600160a01b0316848381518110612e2a57612e2a613605565b60200260200101516001600160a01b031603612e4a575060019392505050565b600101612dec565b50600101612ddb565b50600092915050565b60018201546001600160a01b03808316911603610b9557604051639feb934760e01b815260040160405180910390fd5b8284600301541015612ea857600284018190555b6000612eb8856002015484612d95565b90506000818660020154612ecc91906136e2565b90508015612f1d57600286018290556001870154811115612f00576040516352e521bf60e11b815260040160405180910390fd5b80876001016000016000828254612f1791906136e2565b90915550505b50505050505050565b6000612f30612536565b6001600160a01b0385166000908152600360205260409020600181015460028201549293509091831115612fa4576040518060400160405280612f8b886001600160a01b031660009081526037602052604090206003015490565b8152602090810185905281516001850155015160028301555b6001600160a01b038087166000908152600260209081526040808320938916835292905290812090612fd688886111e5565b90506000612fe689898885611f64565b83549091508114613038578083556040518181526001600160a01b0389811691908b16907faa7c29611027fd4be148712bb54960253b7a7d5998c17769bfc424c2f5f185ad9060200160405180910390a35b6130458584888a86612e94565b84546001808501919091556003840187905585015484146130ac57886001600160a01b0316867f81faf50e2aaf52eaba2ab841071efb9f6f0850a3e7d008b1336e6001d3d4963c87600101600001546040516130a391815260200190565b60405180910390a35b505050505050505050565b60008083601f8401126130c957600080fd5b5081356001600160401b038111156130e057600080fd5b6020830191508360208260051b85010111156130fb57600080fd5b9250929050565b6000806000806040858703121561311857600080fd5b84356001600160401b038082111561312f57600080fd5b61313b888389016130b7565b9096509450602087013591508082111561315457600080fd5b50613161878288016130b7565b95989497509550505050565b600081518084526020808501945080840160005b8381101561319d57815187529582019590820190600101613181565b509495945050505050565b602081526000611157602083018461316d565b6001600160a01b038116811461082c57600080fd5b6000806000604084860312156131e557600080fd5b83356001600160401b038111156131fb57600080fd5b613207868287016130b7565b909450925050602084013561321b816131bb565b809150509250925092565b6000806000806080858703121561323c57600080fd5b8435613247816131bb565b93506020850135613257816131bb565b92506040850135613267816131bb565b9396929550929360600135925050565b60006020828403121561328957600080fd5b8135613294816131bb565b9392505050565b600080604083850312156132ae57600080fd5b82356132b9816131bb565b946020939093013593505050565b6000806000604084860312156132dc57600080fd5b83356132e7816131bb565b925060208401356001600160401b0381111561330257600080fd5b61330e868287016130b7565b9497909650939450505050565b6000806020838503121561332e57600080fd5b82356001600160401b0381111561334457600080fd5b613350858286016130b7565b90969095509350505050565b6000806040838503121561336f57600080fd5b50508035926020909101359150565b60006020828403121561339057600080fd5b5035919050565b600080604083850312156133aa57600080fd5b82356133b5816131bb565b915060208301356133c5816131bb565b809150509250929050565b6000806000606084860312156133e557600080fd5b83356133f0816131bb565b92506020840135613400816131bb565b929592945050506040919091013590565b8035600e81106116ee57600080fd5b6000806040838503121561343357600080fd5b6133b583613411565b60008060006060848603121561345157600080fd5b833561345c816131bb565b95602085013595506040909401359392505050565b60008060008060006060868803121561348957600080fd5b85356001600160401b03808211156134a057600080fd5b6134ac89838a016130b7565b909750955060208801359150808211156134c557600080fd5b506134d2888289016130b7565b96999598509660400135949350505050565b6000602082840312156134f657600080fd5b61115782613411565b60008060006040848603121561351457600080fd5b83356001600160401b0381111561352a57600080fd5b613536868287016130b7565b909790965060209590950135949350505050565b600080600080600060a0868803121561356257600080fd5b853561356d816131bb565b97602087013597506040870135966060810135965060800135945092505050565b634e487b7160e01b600052602160045260246000fd5b600e81106135b4576135b461358e565b9052565b6001600160e01b031984168152606081016135d660208301856135a4565b6001600160a01b03929092166040919091015292915050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60006020828403121561366457600080fd5b5051919050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b8082018082111561115a5761115a6136b9565b8181038181111561115a5761115a6136b9565b6020810161115a82846135a4565b60208082528181018390526000908460408401835b8681101561374657823561372b816131bb565b6001600160a01b031682529183019190830190600101613718565b509695505050505050565b60006020828403121561376357600080fd5b8151801515811461329457600080fd5b808202811582820484141761115a5761115a6136b9565b6000826137a757634e487b7160e01b600052601260045260246000fd5b500490565b80516116ee816131bb565b600060e082840312156137c957600080fd5b60405160e081018181106001600160401b03821117156137f957634e487b7160e01b600052604160045260246000fd5b604052613805836137ac565b8152613813602084016137ac565b6020820152613824604084016137ac565b6040820152613835606084016137ac565b60608201526080830151608082015260a083015160a082015260c083015160c08201528091505092915050565b6001600160e01b03198316815260408101600983106138835761388361358e565b8260208301529392505050565b600081518084526020808501945080840160005b8381101561319d5781516001600160a01b0316875295820195908201906001016138a4565b6040815260006138dc6040830186613890565b82810360208401528381526001600160fb1b038411156138fb57600080fd5b8360051b808660208401370160200195945050505050565b600060018201613925576139256136b9565b5060010190565b6020815260006111576020830184613890565b6060815260006139526060830186613890565b8281036020840152613964818661316d565b90508281036040840152613978818561316d565b969550505050505056fea164736f6c6343000811000a", "devdoc": { "errors": { "ErrAdminOfAnyActivePoolForbidden(address)": [ @@ -1559,7 +1582,7 @@ }, "kind": "dev", "methods": { - "applyValidatorCandidate(address,address,address,address,uint256)": { + "applyValidatorCandidate(address,address,address,uint256)": { "details": "Proposes a candidate to become a validator. Requirements: - The method caller is able to receive RON. - The treasury is able to receive RON. - The amount is larger than or equal to the minimum validator staking amount `minValidatorStakingAmount()`. Emits the event `PoolApproved`.", "params": { "_candidateAdmin": "the candidate admin will be stored in the validator contract, used for calling function that affects to its candidate, e.g. scheduling maintenance." @@ -1671,6 +1694,9 @@ "stake(address)": { "details": "Self-delegates to the validator candidate `_consensusAddr`. Requirements: - The consensus address is a validator candidate. - The method caller is the pool admin. - The `msg.value` is larger than 0. Emits the event `Staked`." }, + "tmp_re_applyValidatorCandidate(address,address,address,uint256)": { + "details": "This method only work on testnet, to hotfix the applied validator candidate that is failed. Should remove this method before deploying it on mainnet." + }, "undelegate(address,uint256)": { "details": "Unstakes from a validator candidate `_consensusAddr` for `_amount`. Requirements: - The method caller is not the pool admin. Emits the `Undelegated` event." }, @@ -1691,7 +1717,7 @@ "storageLayout": { "storage": [ { - "astId": 1636, + "astId": 736, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "_status", "offset": 0, @@ -1699,31 +1725,31 @@ "type": "t_uint256" }, { - "astId": 29742, + "astId": 12296, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "_accumulatedRps", "offset": 0, "slot": "1", - "type": "t_mapping(t_address,t_mapping(t_uint256,t_struct(PeriodWrapper)10328_storage))" + "type": "t_mapping(t_address,t_mapping(t_uint256,t_struct(PeriodWrapper)7460_storage))" }, { - "astId": 29750, + "astId": 12304, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "_userReward", "offset": 0, "slot": "2", - "type": "t_mapping(t_address,t_mapping(t_address,t_struct(UserRewardFields)11140_storage))" + "type": "t_mapping(t_address,t_mapping(t_address,t_struct(UserRewardFields)7887_storage))" }, { - "astId": 29756, + "astId": 12310, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "_stakingPool", "offset": 0, "slot": "3", - "type": "t_mapping(t_address,t_struct(PoolFields)11146_storage)" + "type": "t_mapping(t_address,t_struct(PoolFields)7893_storage)" }, { - "astId": 29761, + "astId": 12315, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "______gap", "offset": 0, @@ -1731,7 +1757,7 @@ "type": "t_array(t_uint256)50_storage" }, { - "astId": 35464, + "astId": 13735, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "______deprecatedValidator", "offset": 0, @@ -1739,15 +1765,15 @@ "type": "t_address" }, { - "astId": 27913, + "astId": 10479, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "_stakingPool", "offset": 0, "slot": "55", - "type": "t_mapping(t_address,t_struct(PoolDetail)10750_storage)" + "type": "t_mapping(t_address,t_struct(PoolDetail)7499_storage)" }, { - "astId": 27916, + "astId": 10482, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "_cooldownSecsToUndelegate", "offset": 0, @@ -1755,7 +1781,7 @@ "type": "t_uint256" }, { - "astId": 27919, + "astId": 10485, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "_waitingSecsToRevoke", "offset": 0, @@ -1763,7 +1789,7 @@ "type": "t_uint256" }, { - "astId": 27924, + "astId": 10490, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "_adminOfActivePoolMapping", "offset": 0, @@ -1771,7 +1797,7 @@ "type": "t_mapping(t_address,t_address)" }, { - "astId": 27929, + "astId": 10495, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "______gap", "offset": 0, @@ -1779,7 +1805,7 @@ "type": "t_array(t_uint256)49_storage" }, { - "astId": 28418, + "astId": 10984, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "_minValidatorStakingAmount", "offset": 0, @@ -1787,7 +1813,7 @@ "type": "t_uint256" }, { - "astId": 28421, + "astId": 10987, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "_maxCommissionRate", "offset": 0, @@ -1795,7 +1821,7 @@ "type": "t_uint256" }, { - "astId": 28424, + "astId": 10990, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "_minCommissionRate", "offset": 0, @@ -1803,7 +1829,7 @@ "type": "t_uint256" }, { - "astId": 28429, + "astId": 10995, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "______gap", "offset": 0, @@ -1811,7 +1837,7 @@ "type": "t_array(t_uint256)48_storage" }, { - "astId": 29197, + "astId": 11751, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "______gap", "offset": 0, @@ -1819,7 +1845,7 @@ "type": "t_array(t_uint256)50_storage" }, { - "astId": 1373, + "astId": 581, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "_initialized", "offset": 0, @@ -1827,7 +1853,7 @@ "type": "t_uint8" }, { - "astId": 1376, + "astId": 584, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "_initializing", "offset": 1, @@ -1871,40 +1897,40 @@ "numberOfBytes": "32", "value": "t_address" }, - "t_mapping(t_address,t_mapping(t_address,t_struct(UserRewardFields)11140_storage))": { + "t_mapping(t_address,t_mapping(t_address,t_struct(UserRewardFields)7887_storage))": { "encoding": "mapping", "key": "t_address", "label": "mapping(address => mapping(address => struct IRewardPool.UserRewardFields))", "numberOfBytes": "32", - "value": "t_mapping(t_address,t_struct(UserRewardFields)11140_storage)" + "value": "t_mapping(t_address,t_struct(UserRewardFields)7887_storage)" }, - "t_mapping(t_address,t_mapping(t_uint256,t_struct(PeriodWrapper)10328_storage))": { + "t_mapping(t_address,t_mapping(t_uint256,t_struct(PeriodWrapper)7460_storage))": { "encoding": "mapping", "key": "t_address", "label": "mapping(address => mapping(uint256 => struct PeriodWrapperConsumer.PeriodWrapper))", "numberOfBytes": "32", - "value": "t_mapping(t_uint256,t_struct(PeriodWrapper)10328_storage)" + "value": "t_mapping(t_uint256,t_struct(PeriodWrapper)7460_storage)" }, - "t_mapping(t_address,t_struct(PoolDetail)10750_storage)": { + "t_mapping(t_address,t_struct(PoolDetail)7499_storage)": { "encoding": "mapping", "key": "t_address", "label": "mapping(address => struct IBaseStaking.PoolDetail)", "numberOfBytes": "32", - "value": "t_struct(PoolDetail)10750_storage" + "value": "t_struct(PoolDetail)7499_storage" }, - "t_mapping(t_address,t_struct(PoolFields)11146_storage)": { + "t_mapping(t_address,t_struct(PoolFields)7893_storage)": { "encoding": "mapping", "key": "t_address", "label": "mapping(address => struct IRewardPool.PoolFields)", "numberOfBytes": "32", - "value": "t_struct(PoolFields)11146_storage" + "value": "t_struct(PoolFields)7893_storage" }, - "t_mapping(t_address,t_struct(UserRewardFields)11140_storage)": { + "t_mapping(t_address,t_struct(UserRewardFields)7887_storage)": { "encoding": "mapping", "key": "t_address", "label": "mapping(address => struct IRewardPool.UserRewardFields)", "numberOfBytes": "32", - "value": "t_struct(UserRewardFields)11140_storage" + "value": "t_struct(UserRewardFields)7887_storage" }, "t_mapping(t_address,t_uint256)": { "encoding": "mapping", @@ -1913,19 +1939,19 @@ "numberOfBytes": "32", "value": "t_uint256" }, - "t_mapping(t_uint256,t_struct(PeriodWrapper)10328_storage)": { + "t_mapping(t_uint256,t_struct(PeriodWrapper)7460_storage)": { "encoding": "mapping", "key": "t_uint256", "label": "mapping(uint256 => struct PeriodWrapperConsumer.PeriodWrapper)", "numberOfBytes": "32", - "value": "t_struct(PeriodWrapper)10328_storage" + "value": "t_struct(PeriodWrapper)7460_storage" }, - "t_struct(PeriodWrapper)10328_storage": { + "t_struct(PeriodWrapper)7460_storage": { "encoding": "inplace", "label": "struct PeriodWrapperConsumer.PeriodWrapper", "members": [ { - "astId": 10325, + "astId": 7457, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "inner", "offset": 0, @@ -1933,7 +1959,7 @@ "type": "t_uint256" }, { - "astId": 10327, + "astId": 7459, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "lastPeriod", "offset": 0, @@ -1943,12 +1969,12 @@ ], "numberOfBytes": "64" }, - "t_struct(PoolDetail)10750_storage": { + "t_struct(PoolDetail)7499_storage": { "encoding": "inplace", "label": "struct IBaseStaking.PoolDetail", "members": [ { - "astId": 10735, + "astId": 7484, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "addr", "offset": 0, @@ -1956,7 +1982,7 @@ "type": "t_address" }, { - "astId": 10737, + "astId": 7486, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "admin", "offset": 0, @@ -1964,7 +1990,7 @@ "type": "t_address" }, { - "astId": 10739, + "astId": 7488, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "stakingAmount", "offset": 0, @@ -1972,7 +1998,7 @@ "type": "t_uint256" }, { - "astId": 10741, + "astId": 7490, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "stakingTotal", "offset": 0, @@ -1980,7 +2006,7 @@ "type": "t_uint256" }, { - "astId": 10745, + "astId": 7494, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "delegatingAmount", "offset": 0, @@ -1988,7 +2014,7 @@ "type": "t_mapping(t_address,t_uint256)" }, { - "astId": 10749, + "astId": 7498, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "lastDelegatingTimestamp", "offset": 0, @@ -1998,12 +2024,12 @@ ], "numberOfBytes": "192" }, - "t_struct(PoolFields)11146_storage": { + "t_struct(PoolFields)7893_storage": { "encoding": "inplace", "label": "struct IRewardPool.PoolFields", "members": [ { - "astId": 11142, + "astId": 7889, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "aRps", "offset": 0, @@ -2011,22 +2037,22 @@ "type": "t_uint256" }, { - "astId": 11145, + "astId": 7892, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "shares", "offset": 0, "slot": "1", - "type": "t_struct(PeriodWrapper)10328_storage" + "type": "t_struct(PeriodWrapper)7460_storage" } ], "numberOfBytes": "96" }, - "t_struct(UserRewardFields)11140_storage": { + "t_struct(UserRewardFields)7887_storage": { "encoding": "inplace", "label": "struct IRewardPool.UserRewardFields", "members": [ { - "astId": 11133, + "astId": 7880, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "debited", "offset": 0, @@ -2034,7 +2060,7 @@ "type": "t_uint256" }, { - "astId": 11135, + "astId": 7882, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "aRps", "offset": 0, @@ -2042,7 +2068,7 @@ "type": "t_uint256" }, { - "astId": 11137, + "astId": 7884, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "lowestAmount", "offset": 0, @@ -2050,7 +2076,7 @@ "type": "t_uint256" }, { - "astId": 11139, + "astId": 7886, "contract": "contracts/ronin/staking/Staking.sol:Staking", "label": "lastPeriod", "offset": 0, diff --git a/deployments/ronin-testnet/solcInputs/6da162a003a00b6a8800b1f2bcac773f.json b/deployments/ronin-testnet/solcInputs/6da162a003a00b6a8800b1f2bcac773f.json new file mode 100644 index 000000000..39b36f458 --- /dev/null +++ b/deployments/ronin-testnet/solcInputs/6da162a003a00b6a8800b1f2bcac773f.json @@ -0,0 +1,262 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts/interfaces/draft-IERC1822.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n *\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\n */\n constructor(address _logic, bytes memory _data) payable {\n _upgradeToAndCall(_logic, _data, false);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function _implementation() internal view virtual override returns (address impl) {\n return ERC1967Upgrade._getImplementation();\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967Upgrade {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _changeAdmin(address newAdmin) internal {\n emit AdminChanged(_getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Emitted when the beacon is upgraded.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Returns the current beacon.\n */\n function _getBeacon() internal view returns (address) {\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n Address.isContract(IBeacon(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(\n address newBeacon,\n bytes memory data,\n bool forceCall\n ) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overridden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC1967/ERC1967Proxy.sol\";\n\n/**\n * @dev This contract implements a proxy that is upgradeable by an admin.\n *\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n *\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches one of the admin functions exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\n * \"admin cannot fallback to proxy target\".\n *\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\n * to sudden errors when trying to call a function from the proxy implementation.\n *\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\n */\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\n /**\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\n */\n constructor(\n address _logic,\n address admin_,\n bytes memory _data\n ) payable ERC1967Proxy(_logic, _data) {\n _changeAdmin(admin_);\n }\n\n /**\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\n */\n modifier ifAdmin() {\n if (msg.sender == _getAdmin()) {\n _;\n } else {\n _fallback();\n }\n }\n\n /**\n * @dev Returns the current admin.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function admin() external ifAdmin returns (address admin_) {\n admin_ = _getAdmin();\n }\n\n /**\n * @dev Returns the current implementation.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n */\n function implementation() external ifAdmin returns (address implementation_) {\n implementation_ = _implementation();\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\n */\n function changeAdmin(address newAdmin) external virtual ifAdmin {\n _changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\n */\n function upgradeTo(address newImplementation) external ifAdmin {\n _upgradeToAndCall(newImplementation, bytes(\"\"), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\n * proxied contract.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\n */\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\n _upgradeToAndCall(newImplementation, data, true);\n }\n\n /**\n * @dev Returns the current admin.\n */\n function _admin() internal view virtual returns (address) {\n return _getAdmin();\n }\n\n /**\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\n */\n function _beforeFallback() internal virtual override {\n require(msg.sender != _getAdmin(), \"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n super._beforeFallback();\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n * initialization step. This is essential to configure modules that are added through upgrades and that require\n * initialization.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/security/ReentrancyGuard.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" + }, + "@openzeppelin/contracts/utils/StorageSlot.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" + }, + "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping(bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (lastIndex != toDeleteIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastValue;\n // Update the index for the moved value\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n return _values(set._inner);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" + }, + "contracts/extensions/bridge-operator-governance/BridgeManager.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { IBridgeManagerCallback, EnumerableSet, BridgeManagerCallbackRegister } from \"./BridgeManagerCallbackRegister.sol\";\nimport { IHasContracts, HasContracts } from \"../../extensions/collections/HasContracts.sol\";\nimport { IQuorum } from \"../../interfaces/IQuorum.sol\";\nimport { IBridgeManager } from \"../../interfaces/bridge/IBridgeManager.sol\";\nimport { AddressArrayUtils } from \"../../libraries/AddressArrayUtils.sol\";\nimport { ContractType } from \"../../utils/ContractType.sol\";\nimport { RoleAccess } from \"../../utils/RoleAccess.sol\";\nimport { TUint256Slot } from \"../../types/Types.sol\";\nimport \"../../utils/CommonErrors.sol\";\n\nabstract contract BridgeManager is IQuorum, IBridgeManager, BridgeManagerCallbackRegister, HasContracts {\n using AddressArrayUtils for address[];\n using EnumerableSet for EnumerableSet.AddressSet;\n\n /// @dev value is equal to keccak256(\"@ronin.dpos.gateway.BridgeAdmin.governorToBridgeOperatorInfo.slot\") - 1\n bytes32 private constant GOVERNOR_TO_BRIDGE_OPERATOR_INFO_SLOT =\n 0x88547008e60f5748911f2e59feb3093b7e4c2e87b2dd69d61f112fcc932de8e3;\n /// @dev value is equal to keccak256(\"@ronin.dpos.gateway.BridgeAdmin.govenorOf.slot\") - 1\n bytes32 private constant GOVENOR_OF_SLOT = 0x8400683eb2cb350596d73644c0c89fe45f108600003457374f4ab3e87b4f3aa3;\n /// @dev value is equal to keccak256(\"@ronin.dpos.gateway.BridgeAdmin.governors.slot\") - 1\n bytes32 private constant GOVERNOR_SET_SLOT = 0x546f6b46ab35b030b6816596b352aef78857377176c8b24baa2046a62cf1998c;\n /// @dev value is equal to keccak256(\"@ronin.dpos.gateway.BridgeAdmin.bridgeOperators.slot\") - 1\n bytes32 private constant BRIDGE_OPERATOR_SET_SLOT =\n 0xd38c234075fde25875da8a6b7e36b58b86681d483271a99eeeee1d78e258a24d;\n\n /**\n * @dev The numerator value used for calculations in the contract.\n * @notice value is equal to keccak256(\"@ronin.dpos.gateway.BridgeAdmin.numerator.slot\") - 1\n */\n TUint256Slot internal constant NUMERATOR_SLOT =\n TUint256Slot.wrap(0xc55405a488814eaa0e2a685a0131142785b8d033d311c8c8244e34a7c12ca40f);\n\n /**\n * @dev The denominator value used for calculations in the contract.\n * @notice value is equal to keccak256(\"@ronin.dpos.gateway.BridgeAdmin.denominator.slot\") - 1\n */\n TUint256Slot internal constant DENOMINATOR_SLOT =\n TUint256Slot.wrap(0xac1ff16a4f04f2a37a9ba5252a69baa100b460e517d1f8019c054a5ad698f9ff);\n\n /**\n * @dev The nonce value used for tracking nonces in the contract.\n * @notice value is equal to keccak256(\"@ronin.dpos.gateway.BridgeAdmin.nonce.slot\") - 1\n */\n TUint256Slot internal constant NONCE_SLOT =\n TUint256Slot.wrap(0x92872d32822c9d44b36a2537d3e0d4c46fc4de1ce154ccfaed560a8a58445f1d);\n\n /**\n * @dev The total weight value used for storing the cumulative weight in the contract.\n * @notice value is equal to keccak256(\"@ronin.dpos.gateway.BridgeAdmin.totalWeights.slot\") - 1\n */\n TUint256Slot internal constant TOTAL_WEIGHTS_SLOT =\n TUint256Slot.wrap(0x6924fe71b0c8b61aea02ca498b5f53b29bd95726278b1fe4eb791bb24a42644c);\n\n /**\n * @inheritdoc IBridgeManager\n */\n bytes32 public immutable DOMAIN_SEPARATOR;\n\n modifier onlyGovernor() virtual {\n _requireGovernor(msg.sender);\n _;\n }\n\n constructor(\n uint256 num,\n uint256 denom,\n uint256 roninChainId,\n address bridgeContract,\n address[] memory callbackRegisters,\n address[] memory bridgeOperators,\n address[] memory governors,\n uint96[] memory voteWeights\n ) payable BridgeManagerCallbackRegister(callbackRegisters) {\n NONCE_SLOT.store(1);\n NUMERATOR_SLOT.store(num);\n DENOMINATOR_SLOT.store(denom);\n\n _setContract(ContractType.BRIDGE, bridgeContract);\n\n DOMAIN_SEPARATOR = keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,bytes32 salt)\"),\n keccak256(\"BridgeAdmin\"), // name hash\n keccak256(\"2\"), // version hash\n keccak256(abi.encode(\"BRIDGE_ADMIN\", roninChainId)) // salt\n )\n );\n\n _addBridgeOperators(voteWeights, governors, bridgeOperators);\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function addBridgeOperators(\n uint96[] calldata voteWeights,\n address[] calldata governors,\n address[] calldata bridgeOperators\n ) external onlySelfCall returns (bool[] memory addeds) {\n addeds = _addBridgeOperators(voteWeights, governors, bridgeOperators);\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function removeBridgeOperators(\n address[] calldata bridgeOperators\n ) external onlySelfCall returns (bool[] memory removeds) {\n removeds = _removeBridgeOperators(bridgeOperators);\n }\n\n /**\n * @inheritdoc IBridgeManager\n * @notice This method checks authorization by querying the corresponding operator of the msg.sender and then\n * attempts to remove it from the `_bridgeOperatorSet` for gas optimization. In case we allow a governor can leave\n * their operator address blank null `address(0)`, consider add authorization check.\n */\n function updateBridgeOperator(address newBridgeOperator) external onlyGovernor {\n _requireNonZeroAddress(newBridgeOperator);\n\n // Queries the previous bridge operator\n mapping(address => BridgeOperatorInfo) storage _gorvernorToBridgeOperatorInfo = _getGovernorToBridgeOperatorInfo();\n address currentBridgeOperator = _gorvernorToBridgeOperatorInfo[msg.sender].addr;\n if (currentBridgeOperator == newBridgeOperator) {\n revert ErrBridgeOperatorAlreadyExisted(newBridgeOperator);\n }\n\n // Tries replace the bridge operator\n EnumerableSet.AddressSet storage _bridgeOperatorSet = _getBridgeOperatorSet();\n bool updated = _bridgeOperatorSet.remove(currentBridgeOperator) && _bridgeOperatorSet.add(newBridgeOperator);\n if (!updated) revert ErrBridgeOperatorUpdateFailed(newBridgeOperator);\n\n mapping(address => address) storage _governorOf = _getGovernorOf();\n delete _governorOf[currentBridgeOperator];\n _governorOf[newBridgeOperator] = msg.sender;\n _gorvernorToBridgeOperatorInfo[msg.sender].addr = newBridgeOperator;\n\n _notifyRegisters(\n IBridgeManagerCallback.onBridgeOperatorUpdated.selector,\n abi.encode(currentBridgeOperator, newBridgeOperator)\n );\n\n emit BridgeOperatorUpdated(msg.sender, currentBridgeOperator, newBridgeOperator);\n }\n\n /**\n * @inheritdoc IHasContracts\n */\n function setContract(ContractType contractType, address addr) external override onlySelfCall {\n _requireHasCode(addr);\n _setContract(contractType, addr);\n }\n\n /**\n * @inheritdoc IQuorum\n */\n function setThreshold(\n uint256 numerator,\n uint256 denominator\n ) external override onlySelfCall returns (uint256, uint256) {\n return _setThreshold(numerator, denominator);\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function getTotalWeights() public view returns (uint256) {\n return TOTAL_WEIGHTS_SLOT.load();\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function getGovernorWeights(address[] calldata governors) external view returns (uint256[] memory weights) {\n weights = _getGovernorWeights(governors);\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function getGovernorWeight(address governor) external view returns (uint256 weight) {\n weight = _getGovernorWeight(governor);\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function sumGovernorsWeight(\n address[] calldata governors\n ) external view nonDuplicate(governors) returns (uint256 sum) {\n sum = _sumGovernorsWeight(governors);\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function totalBridgeOperators() external view returns (uint256) {\n return _getBridgeOperatorSet().length();\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function isBridgeOperator(address addr) external view returns (bool) {\n return _getBridgeOperatorSet().contains(addr);\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function getBridgeOperators() external view returns (address[] memory) {\n return _getBridgeOperators();\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function getGovernors() external view returns (address[] memory) {\n return _getGovernors();\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function getBridgeOperatorOf(address[] memory governors) public view returns (address[] memory bridgeOperators) {\n uint256 length = governors.length;\n bridgeOperators = new address[](length);\n\n mapping(address => BridgeOperatorInfo) storage _gorvernorToBridgeOperator = _getGovernorToBridgeOperatorInfo();\n for (uint256 i; i < length; ) {\n bridgeOperators[i] = _gorvernorToBridgeOperator[governors[i]].addr;\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function getGovernorsOf(address[] calldata bridgeOperators) external view returns (address[] memory governors) {\n uint256 length = bridgeOperators.length;\n governors = new address[](length);\n mapping(address => address) storage _governorOf = _getGovernorOf();\n\n for (uint256 i; i < length; ) {\n governors[i] = _governorOf[bridgeOperators[i]];\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function getFullBridgeOperatorInfos()\n external\n view\n returns (address[] memory governors, address[] memory bridgeOperators, uint256[] memory weights)\n {\n governors = _getGovernors();\n bridgeOperators = getBridgeOperatorOf(governors);\n weights = _getGovernorWeights(governors);\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function getBridgeOperatorWeight(address bridgeOperator) external view returns (uint256 weight) {\n mapping(address => address) storage _governorOf = _getGovernorOf();\n mapping(address => BridgeOperatorInfo) storage _governorToBridgeOperatorInfo = _getGovernorToBridgeOperatorInfo();\n weight = _governorToBridgeOperatorInfo[_governorOf[bridgeOperator]].voteWeight;\n }\n\n /**\n * @inheritdoc IQuorum\n */\n function minimumVoteWeight() public view virtual returns (uint256) {\n return (NUMERATOR_SLOT.mul(TOTAL_WEIGHTS_SLOT.load()) + DENOMINATOR_SLOT.load() - 1) / DENOMINATOR_SLOT.load();\n }\n\n /**\n * @inheritdoc IQuorum\n */\n function getThreshold() external view virtual returns (uint256 num_, uint256 denom_) {\n return (NUMERATOR_SLOT.load(), DENOMINATOR_SLOT.load());\n }\n\n /**\n * @inheritdoc IQuorum\n */\n function checkThreshold(uint256 _voteWeight) external view virtual returns (bool) {\n return _voteWeight * DENOMINATOR_SLOT.load() >= NUMERATOR_SLOT.mul(TOTAL_WEIGHTS_SLOT.load());\n }\n\n /**\n * @dev Internal function to add bridge operators.\n *\n * This function adds the specified `bridgeOperators` to the bridge operator set and establishes the associated mappings.\n *\n * Requirements:\n * - The caller must have the necessary permission to add bridge operators.\n * - The lengths of `voteWeights`, `governors`, and `bridgeOperators` arrays must be equal.\n *\n * @param voteWeights An array of uint256 values representing the vote weights for each bridge operator.\n * @param governors An array of addresses representing the governors for each bridge operator.\n * @return addeds An array of boolean values indicating whether each bridge operator was successfully added.\n */\n function _addBridgeOperators(\n uint96[] memory voteWeights,\n address[] memory governors,\n address[] memory bridgeOperators\n ) internal nonDuplicate(governors.extend(bridgeOperators)) returns (bool[] memory addeds) {\n uint256 length = bridgeOperators.length;\n if (!(length == voteWeights.length && length == governors.length)) revert ErrLengthMismatch(msg.sig);\n addeds = new bool[](length);\n // simply skip add operations if inputs are empty.\n if (length == 0) return addeds;\n\n EnumerableSet.AddressSet storage _governorSet = _getGovernorsSet();\n mapping(address => address) storage _governorOf = _getGovernorOf();\n EnumerableSet.AddressSet storage _bridgeOperatorSet = _getBridgeOperatorSet();\n mapping(address => BridgeOperatorInfo) storage _governorToBridgeOperatorInfo = _getGovernorToBridgeOperatorInfo();\n\n address governor;\n address bridgeOperator;\n uint256 accumulatedWeight;\n BridgeOperatorInfo memory bridgeOperatorInfo;\n\n for (uint256 i; i < length; ) {\n governor = governors[i];\n bridgeOperator = bridgeOperators[i];\n\n _requireNonZeroAddress(governor);\n _requireNonZeroAddress(bridgeOperator);\n if (voteWeights[i] == 0) revert ErrInvalidVoteWeight(msg.sig);\n\n addeds[i] = !(_governorSet.contains(governor) ||\n _governorSet.contains(bridgeOperator) ||\n _bridgeOperatorSet.contains(governor) ||\n _bridgeOperatorSet.contains(bridgeOperator));\n\n if (addeds[i]) {\n _governorSet.add(governor);\n _bridgeOperatorSet.add(bridgeOperator);\n _governorOf[bridgeOperator] = governor;\n bridgeOperatorInfo.addr = bridgeOperator;\n accumulatedWeight += bridgeOperatorInfo.voteWeight = voteWeights[i];\n _governorToBridgeOperatorInfo[governor] = bridgeOperatorInfo;\n }\n\n unchecked {\n ++i;\n }\n }\n\n TOTAL_WEIGHTS_SLOT.addAssign(accumulatedWeight);\n\n _notifyRegisters(IBridgeManagerCallback.onBridgeOperatorsAdded.selector, abi.encode(bridgeOperators, addeds));\n\n emit BridgeOperatorsAdded(addeds, voteWeights, governors, bridgeOperators);\n }\n\n /**\n * @dev Internal function to remove bridge operators.\n *\n * This function removes the specified `bridgeOperators` from the bridge operator set and related mappings.\n *\n * Requirements:\n * - The caller must have the necessary permission to remove bridge operators.\n *\n * @param bridgeOperators An array of addresses representing the bridge operators to be removed.\n * @return removeds An array of boolean values indicating whether each bridge operator was successfully removed.\n */\n function _removeBridgeOperators(\n address[] memory bridgeOperators\n ) internal nonDuplicate(bridgeOperators) returns (bool[] memory removeds) {\n uint256 length = bridgeOperators.length;\n removeds = new bool[](length);\n // simply skip remove operations if inputs are empty.\n if (length == 0) return removeds;\n\n mapping(address => address) storage _governorOf = _getGovernorOf();\n EnumerableSet.AddressSet storage _governorSet = _getGovernorsSet();\n EnumerableSet.AddressSet storage _bridgeOperatorSet = _getBridgeOperatorSet();\n mapping(address => BridgeOperatorInfo) storage _governorToBridgeOperatorInfo = _getGovernorToBridgeOperatorInfo();\n\n address governor;\n address bridgeOperator;\n uint256 accumulatedWeight;\n BridgeOperatorInfo memory bridgeOperatorInfo;\n\n for (uint256 i; i < length; ) {\n bridgeOperator = bridgeOperators[i];\n governor = _governorOf[bridgeOperator];\n\n _requireNonZeroAddress(governor);\n _requireNonZeroAddress(bridgeOperator);\n\n bridgeOperatorInfo = _governorToBridgeOperatorInfo[governor];\n if (bridgeOperatorInfo.addr != bridgeOperator) revert ErrInvalidArguments(msg.sig);\n\n removeds[i] = _bridgeOperatorSet.contains(bridgeOperator) && _governorSet.contains(governor);\n if (removeds[i]) {\n _governorSet.remove(governor);\n _bridgeOperatorSet.remove(bridgeOperator);\n\n delete _governorOf[bridgeOperator];\n delete _governorToBridgeOperatorInfo[governor];\n accumulatedWeight += bridgeOperatorInfo.voteWeight;\n }\n\n unchecked {\n ++i;\n }\n }\n\n TOTAL_WEIGHTS_SLOT.subAssign(accumulatedWeight);\n\n _notifyRegisters(IBridgeManagerCallback.onBridgeOperatorsRemoved.selector, abi.encode(bridgeOperators, removeds));\n\n emit BridgeOperatorsRemoved(removeds, bridgeOperators);\n }\n\n /**\n * @dev Sets threshold and returns the old one.\n *\n * Emits the `ThresholdUpdated` event.\n *\n */\n function _setThreshold(\n uint256 numerator,\n uint256 denominator\n ) internal virtual returns (uint256 previousNum, uint256 previousDenom) {\n if (numerator > denominator) revert ErrInvalidThreshold(msg.sig);\n\n previousNum = NUMERATOR_SLOT.load();\n previousDenom = DENOMINATOR_SLOT.load();\n NUMERATOR_SLOT.store(numerator);\n DENOMINATOR_SLOT.store(denominator);\n\n emit ThresholdUpdated(NONCE_SLOT.postIncrement(), numerator, denominator, previousNum, previousDenom);\n }\n\n /**\n * @dev Internal function to get all bridge operators.\n * @return bridgeOperators An array containing all the registered bridge operator addresses.\n */\n function _getBridgeOperators() internal view returns (address[] memory) {\n return _getBridgeOperatorSet().values();\n }\n\n /**\n * @dev Internal function to get all governors.\n * @return governors An array containing all the registered governor addresses.\n */\n function _getGovernors() internal view returns (address[] memory) {\n return _getGovernorsSet().values();\n }\n\n /**\n * @dev Internal function to get the vote weights of a given array of governors.\n * @param governors An array containing the addresses of governors.\n * @return weights An array containing the vote weights of the corresponding governors.\n */\n function _getGovernorWeights(address[] memory governors) internal view returns (uint256[] memory weights) {\n uint256 length = governors.length;\n weights = new uint256[](length);\n mapping(address => BridgeOperatorInfo) storage _governorToBridgeOperatorInfo = _getGovernorToBridgeOperatorInfo();\n for (uint256 i; i < length; ) {\n weights[i] = _governorToBridgeOperatorInfo[governors[i]].voteWeight;\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @dev Internal function to calculate the sum of vote weights for a given array of governors.\n * @param governors An array containing the addresses of governors to calculate the sum of vote weights.\n * @return sum The total sum of vote weights for the provided governors.\n * @notice The input array `governors` must contain unique addresses to avoid duplicate calculations.\n */\n function _sumGovernorsWeight(address[] memory governors) internal view nonDuplicate(governors) returns (uint256 sum) {\n uint256 length = _getBridgeOperatorSet().length();\n mapping(address => BridgeOperatorInfo) storage _governorToBridgeOperatorInfo = _getGovernorToBridgeOperatorInfo();\n\n for (uint256 i; i < length; ) {\n sum += _governorToBridgeOperatorInfo[governors[i]].voteWeight;\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @dev Internal function to require that the caller has governor role access.\n * @param addr The address to check for governor role access.\n * @dev If the address does not have governor role access (vote weight is zero), a revert with the corresponding error message is triggered.\n */\n function _requireGovernor(address addr) internal view {\n if (_getGovernorWeight(addr) == 0) {\n revert ErrUnauthorized(msg.sig, RoleAccess.GOVERNOR);\n }\n }\n\n /**\n * @dev Internal function to retrieve the vote weight of a specific governor.\n * @param governor The address of the governor to get the vote weight for.\n * @return voteWeight The vote weight of the specified governor.\n */\n function _getGovernorWeight(address governor) internal view returns (uint256) {\n return _getGovernorToBridgeOperatorInfo()[governor].voteWeight;\n }\n\n /**\n * @dev Internal function to access the address set of bridge operators.\n * @return bridgeOperators the storage address set.\n */\n function _getBridgeOperatorSet() internal pure returns (EnumerableSet.AddressSet storage bridgeOperators) {\n assembly (\"memory-safe\") {\n bridgeOperators.slot := BRIDGE_OPERATOR_SET_SLOT\n }\n }\n\n /**\n * @dev Internal function to access the address set of bridge operators.\n * @return governors the storage address set.\n */\n function _getGovernorsSet() internal pure returns (EnumerableSet.AddressSet storage governors) {\n assembly (\"memory-safe\") {\n governors.slot := GOVERNOR_SET_SLOT\n }\n }\n\n /**\n * @dev Internal function to access the mapping from governor => BridgeOperatorInfo.\n * @return governorToBridgeOperatorInfo the mapping from governor => BridgeOperatorInfo.\n */\n function _getGovernorToBridgeOperatorInfo()\n internal\n pure\n returns (mapping(address => BridgeOperatorInfo) storage governorToBridgeOperatorInfo)\n {\n assembly (\"memory-safe\") {\n governorToBridgeOperatorInfo.slot := GOVERNOR_TO_BRIDGE_OPERATOR_INFO_SLOT\n }\n }\n\n /**\n * @dev Internal function to access the mapping from bridge operator => governor.\n * @return governorOf the mapping from bridge operator => governor.\n */\n function _getGovernorOf() internal pure returns (mapping(address => address) storage governorOf) {\n assembly (\"memory-safe\") {\n governorOf.slot := GOVENOR_OF_SLOT\n }\n }\n}\n" + }, + "contracts/extensions/bridge-operator-governance/BridgeManagerCallbackRegister.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { EnumerableSet } from \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport { IBridgeManagerCallbackRegister } from \"../../interfaces/bridge/IBridgeManagerCallbackRegister.sol\";\nimport { IBridgeManagerCallback } from \"../../interfaces/bridge/IBridgeManagerCallback.sol\";\nimport { IdentityGuard } from \"../../utils/IdentityGuard.sol\";\n\n/**\n * @title BridgeManagerCallbackRegister\n * @dev A contract that manages callback registrations and execution for a bridge.\n */\nabstract contract BridgeManagerCallbackRegister is IdentityGuard, IBridgeManagerCallbackRegister {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n /**\n * @dev Storage slot for the address set of callback registers.\n * @dev Value is equal to keccak256(\"@ronin.dpos.gateway.BridgeAdmin.callbackRegisters.slot\") - 1.\n */\n bytes32 private constant CALLBACK_REGISTERS_SLOT = 0x5da136eb38f8d8e354915fc8a767c0dc81d49de5fb65d5477122a82ddd976240;\n\n constructor(address[] memory callbackRegisters) payable {\n _registerCallbacks(callbackRegisters);\n }\n\n /**\n * @inheritdoc IBridgeManagerCallbackRegister\n */\n function registerCallbacks(address[] calldata registers) external onlySelfCall returns (bool[] memory registereds) {\n registereds = _registerCallbacks(registers);\n }\n\n /**\n * @inheritdoc IBridgeManagerCallbackRegister\n */\n function unregisterCallbacks(\n address[] calldata registers\n ) external onlySelfCall returns (bool[] memory unregistereds) {\n unregistereds = _unregisterCallbacks(registers);\n }\n\n /**\n * @inheritdoc IBridgeManagerCallbackRegister\n */\n function getCallbackRegisters() external view returns (address[] memory registers) {\n registers = _getCallbackRegisters().values();\n }\n\n /**\n * @dev Internal function to register multiple callbacks with the bridge.\n * @param registers The array of callback addresses to register.\n * @return registereds An array indicating the success status of each registration.\n */\n function _registerCallbacks(\n address[] memory registers\n ) internal nonDuplicate(registers) returns (bool[] memory registereds) {\n uint256 length = registers.length;\n registereds = new bool[](length);\n if (length == 0) return registereds;\n\n EnumerableSet.AddressSet storage _callbackRegisters = _getCallbackRegisters();\n address register;\n bytes4 callbackInterface = type(IBridgeManagerCallback).interfaceId;\n\n for (uint256 i; i < length; ) {\n register = registers[i];\n\n _requireHasCode(register);\n _requireSupportsInterface(register, callbackInterface);\n\n registereds[i] = _callbackRegisters.add(register);\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @dev Internal function to unregister multiple callbacks from the bridge.\n * @param registers The array of callback addresses to unregister.\n * @return unregistereds An array indicating the success status of each unregistration.\n */\n function _unregisterCallbacks(\n address[] memory registers\n ) internal nonDuplicate(registers) returns (bool[] memory unregistereds) {\n uint256 length = registers.length;\n unregistereds = new bool[](length);\n EnumerableSet.AddressSet storage _callbackRegisters = _getCallbackRegisters();\n\n for (uint256 i; i < length; ) {\n unregistereds[i] = _callbackRegisters.remove(registers[i]);\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @dev Internal function to notify all registered callbacks with the provided function signature and data.\n * @param callbackFnSig The function signature of the callback method.\n * @param inputs The data to pass to the callback method.\n */\n function _notifyRegisters(bytes4 callbackFnSig, bytes memory inputs) internal {\n address[] memory registers = _getCallbackRegisters().values();\n uint256 length = registers.length;\n if (length == 0) return;\n\n bool[] memory statuses = new bool[](length);\n bytes[] memory returnDatas = new bytes[](length);\n bytes memory callData = abi.encodePacked(callbackFnSig, inputs);\n\n for (uint256 i; i < length; ) {\n (statuses[i], returnDatas[i]) = registers[i].call(callData);\n\n unchecked {\n ++i;\n }\n }\n\n emit Notified(callData, registers, statuses, returnDatas);\n }\n\n /**\n * @dev Internal function to retrieve the address set of callback registers.\n * @return callbackRegisters The storage reference to the callback registers.\n */\n function _getCallbackRegisters() internal pure returns (EnumerableSet.AddressSet storage callbackRegisters) {\n assembly (\"memory-safe\") {\n callbackRegisters.slot := CALLBACK_REGISTERS_SLOT\n }\n }\n}\n" + }, + "contracts/extensions/collections/HasContracts.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { HasProxyAdmin } from \"./HasProxyAdmin.sol\";\nimport \"../../interfaces/collections/IHasContracts.sol\";\nimport { IdentityGuard } from \"../../utils/IdentityGuard.sol\";\nimport { ErrUnexpectedInternalCall } from \"../../utils/CommonErrors.sol\";\n\n/**\n * @title HasContracts\n * @dev A contract that provides functionality to manage multiple contracts with different roles.\n */\nabstract contract HasContracts is HasProxyAdmin, IHasContracts, IdentityGuard {\n /// @dev value is equal to keccak256(\"@ronin.dpos.collections.HasContracts.slot\") - 1\n bytes32 private constant _STORAGE_SLOT = 0xdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb;\n\n /**\n * @dev Modifier to restrict access to functions only to contracts with a specific role.\n * @param contractType The contract type that allowed to call\n */\n modifier onlyContract(ContractType contractType) virtual {\n _requireContract(contractType);\n _;\n }\n\n /**\n * @inheritdoc IHasContracts\n */\n function setContract(ContractType contractType, address addr) external virtual onlyAdmin {\n _requireHasCode(addr);\n _setContract(contractType, addr);\n }\n\n /**\n * @inheritdoc IHasContracts\n */\n function getContract(ContractType contractType) public view returns (address contract_) {\n contract_ = _getContractMap()[uint8(contractType)];\n if (contract_ == address(0)) revert ErrContractTypeNotFound(contractType);\n }\n\n /**\n * @dev Internal function to set the address of a contract with a specific role.\n * @param contractType The contract type of the contract to set.\n * @param addr The address of the contract to set.\n */\n function _setContract(ContractType contractType, address addr) internal virtual {\n _getContractMap()[uint8(contractType)] = addr;\n emit ContractUpdated(contractType, addr);\n }\n\n /**\n * @dev Internal function to access the mapping of contract addresses with roles.\n * @return contracts_ The mapping of contract addresses with roles.\n */\n function _getContractMap() private pure returns (mapping(uint8 => address) storage contracts_) {\n assembly {\n contracts_.slot := _STORAGE_SLOT\n }\n }\n\n /**\n * @dev Internal function to check if the calling contract has a specific role.\n * @param contractType The contract type that the calling contract must have.\n * @dev Throws an error if the calling contract does not have the specified role.\n */\n function _requireContract(ContractType contractType) private view {\n if (msg.sender != getContract(contractType)) {\n revert ErrUnexpectedInternalCall(msg.sig, contractType, msg.sender);\n }\n }\n}\n" + }, + "contracts/extensions/collections/HasProxyAdmin.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/StorageSlot.sol\";\nimport \"../../utils/CommonErrors.sol\";\n\nabstract contract HasProxyAdmin {\n // bytes32(uint256(keccak256(\"eip1967.proxy.admin\")) - 1));\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n modifier onlyAdmin() {\n _requireAdmin();\n _;\n }\n\n /**\n * @dev Returns proxy admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n function _requireAdmin() internal view {\n if (msg.sender != _getAdmin()) revert ErrUnauthorized(msg.sig, RoleAccess.ADMIN);\n }\n}\n" + }, + "contracts/extensions/consumers/GlobalConfigConsumer.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nabstract contract GlobalConfigConsumer {\n /// @dev The addition amount of gas sending along in external calls. Total gas stipend is added with default 2300 gas.\n uint256 public constant DEFAULT_ADDITION_GAS = 1200;\n /// @dev The length of a period in second.\n uint256 public constant PERIOD_DURATION = 1 days;\n}\n" + }, + "contracts/extensions/consumers/PercentageConsumer.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract PercentageConsumer {\n uint256 internal constant _MAX_PERCENTAGE = 100_00;\n}\n" + }, + "contracts/extensions/RONTransferHelper.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nabstract contract RONTransferHelper {\n /// @dev Error of sender has insufficient balance.\n error ErrInsufficientBalance(bytes4 msgSig, uint256 currentBalance, uint256 sendAmount);\n /// @dev Error of recipient not accepting RON when transfer RON.\n error ErrRecipientRevert(bytes4 msgSig);\n\n /**\n * @dev See `_sendRON`.\n * Reverts if the recipient does not receive RON.\n */\n function _transferRON(address payable recipient, uint256 amount) internal {\n if (!_sendRON(recipient, amount)) revert ErrRecipientRevert(msg.sig);\n }\n\n /**\n * @dev Send `amount` RON to the address `recipient`.\n * Returns whether the recipient receives RON or not.\n * Reverts once the contract balance is insufficient.\n *\n * Note: consider using `ReentrancyGuard` before calling this function.\n *\n */\n function _sendRON(address payable recipient, uint256 amount) internal returns (bool success) {\n if (address(this).balance < amount) revert ErrInsufficientBalance(msg.sig, address(this).balance, amount);\n return _unsafeSendRON(recipient, amount);\n }\n\n /**\n * @dev Unsafe send `amount` RON to the address `recipient`. If the sender's balance is insufficient,\n * the call does not revert.\n *\n * Note:\n * - Does not assert whether the balance of sender is sufficient.\n * - Does not assert whether the recipient accepts RON.\n * - Consider using `ReentrancyGuard` before calling this function.\n *\n */\n function _unsafeSendRON(address payable recipient, uint256 amount) internal returns (bool success) {\n (success, ) = recipient.call{ value: amount }(\"\");\n }\n\n /**\n * @dev Same purpose with {_unsafeSendRONLimitGas(address,uin256)} but containing gas limit stipend forwarded in the call.\n */\n function _unsafeSendRONLimitGas(\n address payable recipient,\n uint256 amount,\n uint256 gas\n ) internal returns (bool success) {\n (success, ) = recipient.call{ value: amount, gas: gas }(\"\");\n }\n}\n" + }, + "contracts/extensions/sequential-governance/CoreGovernance.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../../libraries/Proposal.sol\";\nimport \"../../libraries/GlobalProposal.sol\";\nimport \"../../utils/CommonErrors.sol\";\nimport \"../../libraries/Ballot.sol\";\nimport \"../../interfaces/consumers/ChainTypeConsumer.sol\";\nimport \"../../interfaces/consumers/SignatureConsumer.sol\";\nimport \"../../interfaces/consumers/VoteStatusConsumer.sol\";\n\nabstract contract CoreGovernance is SignatureConsumer, VoteStatusConsumer, ChainTypeConsumer {\n using Proposal for Proposal.ProposalDetail;\n\n /**\n * @dev Error thrown when attempting to interact with a finalized vote.\n */\n error ErrVoteIsFinalized();\n\n /**\n * @dev Error thrown when the current proposal is not completed.\n */\n error ErrCurrentProposalIsNotCompleted();\n\n struct ProposalVote {\n VoteStatus status;\n bytes32 hash;\n uint256 againstVoteWeight; // Total weight of against votes\n uint256 forVoteWeight; // Total weight of for votes\n address[] forVoteds; // Array of addresses voting for\n address[] againstVoteds; // Array of addresses voting against\n uint256 expiryTimestamp;\n mapping(address => Signature) sig;\n mapping(address => bool) voted;\n }\n\n /// @dev Emitted when a proposal is created\n event ProposalCreated(\n uint256 indexed chainId,\n uint256 indexed round,\n bytes32 indexed proposalHash,\n Proposal.ProposalDetail proposal,\n address creator\n );\n /// @dev Emitted when the proposal is voted\n event ProposalVoted(bytes32 indexed proposalHash, address indexed voter, Ballot.VoteType support, uint256 weight);\n /// @dev Emitted when the proposal is approved\n event ProposalApproved(bytes32 indexed proposalHash);\n /// @dev Emitted when the vote is reject\n event ProposalRejected(bytes32 indexed proposalHash);\n /// @dev Emitted when the vote is expired\n event ProposalExpired(bytes32 indexed proposalHash);\n /// @dev Emitted when the proposal is executed\n event ProposalExecuted(bytes32 indexed proposalHash, bool[] successCalls, bytes[] returnDatas);\n /// @dev Emitted when the proposal expiry duration is changed.\n event ProposalExpiryDurationChanged(uint256 indexed duration);\n\n /// @dev Mapping from chain id => vote round\n /// @notice chain id = 0 for global proposal\n mapping(uint256 => uint256) public round;\n /// @dev Mapping from chain id => vote round => proposal vote\n mapping(uint256 => mapping(uint256 => ProposalVote)) public vote;\n\n uint256 internal _proposalExpiryDuration;\n\n constructor(uint256 _expiryDuration) {\n _setProposalExpiryDuration(_expiryDuration);\n }\n\n /**\n * @dev Creates new voting round by calculating the `_round` number of chain `_chainId`.\n * Increases the `_round` number if the previous one is not expired. Delete the previous proposal\n * if it is expired and not increase the `_round`.\n */\n function _createVotingRound(uint256 _chainId) internal returns (uint256 _round) {\n _round = round[_chainId];\n // Skip checking for the first ever round\n if (_round == 0) {\n _round = round[_chainId] = 1;\n } else {\n ProposalVote storage _latestProposalVote = vote[_chainId][_round];\n bool _isExpired = _tryDeleteExpiredVotingRound(_latestProposalVote);\n // Skip increasing round number if the latest round is expired, allow the vote to be overridden\n if (!_isExpired) {\n if (_latestProposalVote.status == VoteStatus.Pending) revert ErrCurrentProposalIsNotCompleted();\n unchecked {\n _round = ++round[_chainId];\n }\n }\n }\n }\n\n /**\n * @dev Saves new round voting for the proposal `_proposalHash` of chain `_chainId`.\n */\n function _saveVotingRound(ProposalVote storage _vote, bytes32 _proposalHash, uint256 _expiryTimestamp) internal {\n _vote.hash = _proposalHash;\n _vote.expiryTimestamp = _expiryTimestamp;\n }\n\n /**\n * @dev Proposes for a new proposal.\n *\n * Requirements:\n * - The chain id is not equal to 0.\n *\n * Emits the `ProposalCreated` event.\n *\n */\n function _proposeProposal(\n uint256 chainId,\n uint256 expiryTimestamp,\n address[] memory targets,\n uint256[] memory values,\n bytes[] memory calldatas,\n uint256[] memory gasAmounts,\n address creator\n ) internal virtual returns (Proposal.ProposalDetail memory proposal) {\n if (chainId == 0) revert ErrInvalidChainId(msg.sig, 0, block.chainid);\n uint256 round_ = _createVotingRound(chainId);\n\n proposal = Proposal.ProposalDetail(round_, chainId, expiryTimestamp, targets, values, calldatas, gasAmounts);\n proposal.validate(_proposalExpiryDuration);\n\n bytes32 proposalHash = proposal.hash();\n _saveVotingRound(vote[chainId][round_], proposalHash, expiryTimestamp);\n emit ProposalCreated(chainId, round_, proposalHash, proposal, creator);\n }\n\n /**\n * @dev Proposes proposal struct.\n *\n * Requirements:\n * - The chain id is not equal to 0.\n * - The proposal nonce is equal to the new round.\n *\n * Emits the `ProposalCreated` event.\n *\n */\n function _proposeProposalStruct(\n Proposal.ProposalDetail memory proposal,\n address creator\n ) internal virtual returns (uint256 round_) {\n uint256 chainId = proposal.chainId;\n if (chainId == 0) revert ErrInvalidChainId(msg.sig, 0, block.chainid);\n proposal.validate(_proposalExpiryDuration);\n\n bytes32 proposalHash = proposal.hash();\n round_ = _createVotingRound(chainId);\n _saveVotingRound(vote[chainId][round_], proposalHash, proposal.expiryTimestamp);\n if (round_ != proposal.nonce) revert ErrInvalidProposalNonce(msg.sig);\n emit ProposalCreated(chainId, round_, proposalHash, proposal, creator);\n }\n\n /**\n * @dev Casts vote for the proposal with data and returns whether the voting is done.\n *\n * Requirements:\n * - The proposal nonce is equal to the round.\n * - The vote is not finalized.\n * - The voter has not voted for the round.\n *\n * Emits the `ProposalVoted` event. Emits the `ProposalApproved`, `ProposalExecuted` or `ProposalRejected` once the\n * proposal is approved, executed or rejected.\n *\n */\n function _castVote(\n Proposal.ProposalDetail memory proposal,\n Ballot.VoteType support,\n uint256 minimumForVoteWeight,\n uint256 minimumAgainstVoteWeight,\n address voter,\n Signature memory signature,\n uint256 voterWeight\n ) internal virtual returns (bool done) {\n uint256 chainId = proposal.chainId;\n uint256 round_ = proposal.nonce;\n ProposalVote storage _vote = vote[chainId][round_];\n\n if (_tryDeleteExpiredVotingRound(_vote)) {\n return true;\n }\n\n if (round[proposal.chainId] != round_) revert ErrInvalidProposalNonce(msg.sig);\n if (_vote.status != VoteStatus.Pending) revert ErrVoteIsFinalized();\n if (_voted(_vote, voter)) revert ErrAlreadyVoted(voter);\n\n _vote.voted[voter] = true;\n // Stores the signature if it is not empty\n if (signature.r > 0 || signature.s > 0 || signature.v > 0) {\n _vote.sig[voter] = signature;\n }\n emit ProposalVoted(_vote.hash, voter, support, voterWeight);\n\n uint256 _forVoteWeight;\n uint256 _againstVoteWeight;\n if (support == Ballot.VoteType.For) {\n _vote.forVoteds.push(voter);\n _forVoteWeight = _vote.forVoteWeight += voterWeight;\n } else if (support == Ballot.VoteType.Against) {\n _vote.againstVoteds.push(voter);\n _againstVoteWeight = _vote.againstVoteWeight += voterWeight;\n } else revert ErrUnsupportedVoteType(msg.sig);\n\n if (_forVoteWeight >= minimumForVoteWeight) {\n done = true;\n _vote.status = VoteStatus.Approved;\n emit ProposalApproved(_vote.hash);\n _tryExecute(_vote, proposal);\n } else if (_againstVoteWeight >= minimumAgainstVoteWeight) {\n done = true;\n _vote.status = VoteStatus.Rejected;\n emit ProposalRejected(_vote.hash);\n }\n }\n\n /**\n * @dev When the contract is on Ronin chain, checks whether the proposal is expired and delete it if is expired.\n *\n * Emits the event `ProposalExpired` if the vote is expired.\n *\n * Note: This function assumes the vote `_proposalVote` is already created, consider verifying the vote's existence\n * before or it will emit an unexpected event of `ProposalExpired`.\n */\n function _tryDeleteExpiredVotingRound(ProposalVote storage proposalVote) internal returns (bool isExpired) {\n isExpired =\n _getChainType() == ChainType.RoninChain &&\n proposalVote.status == VoteStatus.Pending &&\n proposalVote.expiryTimestamp <= block.timestamp;\n\n if (isExpired) {\n emit ProposalExpired(proposalVote.hash);\n\n for (uint256 _i; _i < proposalVote.forVoteds.length; ) {\n delete proposalVote.voted[proposalVote.forVoteds[_i]];\n delete proposalVote.sig[proposalVote.forVoteds[_i]];\n\n unchecked {\n ++_i;\n }\n }\n for (uint256 _i; _i < proposalVote.againstVoteds.length; ) {\n delete proposalVote.voted[proposalVote.againstVoteds[_i]];\n delete proposalVote.sig[proposalVote.againstVoteds[_i]];\n\n unchecked {\n ++_i;\n }\n }\n delete proposalVote.status;\n delete proposalVote.hash;\n delete proposalVote.againstVoteWeight;\n delete proposalVote.forVoteWeight;\n delete proposalVote.forVoteds;\n delete proposalVote.againstVoteds;\n delete proposalVote.expiryTimestamp;\n }\n }\n\n /**\n * @dev Executes the proposal and update the vote status once the proposal is executable.\n */\n function _tryExecute(ProposalVote storage vote_, Proposal.ProposalDetail memory proposal) internal {\n if (proposal.executable()) {\n vote_.status = VoteStatus.Executed;\n (bool[] memory _successCalls, bytes[] memory _returnDatas) = proposal.execute();\n emit ProposalExecuted(vote_.hash, _successCalls, _returnDatas);\n }\n }\n\n /**\n * @dev Sets the expiry duration for a new proposal.\n */\n function _setProposalExpiryDuration(uint256 expiryDuration) internal {\n _proposalExpiryDuration = expiryDuration;\n emit ProposalExpiryDurationChanged(expiryDuration);\n }\n\n /**\n * @dev Returns the expiry duration for a new proposal.\n */\n function _getProposalExpiryDuration() internal view returns (uint256) {\n return _proposalExpiryDuration;\n }\n\n /**\n * @dev Returns whether the voter casted for the proposal.\n */\n function _voted(ProposalVote storage vote_, address voter) internal view returns (bool) {\n return vote_.voted[voter];\n }\n\n /**\n * @dev Returns total weight from validators.\n */\n function _getTotalWeights() internal view virtual returns (uint256);\n\n /**\n * @dev Returns minimum vote to pass a proposal.\n */\n function _getMinimumVoteWeight() internal view virtual returns (uint256);\n\n /**\n * @dev Returns current context is running on whether Ronin chain or on mainchain.\n */\n function _getChainType() internal view virtual returns (ChainType);\n}\n" + }, + "contracts/extensions/sequential-governance/GlobalCoreGovernance.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../../libraries/Proposal.sol\";\nimport \"../../libraries/GlobalProposal.sol\";\nimport \"./CoreGovernance.sol\";\n\nabstract contract GlobalCoreGovernance is CoreGovernance {\n using Proposal for Proposal.ProposalDetail;\n using GlobalProposal for GlobalProposal.GlobalProposalDetail;\n\n mapping(GlobalProposal.TargetOption => address) internal _targetOptionsMap;\n\n /// @dev Emitted when a proposal is created\n event GlobalProposalCreated(\n uint256 indexed round,\n bytes32 indexed proposalHash,\n Proposal.ProposalDetail proposal,\n bytes32 globalProposalHash,\n GlobalProposal.GlobalProposalDetail globalProposal,\n address creator\n );\n\n /// @dev Emitted when the target options are updated\n event TargetOptionUpdated(GlobalProposal.TargetOption indexed targetOption, address indexed addr);\n\n constructor(GlobalProposal.TargetOption[] memory targetOptions, address[] memory addrs) {\n _updateTargetOption(GlobalProposal.TargetOption.BridgeManager, address(this));\n _updateManyTargetOption(targetOptions, addrs);\n }\n\n /**\n * @dev Proposes for a global proposal.\n *\n * Emits the `GlobalProposalCreated` event.\n *\n */\n function _proposeGlobal(\n uint256 expiryTimestamp,\n GlobalProposal.TargetOption[] calldata targetOptions,\n uint256[] memory values,\n bytes[] memory calldatas,\n uint256[] memory gasAmounts,\n address creator\n ) internal virtual {\n uint256 round_ = _createVotingRound(0);\n GlobalProposal.GlobalProposalDetail memory globalProposal = GlobalProposal.GlobalProposalDetail(\n round_,\n expiryTimestamp,\n targetOptions,\n values,\n calldatas,\n gasAmounts\n );\n Proposal.ProposalDetail memory proposal = globalProposal.intoProposalDetail(\n _resolveTargets({ targetOptions: targetOptions, strict: true })\n );\n proposal.validate(_proposalExpiryDuration);\n\n bytes32 proposalHash = proposal.hash();\n _saveVotingRound(vote[0][round_], proposalHash, expiryTimestamp);\n emit GlobalProposalCreated(round_, proposalHash, proposal, globalProposal.hash(), globalProposal, creator);\n }\n\n /**\n * @dev Proposes global proposal struct.\n *\n * Requirements:\n * - The proposal nonce is equal to the new round.\n *\n * Emits the `GlobalProposalCreated` event.\n *\n */\n function _proposeGlobalStruct(\n GlobalProposal.GlobalProposalDetail memory globalProposal,\n address creator\n ) internal virtual returns (Proposal.ProposalDetail memory proposal) {\n proposal = globalProposal.intoProposalDetail(\n _resolveTargets({ targetOptions: globalProposal.targetOptions, strict: true })\n );\n proposal.validate(_proposalExpiryDuration);\n\n bytes32 proposalHash = proposal.hash();\n uint256 round_ = _createVotingRound(0);\n _saveVotingRound(vote[0][round_], proposalHash, globalProposal.expiryTimestamp);\n\n if (round_ != proposal.nonce) revert ErrInvalidProposalNonce(msg.sig);\n emit GlobalProposalCreated(round_, proposalHash, proposal, globalProposal.hash(), globalProposal, creator);\n }\n\n /**\n * @dev Returns corresponding address of target options. Return address(0) on non-existent target.\n */\n function resolveTargets(\n GlobalProposal.TargetOption[] calldata targetOptions\n ) external view returns (address[] memory targets) {\n return _resolveTargets({ targetOptions: targetOptions, strict: false });\n }\n\n /**\n * @dev Internal helper of {resolveTargets}.\n *\n * @param strict When the param is set to `true`, revert on non-existent target.\n */\n function _resolveTargets(\n GlobalProposal.TargetOption[] memory targetOptions,\n bool strict\n ) internal view returns (address[] memory targets) {\n targets = new address[](targetOptions.length);\n\n for (uint256 i; i < targetOptions.length; ) {\n targets[i] = _targetOptionsMap[targetOptions[i]];\n if (strict && targets[i] == address(0)) revert ErrInvalidArguments(msg.sig);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @dev Updates list of `targetOptions` to `targets`.\n *\n * Requirement:\n * - Only allow self-call through proposal.\n * */\n function updateManyTargetOption(\n GlobalProposal.TargetOption[] memory targetOptions,\n address[] memory targets\n ) external {\n // HACK: Cannot reuse the existing library due to too deep stack\n if (msg.sender != address(this)) revert ErrOnlySelfCall(msg.sig);\n _updateManyTargetOption(targetOptions, targets);\n }\n\n /**\n * @dev Updates list of `targetOptions` to `targets`.\n */\n function _updateManyTargetOption(\n GlobalProposal.TargetOption[] memory targetOptions,\n address[] memory targets\n ) internal {\n for (uint256 i; i < targetOptions.length; ) {\n if (targets[i] == address(this)) revert ErrInvalidArguments(msg.sig);\n _updateTargetOption(targetOptions[i], targets[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @dev Updates `targetOption` to `target`.\n *\n * Requirement:\n * - Emit a `TargetOptionUpdated` event.\n */\n function _updateTargetOption(GlobalProposal.TargetOption targetOption, address target) internal {\n _targetOptionsMap[targetOption] = target;\n emit TargetOptionUpdated(targetOption, target);\n }\n}\n" + }, + "contracts/extensions/sequential-governance/governance-proposal/CommonGovernanceProposal.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../CoreGovernance.sol\";\n\nabstract contract CommonGovernanceProposal is CoreGovernance {\n using Proposal for Proposal.ProposalDetail;\n\n /**\n * @dev Error thrown when an invalid proposal is encountered.\n * @param actual The actual value of the proposal.\n * @param expected The expected value of the proposal.\n */\n error ErrInvalidProposal(bytes32 actual, bytes32 expected);\n\n /**\n * @dev Casts votes by signatures.\n *\n * Note: This method does not verify the proposal hash with the vote hash. Please consider checking it before.\n *\n */\n function _castVotesBySignatures(\n Proposal.ProposalDetail memory _proposal,\n Ballot.VoteType[] calldata _supports,\n Signature[] calldata _signatures,\n bytes32 _forDigest,\n bytes32 _againstDigest\n ) internal {\n if (!(_supports.length != 0 && _supports.length == _signatures.length)) revert ErrLengthMismatch(msg.sig);\n\n uint256 _minimumForVoteWeight = _getMinimumVoteWeight();\n uint256 _minimumAgainstVoteWeight = _getTotalWeights() - _minimumForVoteWeight + 1;\n\n address _lastSigner;\n address _signer;\n Signature calldata _sig;\n bool _hasValidVotes;\n for (uint256 _i; _i < _signatures.length; ) {\n _sig = _signatures[_i];\n\n if (_supports[_i] == Ballot.VoteType.For) {\n _signer = ECDSA.recover(_forDigest, _sig.v, _sig.r, _sig.s);\n } else if (_supports[_i] == Ballot.VoteType.Against) {\n _signer = ECDSA.recover(_againstDigest, _sig.v, _sig.r, _sig.s);\n } else revert ErrUnsupportedVoteType(msg.sig);\n\n if (_lastSigner >= _signer) revert ErrInvalidOrder(msg.sig);\n _lastSigner = _signer;\n\n uint256 _weight = _getWeight(_signer);\n if (_weight > 0) {\n _hasValidVotes = true;\n if (\n _castVote(_proposal, _supports[_i], _minimumForVoteWeight, _minimumAgainstVoteWeight, _signer, _sig, _weight)\n ) {\n return;\n }\n }\n\n unchecked {\n ++_i;\n }\n }\n\n if (!_hasValidVotes) revert ErrInvalidSignatures(msg.sig);\n }\n\n /**\n * @dev Returns the voted signatures for the proposals.\n *\n * Note: The signatures can be empty in case the proposal is voted on the current network.\n *\n */\n function _getProposalSignatures(\n uint256 _chainId,\n uint256 _round\n )\n internal\n view\n returns (address[] memory _voters, Ballot.VoteType[] memory _supports, Signature[] memory _signatures)\n {\n ProposalVote storage _vote = vote[_chainId][_round];\n\n uint256 _forLength = _vote.forVoteds.length;\n uint256 _againstLength = _vote.againstVoteds.length;\n uint256 _voterLength = _forLength + _againstLength;\n\n _supports = new Ballot.VoteType[](_voterLength);\n _signatures = new Signature[](_voterLength);\n _voters = new address[](_voterLength);\n for (uint256 _i; _i < _forLength; ) {\n _supports[_i] = Ballot.VoteType.For;\n _signatures[_i] = vote[_chainId][_round].sig[_vote.forVoteds[_i]];\n _voters[_i] = _vote.forVoteds[_i];\n\n unchecked {\n ++_i;\n }\n }\n for (uint256 _i; _i < _againstLength; ) {\n _supports[_i + _forLength] = Ballot.VoteType.Against;\n _signatures[_i + _forLength] = vote[_chainId][_round].sig[_vote.againstVoteds[_i]];\n _voters[_i + _forLength] = _vote.againstVoteds[_i];\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @dev Returns whether the voter `_voter` casted vote for the proposal.\n */\n function _proposalVoted(uint256 _chainId, uint256 _round, address _voter) internal view returns (bool) {\n return _voted(vote[_chainId][_round], _voter);\n }\n\n /**\n * @dev Returns the weight of a governor.\n */\n function _getWeight(address _governor) internal view virtual returns (uint256);\n}\n" + }, + "contracts/extensions/sequential-governance/governance-proposal/GlobalGovernanceProposal.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../../../libraries/Proposal.sol\";\nimport \"../GlobalCoreGovernance.sol\";\nimport \"./CommonGovernanceProposal.sol\";\n\nabstract contract GlobalGovernanceProposal is GlobalCoreGovernance, CommonGovernanceProposal {\n using Proposal for Proposal.ProposalDetail;\n using GlobalProposal for GlobalProposal.GlobalProposalDetail;\n\n /**\n * @dev Proposes and votes by signature.\n */\n function _proposeGlobalProposalStructAndCastVotes(\n GlobalProposal.GlobalProposalDetail calldata globalProposal,\n Ballot.VoteType[] calldata supports_,\n Signature[] calldata signatures,\n bytes32 domainSeparator,\n address creator\n ) internal returns (Proposal.ProposalDetail memory proposal) {\n proposal = _proposeGlobalStruct(globalProposal, creator);\n bytes32 _globalProposalHash = globalProposal.hash();\n _castVotesBySignatures(\n proposal,\n supports_,\n signatures,\n ECDSA.toTypedDataHash(domainSeparator, Ballot.hash(_globalProposalHash, Ballot.VoteType.For)),\n ECDSA.toTypedDataHash(domainSeparator, Ballot.hash(_globalProposalHash, Ballot.VoteType.Against))\n );\n }\n\n /**\n * @dev Proposes a global proposal struct and casts votes by signature.\n */\n function _castGlobalProposalBySignatures(\n GlobalProposal.GlobalProposalDetail calldata globalProposal,\n Ballot.VoteType[] calldata supports_,\n Signature[] calldata signatures,\n bytes32 domainSeparator\n ) internal {\n Proposal.ProposalDetail memory _proposal = globalProposal.intoProposalDetail(\n _resolveTargets({ targetOptions: globalProposal.targetOptions, strict: true })\n );\n\n bytes32 proposalHash = _proposal.hash();\n if (vote[0][_proposal.nonce].hash != proposalHash)\n revert ErrInvalidProposal(proposalHash, vote[0][_proposal.nonce].hash);\n\n bytes32 globalProposalHash = globalProposal.hash();\n _castVotesBySignatures(\n _proposal,\n supports_,\n signatures,\n ECDSA.toTypedDataHash(domainSeparator, Ballot.hash(globalProposalHash, Ballot.VoteType.For)),\n ECDSA.toTypedDataHash(domainSeparator, Ballot.hash(globalProposalHash, Ballot.VoteType.Against))\n );\n }\n\n /**\n * @dev See {CommonGovernanceProposal-_getProposalSignatures}\n */\n function getGlobalProposalSignatures(\n uint256 round_\n ) external view returns (address[] memory voters, Ballot.VoteType[] memory supports_, Signature[] memory signatures) {\n return _getProposalSignatures(0, round_);\n }\n\n /**\n * @dev See {CommonGovernanceProposal-_proposalVoted}\n */\n function globalProposalVoted(uint256 round_, address voter) external view returns (bool) {\n return _proposalVoted(0, round_, voter);\n }\n}\n" + }, + "contracts/extensions/sequential-governance/governance-proposal/GovernanceProposal.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../CoreGovernance.sol\";\nimport \"./CommonGovernanceProposal.sol\";\n\nabstract contract GovernanceProposal is CoreGovernance, CommonGovernanceProposal {\n using Proposal for Proposal.ProposalDetail;\n\n /**\n * @dev Proposes a proposal struct and casts votes by signature.\n */\n function _proposeProposalStructAndCastVotes(\n Proposal.ProposalDetail calldata _proposal,\n Ballot.VoteType[] calldata _supports,\n Signature[] calldata _signatures,\n bytes32 _domainSeparator,\n address _creator\n ) internal {\n _proposeProposalStruct(_proposal, _creator);\n bytes32 _proposalHash = _proposal.hash();\n _castVotesBySignatures(\n _proposal,\n _supports,\n _signatures,\n ECDSA.toTypedDataHash(_domainSeparator, Ballot.hash(_proposalHash, Ballot.VoteType.For)),\n ECDSA.toTypedDataHash(_domainSeparator, Ballot.hash(_proposalHash, Ballot.VoteType.Against))\n );\n }\n\n /**\n * @dev Proposes a proposal struct and casts votes by signature.\n */\n function _castProposalBySignatures(\n Proposal.ProposalDetail calldata _proposal,\n Ballot.VoteType[] calldata _supports,\n Signature[] calldata _signatures,\n bytes32 _domainSeparator\n ) internal {\n bytes32 _proposalHash = _proposal.hash();\n\n if (vote[_proposal.chainId][_proposal.nonce].hash != _proposalHash) {\n revert ErrInvalidProposal(_proposalHash, vote[_proposal.chainId][_proposal.nonce].hash);\n }\n\n _castVotesBySignatures(\n _proposal,\n _supports,\n _signatures,\n ECDSA.toTypedDataHash(_domainSeparator, Ballot.hash(_proposalHash, Ballot.VoteType.For)),\n ECDSA.toTypedDataHash(_domainSeparator, Ballot.hash(_proposalHash, Ballot.VoteType.Against))\n );\n }\n\n /**\n * @dev See `castProposalVoteForCurrentNetwork`.\n */\n function _castProposalVoteForCurrentNetwork(\n address _voter,\n Proposal.ProposalDetail memory _proposal,\n Ballot.VoteType _support\n ) internal {\n if (_proposal.chainId != block.chainid) revert ErrInvalidChainId(msg.sig, _proposal.chainId, block.chainid);\n\n bytes32 proposalHash = _proposal.hash();\n if (vote[_proposal.chainId][_proposal.nonce].hash != proposalHash)\n revert ErrInvalidProposal(proposalHash, vote[_proposal.chainId][_proposal.nonce].hash);\n\n uint256 _minimumForVoteWeight = _getMinimumVoteWeight();\n uint256 _minimumAgainstVoteWeight = _getTotalWeights() - _minimumForVoteWeight + 1;\n Signature memory _emptySignature;\n _castVote(\n _proposal,\n _support,\n _minimumForVoteWeight,\n _minimumAgainstVoteWeight,\n _voter,\n _emptySignature,\n _getWeight(_voter)\n );\n }\n\n /**\n * @dev See {CommonGovernanceProposal-_getProposalSignatures}\n */\n function getProposalSignatures(\n uint256 _chainId,\n uint256 _round\n )\n external\n view\n returns (address[] memory _voters, Ballot.VoteType[] memory _supports, Signature[] memory _signatures)\n {\n return _getProposalSignatures(_chainId, _round);\n }\n\n /**\n * @dev See {CommonGovernanceProposal-_proposalVoted}\n */\n function proposalVoted(uint256 _chainId, uint256 _round, address _voter) external view returns (bool) {\n return _proposalVoted(_chainId, _round, _voter);\n }\n}\n" + }, + "contracts/extensions/sequential-governance/governance-relay/CommonGovernanceRelay.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../CoreGovernance.sol\";\n\nabstract contract CommonGovernanceRelay is CoreGovernance {\n using Proposal for Proposal.ProposalDetail;\n using GlobalProposal for GlobalProposal.GlobalProposalDetail;\n\n /**\n * @dev Relays votes by signatures.\n *\n * @notice Does not store the voter signature into storage.\n *\n */\n function _relayVotesBySignatures(\n Proposal.ProposalDetail memory _proposal,\n Ballot.VoteType[] calldata _supports,\n Signature[] calldata _signatures,\n bytes32 _forDigest,\n bytes32 _againstDigest\n ) internal {\n if (!(_supports.length > 0 && _supports.length == _signatures.length)) revert ErrLengthMismatch(msg.sig);\n\n uint256 _forVoteCount;\n uint256 _againstVoteCount;\n address[] memory _forVoteSigners = new address[](_signatures.length);\n address[] memory _againstVoteSigners = new address[](_signatures.length);\n\n {\n address _signer;\n address _lastSigner;\n Ballot.VoteType _support;\n Signature calldata _sig;\n\n for (uint256 _i; _i < _signatures.length; ) {\n _sig = _signatures[_i];\n _support = _supports[_i];\n\n if (_support == Ballot.VoteType.For) {\n _signer = ECDSA.recover(_forDigest, _sig.v, _sig.r, _sig.s);\n _forVoteSigners[_forVoteCount++] = _signer;\n } else if (_support == Ballot.VoteType.Against) {\n _signer = ECDSA.recover(_againstDigest, _sig.v, _sig.r, _sig.s);\n _againstVoteSigners[_againstVoteCount++] = _signer;\n } else revert ErrUnsupportedVoteType(msg.sig);\n\n if (_lastSigner >= _signer) revert ErrInvalidOrder(msg.sig);\n _lastSigner = _signer;\n\n unchecked {\n ++_i;\n }\n }\n }\n\n assembly {\n mstore(_forVoteSigners, _forVoteCount)\n mstore(_againstVoteSigners, _againstVoteCount)\n }\n\n ProposalVote storage _vote = vote[_proposal.chainId][_proposal.nonce];\n uint256 _minimumForVoteWeight = _getMinimumVoteWeight();\n uint256 _totalForVoteWeight = _sumWeights(_forVoteSigners);\n if (_totalForVoteWeight >= _minimumForVoteWeight) {\n if (_totalForVoteWeight == 0) revert ErrInvalidVoteWeight(msg.sig);\n _vote.status = VoteStatus.Approved;\n emit ProposalApproved(_vote.hash);\n _tryExecute(_vote, _proposal);\n return;\n }\n\n uint256 _minimumAgainstVoteWeight = _getTotalWeights() - _minimumForVoteWeight + 1;\n uint256 _totalAgainstVoteWeight = _sumWeights(_againstVoteSigners);\n if (_totalAgainstVoteWeight >= _minimumAgainstVoteWeight) {\n if (_totalAgainstVoteWeight == 0) revert ErrInvalidVoteWeight(msg.sig);\n _vote.status = VoteStatus.Rejected;\n emit ProposalRejected(_vote.hash);\n return;\n }\n\n revert ErrRelayFailed(msg.sig);\n }\n\n /**\n * @dev Returns the weight of the governor list.\n */\n function _sumWeights(address[] memory _governors) internal view virtual returns (uint256);\n}\n" + }, + "contracts/extensions/sequential-governance/governance-relay/GlobalGovernanceRelay.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../GlobalCoreGovernance.sol\";\nimport \"./CommonGovernanceRelay.sol\";\n\nabstract contract GlobalGovernanceRelay is CommonGovernanceRelay, GlobalCoreGovernance {\n using GlobalProposal for GlobalProposal.GlobalProposalDetail;\n\n /**\n * @dev Returns whether the voter `_voter` casted vote for the proposal.\n */\n function globalProposalRelayed(uint256 _round) external view returns (bool) {\n return vote[0][_round].status != VoteStatus.Pending;\n }\n\n /**\n * @dev Relays voted global proposal.\n *\n * Requirements:\n * - The relay proposal is finalized.\n *\n */\n function _relayGlobalProposal(\n GlobalProposal.GlobalProposalDetail calldata globalProposal,\n Ballot.VoteType[] calldata supports_,\n Signature[] calldata signatures,\n bytes32 domainSeparator,\n address creator\n ) internal {\n Proposal.ProposalDetail memory _proposal = _proposeGlobalStruct(globalProposal, creator);\n bytes32 globalProposalHash = globalProposal.hash();\n _relayVotesBySignatures(\n _proposal,\n supports_,\n signatures,\n ECDSA.toTypedDataHash(domainSeparator, Ballot.hash(globalProposalHash, Ballot.VoteType.For)),\n ECDSA.toTypedDataHash(domainSeparator, Ballot.hash(globalProposalHash, Ballot.VoteType.Against))\n );\n }\n}\n" + }, + "contracts/extensions/sequential-governance/governance-relay/GovernanceRelay.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../CoreGovernance.sol\";\nimport \"./CommonGovernanceRelay.sol\";\n\nabstract contract GovernanceRelay is CoreGovernance, CommonGovernanceRelay {\n using Proposal for Proposal.ProposalDetail;\n using GlobalProposal for GlobalProposal.GlobalProposalDetail;\n\n /**\n * @dev Relays voted proposal.\n *\n * Requirements:\n * - The relay proposal is finalized.\n *\n */\n function _relayProposal(\n Proposal.ProposalDetail calldata _proposal,\n Ballot.VoteType[] calldata _supports,\n Signature[] calldata _signatures,\n bytes32 _domainSeparator,\n address _creator\n ) internal {\n _proposeProposalStruct(_proposal, _creator);\n bytes32 _proposalHash = _proposal.hash();\n _relayVotesBySignatures(\n _proposal,\n _supports,\n _signatures,\n ECDSA.toTypedDataHash(_domainSeparator, Ballot.hash(_proposalHash, Ballot.VoteType.For)),\n ECDSA.toTypedDataHash(_domainSeparator, Ballot.hash(_proposalHash, Ballot.VoteType.Against))\n );\n }\n}\n" + }, + "contracts/extensions/TransparentUpgradeableProxyV2.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\ncontract TransparentUpgradeableProxyV2 is TransparentUpgradeableProxy {\n constructor(\n address _logic,\n address admin_,\n bytes memory _data\n ) payable TransparentUpgradeableProxy(_logic, admin_, _data) {}\n\n /**\n * @dev Calls a function from the current implementation as specified by `_data`, which should be an encoded function call.\n *\n * Requirements:\n * - Only the admin can call this function.\n *\n * Note: The proxy admin is not allowed to interact with the proxy logic through the fallback function to avoid\n * triggering some unexpected logic. This is to allow the administrator to explicitly call the proxy, please consider\n * reviewing the encoded data `_data` and the method which is called before using this.\n *\n */\n function functionDelegateCall(bytes memory _data) public payable ifAdmin {\n address _addr = _implementation();\n assembly {\n let _result := delegatecall(gas(), _addr, add(_data, 32), mload(_data), 0, 0)\n returndatacopy(0, 0, returndatasize())\n switch _result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n}\n" + }, + "contracts/interfaces/bridge/events/IBridgeManagerEvents.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IBridgeManagerEvents {\n /**\n * @dev The structure representing information about a bridge operator.\n * @param addr The address of the bridge operator.\n * @param voteWeight The vote weight assigned to the bridge operator.\n */\n struct BridgeOperatorInfo {\n address addr;\n uint96 voteWeight;\n }\n\n /**\n * @dev Emitted when new bridge operators are added.\n * @param statuses The array of boolean values represents whether the corresponding bridge operator is added successfully.\n * @param voteWeights The array of vote weights assigned to the added bridge operators.\n * @param governors The array of addresses representing the governors associated with the added bridge operators.\n * @param bridgeOperators The array of addresses representing the added bridge operators.\n */\n event BridgeOperatorsAdded(bool[] statuses, uint96[] voteWeights, address[] governors, address[] bridgeOperators);\n\n /**\n * @dev Emitted when bridge operators are removed.\n * @param statuses The array of boolean values representing the statuses of the removed bridge operators.\n * @param bridgeOperators The array of addresses representing the removed bridge operators.\n */\n event BridgeOperatorsRemoved(bool[] statuses, address[] bridgeOperators);\n\n /**\n * @dev Emitted when a bridge operator is updated.\n * @param governor The address of the governor initiating the update.\n * @param fromBridgeOperator The address of the bridge operator being updated.\n * @param toBridgeOperator The updated address of the bridge operator.\n */\n event BridgeOperatorUpdated(\n address indexed governor,\n address indexed fromBridgeOperator,\n address indexed toBridgeOperator\n );\n}\n" + }, + "contracts/interfaces/bridge/IBridgeManager.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { IBridgeManagerEvents } from \"./events/IBridgeManagerEvents.sol\";\n\n/**\n * @title IBridgeManager\n * @dev The interface for managing bridge operators.\n */\ninterface IBridgeManager is IBridgeManagerEvents {\n /**\n * @dev The domain separator used for computing hash digests in the contract.\n */\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n /**\n * @dev Returns the total number of bridge operators.\n * @return The total number of bridge operators.\n */\n function totalBridgeOperators() external view returns (uint256);\n\n /**\n * @dev Checks if the given address is a bridge operator.\n * @param addr The address to check.\n * @return A boolean indicating whether the address is a bridge operator.\n */\n function isBridgeOperator(address addr) external view returns (bool);\n\n /**\n * @dev Retrieves the full information of all registered bridge operators.\n *\n * This external function allows external callers to obtain the full information of all the registered bridge operators.\n * The returned arrays include the addresses of governors, bridge operators, and their corresponding vote weights.\n *\n * @return governors An array of addresses representing the governors of each bridge operator.\n * @return bridgeOperators An array of addresses representing the registered bridge operators.\n * @return weights An array of uint256 values representing the vote weights of each bridge operator.\n *\n * Note: The length of each array will be the same, and the order of elements corresponds to the same bridge operator.\n *\n * Example Usage:\n * ```\n * (address[] memory governors, address[] memory bridgeOperators, uint256[] memory weights) = getFullBridgeOperatorInfos();\n * for (uint256 i = 0; i < bridgeOperators.length; i++) {\n * // Access individual information for each bridge operator.\n * address governor = governors[i];\n * address bridgeOperator = bridgeOperators[i];\n * uint256 weight = weights[i];\n * // ... (Process or use the information as required) ...\n * }\n * ```\n *\n */\n function getFullBridgeOperatorInfos()\n external\n view\n returns (address[] memory governors, address[] memory bridgeOperators, uint256[] memory weights);\n\n /**\n * @dev Returns total weights of the governor list.\n */\n function sumGovernorsWeight(address[] calldata governors) external view returns (uint256 sum);\n\n /**\n * @dev Returns total weights.\n */\n function getTotalWeights() external view returns (uint256);\n\n /**\n * @dev Returns an array of all bridge operators.\n * @return An array containing the addresses of all bridge operators.\n */\n function getBridgeOperators() external view returns (address[] memory);\n\n /**\n * @dev Returns an array of bridge operators correspoding to governor addresses.\n * @return bridgeOperators_ An array containing the addresses of all bridge operators.\n */\n function getBridgeOperatorOf(address[] calldata gorvernors) external view returns (address[] memory bridgeOperators_);\n\n /**\n * @dev Retrieves the governors corresponding to a given array of bridge operators.\n * This external function allows external callers to obtain the governors associated with a given array of bridge operators.\n * The function takes an input array `bridgeOperators` containing bridge operator addresses and returns an array of corresponding governors.\n * @param bridgeOperators An array of bridge operator addresses for which governors are to be retrieved.\n * @return governors An array of addresses representing the governors corresponding to the provided bridge operators.\n */\n function getGovernorsOf(address[] calldata bridgeOperators) external view returns (address[] memory governors);\n\n /**\n * @dev External function to retrieve the vote weight of a specific governor.\n * @param governor The address of the governor to get the vote weight for.\n * @return voteWeight The vote weight of the specified governor.\n */\n function getGovernorWeight(address governor) external view returns (uint256);\n\n /**\n * @dev External function to retrieve the vote weight of a specific bridge operator.\n * @param bridgeOperator The address of the bridge operator to get the vote weight for.\n * @return weight The vote weight of the specified bridge operator.\n */\n function getBridgeOperatorWeight(address bridgeOperator) external view returns (uint256 weight);\n\n /**\n * @dev Returns the weights of a list of governor addresses.\n */\n function getGovernorWeights(address[] calldata governors) external view returns (uint256[] memory weights);\n\n /**\n * @dev Returns an array of all governors.\n * @return An array containing the addresses of all governors.\n */\n function getGovernors() external view returns (address[] memory);\n\n /**\n * @dev Adds multiple bridge operators.\n * @param governors An array of addresses of hot/cold wallets for bridge operator to update their node address.\n * @param bridgeOperators An array of addresses representing the bridge operators to add.\n * @return addeds An array of booleans indicating whether each bridge operator was added successfully.\n *\n * Note: return boolean array `addeds` indicates whether a group (voteWeight, governor, operator) are recorded.\n * It is expected that FE/BE staticcall to the function first to get the return values and handle it correctly.\n * Governors are expected to see the outcome of this function and decide if they want to vote for the proposal or not.\n *\n * Example Usage:\n * Making an `eth_call` in ethers.js\n * ```\n * const {addeds} = await bridgeManagerContract.callStatic.addBridgeOperators(\n * voteWeights,\n * governors,\n * bridgeOperators,\n * // overriding the caller to the contract itself since we use `onlySelfCall` guard\n * {from: bridgeManagerContract.address}\n * )\n * const filteredOperators = bridgeOperators.filter((_, index) => addeds[index]);\n * const filteredWeights = weights.filter((_, index) => addeds[index]);\n * const filteredGovernors = governors.filter((_, index) => addeds[index]);\n * // ... (Process or use the information as required) ...\n * ```\n */\n function addBridgeOperators(\n uint96[] calldata voteWeights,\n address[] calldata governors,\n address[] calldata bridgeOperators\n ) external returns (bool[] memory addeds);\n\n /**\n * @dev Removes multiple bridge operators.\n * @param bridgeOperators An array of addresses representing the bridge operators to remove.\n * @return removeds An array of booleans indicating whether each bridge operator was removed successfully.\n *\n * * Note: return boolean array `removeds` indicates whether a group (voteWeight, governor, operator) are recorded.\n * It is expected that FE/BE staticcall to the function first to get the return values and handle it correctly.\n * Governors are expected to see the outcome of this function and decide if they want to vote for the proposal or not.\n *\n * Example Usage:\n * Making an `eth_call` in ethers.js\n * ```\n * const {removeds} = await bridgeManagerContract.callStatic.removeBridgeOperators(\n * bridgeOperators,\n * // overriding the caller to the contract itself since we use `onlySelfCall` guard\n * {from: bridgeManagerContract.address}\n * )\n * const filteredOperators = bridgeOperators.filter((_, index) => removeds[index]);\n * // ... (Process or use the information as required) ...\n * ```\n */\n function removeBridgeOperators(address[] calldata bridgeOperators) external returns (bool[] memory removeds);\n\n /**\n * @dev Governor updates their corresponding governor and/or operator address.\n * Requirements:\n * - The caller must the governor of the operator that is requested changes.\n * @param bridgeOperator The address of the bridge operator to update.\n */\n function updateBridgeOperator(address bridgeOperator) external;\n}\n" + }, + "contracts/interfaces/bridge/IBridgeManagerCallback.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { IERC165 } from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\n\n/**\n * @title IBridgeManagerCallback\n * @dev Interface for the callback functions to be implemented by the Bridge Manager contract.\n */\ninterface IBridgeManagerCallback is IERC165 {\n /**\n * @dev Handles the event when bridge operators are added.\n * @param bridgeOperators The addresses of the bridge operators.\n * @param addeds The corresponding boolean values indicating whether the operators were added or not.\n * @return selector The selector of the function being called.\n */\n function onBridgeOperatorsAdded(\n address[] memory bridgeOperators,\n bool[] memory addeds\n ) external returns (bytes4 selector);\n\n /**\n * @dev Handles the event when bridge operators are removed.\n * @param bridgeOperators The addresses of the bridge operators.\n * @param removeds The corresponding boolean values indicating whether the operators were removed or not.\n * @return selector The selector of the function being called.\n */\n function onBridgeOperatorsRemoved(\n address[] memory bridgeOperators,\n bool[] memory removeds\n ) external returns (bytes4 selector);\n\n /**\n * @dev Handles the event when a bridge operator is updated.\n * @param currentBridgeOperator The address of the current bridge operator.\n * @param newbridgeOperator The new address of the bridge operator.\n * @return selector The selector of the function being called.\n */\n function onBridgeOperatorUpdated(\n address currentBridgeOperator,\n address newbridgeOperator\n ) external returns (bytes4 selector);\n}\n" + }, + "contracts/interfaces/bridge/IBridgeManagerCallbackRegister.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IBridgeManagerCallbackRegister {\n /**\n * @dev Emitted when the contract notifies multiple registers with statuses and return data.\n */\n event Notified(bytes callData, address[] registers, bool[] statuses, bytes[] returnDatas);\n\n /**\n * @dev Retrieves the addresses of registered callbacks.\n * @return registers An array containing the addresses of registered callbacks.\n */\n function getCallbackRegisters() external view returns (address[] memory registers);\n\n /**\n * @dev Registers multiple callbacks with the bridge.\n * @param registers The array of callback addresses to register.\n * @return registereds An array indicating the success status of each registration.\n */\n function registerCallbacks(address[] calldata registers) external returns (bool[] memory registereds);\n\n /**\n * @dev Unregisters multiple callbacks from the bridge.\n * @param registers The array of callback addresses to unregister.\n * @return unregistereds An array indicating the success status of each unregistration.\n */\n function unregisterCallbacks(address[] calldata registers) external returns (bool[] memory unregistereds);\n}\n" + }, + "contracts/interfaces/collections/IHasContracts.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport { ContractType } from \"../../utils/ContractType.sol\";\n\ninterface IHasContracts {\n /// @dev Error of invalid role.\n error ErrContractTypeNotFound(ContractType contractType);\n\n /// @dev Emitted when a contract is updated.\n event ContractUpdated(ContractType indexed contractType, address indexed addr);\n\n /**\n * @dev Returns the address of a contract with a specific role.\n * Throws an error if no contract is set for the specified role.\n *\n * @param contractType The role of the contract to retrieve.\n * @return contract_ The address of the contract with the specified role.\n */\n function getContract(ContractType contractType) external view returns (address contract_);\n\n /**\n * @dev Sets the address of a contract with a specific role.\n * Emits the event {ContractUpdated}.\n * @param contractType The role of the contract to set.\n * @param addr The address of the contract to set.\n */\n function setContract(ContractType contractType, address addr) external;\n}\n" + }, + "contracts/interfaces/consumers/ChainTypeConsumer.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface ChainTypeConsumer {\n enum ChainType {\n RoninChain,\n Mainchain\n }\n}\n" + }, + "contracts/interfaces/consumers/PeriodWrapperConsumer.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface PeriodWrapperConsumer {\n struct PeriodWrapper {\n // Inner value.\n uint256 inner;\n // Last period number that the info updated.\n uint256 lastPeriod;\n }\n}\n" + }, + "contracts/interfaces/consumers/SignatureConsumer.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface SignatureConsumer {\n struct Signature {\n uint8 v;\n bytes32 r;\n bytes32 s;\n }\n}\n" + }, + "contracts/interfaces/consumers/VoteStatusConsumer.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface VoteStatusConsumer {\n enum VoteStatus {\n Pending,\n Approved,\n Executed,\n Rejected,\n Expired\n }\n}\n" + }, + "contracts/interfaces/IQuorum.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IQuorum {\n /// @dev Emitted when the threshold is updated\n event ThresholdUpdated(\n uint256 indexed nonce,\n uint256 indexed numerator,\n uint256 indexed denominator,\n uint256 previousNumerator,\n uint256 previousDenominator\n );\n\n /**\n * @dev Returns the threshold.\n */\n function getThreshold() external view returns (uint256 _num, uint256 _denom);\n\n /**\n * @dev Checks whether the `_voteWeight` passes the threshold.\n */\n function checkThreshold(uint256 _voteWeight) external view returns (bool);\n\n /**\n * @dev Returns the minimum vote weight to pass the threshold.\n */\n function minimumVoteWeight() external view returns (uint256);\n\n /**\n * @dev Sets the threshold.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `ThresholdUpdated` event.\n *\n */\n function setThreshold(\n uint256 _numerator,\n uint256 _denominator\n ) external returns (uint256 _previousNum, uint256 _previousDenom);\n}\n" + }, + "contracts/interfaces/staking/IBaseStaking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface IBaseStaking {\n struct PoolDetail {\n // Address of the pool i.e. consensus address of the validator\n address addr;\n // Pool admin address\n address admin;\n // Self-staking amount\n uint256 stakingAmount;\n // Total number of RON staking for the pool\n uint256 stakingTotal;\n // Mapping from delegator => delegating amount\n mapping(address => uint256) delegatingAmount;\n // Mapping from delegator => the last timestamp that delegator staked\n mapping(address => uint256) lastDelegatingTimestamp;\n }\n\n /// @dev Emitted when the minium number of seconds to undelegate is updated.\n event CooldownSecsToUndelegateUpdated(uint256 minSecs);\n /// @dev Emitted when the number of seconds that a candidate must wait to be revoked.\n event WaitingSecsToRevokeUpdated(uint256 secs);\n\n /// @dev Error of cannot transfer RON.\n error ErrCannotTransferRON();\n /// @dev Error of receiving zero message value.\n error ErrZeroValue();\n /// @dev Error of pool admin is not allowed to call.\n error ErrPoolAdminForbidden();\n /// @dev Error of no one is allowed to call but the pool's admin.\n error ErrOnlyPoolAdminAllowed();\n /// @dev Error of admin of any active pool cannot delegate.\n error ErrAdminOfAnyActivePoolForbidden(address admin);\n /// @dev Error of querying inactive pool.\n error ErrInactivePool(address poolAddr);\n /// @dev Error of length of input arrays are not of the same.\n error ErrInvalidArrays();\n\n /**\n * @dev Returns whether the `_poolAdminAddr` is currently active.\n */\n function isAdminOfActivePool(address _poolAdminAddr) external view returns (bool);\n\n /**\n * @dev Returns the consensus address corresponding to the pool admin.\n */\n function getPoolAddressOf(address _poolAdminAddr) external view returns (address);\n\n /**\n * @dev Returns the staking pool detail.\n */\n function getPoolDetail(address) external view returns (address _admin, uint256 _stakingAmount, uint256 _stakingTotal);\n\n /**\n * @dev Returns the self-staking amounts of the pools.\n */\n function getManySelfStakings(address[] calldata) external view returns (uint256[] memory);\n\n /**\n * @dev Returns The cooldown time in seconds to undelegate from the last timestamp (s)he delegated.\n */\n function cooldownSecsToUndelegate() external view returns (uint256);\n\n /**\n * @dev Returns the number of seconds that a candidate must wait for the renounce request gets affected.\n */\n function waitingSecsToRevoke() external view returns (uint256);\n\n /**\n * @dev Sets the cooldown time in seconds to undelegate from the last timestamp (s)he delegated.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `CooldownSecsToUndelegateUpdated`.\n *\n */\n function setCooldownSecsToUndelegate(uint256 _cooldownSecs) external;\n\n /**\n * @dev Sets the number of seconds that a candidate must wait to be revoked.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `WaitingSecsToRevokeUpdated`.\n *\n */\n function setWaitingSecsToRevoke(uint256 _secs) external;\n}\n" + }, + "contracts/interfaces/staking/ICandidateStaking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IRewardPool.sol\";\n\ninterface ICandidateStaking is IRewardPool {\n /// @dev Emitted when the minimum staking amount for being a validator is updated.\n event MinValidatorStakingAmountUpdated(uint256 threshold);\n /// @dev Emitted when the commission rate range is updated.\n event CommissionRateRangeUpdated(uint256 minRate, uint256 maxRate);\n\n /// @dev Emitted when the pool admin staked for themself.\n event Staked(address indexed consensuAddr, uint256 amount);\n /// @dev Emitted when the pool admin unstaked the amount of RON from themself.\n event Unstaked(address indexed consensuAddr, uint256 amount);\n\n /// @dev Emitted when the validator pool is approved.\n event PoolApproved(address indexed validator, address indexed admin);\n /// @dev Emitted when the validator pool is deprecated.\n event PoolsDeprecated(address[] validator);\n /// @dev Emitted when the staking amount transfer failed.\n event StakingAmountTransferFailed(\n address indexed validator,\n address indexed admin,\n uint256 amount,\n uint256 contractBalance\n );\n /// @dev Emitted when the staking amount deducted failed, e.g. when the validator gets slashed.\n event StakingAmountDeductFailed(\n address indexed validator,\n address indexed recipient,\n uint256 amount,\n uint256 contractBalance\n );\n\n /// @dev Error of cannot transfer RON to specified target.\n error ErrCannotInitTransferRON(address addr, string extraInfo);\n /// @dev Error of three interaction addresses must be of the same in applying for validator candidate.\n error ErrThreeInteractionAddrsNotEqual();\n /// @dev Error of unstaking zero amount.\n error ErrUnstakeZeroAmount();\n /// @dev Error of invalid staking amount left after deducted.\n error ErrStakingAmountLeft();\n /// @dev Error of insufficient staking amount for unstaking.\n error ErrInsufficientStakingAmount();\n /// @dev Error of unstaking too early.\n error ErrUnstakeTooEarly();\n /// @dev Error of setting commission rate exceeds max allowed.\n error ErrInvalidCommissionRate();\n\n /**\n * @dev Returns the minimum threshold for being a validator candidate.\n */\n function minValidatorStakingAmount() external view returns (uint256);\n\n /**\n * @dev Returns the commission rate range that the candidate can set.\n */\n function getCommissionRateRange() external view returns (uint256 _minRange, uint256 _maxRange);\n\n /**\n * @dev Sets the minimum threshold for being a validator candidate.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `MinValidatorStakingAmountUpdated` event.\n *\n */\n function setMinValidatorStakingAmount(uint256) external;\n\n /**\n * @dev Sets the commission rate range that a candidate can set.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `CommissionRateRangeUpdated` event.\n *\n */\n function setCommissionRateRange(uint256 _minRate, uint256 _maxRate) external;\n\n /**\n * @dev Proposes a candidate to become a validator.\n *\n * Requirements:\n * - The method caller is able to receive RON.\n * - The treasury is able to receive RON.\n * - The amount is larger than or equal to the minimum validator staking amount `minValidatorStakingAmount()`.\n *\n * Emits the event `PoolApproved`.\n *\n * @param _candidateAdmin the candidate admin will be stored in the validator contract, used for calling function that affects\n * to its candidate, e.g. scheduling maintenance.\n *\n */\n function applyValidatorCandidate(\n address _candidateAdmin,\n address _consensusAddr,\n address payable _treasuryAddr,\n uint256 _commissionRate\n ) external payable;\n\n /**\n * @dev Deprecates the pool.\n * - Deduct self-staking amount of the pool admin to zero.\n * - Transfer the deducted amount to the pool admin.\n * - Deactivate the pool admin address in the mapping of active pool admins\n *\n * Requirements:\n * - The method caller is validator contract.\n *\n * Emits the event `PoolsDeprecated` and `Unstaked` events.\n * Emits the event `StakingAmountTransferFailed` if the contract cannot transfer RON back to the pool admin.\n *\n */\n function execDeprecatePools(address[] calldata _pools, uint256 _period) external;\n\n /**\n * @dev Self-delegates to the validator candidate `_consensusAddr`.\n *\n * Requirements:\n * - The consensus address is a validator candidate.\n * - The method caller is the pool admin.\n * - The `msg.value` is larger than 0.\n *\n * Emits the event `Staked`.\n *\n */\n function stake(address _consensusAddr) external payable;\n\n /**\n * @dev Unstakes from the validator candidate `_consensusAddr` for `_amount`.\n *\n * Requirements:\n * - The consensus address is a validator candidate.\n * - The method caller is the pool admin.\n *\n * Emits the event `Unstaked`.\n *\n */\n function unstake(address _consensusAddr, uint256 _amount) external;\n\n /**\n * @dev Pool admin requests update validator commission rate. The request will be forwarded to the candidate manager\n * contract, and the value is getting updated in {ICandidateManager-execRequestUpdateCommissionRate}.\n *\n * Requirements:\n * - The consensus address is a validator candidate.\n * - The method caller is the pool admin.\n * - The `_effectiveDaysOnwards` must be equal to or larger than the {CandidateManager-_minEffectiveDaysOnwards}.\n * - The `_rate` must be in range of [0_00; 100_00].\n *\n * Emits the event `CommissionRateUpdated`.\n *\n */\n function requestUpdateCommissionRate(\n address _consensusAddr,\n uint256 _effectiveDaysOnwards,\n uint256 _commissionRate\n ) external;\n\n /**\n * @dev Renounces being a validator candidate and takes back the delegating/staking amount.\n *\n * Requirements:\n * - The consensus address is a validator candidate.\n * - The method caller is the pool admin.\n *\n */\n function requestRenounce(address _consensusAddr) external;\n\n /**\n * @dev Renounces being a validator candidate and takes back the delegating/staking amount.\n *\n * Requirements:\n * - The consensus address is a validator candidate.\n * - The method caller is the pool admin.\n *\n */\n function requestEmergencyExit(address _consensusAddr) external;\n}\n" + }, + "contracts/interfaces/staking/IDelegatorStaking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IRewardPool.sol\";\n\ninterface IDelegatorStaking is IRewardPool {\n /// @dev Emitted when the delegator staked for a validator candidate.\n event Delegated(address indexed delegator, address indexed consensuAddr, uint256 amount);\n /// @dev Emitted when the delegator unstaked from a validator candidate.\n event Undelegated(address indexed delegator, address indexed consensuAddr, uint256 amount);\n\n /// @dev Error of undelegating zero amount.\n error ErrUndelegateZeroAmount();\n /// @dev Error of undelegating insufficient amount.\n error ErrInsufficientDelegatingAmount();\n /// @dev Error of undelegating too early.\n error ErrUndelegateTooEarly();\n\n /**\n * @dev Stakes for a validator candidate `_consensusAddr`.\n *\n * Requirements:\n * - The consensus address is a validator candidate.\n * - The method caller is not the pool admin.\n *\n * Emits the `Delegated` event.\n *\n */\n function delegate(address _consensusAddr) external payable;\n\n /**\n * @dev Unstakes from a validator candidate `_consensusAddr` for `_amount`.\n *\n * Requirements:\n * - The method caller is not the pool admin.\n *\n * Emits the `Undelegated` event.\n *\n */\n function undelegate(address _consensusAddr, uint256 _amount) external;\n\n /**\n * @dev Bulk unstakes from a list of candidates.\n *\n * Requirements:\n * - The method caller is not the pool admin.\n *\n * Emits the events `Undelegated`.\n *\n */\n function bulkUndelegate(address[] calldata _consensusAddrs, uint256[] calldata _amounts) external;\n\n /**\n * @dev Unstakes an amount of RON from the `_consensusAddrSrc` and stake for `_consensusAddrDst`.\n *\n * Requirements:\n * - The method caller is not the pool admin.\n * - The consensus address `_consensusAddrDst` is a validator candidate.\n *\n * Emits the `Undelegated` event and the `Delegated` event.\n *\n */\n function redelegate(address _consensusAddrSrc, address _consensusAddrDst, uint256 _amount) external;\n\n /**\n * @dev Returns the claimable reward of the user `_user`.\n */\n function getRewards(\n address _user,\n address[] calldata _poolAddrList\n ) external view returns (uint256[] memory _rewards);\n\n /**\n * @dev Claims the reward of method caller.\n *\n * Emits the `RewardClaimed` event.\n *\n */\n function claimRewards(address[] calldata _consensusAddrList) external returns (uint256 _amount);\n\n /**\n * @dev Claims the rewards and delegates them to the consensus address.\n *\n * Requirements:\n * - The method caller is not the pool admin.\n * - The consensus address `_consensusAddrDst` is a validator candidate.\n *\n * Emits the `RewardClaimed` event and the `Delegated` event.\n *\n */\n function delegateRewards(\n address[] calldata _consensusAddrList,\n address _consensusAddrDst\n ) external returns (uint256 _amount);\n}\n" + }, + "contracts/interfaces/staking/IRewardPool.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../interfaces/consumers/PeriodWrapperConsumer.sol\";\n\ninterface IRewardPool is PeriodWrapperConsumer {\n struct UserRewardFields {\n // Recorded reward amount.\n uint256 debited;\n // The last accumulated of the amount rewards per share (one unit staking) that the info updated.\n uint256 aRps;\n // Lowest staking amount in the period.\n uint256 lowestAmount;\n // Last period number that the info updated.\n uint256 lastPeriod;\n }\n\n struct PoolFields {\n // Accumulated of the amount rewards per share (one unit staking).\n uint256 aRps;\n // The staking total to share reward of the current period.\n PeriodWrapper shares;\n }\n\n /// @dev Emitted when the fields to calculate pending reward for the user is updated.\n event UserRewardUpdated(address indexed poolAddr, address indexed user, uint256 debited);\n /// @dev Emitted when the user claimed their reward\n event RewardClaimed(address indexed poolAddr, address indexed user, uint256 amount);\n\n /// @dev Emitted when the pool shares are updated\n event PoolSharesUpdated(uint256 indexed period, address indexed poolAddr, uint256 shares);\n /// @dev Emitted when the pools are updated\n event PoolsUpdated(uint256 indexed period, address[] poolAddrs, uint256[] aRps, uint256[] shares);\n /// @dev Emitted when the contract fails when updating the pools\n event PoolsUpdateFailed(uint256 indexed period, address[] poolAddrs, uint256[] rewards);\n /// @dev Emitted when the contract fails when updating the pools that already set\n event PoolsUpdateConflicted(uint256 indexed period, address[] poolAddrs);\n\n /// @dev Error of invalid pool share.\n error ErrInvalidPoolShare();\n\n /**\n * @dev Returns the reward amount that user claimable.\n */\n function getReward(address _poolAddr, address _user) external view returns (uint256);\n\n /**\n * @dev Returns the staking amount of an user.\n */\n function getStakingAmount(address _poolAddr, address _user) external view returns (uint256);\n\n /**\n * @dev Returns the staking amounts of the users.\n */\n function getManyStakingAmounts(\n address[] calldata _poolAddrs,\n address[] calldata _userList\n ) external view returns (uint256[] memory);\n\n /**\n * @dev Returns the total staking amount of all users for a pool.\n */\n function getStakingTotal(address _poolAddr) external view returns (uint256);\n\n /**\n * @dev Returns the total staking amounts of all users for the pools `_poolAddrs`.\n */\n function getManyStakingTotals(address[] calldata _poolAddrs) external view returns (uint256[] memory);\n}\n" + }, + "contracts/interfaces/staking/IStaking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IBaseStaking.sol\";\nimport \"./ICandidateStaking.sol\";\nimport \"./IDelegatorStaking.sol\";\n\ninterface IStaking is IRewardPool, IBaseStaking, ICandidateStaking, IDelegatorStaking {\n /**\n * @dev Records the amount of rewards `_rewards` for the pools `_consensusAddrs`.\n *\n * Requirements:\n * - The method caller must be validator contract.\n *\n * Emits the event `PoolsUpdated` once the contract recorded the rewards successfully.\n * Emits the event `PoolsUpdateFailed` once the input array lengths are not equal.\n * Emits the event `PoolsUpdateConflicted` when there are some pools which already updated in the period.\n *\n * Note: This method should be called once at the period ending.\n *\n */\n function execRecordRewards(\n address[] calldata _consensusAddrs,\n uint256[] calldata _rewards,\n uint256 _period\n ) external payable;\n\n /**\n * @dev Deducts from staking amount of the validator `_consensusAddr` for `_amount`.\n *\n * Requirements:\n * - The method caller must be validator contract.\n *\n * Emits the event `Unstaked`.\n *\n */\n function execDeductStakingAmount(\n address _consensusAddr,\n uint256 _amount\n ) external returns (uint256 _actualDeductingAmount);\n}\n" + }, + "contracts/interfaces/validator/ICandidateManager.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface ICandidateManager {\n struct ValidatorCandidate {\n // Admin of the candidate\n address admin;\n // Address of the validator that produces block, e.g. block.coinbase. This is so-called validator address.\n address consensusAddr;\n // Address that receives mining reward of the validator\n address payable treasuryAddr;\n // Address of the bridge operator corresponding to the candidate\n address ______deprecatedbridgeOperatorAddr;\n // The percentage of reward that validators can be received, the rest goes to the delegators.\n // Values in range [0; 100_00] stands for 0-100%\n uint256 commissionRate;\n // The timestamp that scheduled to revoke the candidate (no schedule=0)\n uint256 revokingTimestamp;\n // The deadline that the candidate must top up staking amount to keep it larger than or equal to the threshold (no deadline=0)\n uint256 topupDeadline;\n }\n\n struct CommissionSchedule {\n // The timestamp that the commission schedule gets affected (no schedule=0).\n uint256 effectiveTimestamp;\n // The new commission rate. Value is in range [0; 100_00], stands for 0-100%\n uint256 commissionRate;\n }\n\n /// @dev Emitted when the maximum number of validator candidates is updated.\n event MaxValidatorCandidateUpdated(uint256 threshold);\n /// @dev Emitted when the min offset to the effective date of commission rate change is updated.\n event MinEffectiveDaysOnwardsUpdated(uint256 numOfDays);\n /// @dev Emitted when the validator candidate is granted.\n event CandidateGranted(address indexed consensusAddr, address indexed treasuryAddr, address indexed admin);\n /// @dev Emitted when the revoking timestamp of a candidate is updated.\n event CandidateRevokingTimestampUpdated(address indexed consensusAddr, uint256 revokingTimestamp);\n /// @dev Emitted when the topup deadline of a candidate is updated.\n event CandidateTopupDeadlineUpdated(address indexed consensusAddr, uint256 topupDeadline);\n /// @dev Emitted when the validator candidate is revoked.\n event CandidatesRevoked(address[] consensusAddrs);\n\n /// @dev Emitted when a schedule for updating commission rate is set.\n event CommissionRateUpdateScheduled(address indexed consensusAddr, uint256 effectiveTimestamp, uint256 rate);\n /// @dev Emitted when the commission rate of a validator is updated.\n event CommissionRateUpdated(address indexed consensusAddr, uint256 rate);\n\n /// @dev Error of exceeding maximum number of candidates.\n error ErrExceedsMaxNumberOfCandidate();\n /// @dev Error of querying for already existent candidate.\n error ErrExistentCandidate();\n /// @dev Error of querying for non-existent candidate.\n error ErrNonExistentCandidate();\n /// @dev Error of candidate admin already exists.\n error ErrExistentCandidateAdmin(address _candidateAdminAddr);\n /// @dev Error of treasury already exists.\n error ErrExistentTreasury(address _treasuryAddr);\n /// @dev Error of invalid commission rate.\n error ErrInvalidCommissionRate();\n /// @dev Error of invalid effective days onwards.\n error ErrInvalidEffectiveDaysOnwards();\n /// @dev Error of invalid min effective days onwards.\n error ErrInvalidMinEffectiveDaysOnwards();\n /// @dev Error of already requested revoking candidate before.\n error ErrAlreadyRequestedRevokingCandidate();\n /// @dev Error of commission change schedule exists.\n error ErrAlreadyRequestedUpdatingCommissionRate();\n /// @dev Error of trusted org cannot renounce.\n error ErrTrustedOrgCannotRenounce();\n\n /**\n * @dev Returns the maximum number of validator candidate.\n */\n function maxValidatorCandidate() external view returns (uint256);\n\n /**\n * @dev Returns the minimum number of days to the effective date of commission rate change.\n */\n function minEffectiveDaysOnwards() external view returns (uint256);\n\n /**\n * @dev Sets the maximum number of validator candidate.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `MaxValidatorCandidateUpdated` event.\n *\n */\n function setMaxValidatorCandidate(uint256) external;\n\n /**\n * @dev Sets the minimum number of days to the effective date of commision rate change.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `MinEffectiveDaysOnwardsUpdated` event.\n *\n */\n function setMinEffectiveDaysOnwards(uint256 _numOfDays) external;\n\n /**\n * @dev Grants a validator candidate.\n *\n * Requirements:\n * - The method caller is staking contract.\n *\n * Emits the event `CandidateGranted`.\n *\n */\n function execApplyValidatorCandidate(\n address _admin,\n address _consensusAddr,\n address payable _treasuryAddr,\n uint256 _commissionRate\n ) external;\n\n /**\n * @dev Requests to revoke a validator candidate in next `_secsLeft` seconds.\n *\n * Requirements:\n * - The method caller is staking contract.\n *\n * Emits the event `CandidateRevokingTimestampUpdated`.\n *\n */\n function execRequestRenounceCandidate(address, uint256 _secsLeft) external;\n\n /**\n * @dev Fallback function of `CandidateStaking-requestUpdateCommissionRate`.\n *\n * Requirements:\n * - The method caller is the staking contract.\n * - The `_effectiveTimestamp` must be the beginning of a UTC day, and at least from 7 days onwards\n * - The `_rate` must be in range of [0_00; 100_00].\n *\n * Emits the event `CommissionRateUpdateScheduled`.\n *\n */\n function execRequestUpdateCommissionRate(address _consensusAddr, uint256 _effectiveTimestamp, uint256 _rate) external;\n\n /**\n * @dev Returns whether the address is a validator (candidate).\n */\n function isValidatorCandidate(address _addr) external view returns (bool);\n\n /**\n * @dev Returns the validator candidate.\n */\n function getValidatorCandidates() external view returns (address[] memory);\n\n /**\n * @dev Returns all candidate info.\n */\n function getCandidateInfos() external view returns (ValidatorCandidate[] memory);\n\n /**\n * @dev Returns the info of a candidate.\n */\n function getCandidateInfo(address _candidate) external view returns (ValidatorCandidate memory);\n\n /**\n * @dev Returns whether the address is the candidate admin.\n */\n function isCandidateAdmin(address _candidate, address _admin) external view returns (bool);\n\n /**\n * @dev Returns the schedule of changing commission rate of a candidate address.\n */\n function getCommissionChangeSchedule(address _candidate) external view returns (CommissionSchedule memory);\n}\n" + }, + "contracts/interfaces/validator/ICoinbaseExecution.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./ISlashingExecution.sol\";\n\ninterface ICoinbaseExecution is ISlashingExecution {\n enum BlockRewardDeprecatedType {\n UNKNOWN,\n UNAVAILABILITY,\n AFTER_BAILOUT\n }\n\n /// @dev Emitted when the validator set is updated\n event ValidatorSetUpdated(uint256 indexed period, address[] consensusAddrs);\n /// @dev Emitted when the bridge operator set is updated, to mirror the in-jail and maintaining status of the validator.\n event BlockProducerSetUpdated(uint256 indexed period, uint256 indexed epoch, address[] consensusAddrs);\n /// @dev Emitted when the bridge operator set is updated.\n event BridgeOperatorSetUpdated(uint256 indexed period, uint256 indexed epoch, address[] bridgeOperators);\n\n /// @dev Emitted when the reward of the block producer is deprecated.\n event BlockRewardDeprecated(\n address indexed coinbaseAddr,\n uint256 rewardAmount,\n BlockRewardDeprecatedType deprecatedType\n );\n /// @dev Emitted when the block reward is submitted.\n event BlockRewardSubmitted(address indexed coinbaseAddr, uint256 submittedAmount, uint256 bonusAmount);\n\n /// @dev Emitted when the block producer reward is distributed.\n event MiningRewardDistributed(address indexed consensusAddr, address indexed recipient, uint256 amount);\n /// @dev Emitted when the contract fails when distributing the block producer reward.\n event MiningRewardDistributionFailed(\n address indexed consensusAddr,\n address indexed recipient,\n uint256 amount,\n uint256 contractBalance\n );\n\n /// @dev Emitted when the bridge operator reward is distributed.\n event BridgeOperatorRewardDistributed(\n address indexed consensusAddr,\n address indexed bridgeOperator,\n address indexed recipientAddr,\n uint256 amount\n );\n /// @dev Emitted when the contract fails when distributing the bridge operator reward.\n event BridgeOperatorRewardDistributionFailed(\n address indexed consensusAddr,\n address indexed bridgeOperator,\n address indexed recipient,\n uint256 amount,\n uint256 contractBalance\n );\n\n /// @dev Emitted when the amount of RON reward is distributed to staking contract.\n event StakingRewardDistributed(uint256 totalAmount, address[] consensusAddrs, uint256[] amounts);\n /// @dev Emitted when the contracts fails when distributing the amount of RON to the staking contract.\n event StakingRewardDistributionFailed(\n uint256 totalAmount,\n address[] consensusAddrs,\n uint256[] amounts,\n uint256 contractBalance\n );\n\n /// @dev Emitted when the epoch is wrapped up.\n event WrappedUpEpoch(uint256 indexed periodNumber, uint256 indexed epochNumber, bool periodEnding);\n\n /// @dev Error of method caller must be coinbase\n error ErrCallerMustBeCoinbase();\n /// @dev Error of only allowed at the end of epoch\n error ErrAtEndOfEpochOnly();\n /// @dev Error of query for already wrapped up epoch\n error ErrAlreadyWrappedEpoch();\n\n /**\n * @dev Submits reward of the current block.\n *\n * Requirements:\n * - The method caller is coinbase.\n *\n * Emits the event `MiningRewardDeprecated` if the coinbase is slashed or no longer be a block producer.\n * Emits the event `BlockRewardSubmitted` for the valid call.\n *\n */\n function submitBlockReward() external payable;\n\n /**\n * @dev Wraps up the current epoch.\n *\n * Requirements:\n * - The method must be called when the current epoch is ending.\n * - The epoch is not wrapped yet.\n * - The method caller is coinbase.\n *\n * Emits the event `MiningRewardDistributed` when some validator has reward distributed.\n * Emits the event `StakingRewardDistributed` when some staking pool has reward distributed.\n * Emits the event `BlockProducerSetUpdated` when the epoch is wrapped up.\n * Emits the event `BridgeOperatorSetUpdated` when the epoch is wrapped up at period ending.\n * Emits the event `ValidatorSetUpdated` when the epoch is wrapped up at period ending, and the validator set gets updated.\n * Emits the event `WrappedUpEpoch`.\n *\n */\n function wrapUpEpoch() external payable;\n}\n" + }, + "contracts/interfaces/validator/IEmergencyExit.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface IEmergencyExit {\n /// @dev Emitted when the fund is locked from an emergency exit request\n event EmergencyExitRequested(address indexed consensusAddr, uint256 lockedAmount);\n /// @dev Emitted when the fund that locked from an emergency exit request is transferred to the recipient.\n event EmergencyExitLockedFundReleased(\n address indexed consensusAddr,\n address indexed recipient,\n uint256 unlockedAmount\n );\n /// @dev Emitted when the fund that locked from an emergency exit request is failed to transferred back.\n event EmergencyExitLockedFundReleasingFailed(\n address indexed consensusAddr,\n address indexed recipient,\n uint256 unlockedAmount,\n uint256 contractBalance\n );\n\n /// @dev Emitted when the emergency exit locked amount is updated.\n event EmergencyExitLockedAmountUpdated(uint256 amount);\n /// @dev Emitted when the emergency expiry duration is updated.\n event EmergencyExpiryDurationUpdated(uint256 amount);\n\n /// @dev Error of already requested emergency exit before.\n error ErrAlreadyRequestedEmergencyExit();\n\n /**\n * @dev Returns the amount of RON to lock from a consensus address.\n */\n function emergencyExitLockedAmount() external returns (uint256);\n\n /**\n * @dev Returns the duration that an emergency request is expired and the fund will be recycled.\n */\n function emergencyExpiryDuration() external returns (uint256);\n\n /**\n * @dev Sets the amount of RON to lock from a consensus address.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `EmergencyExitLockedAmountUpdated`.\n *\n */\n function setEmergencyExitLockedAmount(uint256 _emergencyExitLockedAmount) external;\n\n /**\n * @dev Sets the duration that an emergency request is expired and the fund will be recycled.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `EmergencyExpiryDurationUpdated`.\n *\n */\n function setEmergencyExpiryDuration(uint256 _emergencyExpiryDuration) external;\n\n /**\n * @dev Unlocks fund for emergency exit request.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `EmergencyExitLockedFundReleased` if the fund is successfully unlocked.\n * Emits the event `EmergencyExitLockedFundReleasingFailed` if the fund is failed to unlock.\n *\n */\n function execReleaseLockedFundForEmergencyExitRequest(address _consensusAddr, address payable _recipient) external;\n\n /**\n * @dev Fallback function of `IStaking-requestEmergencyExit`.\n *\n * Requirements:\n * - The method caller is staking contract.\n *\n */\n function execEmergencyExit(address _consensusAddr, uint256 _secLeftToRevoke) external;\n}\n" + }, + "contracts/interfaces/validator/info-fragments/ICommonInfo.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IJailingInfo.sol\";\nimport \"./ITimingInfo.sol\";\nimport \"./IValidatorInfoV2.sol\";\n\ninterface ICommonInfo is ITimingInfo, IJailingInfo, IValidatorInfoV2 {\n struct EmergencyExitInfo {\n uint256 lockedAmount;\n // The timestamp that this locked amount will be recycled to staking vesting contract\n uint256 recyclingAt;\n }\n\n /// @dev Emitted when the deprecated reward is withdrawn.\n event DeprecatedRewardRecycled(address indexed recipientAddr, uint256 amount);\n /// @dev Emitted when the deprecated reward withdrawal is failed\n event DeprecatedRewardRecycleFailed(address indexed recipientAddr, uint256 amount, uint256 balance);\n\n /// @dev Error thrown when receives RON from neither staking vesting contract nor staking contract\n error ErrUnauthorizedReceiveRON();\n /// @dev Error thrown when queries for a non existent info.\n error NonExistentRecyclingInfo();\n\n /**\n * @dev Returns the total deprecated reward, which includes reward that is not sent for slashed validators and unsastified bridge operators\n */\n function totalDeprecatedReward() external view returns (uint256);\n\n /**\n * @dev Returns the emergency exit request.\n */\n function getEmergencyExitInfo(address _consensusAddr) external view returns (EmergencyExitInfo memory);\n}\n" + }, + "contracts/interfaces/validator/info-fragments/IJailingInfo.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface IJailingInfo {\n /**\n * @dev Returns whether the validator are put in jail (cannot join the set of validators) during the current period.\n */\n function checkJailed(address) external view returns (bool);\n\n /**\n * @dev Returns whether the validator are put in jail and the number of block and epoch that he still is in the jail.\n */\n function getJailedTimeLeft(\n address _addr\n ) external view returns (bool isJailed_, uint256 blockLeft_, uint256 epochLeft_);\n\n /**\n * @dev Returns whether the validator are put in jail (cannot join the set of validators) at a specific block.\n */\n function checkJailedAtBlock(address _addr, uint256 _blockNum) external view returns (bool);\n\n /**\n * @dev Returns whether the validator are put in jail at a specific block and the number of block and epoch that he still is in the jail.\n */\n function getJailedTimeLeftAtBlock(\n address _addr,\n uint256 _blockNum\n ) external view returns (bool isJailed_, uint256 blockLeft_, uint256 epochLeft_);\n\n /**\n * @dev Returns whether the validators are put in jail (cannot join the set of validators) during the current period.\n */\n function checkManyJailed(address[] calldata) external view returns (bool[] memory);\n\n /**\n * @dev Returns whether the incoming reward of the block producer is deprecated during the current period.\n */\n function checkMiningRewardDeprecated(address _blockProducer) external view returns (bool);\n\n /**\n * @dev Returns whether the incoming reward of the block producer is deprecated during a specific period.\n */\n function checkMiningRewardDeprecatedAtPeriod(address _blockProducer, uint256 _period) external view returns (bool);\n}\n" + }, + "contracts/interfaces/validator/info-fragments/ITimingInfo.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface ITimingInfo {\n /**\n * @dev Returns the block that validator set was updated.\n */\n function getLastUpdatedBlock() external view returns (uint256);\n\n /**\n * @dev Returns the number of blocks in a epoch.\n */\n function numberOfBlocksInEpoch() external view returns (uint256 _numberOfBlocks);\n\n /**\n * @dev Returns the epoch index from the block number.\n */\n function epochOf(uint256 _block) external view returns (uint256);\n\n /**\n * @dev Returns whether the epoch ending is at the block number `_block`.\n */\n function epochEndingAt(uint256 _block) external view returns (bool);\n\n /**\n * @dev Tries to get the period index from the epoch number.\n */\n function tryGetPeriodOfEpoch(uint256 _epoch) external view returns (bool _filled, uint256 _periodNumber);\n\n /**\n * @dev Returns whether the period ending at the current block number.\n */\n function isPeriodEnding() external view returns (bool);\n\n /**\n * @dev Returns the period index from the current block.\n */\n function currentPeriod() external view returns (uint256);\n\n /**\n * @dev Returns the block number that the current period starts at.\n */\n function currentPeriodStartAtBlock() external view returns (uint256);\n}\n" + }, + "contracts/interfaces/validator/info-fragments/IValidatorInfoV2.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../../libraries/EnumFlags.sol\";\n\ninterface IValidatorInfoV2 {\n /**\n * @dev Error thrown when an invalid maximum prioritized validator number is provided.\n */\n error ErrInvalidMaxPrioritizedValidatorNumber();\n\n /// @dev Emitted when the number of max validator is updated.\n event MaxValidatorNumberUpdated(uint256);\n /// @dev Emitted when the number of reserved slots for prioritized validators is updated.\n event MaxPrioritizedValidatorNumberUpdated(uint256);\n\n /**\n * @dev Returns the maximum number of validators in the epoch.\n */\n function maxValidatorNumber() external view returns (uint256 _maximumValidatorNumber);\n\n /**\n * @dev Returns the number of reserved slots for prioritized validators.\n */\n function maxPrioritizedValidatorNumber() external view returns (uint256 _maximumPrioritizedValidatorNumber);\n\n /**\n * @dev Returns the current validator list.\n */\n function getValidators() external view returns (address[] memory _validatorList);\n\n /**\n * @dev Returns the current block producer list.\n */\n function getBlockProducers() external view returns (address[] memory);\n\n /**\n * @dev Returns whether the address is block producer or not.\n */\n function isBlockProducer(address _addr) external view returns (bool);\n\n /**\n * @dev Returns total numbers of the block producers.\n */\n function totalBlockProducers() external view returns (uint256);\n\n /**\n * @dev Updates the max validator number\n *\n * Requirements:\n * - The method caller is admin\n *\n * Emits the event `MaxValidatorNumberUpdated`\n *\n */\n function setMaxValidatorNumber(uint256 _maxValidatorNumber) external;\n\n /**\n * @dev Updates the number of reserved slots for prioritized validators\n *\n * Requirements:\n * - The method caller is admin\n *\n * Emits the event `MaxPrioritizedValidatorNumberUpdated`\n *\n */\n function setMaxPrioritizedValidatorNumber(uint256 _maxPrioritizedValidatorNumber) external;\n}\n" + }, + "contracts/interfaces/validator/IRoninValidatorSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./ICandidateManager.sol\";\nimport \"./info-fragments/ICommonInfo.sol\";\nimport \"./ICoinbaseExecution.sol\";\nimport \"./ISlashingExecution.sol\";\nimport \"./IEmergencyExit.sol\";\n\ninterface IRoninValidatorSet is\n ICandidateManager,\n ICommonInfo,\n ISlashingExecution,\n ICoinbaseExecution,\n IEmergencyExit\n{}\n" + }, + "contracts/interfaces/validator/ISlashingExecution.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface ISlashingExecution {\n /// @dev Emitted when the validator is punished.\n event ValidatorPunished(\n address indexed consensusAddr,\n uint256 indexed period,\n uint256 jailedUntil,\n uint256 deductedStakingAmount,\n bool blockProducerRewardDeprecated,\n bool bridgeOperatorRewardDeprecated\n );\n /// @dev Emitted when the validator get out of jail by bailout.\n event ValidatorUnjailed(address indexed validator, uint256 period);\n\n /// @dev Error of cannot bailout due to high tier slash.\n error ErrCannotBailout(address validator);\n\n /**\n * @dev Finalize the slash request from slash indicator contract.\n *\n * Requirements:\n * - The method caller is slash indicator contract.\n *\n * Emits the event `ValidatorPunished`.\n *\n */\n function execSlash(\n address _validatorAddr,\n uint256 _newJailedUntil,\n uint256 _slashAmount,\n bool _cannotBailout\n ) external;\n\n /**\n * @dev Finalize the bailout request from slash indicator contract.\n *\n * Requirements:\n * - The method caller is slash indicator contract.\n *\n * Emits the event `ValidatorUnjailed`.\n *\n */\n function execBailOut(address _validatorAddr, uint256 _period) external;\n}\n" + }, + "contracts/libraries/AddressArrayUtils.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\nlibrary AddressArrayUtils {\n /**\n * @dev Error thrown when a duplicated element is detected in an array.\n * @param msgSig The function signature that invoke the error.\n */\n error ErrDuplicated(bytes4 msgSig);\n\n /**\n * @dev Returns whether or not there's a duplicate. Runs in O(n^2).\n * @param A Array to search\n * @return Returns true if duplicate, false otherwise\n */\n function hasDuplicate(address[] memory A) internal pure returns (bool) {\n if (A.length == 0) {\n return false;\n }\n unchecked {\n for (uint256 i = 0; i < A.length - 1; i++) {\n for (uint256 j = i + 1; j < A.length; j++) {\n if (A[i] == A[j]) {\n return true;\n }\n }\n }\n }\n return false;\n }\n\n /**\n * @dev Returns whether two arrays of addresses are equal or not.\n */\n function isEqual(address[] memory _this, address[] memory _other) internal pure returns (bool yes_) {\n // Hashing two arrays and compare their hash\n assembly {\n let _thisHash := keccak256(add(_this, 32), mul(mload(_this), 32))\n let _otherHash := keccak256(add(_other, 32), mul(mload(_other), 32))\n yes_ := eq(_thisHash, _otherHash)\n }\n }\n\n /**\n * @dev Return the concatenated array from a and b.\n */\n function extend(address[] memory a, address[] memory b) internal pure returns (address[] memory c) {\n uint256 lengthA = a.length;\n uint256 lengthB = b.length;\n unchecked {\n c = new address[](lengthA + lengthB);\n }\n uint256 i;\n for (; i < lengthA; ) {\n c[i] = a[i];\n unchecked {\n ++i;\n }\n }\n for (uint256 j; j < lengthB; ) {\n c[i] = b[j];\n unchecked {\n ++i;\n ++j;\n }\n }\n }\n}\n" + }, + "contracts/libraries/Ballot.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\n\nlibrary Ballot {\n using ECDSA for bytes32;\n\n enum VoteType {\n For,\n Against\n }\n\n // keccak256(\"Ballot(bytes32 proposalHash,uint8 support)\");\n bytes32 private constant BALLOT_TYPEHASH = 0xd900570327c4c0df8dd6bdd522b7da7e39145dd049d2fd4602276adcd511e3c2;\n\n function hash(bytes32 _proposalHash, VoteType _support) internal pure returns (bytes32 digest) {\n // return keccak256(abi.encode(BALLOT_TYPEHASH, _proposalHash, _support));\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, BALLOT_TYPEHASH)\n mstore(add(ptr, 0x20), _proposalHash)\n mstore(add(ptr, 0x40), _support)\n digest := keccak256(ptr, 0x60)\n }\n }\n}\n" + }, + "contracts/libraries/EnumFlags.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This library implements checking flag of an enumerated value.\n * The originated idea is inherited from [Enum.HashFlag(Enum)](https://learn.microsoft.com/en-us/dotnet/api/system.enum.hasflag?view=net-6.0) method of C#.\n */\nlibrary EnumFlags {\n enum ValidatorFlag {\n None, // bit(00)\n BlockProducer, // bit(01)\n DeprecatedBridgeOperator, // bit(10)\n Both // bit(11)\n }\n\n function isNone(ValidatorFlag _value) internal pure returns (bool) {\n return uint8(_value) == 0;\n }\n\n /**\n * @dev Checks if `_value` has `_flag`.\n */\n function hasFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (bool) {\n return (uint8(_value) & uint8(_flag)) != 0;\n }\n\n /**\n * @dev Calculate new value of `_value` after adding `_flag`.\n */\n function addFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (ValidatorFlag) {\n return ValidatorFlag(uint8(_value) | uint8(_flag));\n }\n\n /**\n * @dev Calculate new value of `_value` after remove `_flag`.\n */\n function removeFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (ValidatorFlag) {\n return ValidatorFlag(uint8(_value) & ~uint8(_flag));\n }\n}\n" + }, + "contracts/libraries/GlobalProposal.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./Proposal.sol\";\n\nlibrary GlobalProposal {\n /**\n * @dev Error thrown when attempting to interact with an unsupported target.\n */\n error ErrUnsupportedTarget(bytes32 proposalHash, uint256 targetNumber);\n\n enum TargetOption {\n /* 0 */ BridgeManager,\n /* 1 */ GatewayContract,\n /* 2 */ BridgeReward,\n /* 3 */ BridgeSlash\n }\n\n struct GlobalProposalDetail {\n // Nonce to make sure proposals are executed in order\n uint256 nonce;\n uint256 expiryTimestamp;\n TargetOption[] targetOptions;\n uint256[] values;\n bytes[] calldatas;\n uint256[] gasAmounts;\n }\n\n // keccak256(\"GlobalProposalDetail(uint256 nonce,uint256 expiryTimestamp,uint8[] targetOptions,uint256[] values,bytes[] calldatas,uint256[] gasAmounts)\");\n bytes32 public constant TYPE_HASH = 0x1463f426c05aff2c1a7a0957a71c9898bc8b47142540538e79ee25ee91141350;\n\n /**\n * @dev Returns struct hash of the proposal.\n */\n function hash(GlobalProposalDetail memory self) internal pure returns (bytes32 digest_) {\n uint256[] memory values = self.values;\n TargetOption[] memory targets = self.targetOptions;\n bytes32[] memory calldataHashList = new bytes32[](self.calldatas.length);\n uint256[] memory gasAmounts = self.gasAmounts;\n\n for (uint256 i; i < calldataHashList.length; ) {\n calldataHashList[i] = keccak256(self.calldatas[i]);\n\n unchecked {\n ++i;\n }\n }\n\n /*\n * return\n * keccak256(\n * abi.encode(\n * TYPE_HASH,\n * _proposal.nonce,\n * _proposal.expiryTimestamp,\n * _targetsHash,\n * _valuesHash,\n * _calldatasHash,\n * _gasAmountsHash\n * )\n * );\n */\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, TYPE_HASH)\n mstore(add(ptr, 0x20), mload(self)) // _proposal.nonce\n mstore(add(ptr, 0x40), mload(add(self, 0x20))) // _proposal.expiryTimestamp\n\n let arrayHashed\n arrayHashed := keccak256(add(targets, 32), mul(mload(targets), 32)) // targetsHash\n mstore(add(ptr, 0x60), arrayHashed)\n arrayHashed := keccak256(add(values, 32), mul(mload(values), 32)) // _valuesHash\n mstore(add(ptr, 0x80), arrayHashed)\n arrayHashed := keccak256(add(calldataHashList, 32), mul(mload(calldataHashList), 32)) // _calldatasHash\n mstore(add(ptr, 0xa0), arrayHashed)\n arrayHashed := keccak256(add(gasAmounts, 32), mul(mload(gasAmounts), 32)) // _gasAmountsHash\n mstore(add(ptr, 0xc0), arrayHashed)\n digest_ := keccak256(ptr, 0xe0)\n }\n }\n\n /**\n * @dev Converts into the normal proposal.\n */\n function intoProposalDetail(\n GlobalProposalDetail memory self,\n address[] memory targets\n ) internal pure returns (Proposal.ProposalDetail memory detail_) {\n detail_.nonce = self.nonce;\n detail_.expiryTimestamp = self.expiryTimestamp;\n detail_.chainId = 0;\n detail_.targets = new address[](self.targetOptions.length);\n detail_.values = self.values;\n detail_.calldatas = self.calldatas;\n detail_.gasAmounts = self.gasAmounts;\n\n for (uint256 i; i < self.targetOptions.length; ) {\n detail_.targets[i] = targets[i];\n unchecked {\n ++i;\n }\n }\n }\n}\n" + }, + "contracts/libraries/Math.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\nlibrary Math {\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a >= b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns whether the number `c` is in range of [a; b].\n */\n function inRange(uint256 c, uint256 a, uint256 b) internal pure returns (bool) {\n return a <= c && c <= b;\n }\n\n /**\n * @dev Returns whether two inclusive ranges [x1;x2] and [y1;y2] overlap.\n */\n function twoRangeOverlap(uint256 x1, uint256 x2, uint256 y1, uint256 y2) internal pure returns (bool) {\n return x1 <= y2 && y1 <= x2;\n }\n\n /**\n * @dev Returns value of a + b; in case result is larger than upperbound, upperbound is returned.\n */\n function addWithUpperbound(uint256 a, uint256 b, uint256 upperbound) internal pure returns (uint256) {\n return min(a + b, upperbound);\n }\n\n /**\n * @dev Returns value of a - b; in case of negative result, 0 is returned.\n */\n function subNonNegative(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a - b : 0;\n }\n\n /**\n * @dev Returns value of `a + zeroable` if zerobale is not 0; otherwise, return 0.\n */\n function addIfNonZero(uint256 a, uint256 zeroable) internal pure returns (uint256) {\n return zeroable != 0 ? a + zeroable : 0;\n }\n}\n" + }, + "contracts/libraries/Proposal.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { ErrInvalidChainId, ErrLengthMismatch } from \"../utils/CommonErrors.sol\";\n\nlibrary Proposal {\n /**\n * @dev Error thrown when there is insufficient gas to execute a function.\n */\n error ErrInsufficientGas(bytes32 proposalHash);\n\n /**\n * @dev Error thrown when an invalid expiry timestamp is provided.\n */\n error ErrInvalidExpiryTimestamp();\n\n struct ProposalDetail {\n // Nonce to make sure proposals are executed in order\n uint256 nonce;\n // Value 0: all chain should run this proposal\n // Other values: only specifc chain has to execute\n uint256 chainId;\n uint256 expiryTimestamp;\n address[] targets;\n uint256[] values;\n bytes[] calldatas;\n uint256[] gasAmounts;\n }\n\n // keccak256(\"ProposalDetail(uint256 nonce,uint256 chainId,uint256 expiryTimestamp,address[] targets,uint256[] values,bytes[] calldatas,uint256[] gasAmounts)\");\n bytes32 public constant TYPE_HASH = 0xd051578048e6ff0bbc9fca3b65a42088dbde10f36ca841de566711087ad9b08a;\n\n /**\n * @dev Validates the proposal.\n */\n function validate(ProposalDetail memory _proposal, uint256 _maxExpiryDuration) internal view {\n if (\n !(_proposal.targets.length > 0 &&\n _proposal.targets.length == _proposal.values.length &&\n _proposal.targets.length == _proposal.calldatas.length &&\n _proposal.targets.length == _proposal.gasAmounts.length)\n ) {\n revert ErrLengthMismatch(msg.sig);\n }\n\n if (_proposal.expiryTimestamp > block.timestamp + _maxExpiryDuration) {\n revert ErrInvalidExpiryTimestamp();\n }\n }\n\n /**\n * @dev Returns struct hash of the proposal.\n */\n function hash(ProposalDetail memory _proposal) internal pure returns (bytes32 digest_) {\n uint256[] memory _values = _proposal.values;\n address[] memory _targets = _proposal.targets;\n bytes32[] memory _calldataHashList = new bytes32[](_proposal.calldatas.length);\n uint256[] memory _gasAmounts = _proposal.gasAmounts;\n\n for (uint256 _i; _i < _calldataHashList.length; ) {\n _calldataHashList[_i] = keccak256(_proposal.calldatas[_i]);\n\n unchecked {\n ++_i;\n }\n }\n\n // return\n // keccak256(\n // abi.encode(\n // TYPE_HASH,\n // _proposal.nonce,\n // _proposal.chainId,\n // _targetsHash,\n // _valuesHash,\n // _calldatasHash,\n // _gasAmountsHash\n // )\n // );\n // /\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, TYPE_HASH)\n mstore(add(ptr, 0x20), mload(_proposal)) // _proposal.nonce\n mstore(add(ptr, 0x40), mload(add(_proposal, 0x20))) // _proposal.chainId\n mstore(add(ptr, 0x60), mload(add(_proposal, 0x40))) // expiry timestamp\n\n let arrayHashed\n arrayHashed := keccak256(add(_targets, 32), mul(mload(_targets), 32)) // targetsHash\n mstore(add(ptr, 0x80), arrayHashed)\n arrayHashed := keccak256(add(_values, 32), mul(mload(_values), 32)) // _valuesHash\n mstore(add(ptr, 0xa0), arrayHashed)\n arrayHashed := keccak256(add(_calldataHashList, 32), mul(mload(_calldataHashList), 32)) // _calldatasHash\n mstore(add(ptr, 0xc0), arrayHashed)\n arrayHashed := keccak256(add(_gasAmounts, 32), mul(mload(_gasAmounts), 32)) // _gasAmountsHash\n mstore(add(ptr, 0xe0), arrayHashed)\n digest_ := keccak256(ptr, 0x100)\n }\n }\n\n /**\n * @dev Returns whether the proposal is executable for the current chain.\n *\n * @notice Does not check whether the call result is successful or not. Please use `execute` instead.\n *\n */\n function executable(ProposalDetail memory _proposal) internal view returns (bool _result) {\n return _proposal.chainId == 0 || _proposal.chainId == block.chainid;\n }\n\n /**\n * @dev Executes the proposal.\n */\n function execute(\n ProposalDetail memory _proposal\n ) internal returns (bool[] memory _successCalls, bytes[] memory _returnDatas) {\n if (!executable(_proposal)) revert ErrInvalidChainId(msg.sig, _proposal.chainId, block.chainid);\n\n _successCalls = new bool[](_proposal.targets.length);\n _returnDatas = new bytes[](_proposal.targets.length);\n for (uint256 _i = 0; _i < _proposal.targets.length; ) {\n if (gasleft() <= _proposal.gasAmounts[_i]) revert ErrInsufficientGas(hash(_proposal));\n\n (_successCalls[_i], _returnDatas[_i]) = _proposal.targets[_i].call{\n value: _proposal.values[_i],\n gas: _proposal.gasAmounts[_i]\n }(_proposal.calldatas[_i]);\n\n unchecked {\n ++_i;\n }\n }\n }\n}\n" + }, + "contracts/mainchain/MainchainBridgeManager.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { CoreGovernance } from \"../extensions/sequential-governance/CoreGovernance.sol\";\nimport { GlobalCoreGovernance, GlobalGovernanceRelay } from \"../extensions/sequential-governance/governance-relay/GlobalGovernanceRelay.sol\";\nimport { GovernanceRelay } from \"../extensions/sequential-governance/governance-relay/GovernanceRelay.sol\";\nimport { ContractType, BridgeManager } from \"../extensions/bridge-operator-governance/BridgeManager.sol\";\nimport { Ballot } from \"../libraries/Ballot.sol\";\nimport { Proposal } from \"../libraries/Proposal.sol\";\nimport { GlobalProposal } from \"../libraries/GlobalProposal.sol\";\nimport \"../utils/CommonErrors.sol\";\n\ncontract MainchainBridgeManager is BridgeManager, GovernanceRelay, GlobalGovernanceRelay {\n uint256 private constant DEFAULT_EXPIRY_DURATION = 1 << 255;\n\n constructor(\n uint256 num,\n uint256 denom,\n uint256 roninChainId,\n address bridgeContract,\n address[] memory callbackRegisters,\n address[] memory bridgeOperators,\n address[] memory governors,\n uint96[] memory voteWeights,\n GlobalProposal.TargetOption[] memory targetOptions,\n address[] memory targets\n )\n payable\n CoreGovernance(DEFAULT_EXPIRY_DURATION)\n GlobalCoreGovernance(targetOptions, targets)\n BridgeManager(num, denom, roninChainId, bridgeContract, callbackRegisters, bridgeOperators, governors, voteWeights)\n {}\n\n /**\n * @dev See `GovernanceRelay-_relayProposal`.\n *\n * Requirements:\n * - The method caller is governor.\n */\n function relayProposal(\n Proposal.ProposalDetail calldata proposal,\n Ballot.VoteType[] calldata supports_,\n Signature[] calldata signatures\n ) external onlyGovernor {\n _relayProposal(proposal, supports_, signatures, DOMAIN_SEPARATOR, msg.sender);\n }\n\n /**\n * @dev See `GovernanceRelay-_relayGlobalProposal`.\n *\n * Requirements:\n * - The method caller is governor.\n */\n function relayGlobalProposal(\n GlobalProposal.GlobalProposalDetail calldata globalProposal,\n Ballot.VoteType[] calldata supports_,\n Signature[] calldata signatures\n ) external onlyGovernor {\n _relayGlobalProposal({\n globalProposal: globalProposal,\n supports_: supports_,\n signatures: signatures,\n domainSeparator: DOMAIN_SEPARATOR,\n creator: msg.sender\n });\n }\n\n /**\n * @dev Internal function to retrieve the minimum vote weight required for governance actions.\n * @return minimumVoteWeight The minimum vote weight required for governance actions.\n */\n function _getMinimumVoteWeight() internal view override returns (uint256) {\n return minimumVoteWeight();\n }\n\n /**\n * @dev Returns the expiry duration for a new proposal.\n */\n function getProposalExpiryDuration() external view returns (uint256) {\n return _getProposalExpiryDuration();\n }\n\n /**\n * @dev Internal function to retrieve the total weights of all governors.\n * @return totalWeights The total weights of all governors combined.\n */\n function _getTotalWeights() internal view override returns (uint256) {\n return getTotalWeights();\n }\n\n /**\n * @dev Internal function to calculate the sum of weights for a given array of governors.\n * @param governors An array containing the addresses of governors to calculate the sum of weights.\n * @return sumWeights The sum of weights for the provided governors.\n */\n function _sumWeights(address[] memory governors) internal view override returns (uint256) {\n return _sumGovernorsWeight(governors);\n }\n\n /**\n * @dev Internal function to retrieve the chain type of the contract.\n * @return chainType The chain type, indicating the type of the chain the contract operates on (e.g., Mainchain).\n */\n function _getChainType() internal pure override returns (ChainType) {\n return ChainType.Mainchain;\n }\n}\n" + }, + "contracts/mocks/ronin/MockBridgeManager.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { RoleAccess, ContractType, AddressArrayUtils, IBridgeManager, BridgeManager } from \"../../extensions/bridge-operator-governance/BridgeManager.sol\";\n\ncontract MockBridgeManager is BridgeManager {\n constructor(\n address[] memory bridgeOperators,\n address[] memory governors,\n uint96[] memory voteWeights\n ) payable BridgeManager(0, 0, 0, address(0), _getEmptyAddressArray(), bridgeOperators, governors, voteWeights) {}\n\n function _requireSelfCall() internal view override {}\n\n function _getEmptyAddressArray() internal pure returns (address[] memory arr) {}\n}\n" + }, + "contracts/mocks/ronin/MockRoninBridgeManager.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { RoninBridgeManager } from \"../../ronin/gateway/RoninBridgeManager.sol\";\nimport { GlobalProposal } from \"../../extensions/sequential-governance/governance-proposal/GovernanceProposal.sol\";\n\ncontract MockRoninBridgeManager is RoninBridgeManager {\n constructor(\n uint256 num,\n uint256 denom,\n uint256 roninChainId,\n uint256 expiryDuration,\n address bridgeContract,\n address[] memory callbackRegisters,\n address[] memory bridgeOperators,\n address[] memory governors,\n uint96[] memory voteWeights,\n GlobalProposal.TargetOption[] memory targetOptions,\n address[] memory targets\n )\n RoninBridgeManager(\n num,\n denom,\n roninChainId,\n expiryDuration,\n bridgeContract,\n callbackRegisters,\n bridgeOperators,\n governors,\n voteWeights,\n targetOptions,\n targets\n )\n {}\n}\n" + }, + "contracts/ronin/gateway/RoninBridgeManager.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { ContractType, RoleAccess, ErrUnauthorized, BridgeManager } from \"../../extensions/bridge-operator-governance/BridgeManager.sol\";\nimport { Ballot, GlobalProposal, Proposal, GovernanceProposal } from \"../../extensions/sequential-governance/governance-proposal/GovernanceProposal.sol\";\nimport { CoreGovernance, GlobalCoreGovernance, GlobalGovernanceProposal } from \"../../extensions/sequential-governance/governance-proposal/GlobalGovernanceProposal.sol\";\nimport { VoteStatusConsumer } from \"../../interfaces/consumers/VoteStatusConsumer.sol\";\nimport { ErrQueryForEmptyVote } from \"../../utils/CommonErrors.sol\";\n\ncontract RoninBridgeManager is BridgeManager, GovernanceProposal, GlobalGovernanceProposal {\n constructor(\n uint256 num,\n uint256 denom,\n uint256 roninChainId,\n uint256 expiryDuration,\n address bridgeContract,\n address[] memory callbackRegisters,\n address[] memory bridgeOperators,\n address[] memory governors,\n uint96[] memory voteWeights,\n GlobalProposal.TargetOption[] memory targetOptions,\n address[] memory targets\n )\n payable\n CoreGovernance(expiryDuration)\n GlobalCoreGovernance(targetOptions, targets)\n BridgeManager(num, denom, roninChainId, bridgeContract, callbackRegisters, bridgeOperators, governors, voteWeights)\n {}\n\n /**\n * CURRENT NETWORK\n */\n\n /**\n * @dev See `CoreGovernance-_proposeProposal`.\n *\n * Requirements:\n * - The method caller is governor.\n *\n */\n function propose(\n uint256 _chainId,\n uint256 _expiryTimestamp,\n address[] calldata _targets,\n uint256[] calldata _values,\n bytes[] calldata _calldatas,\n uint256[] calldata _gasAmounts\n ) external onlyGovernor {\n _proposeProposal(_chainId, _expiryTimestamp, _targets, _values, _calldatas, _gasAmounts, msg.sender);\n }\n\n /**\n * @dev See `GovernanceProposal-_proposeProposalStructAndCastVotes`.\n *\n * Requirements:\n * - The method caller is governor.\n * - The proposal is for the current network.\n *\n */\n function proposeProposalStructAndCastVotes(\n Proposal.ProposalDetail calldata _proposal,\n Ballot.VoteType[] calldata _supports,\n Signature[] calldata _signatures\n ) external onlyGovernor {\n _proposeProposalStructAndCastVotes(_proposal, _supports, _signatures, DOMAIN_SEPARATOR, msg.sender);\n }\n\n /**\n * @dev Proposes and casts vote for a proposal on the current network.\n *\n * Requirements:\n * - The method caller is governor.\n * - The proposal is for the current network.\n *\n */\n function proposeProposalForCurrentNetwork(\n uint256 expiryTimestamp,\n address[] calldata targets,\n uint256[] calldata values,\n bytes[] calldata calldatas,\n uint256[] calldata gasAmounts,\n Ballot.VoteType support\n ) external onlyGovernor {\n address _voter = msg.sender;\n Proposal.ProposalDetail memory _proposal = _proposeProposal({\n chainId: block.chainid,\n expiryTimestamp: expiryTimestamp,\n targets: targets,\n values: values,\n calldatas: calldatas,\n gasAmounts: gasAmounts,\n creator: _voter\n });\n _castProposalVoteForCurrentNetwork(_voter, _proposal, support);\n }\n\n /**\n * @dev Casts vote for a proposal on the current network.\n *\n * Requirements:\n * - The method caller is governor.\n *\n */\n function castProposalVoteForCurrentNetwork(\n Proposal.ProposalDetail calldata proposal,\n Ballot.VoteType support\n ) external onlyGovernor {\n _castProposalVoteForCurrentNetwork(msg.sender, proposal, support);\n }\n\n /**\n * @dev See `GovernanceProposal-_castProposalBySignatures`.\n */\n function castProposalBySignatures(\n Proposal.ProposalDetail calldata proposal,\n Ballot.VoteType[] calldata supports_,\n Signature[] calldata signatures\n ) external {\n _castProposalBySignatures(proposal, supports_, signatures, DOMAIN_SEPARATOR);\n }\n\n /**\n * GLOBAL NETWORK\n */\n\n /**\n * @dev See `CoreGovernance-_proposeGlobal`.\n *\n * Requirements:\n * - The method caller is governor.\n *\n */\n function proposeGlobal(\n uint256 expiryTimestamp,\n GlobalProposal.TargetOption[] calldata targetOptions,\n uint256[] calldata values,\n bytes[] calldata calldatas,\n uint256[] calldata gasAmounts\n ) external onlyGovernor {\n _proposeGlobal({\n expiryTimestamp: expiryTimestamp,\n targetOptions: targetOptions,\n values: values,\n calldatas: calldatas,\n gasAmounts: gasAmounts,\n creator: msg.sender\n });\n }\n\n /**\n * @dev See `GovernanceProposal-_proposeGlobalProposalStructAndCastVotes`.\n *\n * Requirements:\n * - The method caller is governor.\n *\n */\n function proposeGlobalProposalStructAndCastVotes(\n GlobalProposal.GlobalProposalDetail calldata globalProposal,\n Ballot.VoteType[] calldata supports_,\n Signature[] calldata signatures\n ) external onlyGovernor {\n _proposeGlobalProposalStructAndCastVotes({\n globalProposal: globalProposal,\n supports_: supports_,\n signatures: signatures,\n domainSeparator: DOMAIN_SEPARATOR,\n creator: msg.sender\n });\n }\n\n /**\n * @dev See `GovernanceProposal-_castGlobalProposalBySignatures`.\n */\n function castGlobalProposalBySignatures(\n GlobalProposal.GlobalProposalDetail calldata globalProposal,\n Ballot.VoteType[] calldata supports_,\n Signature[] calldata signatures\n ) external {\n _castGlobalProposalBySignatures({\n globalProposal: globalProposal,\n supports_: supports_,\n signatures: signatures,\n domainSeparator: DOMAIN_SEPARATOR\n });\n }\n\n /**\n * COMMON METHODS\n */\n\n /**\n * @dev Deletes the expired proposal by its chainId and nonce, without creating a new proposal.\n *\n * Requirements:\n * - The proposal is already created.\n *\n */\n function deleteExpired(uint256 _chainId, uint256 _round) external {\n ProposalVote storage _vote = vote[_chainId][_round];\n if (_vote.hash == 0) revert ErrQueryForEmptyVote();\n\n _tryDeleteExpiredVotingRound(_vote);\n }\n\n /**\n * @dev Returns the expiry duration for a new proposal.\n */\n function getProposalExpiryDuration() external view returns (uint256) {\n return _getProposalExpiryDuration();\n }\n\n /**\n * @dev Internal function to get the chain type of the contract.\n * @return The chain type, indicating the type of the chain the contract operates on (e.g., RoninChain).\n */\n function _getChainType() internal pure override returns (ChainType) {\n return ChainType.RoninChain;\n }\n\n /**\n * @dev Internal function to get the total weights of all governors.\n * @return The total weights of all governors combined.\n */\n function _getTotalWeights() internal view virtual override returns (uint256) {\n return getTotalWeights();\n }\n\n /**\n * @dev Internal function to get the minimum vote weight required for governance actions.\n * @return The minimum vote weight required for governance actions.\n */\n function _getMinimumVoteWeight() internal view virtual override returns (uint256) {\n return minimumVoteWeight();\n }\n\n /**\n * @dev Internal function to get the vote weight of a specific governor.\n * @param _governor The address of the governor to get the vote weight for.\n * @return The vote weight of the specified governor.\n */\n function _getWeight(address _governor) internal view virtual override returns (uint256) {\n return _getGovernorWeight(_governor);\n }\n}\n" + }, + "contracts/ronin/staking/BaseStaking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"../../extensions/RONTransferHelper.sol\";\nimport \"../../extensions/collections/HasContracts.sol\";\nimport \"../../interfaces/staking/IBaseStaking.sol\";\nimport \"../../interfaces/validator/IRoninValidatorSet.sol\";\nimport \"../../libraries/Math.sol\";\nimport { HasValidatorDeprecated } from \"../../utils/DeprecatedSlots.sol\";\nimport \"./RewardCalculation.sol\";\n\nabstract contract BaseStaking is\n RONTransferHelper,\n ReentrancyGuard,\n RewardCalculation,\n HasContracts,\n IBaseStaking,\n HasValidatorDeprecated\n{\n /// @dev Mapping from pool address => staking pool detail\n mapping(address => PoolDetail) internal _stakingPool;\n\n /// @dev The cooldown time in seconds to undelegate from the last timestamp (s)he delegated.\n uint256 internal _cooldownSecsToUndelegate;\n /// @dev The number of seconds that a candidate must wait to be revoked and take the self-staking amount back.\n uint256 internal _waitingSecsToRevoke;\n\n /// @dev Mapping from admin address of an active pool => consensus address.\n mapping(address => address) internal _adminOfActivePoolMapping;\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[49] private ______gap;\n\n modifier noEmptyValue() {\n _requireValue();\n _;\n }\n\n modifier anyExceptPoolAdmin(PoolDetail storage _pool, address _delegator) {\n _anyExceptPoolAdmin(_pool, _delegator);\n _;\n }\n\n modifier onlyPoolAdmin(PoolDetail storage _pool, address _requester) {\n _requirePoolAdmin(_pool, _requester);\n _;\n }\n\n modifier poolIsActive(address _poolAddr) {\n _poolIsActive(_poolAddr);\n _;\n }\n\n function _requireValue() private view {\n if (msg.value == 0) revert ErrZeroValue();\n }\n\n function _requirePoolAdmin(PoolDetail storage _pool, address _requester) private view {\n if (_pool.admin != _requester) revert ErrOnlyPoolAdminAllowed();\n }\n\n function _anyExceptPoolAdmin(PoolDetail storage _pool, address _delegator) private view {\n if (_pool.admin == _delegator) revert ErrPoolAdminForbidden();\n }\n\n function _poolIsActive(address _poolAddr) private view {\n if (!IRoninValidatorSet(getContract(ContractType.VALIDATOR)).isValidatorCandidate(_poolAddr))\n revert ErrInactivePool(_poolAddr);\n }\n\n /**\n * @inheritdoc IBaseStaking\n */\n function isAdminOfActivePool(address _poolAdminAddr) public view override returns (bool) {\n return _adminOfActivePoolMapping[_poolAdminAddr] != address(0);\n }\n\n /**\n * @inheritdoc IBaseStaking\n */\n function getPoolAddressOf(address _poolAdminAddr) external view override returns (address) {\n return _adminOfActivePoolMapping[_poolAdminAddr];\n }\n\n /**\n * @inheritdoc IBaseStaking\n */\n function getPoolDetail(\n address _poolAddr\n ) external view returns (address _admin, uint256 _stakingAmount, uint256 _stakingTotal) {\n PoolDetail storage _pool = _stakingPool[_poolAddr];\n return (_pool.admin, _pool.stakingAmount, _pool.stakingTotal);\n }\n\n /**\n * @inheritdoc IBaseStaking\n */\n function getManySelfStakings(address[] calldata _pools) external view returns (uint256[] memory _selfStakings) {\n _selfStakings = new uint256[](_pools.length);\n for (uint _i = 0; _i < _pools.length; ) {\n _selfStakings[_i] = _stakingPool[_pools[_i]].stakingAmount;\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IRewardPool\n */\n function getStakingTotal(address _poolAddr) public view override returns (uint256) {\n return _stakingPool[_poolAddr].stakingTotal;\n }\n\n /**\n * @inheritdoc IRewardPool\n */\n function getManyStakingTotals(\n address[] calldata _poolList\n ) public view override returns (uint256[] memory _stakingAmounts) {\n _stakingAmounts = new uint256[](_poolList.length);\n for (uint _i = 0; _i < _poolList.length; ) {\n _stakingAmounts[_i] = getStakingTotal(_poolList[_i]);\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IRewardPool\n */\n function getStakingAmount(address _poolAddr, address _user) public view override returns (uint256) {\n return _stakingPool[_poolAddr].delegatingAmount[_user];\n }\n\n /**\n * @inheritdoc IRewardPool\n */\n function getManyStakingAmounts(\n address[] calldata _poolAddrs,\n address[] calldata _userList\n ) external view override returns (uint256[] memory _stakingAmounts) {\n if (_poolAddrs.length != _userList.length) revert ErrInvalidArrays();\n _stakingAmounts = new uint256[](_poolAddrs.length);\n for (uint _i = 0; _i < _stakingAmounts.length; ) {\n _stakingAmounts[_i] = _stakingPool[_poolAddrs[_i]].delegatingAmount[_userList[_i]];\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IBaseStaking\n */\n function cooldownSecsToUndelegate() external view returns (uint256) {\n return _cooldownSecsToUndelegate;\n }\n\n /**\n * @inheritdoc IBaseStaking\n */\n function waitingSecsToRevoke() external view returns (uint256) {\n return _waitingSecsToRevoke;\n }\n\n /**\n * @inheritdoc IBaseStaking\n */\n function setCooldownSecsToUndelegate(uint256 _cooldownSecs) external override onlyAdmin {\n _setCooldownSecsToUndelegate(_cooldownSecs);\n }\n\n /**\n * @inheritdoc IBaseStaking\n */\n function setWaitingSecsToRevoke(uint256 _secs) external override onlyAdmin {\n _setWaitingSecsToRevoke(_secs);\n }\n\n /**\n * @dev Sets the minium number of seconds to undelegate.\n *\n * Emits the event `CooldownSecsToUndelegateUpdated`.\n *\n */\n function _setCooldownSecsToUndelegate(uint256 _cooldownSecs) internal {\n _cooldownSecsToUndelegate = _cooldownSecs;\n emit CooldownSecsToUndelegateUpdated(_cooldownSecs);\n }\n\n /**\n * @dev Sets the number of seconds that a candidate must wait to be revoked.\n *\n * Emits the event `WaitingSecsToRevokeUpdated`.\n *\n */\n function _setWaitingSecsToRevoke(uint256 _secs) internal {\n _waitingSecsToRevoke = _secs;\n emit WaitingSecsToRevokeUpdated(_secs);\n }\n\n /**\n * @dev Changes the delegate amount.\n */\n function _changeDelegatingAmount(\n PoolDetail storage _pool,\n address _delegator,\n uint256 _newDelegatingAmount,\n uint256 _newStakingTotal\n ) internal {\n _syncUserReward(_pool.addr, _delegator, _newDelegatingAmount);\n _pool.stakingTotal = _newStakingTotal;\n _pool.delegatingAmount[_delegator] = _newDelegatingAmount;\n }\n}\n" + }, + "contracts/ronin/staking/CandidateStaking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../extensions/consumers/GlobalConfigConsumer.sol\";\nimport \"../../extensions/consumers/PercentageConsumer.sol\";\nimport \"../../libraries/AddressArrayUtils.sol\";\nimport \"../../interfaces/staking/ICandidateStaking.sol\";\nimport \"./BaseStaking.sol\";\n\nabstract contract CandidateStaking is BaseStaking, ICandidateStaking, GlobalConfigConsumer, PercentageConsumer {\n /// @dev The minimum threshold for being a validator candidate.\n uint256 internal _minValidatorStakingAmount;\n\n /// @dev The max commission rate that the validator can set (in range of [0;100_00] means [0-100%])\n uint256 internal _maxCommissionRate;\n /// @dev The min commission rate that the validator can set (in range of [0;100_00] means [0-100%])\n uint256 internal _minCommissionRate;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[48] ______gap;\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function minValidatorStakingAmount() public view override returns (uint256) {\n return _minValidatorStakingAmount;\n }\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function getCommissionRateRange() external view override returns (uint256, uint256) {\n return (_minCommissionRate, _maxCommissionRate);\n }\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function setMinValidatorStakingAmount(uint256 _threshold) external override onlyAdmin {\n _setMinValidatorStakingAmount(_threshold);\n }\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function setCommissionRateRange(uint256 _minRate, uint256 _maxRate) external override onlyAdmin {\n _setCommissionRateRange(_minRate, _maxRate);\n }\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function applyValidatorCandidate(\n address _candidateAdmin,\n address _consensusAddr,\n address payable _treasuryAddr,\n uint256 _commissionRate\n ) external payable override nonReentrant {\n if (isAdminOfActivePool(msg.sender)) revert ErrAdminOfAnyActivePoolForbidden(msg.sender);\n if (_commissionRate > _maxCommissionRate || _commissionRate < _minCommissionRate) revert ErrInvalidCommissionRate();\n\n uint256 _amount = msg.value;\n address payable _poolAdmin = payable(msg.sender);\n _applyValidatorCandidate({\n _poolAdmin: _poolAdmin,\n _candidateAdmin: _candidateAdmin,\n _consensusAddr: _consensusAddr,\n _treasuryAddr: _treasuryAddr,\n _commissionRate: _commissionRate,\n _amount: _amount\n });\n\n PoolDetail storage _pool = _stakingPool[_consensusAddr];\n _pool.admin = _poolAdmin;\n _pool.addr = _consensusAddr;\n _adminOfActivePoolMapping[_poolAdmin] = _consensusAddr;\n\n _stake(_stakingPool[_consensusAddr], _poolAdmin, _amount);\n emit PoolApproved(_consensusAddr, _poolAdmin);\n }\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function requestUpdateCommissionRate(\n address _consensusAddr,\n uint256 _effectiveDaysOnwards,\n uint256 _commissionRate\n ) external override poolIsActive(_consensusAddr) onlyPoolAdmin(_stakingPool[_consensusAddr], msg.sender) {\n if (_commissionRate > _maxCommissionRate || _commissionRate < _minCommissionRate) revert ErrInvalidCommissionRate();\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execRequestUpdateCommissionRate(\n _consensusAddr,\n _effectiveDaysOnwards,\n _commissionRate\n );\n }\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function execDeprecatePools(\n address[] calldata _pools,\n uint256 _newPeriod\n ) external override onlyContract(ContractType.VALIDATOR) {\n if (_pools.length == 0) {\n return;\n }\n\n for (uint _i = 0; _i < _pools.length; ) {\n PoolDetail storage _pool = _stakingPool[_pools[_i]];\n // Deactivate the pool admin in the active mapping.\n delete _adminOfActivePoolMapping[_pool.admin];\n\n // Deduct and transfer the self staking amount to the pool admin.\n uint256 _deductingAmount = _pool.stakingAmount;\n if (_deductingAmount > 0) {\n _deductStakingAmount(_pool, _deductingAmount);\n if (!_unsafeSendRONLimitGas(payable(_pool.admin), _deductingAmount, DEFAULT_ADDITION_GAS)) {\n emit StakingAmountTransferFailed(_pool.addr, _pool.admin, _deductingAmount, address(this).balance);\n }\n }\n\n // Settle the unclaimed reward and transfer to the pool admin.\n uint256 _lastRewardAmount = _claimReward(_pools[_i], _pool.admin, _newPeriod);\n if (_lastRewardAmount > 0) {\n _unsafeSendRONLimitGas(payable(_pool.admin), _lastRewardAmount, DEFAULT_ADDITION_GAS);\n }\n\n unchecked {\n ++_i;\n }\n }\n\n emit PoolsDeprecated(_pools);\n }\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function stake(address _consensusAddr) external payable override noEmptyValue poolIsActive(_consensusAddr) {\n _stake(_stakingPool[_consensusAddr], msg.sender, msg.value);\n }\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function unstake(\n address _consensusAddr,\n uint256 _amount\n ) external override nonReentrant poolIsActive(_consensusAddr) {\n if (_amount == 0) revert ErrUnstakeZeroAmount();\n address _requester = msg.sender;\n PoolDetail storage _pool = _stakingPool[_consensusAddr];\n uint256 _remainAmount = _pool.stakingAmount - _amount;\n if (_remainAmount < _minValidatorStakingAmount) revert ErrStakingAmountLeft();\n\n _unstake(_pool, _requester, _amount);\n if (!_unsafeSendRONLimitGas(payable(_requester), _amount, DEFAULT_ADDITION_GAS)) revert ErrCannotTransferRON();\n }\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function requestRenounce(\n address _consensusAddr\n ) external override poolIsActive(_consensusAddr) onlyPoolAdmin(_stakingPool[_consensusAddr], msg.sender) {\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execRequestRenounceCandidate(\n _consensusAddr,\n _waitingSecsToRevoke\n );\n }\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function requestEmergencyExit(\n address _consensusAddr\n ) external override poolIsActive(_consensusAddr) onlyPoolAdmin(_stakingPool[_consensusAddr], msg.sender) {\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execEmergencyExit(_consensusAddr, _waitingSecsToRevoke);\n }\n\n /**\n * @dev See `ICandidateStaking-applyValidatorCandidate`\n */\n function _applyValidatorCandidate(\n address payable _poolAdmin,\n address _candidateAdmin,\n address _consensusAddr,\n address payable _treasuryAddr,\n uint256 _commissionRate,\n uint256 _amount\n ) internal {\n if (!_unsafeSendRONLimitGas(_poolAdmin, 0, DEFAULT_ADDITION_GAS))\n revert ErrCannotInitTransferRON(_poolAdmin, \"pool admin\");\n if (!_unsafeSendRONLimitGas(_treasuryAddr, 0, DEFAULT_ADDITION_GAS))\n revert ErrCannotInitTransferRON(_treasuryAddr, \"treasury\");\n if (_amount < _minValidatorStakingAmount) revert ErrInsufficientStakingAmount();\n if (_poolAdmin != _candidateAdmin || _candidateAdmin != _treasuryAddr) revert ErrThreeInteractionAddrsNotEqual();\n\n {\n address[] memory _diffAddrs = new address[](2);\n _diffAddrs[0] = _poolAdmin;\n _diffAddrs[1] = _consensusAddr;\n if (AddressArrayUtils.hasDuplicate(_diffAddrs)) revert AddressArrayUtils.ErrDuplicated(msg.sig);\n }\n\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execApplyValidatorCandidate(\n _candidateAdmin,\n _consensusAddr,\n _treasuryAddr,\n _commissionRate\n );\n }\n\n /**\n * @dev See `ICandidateStaking-stake`\n */\n function _stake(\n PoolDetail storage _pool,\n address _requester,\n uint256 _amount\n ) internal onlyPoolAdmin(_pool, _requester) {\n _pool.stakingAmount += _amount;\n _changeDelegatingAmount(_pool, _requester, _pool.stakingAmount, _pool.stakingTotal + _amount);\n _pool.lastDelegatingTimestamp[_requester] = block.timestamp;\n emit Staked(_pool.addr, _amount);\n }\n\n /**\n * @dev See `ICandidateStaking-unstake`\n */\n function _unstake(\n PoolDetail storage _pool,\n address _requester,\n uint256 _amount\n ) internal onlyPoolAdmin(_pool, _requester) {\n if (_amount > _pool.stakingAmount) revert ErrInsufficientStakingAmount();\n if (_pool.lastDelegatingTimestamp[_requester] + _cooldownSecsToUndelegate > block.timestamp) {\n revert ErrUnstakeTooEarly();\n }\n\n _pool.stakingAmount -= _amount;\n _changeDelegatingAmount(_pool, _requester, _pool.stakingAmount, _pool.stakingTotal - _amount);\n emit Unstaked(_pool.addr, _amount);\n }\n\n /**\n * @dev Deducts from staking amount of the validator `_consensusAddr` for `_amount`.\n *\n * Emits the event `Unstaked`.\n *\n * @return The actual deducted amount\n */\n function _deductStakingAmount(PoolDetail storage _pool, uint256 _amount) internal virtual returns (uint256);\n\n /**\n * @dev Sets the minimum threshold for being a validator candidate.\n *\n * Emits the `MinValidatorStakingAmountUpdated` event.\n *\n */\n function _setMinValidatorStakingAmount(uint256 _threshold) internal {\n _minValidatorStakingAmount = _threshold;\n emit MinValidatorStakingAmountUpdated(_threshold);\n }\n\n /**\n * @dev Sets the max commission rate that a candidate can set.\n *\n * Emits the `MaxCommissionRateUpdated` event.\n *\n */\n function _setCommissionRateRange(uint256 _minRate, uint256 _maxRate) internal {\n if (_maxRate > _MAX_PERCENTAGE || _minRate > _maxRate) revert ErrInvalidCommissionRate();\n _maxCommissionRate = _maxRate;\n _minCommissionRate = _minRate;\n emit CommissionRateRangeUpdated(_minRate, _maxRate);\n }\n}\n" + }, + "contracts/ronin/staking/DelegatorStaking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../interfaces/staking/IDelegatorStaking.sol\";\nimport \"./BaseStaking.sol\";\n\nabstract contract DelegatorStaking is BaseStaking, IDelegatorStaking {\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[50] private ______gap;\n\n /**\n * @inheritdoc IDelegatorStaking\n */\n function delegate(address _consensusAddr) external payable noEmptyValue poolIsActive(_consensusAddr) {\n if (isAdminOfActivePool(msg.sender)) revert ErrAdminOfAnyActivePoolForbidden(msg.sender);\n _delegate(_stakingPool[_consensusAddr], msg.sender, msg.value);\n }\n\n /**\n * @inheritdoc IDelegatorStaking\n */\n function undelegate(address _consensusAddr, uint256 _amount) external nonReentrant {\n address payable _delegator = payable(msg.sender);\n _undelegate(_stakingPool[_consensusAddr], _delegator, _amount);\n if (!_sendRON(_delegator, _amount)) revert ErrCannotTransferRON();\n }\n\n /**\n * @inheritdoc IDelegatorStaking\n */\n function bulkUndelegate(address[] calldata _consensusAddrs, uint256[] calldata _amounts) external nonReentrant {\n if (_consensusAddrs.length == 0 || _consensusAddrs.length != _amounts.length) revert ErrInvalidArrays();\n\n address payable _delegator = payable(msg.sender);\n uint256 _total;\n\n for (uint _i = 0; _i < _consensusAddrs.length; ) {\n _total += _amounts[_i];\n _undelegate(_stakingPool[_consensusAddrs[_i]], _delegator, _amounts[_i]);\n\n unchecked {\n ++_i;\n }\n }\n\n if (!_sendRON(_delegator, _total)) revert ErrCannotTransferRON();\n }\n\n /**\n * @inheritdoc IDelegatorStaking\n */\n function redelegate(\n address _consensusAddrSrc,\n address _consensusAddrDst,\n uint256 _amount\n ) external nonReentrant poolIsActive(_consensusAddrDst) {\n address _delegator = msg.sender;\n _undelegate(_stakingPool[_consensusAddrSrc], _delegator, _amount);\n _delegate(_stakingPool[_consensusAddrDst], _delegator, _amount);\n }\n\n /**\n * @inheritdoc IDelegatorStaking\n */\n function claimRewards(\n address[] calldata _consensusAddrList\n ) external override nonReentrant returns (uint256 _amount) {\n _amount = _claimRewards(msg.sender, _consensusAddrList);\n _transferRON(payable(msg.sender), _amount);\n }\n\n /**\n * @inheritdoc IDelegatorStaking\n */\n function delegateRewards(\n address[] calldata _consensusAddrList,\n address _consensusAddrDst\n ) external override nonReentrant poolIsActive(_consensusAddrDst) returns (uint256 _amount) {\n if (isAdminOfActivePool(msg.sender)) revert ErrAdminOfAnyActivePoolForbidden(msg.sender);\n return _delegateRewards(msg.sender, _consensusAddrList, _consensusAddrDst);\n }\n\n /**\n * @inheritdoc IDelegatorStaking\n */\n function getRewards(\n address _user,\n address[] calldata _poolAddrList\n ) external view returns (uint256[] memory _rewards) {\n address _consensusAddr;\n uint256 _period = IRoninValidatorSet(getContract(ContractType.VALIDATOR)).currentPeriod();\n _rewards = new uint256[](_poolAddrList.length);\n\n for (uint256 _i = 0; _i < _poolAddrList.length; ) {\n _consensusAddr = _poolAddrList[_i];\n _rewards[_i] = _getReward(_consensusAddr, _user, _period, getStakingAmount(_consensusAddr, _user));\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @dev Delegates from a validator address.\n *\n * Requirements:\n * - The delegator is not the pool admin.\n *\n * Emits the `Delegated` event.\n *\n * Note: This function does not verify the `msg.value` with the amount.\n *\n */\n function _delegate(\n PoolDetail storage _pool,\n address _delegator,\n uint256 _amount\n ) internal anyExceptPoolAdmin(_pool, _delegator) {\n _changeDelegatingAmount(\n _pool,\n _delegator,\n _pool.delegatingAmount[_delegator] + _amount,\n _pool.stakingTotal + _amount\n );\n _pool.lastDelegatingTimestamp[_delegator] = block.timestamp;\n emit Delegated(_delegator, _pool.addr, _amount);\n }\n\n /**\n * @dev Undelegates from a validator address.\n *\n * Requirements:\n * - The delegator is not the pool admin.\n * - The amount is larger than 0.\n * - The delegating amount is larger than or equal to the undelegating amount.\n *\n * Emits the `Undelegated` event.\n *\n * Note: Consider transferring back the amount of RON after calling this function.\n *\n */\n function _undelegate(\n PoolDetail storage _pool,\n address _delegator,\n uint256 _amount\n ) private anyExceptPoolAdmin(_pool, _delegator) {\n if (_amount == 0) revert ErrUndelegateZeroAmount();\n if (_pool.delegatingAmount[_delegator] < _amount) revert ErrInsufficientDelegatingAmount();\n\n IRoninValidatorSet _validatorContract = IRoninValidatorSet(getContract(ContractType.VALIDATOR));\n if (\n _validatorContract.isValidatorCandidate(_pool.addr) &&\n _validatorContract.getCandidateInfo(_pool.addr).revokingTimestamp == 0 && // if candidate is not on renunciation\n _pool.lastDelegatingTimestamp[_delegator] + _cooldownSecsToUndelegate >= block.timestamp // delegator is still in cooldown\n ) revert ErrUndelegateTooEarly();\n\n _changeDelegatingAmount(\n _pool,\n _delegator,\n _pool.delegatingAmount[_delegator] - _amount,\n _pool.stakingTotal - _amount\n );\n emit Undelegated(_delegator, _pool.addr, _amount);\n }\n\n /**\n * @dev Claims rewards from the pools `_poolAddrList`.\n * Note: This function does not transfer reward to user.\n */\n function _claimRewards(address _user, address[] memory _poolAddrList) internal returns (uint256 _amount) {\n uint256 _period = _currentPeriod();\n for (uint256 _i = 0; _i < _poolAddrList.length; ) {\n _amount += _claimReward(_poolAddrList[_i], _user, _period);\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @dev Claims the rewards and delegates them to the consensus address.\n */\n function _delegateRewards(\n address _user,\n address[] calldata _poolAddrList,\n address _poolAddrDst\n ) internal returns (uint256 _amount) {\n _amount = _claimRewards(_user, _poolAddrList);\n _delegate(_stakingPool[_poolAddrDst], _user, _amount);\n }\n}\n" + }, + "contracts/ronin/staking/RewardCalculation.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../interfaces/staking/IRewardPool.sol\";\nimport \"../../libraries/Math.sol\";\n\n/**\n * @title RewardCalculation contract\n * @dev This contract mainly contains the methods to calculate reward for staking contract.\n */\nabstract contract RewardCalculation is IRewardPool {\n /// @dev Mapping from pool address => period number => accumulated rewards per share (one unit staking)\n mapping(address => mapping(uint256 => PeriodWrapper)) private _accumulatedRps;\n /// @dev Mapping from the pool address => user address => the reward info of the user\n mapping(address => mapping(address => UserRewardFields)) private _userReward;\n /// @dev Mapping from the pool address => reward pool fields\n mapping(address => PoolFields) private _stakingPool;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[50] private ______gap;\n\n /**\n * @inheritdoc IRewardPool\n */\n function getReward(address _poolAddr, address _user) external view returns (uint256) {\n return _getReward(_poolAddr, _user, _currentPeriod(), getStakingAmount(_poolAddr, _user));\n }\n\n /**\n * @inheritdoc IRewardPool\n */\n function getStakingAmount(address _poolAddr, address _user) public view virtual returns (uint256);\n\n /**\n * @inheritdoc IRewardPool\n */\n function getStakingTotal(address _poolAddr) public view virtual returns (uint256);\n\n /**\n * @dev Returns the reward amount that user claimable.\n */\n function _getReward(\n address _poolAddr,\n address _user,\n uint256 _latestPeriod,\n uint256 _latestStakingAmount\n ) internal view returns (uint256) {\n UserRewardFields storage _reward = _userReward[_poolAddr][_user];\n\n if (_reward.lastPeriod == _latestPeriod) {\n return _reward.debited;\n }\n\n uint256 _aRps;\n uint256 _lastPeriodReward;\n PoolFields storage _pool = _stakingPool[_poolAddr];\n PeriodWrapper storage _wrappedArps = _accumulatedRps[_poolAddr][_reward.lastPeriod];\n\n if (_wrappedArps.lastPeriod > 0) {\n // Calculates the last period reward if the aRps at the period is set\n _aRps = _wrappedArps.inner;\n _lastPeriodReward = _reward.lowestAmount * (_aRps - _reward.aRps);\n } else {\n // Fallbacks to the previous aRps in case the aRps is not set\n _aRps = _reward.aRps;\n }\n\n uint256 _newPeriodsReward = _latestStakingAmount * (_pool.aRps - _aRps);\n return _reward.debited + (_lastPeriodReward + _newPeriodsReward) / 1e18;\n }\n\n /**\n * @dev Syncs the user reward.\n *\n * Emits the event `UserRewardUpdated` once the debit amount is updated.\n * Emits the event `PoolSharesUpdated` once the pool share is updated.\n *\n * Note: The method should be called whenever the user's staking amount changes.\n *\n */\n function _syncUserReward(address _poolAddr, address _user, uint256 _newStakingAmount) internal {\n uint256 _period = _currentPeriod();\n PoolFields storage _pool = _stakingPool[_poolAddr];\n uint256 _lastShares = _pool.shares.inner;\n\n // Updates the pool shares if it is outdated\n if (_pool.shares.lastPeriod < _period) {\n _pool.shares = PeriodWrapper(getStakingTotal(_poolAddr), _period);\n }\n\n UserRewardFields storage _reward = _userReward[_poolAddr][_user];\n uint256 _currentStakingAmount = getStakingAmount(_poolAddr, _user);\n uint256 _debited = _getReward(_poolAddr, _user, _period, _currentStakingAmount);\n\n if (_reward.debited != _debited) {\n _reward.debited = _debited;\n emit UserRewardUpdated(_poolAddr, _user, _debited);\n }\n\n _syncMinStakingAmount(_pool, _reward, _period, _newStakingAmount, _currentStakingAmount);\n _reward.aRps = _pool.aRps;\n _reward.lastPeriod = _period;\n\n if (_pool.shares.inner != _lastShares) {\n emit PoolSharesUpdated(_period, _poolAddr, _pool.shares.inner);\n }\n }\n\n /**\n * @dev Syncs the minimum staking amount of an user in the current period.\n */\n function _syncMinStakingAmount(\n PoolFields storage _pool,\n UserRewardFields storage _reward,\n uint256 _latestPeriod,\n uint256 _newStakingAmount,\n uint256 _currentStakingAmount\n ) internal {\n if (_reward.lastPeriod < _latestPeriod) {\n _reward.lowestAmount = _currentStakingAmount;\n }\n\n uint256 _lowestAmount = Math.min(_reward.lowestAmount, _newStakingAmount);\n uint256 _diffAmount = _reward.lowestAmount - _lowestAmount;\n if (_diffAmount > 0) {\n _reward.lowestAmount = _lowestAmount;\n if (_pool.shares.inner < _diffAmount) revert ErrInvalidPoolShare();\n _pool.shares.inner -= _diffAmount;\n }\n }\n\n /**\n * @dev Claims the settled reward for a specific user.\n *\n * @param _lastPeriod Must be in two possible value: `_currentPeriod` in normal calculation, or\n * `_currentPeriod + 1` in case of calculating the reward for revoked validators.\n *\n * Emits the `RewardClaimed` event and the `UserRewardUpdated` event.\n *\n * Note: This method should be called before transferring rewards for the user.\n *\n */\n function _claimReward(address _poolAddr, address _user, uint256 _lastPeriod) internal returns (uint256 _amount) {\n uint256 _currentStakingAmount = getStakingAmount(_poolAddr, _user);\n _amount = _getReward(_poolAddr, _user, _lastPeriod, _currentStakingAmount);\n emit RewardClaimed(_poolAddr, _user, _amount);\n\n UserRewardFields storage _reward = _userReward[_poolAddr][_user];\n _reward.debited = 0;\n _syncMinStakingAmount(_stakingPool[_poolAddr], _reward, _lastPeriod, _currentStakingAmount, _currentStakingAmount);\n _reward.lastPeriod = _lastPeriod;\n _reward.aRps = _stakingPool[_poolAddr].aRps;\n emit UserRewardUpdated(_poolAddr, _user, 0);\n }\n\n /**\n * @dev Records the amount of rewards `_rewards` for the pools `_poolAddrs`.\n *\n * Emits the event `PoolsUpdated` once the contract recorded the rewards successfully.\n * Emits the event `PoolsUpdateFailed` once the input array lengths are not equal.\n * Emits the event `PoolUpdateConflicted` when the pool is already updated in the period.\n *\n * Note: This method should be called once at the period ending.\n *\n */\n function _recordRewards(address[] memory _poolAddrs, uint256[] calldata _rewards, uint256 _period) internal {\n if (_poolAddrs.length != _rewards.length) {\n emit PoolsUpdateFailed(_period, _poolAddrs, _rewards);\n return;\n }\n\n uint256 _rps;\n uint256 _count;\n address _poolAddr;\n uint256 _stakingTotal;\n uint256[] memory _aRps = new uint256[](_poolAddrs.length);\n uint256[] memory _shares = new uint256[](_poolAddrs.length);\n address[] memory _conflicted = new address[](_poolAddrs.length);\n\n for (uint _i = 0; _i < _poolAddrs.length; _i++) {\n _poolAddr = _poolAddrs[_i];\n PoolFields storage _pool = _stakingPool[_poolAddr];\n _stakingTotal = getStakingTotal(_poolAddr);\n\n if (_accumulatedRps[_poolAddr][_period].lastPeriod == _period) {\n unchecked {\n _conflicted[_count++] = _poolAddr;\n }\n continue;\n }\n\n // Updates the pool shares if it is outdated\n if (_pool.shares.lastPeriod < _period) {\n _pool.shares = PeriodWrapper(_stakingTotal, _period);\n }\n\n // The rps is 0 if no one stakes for the pool\n _rps = _pool.shares.inner == 0 ? 0 : (_rewards[_i] * 1e18) / _pool.shares.inner;\n _aRps[_i - _count] = _pool.aRps += _rps;\n _accumulatedRps[_poolAddr][_period] = PeriodWrapper(_pool.aRps, _period);\n _pool.shares.inner = _stakingTotal;\n _shares[_i - _count] = _pool.shares.inner;\n _poolAddrs[_i - _count] = _poolAddr;\n }\n\n if (_count > 0) {\n assembly {\n mstore(_conflicted, _count)\n mstore(_poolAddrs, sub(mload(_poolAddrs), _count))\n }\n emit PoolsUpdateConflicted(_period, _conflicted);\n }\n\n if (_poolAddrs.length > 0) {\n emit PoolsUpdated(_period, _poolAddrs, _aRps, _shares);\n }\n }\n\n /**\n * @dev Returns the current period.\n */\n function _currentPeriod() internal view virtual returns (uint256);\n}\n" + }, + "contracts/ronin/staking/Staking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport \"../../libraries/Math.sol\";\nimport \"../../interfaces/staking/IStaking.sol\";\nimport \"../../interfaces/validator/IRoninValidatorSet.sol\";\nimport \"./CandidateStaking.sol\";\nimport \"./DelegatorStaking.sol\";\n\ncontract Staking is IStaking, CandidateStaking, DelegatorStaking, Initializable {\n constructor() {\n _disableInitializers();\n }\n\n receive() external payable onlyContract(ContractType.VALIDATOR) {}\n\n fallback() external payable onlyContract(ContractType.VALIDATOR) {}\n\n /**\n * @dev Initializes the contract storage.\n */\n function initialize(\n address __validatorContract,\n uint256 __minValidatorStakingAmount,\n uint256 __maxCommissionRate,\n uint256 __cooldownSecsToUndelegate,\n uint256 __waitingSecsToRevoke\n ) external initializer {\n _setContract(ContractType.VALIDATOR, __validatorContract);\n _setMinValidatorStakingAmount(__minValidatorStakingAmount);\n _setCommissionRateRange(0, __maxCommissionRate);\n _setCooldownSecsToUndelegate(__cooldownSecsToUndelegate);\n _setWaitingSecsToRevoke(__waitingSecsToRevoke);\n }\n\n function initializeV2() external reinitializer(2) {\n _setContract(ContractType.VALIDATOR, ______deprecatedValidator);\n delete ______deprecatedValidator;\n }\n\n /**\n * @dev This method only work on testnet, to hotfix the applied validator candidate that is failed.\n * Should remove this method before deploying it on mainnet.\n */\n function tmp_re_applyValidatorCandidate(\n address _candidateAdmin,\n address _consensusAddr,\n address payable _treasuryAddr,\n uint256 _commissionRate\n ) external {\n require(block.chainid == 2021, \"E1\");\n require(msg.sender == 0x57832A94810E18c84a5A5E2c4dD67D012ade574F, \"E2\");\n\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execApplyValidatorCandidate(\n _candidateAdmin,\n _consensusAddr,\n _treasuryAddr,\n _commissionRate\n );\n }\n\n /**\n * @inheritdoc IStaking\n */\n function execRecordRewards(\n address[] calldata _consensusAddrs,\n uint256[] calldata _rewards,\n uint256 _period\n ) external payable override onlyContract(ContractType.VALIDATOR) {\n _recordRewards(_consensusAddrs, _rewards, _period);\n }\n\n /**\n * @inheritdoc IStaking\n */\n function execDeductStakingAmount(\n address _consensusAddr,\n uint256 _amount\n ) external override onlyContract(ContractType.VALIDATOR) returns (uint256 _actualDeductingAmount) {\n _actualDeductingAmount = _deductStakingAmount(_stakingPool[_consensusAddr], _amount);\n address payable _validatorContractAddr = payable(msg.sender);\n if (!_unsafeSendRON(_validatorContractAddr, _actualDeductingAmount)) {\n emit StakingAmountDeductFailed(\n _consensusAddr,\n _validatorContractAddr,\n _actualDeductingAmount,\n address(this).balance\n );\n }\n }\n\n /**\n * @inheritdoc RewardCalculation\n */\n function _currentPeriod() internal view virtual override returns (uint256) {\n return IRoninValidatorSet(getContract(ContractType.VALIDATOR)).currentPeriod();\n }\n\n /**\n * @inheritdoc CandidateStaking\n */\n function _deductStakingAmount(\n PoolDetail storage _pool,\n uint256 _amount\n ) internal override returns (uint256 _actualDeductingAmount) {\n _actualDeductingAmount = Math.min(_pool.stakingAmount, _amount);\n\n _pool.stakingAmount -= _actualDeductingAmount;\n _changeDelegatingAmount(\n _pool,\n _pool.admin,\n _pool.stakingAmount,\n Math.subNonNegative(_pool.stakingTotal, _actualDeductingAmount)\n );\n emit Unstaked(_pool.addr, _actualDeductingAmount);\n }\n}\n" + }, + "contracts/types/operations/LibTUint256Slot.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.17;\n\nimport { TUint256Slot } from \"../Types.sol\";\n\n/**\n * @title LibTUint256Slot\n * @dev Library for handling unsigned 256-bit integers.\n */\nlibrary LibTUint256Slot {\n /// @dev value is equal to bytes4(keccak256(\"Panic(uint256)\"))\n /// @dev see: https://github.com/foundry-rs/forge-std/blob/master/src/StdError.sol\n uint256 private constant PANIC_ERROR_SIGNATURE = 0x4e487b71;\n /// @dev error code for {Arithmetic over/underflow} error\n uint256 private constant ARITHMETIC_ERROR_CODE = 0x11;\n /// @dev error code for {Division or modulo by 0} error\n uint256 private constant DIVISION_ERROR_CODE = 0x12;\n\n /**\n * @dev Loads the value of the TUint256Slot variable.\n * @param self The TUint256Slot variable.\n * @return val The loaded value.\n */\n function load(TUint256Slot self) internal view returns (uint256 val) {\n assembly {\n val := sload(self)\n }\n }\n\n /**\n * @dev Stores a value into the TUint256Slot variable.\n * @param self The TUint256Slot variable.\n * @param other The value to be stored.\n */\n function store(TUint256Slot self, uint256 other) internal {\n assembly {\n sstore(self, other)\n }\n }\n\n /**\n * @dev Multiplies the TUint256Slot variable by a given value.\n * @param self The TUint256Slot variable.\n * @param other The value to multiply by.\n * @return res The resulting value after multiplication.\n */\n function mul(TUint256Slot self, uint256 other) internal view returns (uint256 res) {\n assembly {\n let storedVal := sload(self)\n if iszero(iszero(storedVal)) {\n res := mul(storedVal, other)\n\n // Overflow check\n if iszero(eq(other, div(res, storedVal))) {\n // Store 4 bytes the function selector of Panic(uint256)\n // Equivalent to revert Panic(uint256)\n mstore(0x00, PANIC_ERROR_SIGNATURE)\n // Store 4 bytes of division error code in the next slot\n mstore(0x20, ARITHMETIC_ERROR_CODE)\n // Revert 36 bytes of error starting from 0x1c\n revert(0x1c, 0x24)\n }\n }\n }\n }\n\n /**\n * @dev Divides the TUint256Slot variable by a given value.\n * @param self The TUint256Slot variable.\n * @param other The value to divide by.\n * @return res The resulting value after division.\n */\n function div(TUint256Slot self, uint256 other) internal view returns (uint256 res) {\n assembly {\n let storedVal := sload(self)\n // revert if divide by zero\n if iszero(other) {\n // Store 4 bytes the function selector of Panic(uint256)\n // Equivalent to revert Panic(uint256)\n mstore(0x00, PANIC_ERROR_SIGNATURE)\n // Store 4 bytes of division error code in the next slot\n mstore(0x20, DIVISION_ERROR_CODE)\n // Revert 36 bytes of error starting from 0x1c\n revert(0x1c, 0x24)\n }\n res := div(storedVal, other)\n }\n }\n\n /**\n * @dev Subtracts a given value from the TUint256Slot variable.\n * @param self The TUint256Slot variable.\n * @param other The value to subtract.\n * @return res The resulting value after subtraction.\n */\n function sub(TUint256Slot self, uint256 other) internal view returns (uint256 res) {\n assembly {\n let storedVal := sload(self)\n\n // Underflow check\n if lt(storedVal, other) {\n // Store 4 bytes the function selector of Panic(uint256)\n // Equivalent to revert Panic(uint256)\n mstore(0x00, PANIC_ERROR_SIGNATURE)\n // Store 4 bytes of division error code in the next slot\n mstore(0x20, ARITHMETIC_ERROR_CODE)\n // Revert 36 bytes of error starting from 0x1c\n revert(0x1c, 0x24)\n }\n\n res := sub(storedVal, other)\n }\n }\n\n /**\n * @dev Adds a given value to the TUint256Slot variable.\n * @param self The TUint256Slot variable.\n * @param other The value to add.\n * @return res The resulting value after addition.\n */\n function add(TUint256Slot self, uint256 other) internal view returns (uint256 res) {\n assembly {\n let storedVal := sload(self)\n res := add(storedVal, other)\n\n // Overflow check\n if lt(res, other) {\n // Store 4 bytes the function selector of Panic(uint256)\n // Equivalent to revert Panic(uint256)\n mstore(0x00, PANIC_ERROR_SIGNATURE)\n // Store 4 bytes of division error code in the next slot\n mstore(0x20, ARITHMETIC_ERROR_CODE)\n // Revert 36 bytes of error starting from 0x1c\n revert(0x1c, 0x24)\n }\n }\n }\n\n /**\n * @dev Increments the TUint256Slot variable by 1 and returns the new value.\n * @param self The TUint256Slot variable.\n * @return res The resulting value after incrementing.\n */\n function preIncrement(TUint256Slot self) internal returns (uint256 res) {\n res = addAssign(self, 1);\n }\n\n /**\n * @dev Increments the TUint256Slot variable by 1 and returns the original value.\n * @param self The TUint256Slot variable.\n * @return res The original value before incrementing.\n */\n function postIncrement(TUint256Slot self) internal returns (uint256 res) {\n res = load(self);\n store(self, res + 1);\n }\n\n /**\n * @dev Decrements the TUint256Slot variable by 1 and returns the new value.\n * @param self The TUint256Slot variable.\n * @return res The resulting value after decrementing.\n */\n function preDecrement(TUint256Slot self) internal returns (uint256 res) {\n res = subAssign(self, 1);\n }\n\n /**\n * @dev Decrements the TUint256Slot variable by 1 and returns the new value.\n * @param self The TUint256Slot variable.\n * @return res The resulting value before decrementing.\n */\n function postDecrement(TUint256Slot self) internal returns (uint256 res) {\n res = load(self);\n store(self, res - 1);\n }\n\n /**\n * @dev Adds a given value to the TUint256Slot variable and stores the result.\n * @param self The TUint256Slot variable.\n * @param other The value to add.\n * @return res The resulting value after addition and storage.\n */\n function addAssign(TUint256Slot self, uint256 other) internal returns (uint256 res) {\n store(self, res = add(self, other));\n }\n\n /**\n * @dev Subtracts a given value from the TUint256Slot variable and stores the result.\n * @param self The TUint256Slot variable.\n * @param other The value to subtract.\n * @return res The resulting value after subtraction and storage.\n */\n function subAssign(TUint256Slot self, uint256 other) internal returns (uint256 res) {\n store(self, res = sub(self, other));\n }\n}\n" + }, + "contracts/types/Types.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.17;\n\nimport { LibTUint256Slot } from \"./operations/LibTUint256Slot.sol\";\n\ntype TUint256Slot is bytes32;\n\nusing {\n LibTUint256Slot.add,\n LibTUint256Slot.sub,\n LibTUint256Slot.mul,\n LibTUint256Slot.div,\n LibTUint256Slot.load,\n LibTUint256Slot.store,\n LibTUint256Slot.addAssign,\n LibTUint256Slot.subAssign,\n LibTUint256Slot.preDecrement,\n LibTUint256Slot.postDecrement,\n LibTUint256Slot.preIncrement,\n LibTUint256Slot.postIncrement\n} for TUint256Slot global;\n" + }, + "contracts/utils/CommonErrors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { ContractType } from \"./ContractType.sol\";\nimport { RoleAccess } from \"./RoleAccess.sol\";\n\nerror ErrSyncTooFarPeriod(uint256 period, uint256 latestRewardedPeriod);\n/**\n * @dev Error thrown when an address is expected to be an already created externally owned account (EOA).\n * This error indicates that the provided address is invalid for certain contract operations that require already created EOA.\n */\nerror ErrAddressIsNotCreatedEOA(address addr, bytes32 codehash);\n/**\n * @dev Error raised when a bridge operator update operation fails.\n * @param bridgeOperator The address of the bridge operator that failed to update.\n */\nerror ErrBridgeOperatorUpdateFailed(address bridgeOperator);\n/**\n * @dev Error thrown when attempting to add a bridge operator that already exists in the contract.\n * This error indicates that the provided bridge operator address is already registered as a bridge operator in the contract.\n */\nerror ErrBridgeOperatorAlreadyExisted(address bridgeOperator);\n/**\n * @dev The error indicating an unsupported interface.\n * @param interfaceId The bytes4 interface identifier that is not supported.\n * @param addr The address where the unsupported interface was encountered.\n */\nerror ErrUnsupportedInterface(bytes4 interfaceId, address addr);\n/**\n * @dev Error thrown when the return data from a callback function is invalid.\n * @param callbackFnSig The signature of the callback function that returned invalid data.\n * @param register The address of the register where the callback function was invoked.\n * @param returnData The invalid return data received from the callback function.\n */\nerror ErrInvalidReturnData(bytes4 callbackFnSig, address register, bytes returnData);\n/**\n * @dev Error of set to non-contract.\n */\nerror ErrZeroCodeContract(address addr);\n/**\n * @dev Error indicating that arguments are invalid.\n */\nerror ErrInvalidArguments(bytes4 msgSig);\n/**\n * @dev Error indicating that given address is null when it should not.\n */\nerror ErrZeroAddress(bytes4 msgSig);\n/**\n * @dev Error indicating that the provided threshold is invalid for a specific function signature.\n * @param msgSig The function signature (bytes4) that the invalid threshold applies to.\n */\nerror ErrInvalidThreshold(bytes4 msgSig);\n\n/**\n * @dev Error indicating that a function can only be called by the contract itself.\n * @param msgSig The function signature (bytes4) that can only be called by the contract itself.\n */\nerror ErrOnlySelfCall(bytes4 msgSig);\n\n/**\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\n * @param msgSig The function signature (bytes4) that the caller is unauthorized to perform.\n * @param expectedRole The role required to perform the function.\n */\nerror ErrUnauthorized(bytes4 msgSig, RoleAccess expectedRole);\n\n/**\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\n * @param msgSig The function signature (bytes4) that the caller is unauthorized to perform.\n */\nerror ErrUnauthorizedCall(bytes4 msgSig);\n\n/**\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\n * @param msgSig The function signature (bytes4).\n * @param expectedContractType The contract type required to perform the function.\n * @param actual The actual address that called to the function.\n */\nerror ErrUnexpectedInternalCall(bytes4 msgSig, ContractType expectedContractType, address actual);\n\n/**\n * @dev Error indicating that an array is empty when it should contain elements.\n */\nerror ErrEmptyArray();\n\n/**\n * @dev Error indicating a mismatch in the length of input parameters or arrays for a specific function.\n * @param msgSig The function signature (bytes4) that has a length mismatch.\n */\nerror ErrLengthMismatch(bytes4 msgSig);\n\n/**\n * @dev Error indicating that a proxy call to an external contract has failed.\n * @param msgSig The function signature (bytes4) of the proxy call that failed.\n * @param extCallSig The function signature (bytes4) of the external contract call that failed.\n */\nerror ErrProxyCallFailed(bytes4 msgSig, bytes4 extCallSig);\n\n/**\n * @dev Error indicating that a function tried to call a precompiled contract that is not allowed.\n * @param msgSig The function signature (bytes4) that attempted to call a precompiled contract.\n */\nerror ErrCallPrecompiled(bytes4 msgSig);\n\n/**\n * @dev Error indicating that a native token transfer has failed.\n * @param msgSig The function signature (bytes4) of the token transfer that failed.\n */\nerror ErrNativeTransferFailed(bytes4 msgSig);\n\n/**\n * @dev Error indicating that an order is invalid.\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid order.\n */\nerror ErrInvalidOrder(bytes4 msgSig);\n\n/**\n * @dev Error indicating that the chain ID is invalid.\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid chain ID.\n * @param actual Current chain ID that executing function.\n * @param expected Expected chain ID required for the tx to success.\n */\nerror ErrInvalidChainId(bytes4 msgSig, uint256 actual, uint256 expected);\n\n/**\n * @dev Error indicating that a vote type is not supported.\n * @param msgSig The function signature (bytes4) of the operation that encountered an unsupported vote type.\n */\nerror ErrUnsupportedVoteType(bytes4 msgSig);\n\n/**\n * @dev Error indicating that the proposal nonce is invalid.\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid proposal nonce.\n */\nerror ErrInvalidProposalNonce(bytes4 msgSig);\n\n/**\n * @dev Error indicating that a voter has already voted.\n * @param voter The address of the voter who has already voted.\n */\nerror ErrAlreadyVoted(address voter);\n\n/**\n * @dev Error indicating that a signature is invalid for a specific function signature.\n * @param msgSig The function signature (bytes4) that encountered an invalid signature.\n */\nerror ErrInvalidSignatures(bytes4 msgSig);\n\n/**\n * @dev Error indicating that a relay call has failed.\n * @param msgSig The function signature (bytes4) of the relay call that failed.\n */\nerror ErrRelayFailed(bytes4 msgSig);\n/**\n * @dev Error indicating that a vote weight is invalid for a specific function signature.\n * @param msgSig The function signature (bytes4) that encountered an invalid vote weight.\n */\nerror ErrInvalidVoteWeight(bytes4 msgSig);\n\n/**\n * @dev Error indicating that a query was made for an outdated bridge operator set.\n */\nerror ErrQueryForOutdatedBridgeOperatorSet();\n\n/**\n * @dev Error indicating that a request is invalid.\n */\nerror ErrInvalidRequest();\n\n/**\n * @dev Error indicating that a token standard is invalid.\n */\nerror ErrInvalidTokenStandard();\n\n/**\n * @dev Error indicating that a token is not supported.\n */\nerror ErrUnsupportedToken();\n\n/**\n * @dev Error indicating that a receipt kind is invalid.\n */\nerror ErrInvalidReceiptKind();\n\n/**\n * @dev Error indicating that a receipt is invalid.\n */\nerror ErrInvalidReceipt();\n\n/**\n * @dev Error indicating that an address is not payable.\n */\nerror ErrNonpayableAddress(address);\n\n/**\n * @dev Error indicating that the period is already processed, i.e. scattered reward.\n */\nerror ErrPeriodAlreadyProcessed(uint256 requestingPeriod, uint256 latestPeriod);\n\n/**\n * @dev Error thrown when an invalid vote hash is provided.\n */\nerror ErrInvalidVoteHash();\n\n/**\n * @dev Error thrown when querying for an empty vote.\n */\nerror ErrQueryForEmptyVote();\n\n/**\n * @dev Error thrown when querying for an expired vote.\n */\nerror ErrQueryForExpiredVote();\n\n/**\n * @dev Error thrown when querying for a non-existent vote.\n */\nerror ErrQueryForNonExistentVote();\n" + }, + "contracts/utils/ContractType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nenum ContractType {\n /* 0 */ UNKNOWN,\n /* 1 */ PAUSE_ENFORCER,\n /* 2 */ BRIDGE,\n /* 3 */ BRIDGE_TRACKING,\n /* 4 */ GOVERNANCE_ADMIN,\n /* 5 */ MAINTENANCE,\n /* 6 */ SLASH_INDICATOR,\n /* 7 */ STAKING_VESTING,\n /* 8 */ VALIDATOR,\n /* 9 */ STAKING,\n /* 10 */ RONIN_TRUSTED_ORGANIZATION,\n /* 11 */ BRIDGE_MANAGER,\n /* 12 */ BRIDGE_SLASH,\n /* 13 */ BRIDGE_REWARD\n}\n" + }, + "contracts/utils/DeprecatedSlots.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n * @title Deprecated Contracts\n * @dev These abstract contracts are deprecated and should not be used in new implementations.\n * They provide functionality related to various aspects of a smart contract but have been marked\n * as deprecated to indicate that they are no longer actively maintained or recommended for use.\n * The purpose of these contracts is to preserve the slots for already deployed contracts.\n */\ncontract HasSlashIndicatorDeprecated {\n /// @custom:deprecated Previously `_slashIndicatorContract` (non-zero value)\n address internal ______deprecatedSlashIndicator;\n}\n\ncontract HasStakingVestingDeprecated {\n /// @custom:deprecated Previously `_stakingVestingContract` (non-zero value)\n address internal ______deprecatedStakingVesting;\n}\n\ncontract HasBridgeDeprecated {\n /// @custom:deprecated Previously `_bridgeContract` (non-zero value)\n address internal ______deprecatedBridge;\n}\n\ncontract HasValidatorDeprecated {\n /// @custom:deprecated Previously `_validatorContract` (non-zero value)\n address internal ______deprecatedValidator;\n}\n\ncontract HasStakingDeprecated {\n /// @custom:deprecated Previously `_stakingContract` (non-zero value)\n address internal ______deprecatedStakingContract;\n}\n\ncontract HasMaintenanceDeprecated {\n /// @custom:deprecated Previously `_maintenanceContract` (non-zero value)\n address internal ______deprecatedMaintenance;\n}\n\ncontract HasTrustedOrgDeprecated {\n /// @custom:deprecated Previously `_trustedOrgContract` (non-zero value)\n address internal ______deprecatedTrustedOrg;\n}\n\ncontract HasGovernanceAdminDeprecated {\n /// @custom:deprecated Previously `_governanceAdminContract` (non-zero value)\n address internal ______deprecatedGovernanceAdmin;\n}\n\ncontract HasBridgeTrackingDeprecated {\n /// @custom:deprecated Previously `_bridgeTrackingContract` (non-zero value)\n address internal ______deprecatedBridgeTracking;\n}\n" + }, + "contracts/utils/IdentityGuard.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { AddressArrayUtils } from \"../libraries/AddressArrayUtils.sol\";\nimport { IERC165 } from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport { TransparentUpgradeableProxyV2 } from \"../extensions/TransparentUpgradeableProxyV2.sol\";\nimport { ErrAddressIsNotCreatedEOA, ErrZeroAddress, ErrOnlySelfCall, ErrZeroCodeContract, ErrUnsupportedInterface } from \"./CommonErrors.sol\";\n\nabstract contract IdentityGuard {\n using AddressArrayUtils for address[];\n\n /// @dev value is equal to keccak256(abi.encode())\n /// @dev see: https://eips.ethereum.org/EIPS/eip-1052\n bytes32 internal constant CREATED_ACCOUNT_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\n\n /**\n * @dev Modifier to restrict functions to only be called by this contract.\n * @dev Reverts if the caller is not this contract.\n */\n modifier onlySelfCall() virtual {\n _requireSelfCall();\n _;\n }\n\n /**\n * @dev Modifier to ensure that the elements in the `arr` array are non-duplicates.\n * It calls the internal `_checkDuplicate` function to perform the duplicate check.\n *\n * Requirements:\n * - The elements in the `arr` array must not contain any duplicates.\n */\n modifier nonDuplicate(address[] memory arr) virtual {\n _requireNonDuplicate(arr);\n _;\n }\n\n /**\n * @dev Internal method to check the method caller.\n * @dev Reverts if the method caller is not this contract.\n */\n function _requireSelfCall() internal view virtual {\n if (msg.sender != address(this)) revert ErrOnlySelfCall(msg.sig);\n }\n\n /**\n * @dev Internal function to check if a contract address has code.\n * @param addr The address of the contract to check.\n * @dev Throws an error if the contract address has no code.\n */\n function _requireHasCode(address addr) internal view {\n if (addr.code.length == 0) revert ErrZeroCodeContract(addr);\n }\n\n /**\n * @dev Checks if an address is zero and reverts if it is.\n * @param addr The address to check.\n */\n function _requireNonZeroAddress(address addr) internal pure {\n if (addr == address(0)) revert ErrZeroAddress(msg.sig);\n }\n\n /**\n * @dev Check if arr is empty and revert if it is.\n * Checks if an array contains any duplicate addresses and reverts if duplicates are found.\n * @param arr The array of addresses to check.\n */\n function _requireNonDuplicate(address[] memory arr) internal pure {\n if (arr.hasDuplicate()) revert AddressArrayUtils.ErrDuplicated(msg.sig);\n }\n\n /**\n * @dev Internal function to require that the provided address is a created externally owned account (EOA).\n * This internal function is used to ensure that the provided address is a valid externally owned account (EOA).\n * It checks the codehash of the address against a predefined constant to confirm that the address is a created EOA.\n * @notice This method only works with non-state EOA accounts\n */\n function _requireCreatedEOA(address addr) internal view {\n _requireNonZeroAddress(addr);\n bytes32 codehash = addr.codehash;\n if (codehash != CREATED_ACCOUNT_HASH) revert ErrAddressIsNotCreatedEOA(addr, codehash);\n }\n\n /**\n * @dev Internal function to require that the specified contract supports the given interface. This method handle in\n * both case that the callee is either or not the proxy admin of the caller. If the contract does not support the\n * interface `interfaceId` or EIP165, a revert with the corresponding error message is triggered.\n *\n * @param contractAddr The address of the contract to check for interface support.\n * @param interfaceId The interface ID to check for support.\n */\n function _requireSupportsInterface(address contractAddr, bytes4 interfaceId) internal view {\n bytes memory supportsInterfaceParams = abi.encodeCall(IERC165.supportsInterface, (interfaceId));\n (bool success, bytes memory returnOrRevertData) = contractAddr.staticcall(supportsInterfaceParams);\n if (!success) {\n (success, returnOrRevertData) = contractAddr.staticcall(\n abi.encodeCall(TransparentUpgradeableProxyV2.functionDelegateCall, (supportsInterfaceParams))\n );\n if (!success) revert ErrUnsupportedInterface(interfaceId, contractAddr);\n }\n if (!abi.decode(returnOrRevertData, (bool))) revert ErrUnsupportedInterface(interfaceId, contractAddr);\n }\n}\n" + }, + "contracts/utils/RoleAccess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nenum RoleAccess {\n /* 0 */ UNKNOWN,\n /* 1 */ ADMIN,\n /* 2 */ COINBASE,\n /* 3 */ GOVERNOR,\n /* 4 */ CANDIDATE_ADMIN,\n /* 5 */ WITHDRAWAL_MIGRATOR,\n /* 6 */ __DEPRECATED_BRIDGE_OPERATOR,\n /* 7 */ BLOCK_PRODUCER,\n /* 8 */ VALIDATOR_CANDIDATE\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "metadata": { + "bytecodeHash": "none", + "useLiteralContent": true + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates", + "storageLayout" + ], + "": [ + "ast" + ] + } + } + } +} \ No newline at end of file diff --git a/deployments/ronin-testnet/solcInputs/95921af9e3b453fd5a2d5edf43163a69.json b/deployments/ronin-testnet/solcInputs/95921af9e3b453fd5a2d5edf43163a69.json new file mode 100644 index 000000000..e8fa4da3a --- /dev/null +++ b/deployments/ronin-testnet/solcInputs/95921af9e3b453fd5a2d5edf43163a69.json @@ -0,0 +1,604 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts/access/AccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n * Overriding this function changes the behavior of the {onlyRole} modifier.\n *\n * Format of the revert message is described in {_checkRole}.\n *\n * _Available since v4.6._\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(uint160(account), 20),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * May emit a {RoleGranted} event.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" + }, + "@openzeppelin/contracts/access/AccessControlEnumerable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlEnumerable.sol\";\nimport \"./AccessControl.sol\";\nimport \"../utils/structs/EnumerableSet.sol\";\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override {\n super._grantRole(role, account);\n _roleMembers[role].add(account);\n }\n\n /**\n * @dev Overload {_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override {\n super._revokeRole(role, account);\n _roleMembers[role].remove(account);\n }\n}\n" + }, + "@openzeppelin/contracts/access/IAccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" + }, + "@openzeppelin/contracts/access/IAccessControlEnumerable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n" + }, + "@openzeppelin/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "@openzeppelin/contracts/interfaces/draft-IERC1822.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n *\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\n */\n constructor(address _logic, bytes memory _data) payable {\n _upgradeToAndCall(_logic, _data, false);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function _implementation() internal view virtual override returns (address impl) {\n return ERC1967Upgrade._getImplementation();\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967Upgrade {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _changeAdmin(address newAdmin) internal {\n emit AdminChanged(_getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Emitted when the beacon is upgraded.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Returns the current beacon.\n */\n function _getBeacon() internal view returns (address) {\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n Address.isContract(IBeacon(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(\n address newBeacon,\n bytes memory data,\n bool forceCall\n ) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overridden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./TransparentUpgradeableProxy.sol\";\nimport \"../../access/Ownable.sol\";\n\n/**\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\n */\ncontract ProxyAdmin is Ownable {\n /**\n * @dev Returns the current implementation of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"implementation()\")) == 0x5c60da1b\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"5c60da1b\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Returns the current admin of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"admin()\")) == 0xf851a440\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"f851a440\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Changes the admin of `proxy` to `newAdmin`.\n *\n * Requirements:\n *\n * - This contract must be the current admin of `proxy`.\n */\n function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {\n proxy.changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {\n proxy.upgradeTo(implementation);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\n * {TransparentUpgradeableProxy-upgradeToAndCall}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgradeAndCall(\n TransparentUpgradeableProxy proxy,\n address implementation,\n bytes memory data\n ) public payable virtual onlyOwner {\n proxy.upgradeToAndCall{value: msg.value}(implementation, data);\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC1967/ERC1967Proxy.sol\";\n\n/**\n * @dev This contract implements a proxy that is upgradeable by an admin.\n *\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n *\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches one of the admin functions exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\n * \"admin cannot fallback to proxy target\".\n *\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\n * to sudden errors when trying to call a function from the proxy implementation.\n *\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\n */\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\n /**\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\n */\n constructor(\n address _logic,\n address admin_,\n bytes memory _data\n ) payable ERC1967Proxy(_logic, _data) {\n _changeAdmin(admin_);\n }\n\n /**\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\n */\n modifier ifAdmin() {\n if (msg.sender == _getAdmin()) {\n _;\n } else {\n _fallback();\n }\n }\n\n /**\n * @dev Returns the current admin.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function admin() external ifAdmin returns (address admin_) {\n admin_ = _getAdmin();\n }\n\n /**\n * @dev Returns the current implementation.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n */\n function implementation() external ifAdmin returns (address implementation_) {\n implementation_ = _implementation();\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\n */\n function changeAdmin(address newAdmin) external virtual ifAdmin {\n _changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\n */\n function upgradeTo(address newImplementation) external ifAdmin {\n _upgradeToAndCall(newImplementation, bytes(\"\"), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\n * proxied contract.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\n */\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\n _upgradeToAndCall(newImplementation, data, true);\n }\n\n /**\n * @dev Returns the current admin.\n */\n function _admin() internal view virtual returns (address) {\n return _getAdmin();\n }\n\n /**\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\n */\n function _beforeFallback() internal virtual override {\n require(msg.sender != _getAdmin(), \"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n super._beforeFallback();\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n * initialization step. This is essential to configure modules that are added through upgrades and that require\n * initialization.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/security/Pausable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n constructor() {\n _paused = false;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n _requireNotPaused();\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n _requirePaused();\n _;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Throws if the contract is paused.\n */\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n /**\n * @dev Throws if the contract is not paused.\n */\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n}\n" + }, + "@openzeppelin/contracts/security/ReentrancyGuard.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../../../utils/Context.sol\";\n\n/**\n * @dev Extension of {ERC20} that allows token holders to destroy both their own\n * tokens and those that they have an allowance for, in a way that can be\n * recognized off-chain (via event analysis).\n */\nabstract contract ERC20Burnable is Context, ERC20 {\n /**\n * @dev Destroys `amount` tokens from the caller.\n *\n * See {ERC20-_burn}.\n */\n function burn(uint256 amount) public virtual {\n _burn(_msgSender(), amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, deducting from the caller's\n * allowance.\n *\n * See {ERC20-_burn} and {ERC20-allowance}.\n *\n * Requirements:\n *\n * - the caller must have allowance for ``accounts``'s tokens of at least\n * `amount`.\n */\n function burnFrom(address account, uint256 amount) public virtual {\n _spendAllowance(account, _msgSender(), amount);\n _burn(account, amount);\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../../../security/Pausable.sol\";\n\n/**\n * @dev ERC20 token with pausable token transfers, minting and burning.\n *\n * Useful for scenarios such as preventing trades until the end of an evaluation\n * period, or having an emergency switch for freezing all token transfers in the\n * event of a large bug.\n */\nabstract contract ERC20Pausable is ERC20, Pausable {\n /**\n * @dev See {ERC20-_beforeTokenTransfer}.\n *\n * Requirements:\n *\n * - the contract must not be paused.\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, amount);\n\n require(!paused(), \"ERC20Pausable: token transfer while paused\");\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/presets/ERC20PresetMinterPauser.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../extensions/ERC20Burnable.sol\";\nimport \"../extensions/ERC20Pausable.sol\";\nimport \"../../../access/AccessControlEnumerable.sol\";\nimport \"../../../utils/Context.sol\";\n\n/**\n * @dev {ERC20} token, including:\n *\n * - ability for holders to burn (destroy) their tokens\n * - a minter role that allows for token minting (creation)\n * - a pauser role that allows to stop all token transfers\n *\n * This contract uses {AccessControl} to lock permissioned functions using the\n * different roles - head to its documentation for details.\n *\n * The account that deploys the contract will be granted the minter and pauser\n * roles, as well as the default admin role, which will let it grant both minter\n * and pauser roles to other accounts.\n *\n * _Deprecated in favor of https://wizard.openzeppelin.com/[Contracts Wizard]._\n */\ncontract ERC20PresetMinterPauser is Context, AccessControlEnumerable, ERC20Burnable, ERC20Pausable {\n bytes32 public constant MINTER_ROLE = keccak256(\"MINTER_ROLE\");\n bytes32 public constant PAUSER_ROLE = keccak256(\"PAUSER_ROLE\");\n\n /**\n * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the\n * account that deploys the contract.\n *\n * See {ERC20-constructor}.\n */\n constructor(string memory name, string memory symbol) ERC20(name, symbol) {\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n\n _setupRole(MINTER_ROLE, _msgSender());\n _setupRole(PAUSER_ROLE, _msgSender());\n }\n\n /**\n * @dev Creates `amount` new tokens for `to`.\n *\n * See {ERC20-_mint}.\n *\n * Requirements:\n *\n * - the caller must have the `MINTER_ROLE`.\n */\n function mint(address to, uint256 amount) public virtual {\n require(hasRole(MINTER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have minter role to mint\");\n _mint(to, amount);\n }\n\n /**\n * @dev Pauses all token transfers.\n *\n * See {ERC20Pausable} and {Pausable-_pause}.\n *\n * Requirements:\n *\n * - the caller must have the `PAUSER_ROLE`.\n */\n function pause() public virtual {\n require(hasRole(PAUSER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have pauser role to pause\");\n _pause();\n }\n\n /**\n * @dev Unpauses all token transfers.\n *\n * See {ERC20Pausable} and {Pausable-_unpause}.\n *\n * Requirements:\n *\n * - the caller must have the `PAUSER_ROLE`.\n */\n function unpause() public virtual {\n require(hasRole(PAUSER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have pauser role to unpause\");\n _unpause();\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override(ERC20, ERC20Pausable) {\n super._beforeTokenTransfer(from, to, amount);\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/ERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" + }, + "@openzeppelin/contracts/utils/StorageSlot.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" + }, + "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping(bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (lastIndex != toDeleteIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastValue;\n // Update the index for the moved value\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n return _values(set._inner);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" + }, + "contracts/extensions/bridge-operator-governance/BridgeManager.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { IBridgeManagerCallback, EnumerableSet, BridgeManagerCallbackRegister } from \"./BridgeManagerCallbackRegister.sol\";\nimport { IHasContracts, HasContracts } from \"../../extensions/collections/HasContracts.sol\";\nimport { IQuorum } from \"../../interfaces/IQuorum.sol\";\nimport { IBridgeManager } from \"../../interfaces/bridge/IBridgeManager.sol\";\nimport { AddressArrayUtils } from \"../../libraries/AddressArrayUtils.sol\";\nimport { ContractType } from \"../../utils/ContractType.sol\";\nimport { RoleAccess } from \"../../utils/RoleAccess.sol\";\nimport { TUint256Slot } from \"../../types/Types.sol\";\nimport \"../../utils/CommonErrors.sol\";\n\nabstract contract BridgeManager is IQuorum, IBridgeManager, BridgeManagerCallbackRegister, HasContracts {\n using AddressArrayUtils for address[];\n using EnumerableSet for EnumerableSet.AddressSet;\n\n /// @dev value is equal to keccak256(\"@ronin.dpos.gateway.BridgeAdmin.governorToBridgeOperatorInfo.slot\") - 1\n bytes32 private constant GOVERNOR_TO_BRIDGE_OPERATOR_INFO_SLOT =\n 0x88547008e60f5748911f2e59feb3093b7e4c2e87b2dd69d61f112fcc932de8e3;\n /// @dev value is equal to keccak256(\"@ronin.dpos.gateway.BridgeAdmin.govenorOf.slot\") - 1\n bytes32 private constant GOVENOR_OF_SLOT = 0x8400683eb2cb350596d73644c0c89fe45f108600003457374f4ab3e87b4f3aa3;\n /// @dev value is equal to keccak256(\"@ronin.dpos.gateway.BridgeAdmin.governors.slot\") - 1\n bytes32 private constant GOVERNOR_SET_SLOT = 0x546f6b46ab35b030b6816596b352aef78857377176c8b24baa2046a62cf1998c;\n /// @dev value is equal to keccak256(\"@ronin.dpos.gateway.BridgeAdmin.bridgeOperators.slot\") - 1\n bytes32 private constant BRIDGE_OPERATOR_SET_SLOT =\n 0xd38c234075fde25875da8a6b7e36b58b86681d483271a99eeeee1d78e258a24d;\n\n /**\n * @dev The numerator value used for calculations in the contract.\n * @notice value is equal to keccak256(\"@ronin.dpos.gateway.BridgeAdmin.numerator.slot\") - 1\n */\n TUint256Slot internal constant NUMERATOR_SLOT =\n TUint256Slot.wrap(0xc55405a488814eaa0e2a685a0131142785b8d033d311c8c8244e34a7c12ca40f);\n\n /**\n * @dev The denominator value used for calculations in the contract.\n * @notice value is equal to keccak256(\"@ronin.dpos.gateway.BridgeAdmin.denominator.slot\") - 1\n */\n TUint256Slot internal constant DENOMINATOR_SLOT =\n TUint256Slot.wrap(0xac1ff16a4f04f2a37a9ba5252a69baa100b460e517d1f8019c054a5ad698f9ff);\n\n /**\n * @dev The nonce value used for tracking nonces in the contract.\n * @notice value is equal to keccak256(\"@ronin.dpos.gateway.BridgeAdmin.nonce.slot\") - 1\n */\n TUint256Slot internal constant NONCE_SLOT =\n TUint256Slot.wrap(0x92872d32822c9d44b36a2537d3e0d4c46fc4de1ce154ccfaed560a8a58445f1d);\n\n /**\n * @dev The total weight value used for storing the cumulative weight in the contract.\n * @notice value is equal to keccak256(\"@ronin.dpos.gateway.BridgeAdmin.totalWeights.slot\") - 1\n */\n TUint256Slot internal constant TOTAL_WEIGHTS_SLOT =\n TUint256Slot.wrap(0x6924fe71b0c8b61aea02ca498b5f53b29bd95726278b1fe4eb791bb24a42644c);\n\n /**\n * @inheritdoc IBridgeManager\n */\n bytes32 public immutable DOMAIN_SEPARATOR;\n\n modifier onlyGovernor() virtual {\n _requireGovernor(msg.sender);\n _;\n }\n\n constructor(\n uint256 num,\n uint256 denom,\n uint256 roninChainId,\n address bridgeContract,\n address[] memory callbackRegisters,\n address[] memory bridgeOperators,\n address[] memory governors,\n uint96[] memory voteWeights\n ) payable BridgeManagerCallbackRegister(callbackRegisters) {\n NONCE_SLOT.store(1);\n NUMERATOR_SLOT.store(num);\n DENOMINATOR_SLOT.store(denom);\n\n _setContract(ContractType.BRIDGE, bridgeContract);\n\n DOMAIN_SEPARATOR = keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,bytes32 salt)\"),\n keccak256(\"BridgeAdmin\"), // name hash\n keccak256(\"2\"), // version hash\n keccak256(abi.encode(\"BRIDGE_ADMIN\", roninChainId)) // salt\n )\n );\n\n _addBridgeOperators(voteWeights, governors, bridgeOperators);\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function addBridgeOperators(\n uint96[] calldata voteWeights,\n address[] calldata governors,\n address[] calldata bridgeOperators\n ) external onlySelfCall returns (bool[] memory addeds) {\n addeds = _addBridgeOperators(voteWeights, governors, bridgeOperators);\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function removeBridgeOperators(\n address[] calldata bridgeOperators\n ) external onlySelfCall returns (bool[] memory removeds) {\n removeds = _removeBridgeOperators(bridgeOperators);\n }\n\n /**\n * @inheritdoc IBridgeManager\n * @notice This method checks authorization by querying the corresponding operator of the msg.sender and then\n * attempts to remove it from the `_bridgeOperatorSet` for gas optimization. In case we allow a governor can leave\n * their operator address blank null `address(0)`, consider add authorization check.\n */\n function updateBridgeOperator(address newBridgeOperator) external onlyGovernor {\n _requireNonZeroAddress(newBridgeOperator);\n\n // Queries the previous bridge operator\n mapping(address => BridgeOperatorInfo) storage _gorvernorToBridgeOperatorInfo = _getGovernorToBridgeOperatorInfo();\n address currentBridgeOperator = _gorvernorToBridgeOperatorInfo[msg.sender].addr;\n if (currentBridgeOperator == newBridgeOperator) {\n revert ErrBridgeOperatorAlreadyExisted(newBridgeOperator);\n }\n\n // Tries replace the bridge operator\n EnumerableSet.AddressSet storage _bridgeOperatorSet = _getBridgeOperatorSet();\n bool updated = _bridgeOperatorSet.remove(currentBridgeOperator) && _bridgeOperatorSet.add(newBridgeOperator);\n if (!updated) revert ErrBridgeOperatorUpdateFailed(newBridgeOperator);\n\n mapping(address => address) storage _governorOf = _getGovernorOf();\n delete _governorOf[currentBridgeOperator];\n _governorOf[newBridgeOperator] = msg.sender;\n _gorvernorToBridgeOperatorInfo[msg.sender].addr = newBridgeOperator;\n\n _notifyRegisters(\n IBridgeManagerCallback.onBridgeOperatorUpdated.selector,\n abi.encode(currentBridgeOperator, newBridgeOperator)\n );\n\n emit BridgeOperatorUpdated(msg.sender, currentBridgeOperator, newBridgeOperator);\n }\n\n /**\n * @inheritdoc IHasContracts\n */\n function setContract(ContractType contractType, address addr) external override onlySelfCall {\n _requireHasCode(addr);\n _setContract(contractType, addr);\n }\n\n /**\n * @inheritdoc IQuorum\n */\n function setThreshold(\n uint256 numerator,\n uint256 denominator\n ) external override onlySelfCall returns (uint256, uint256) {\n return _setThreshold(numerator, denominator);\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function getTotalWeights() public view returns (uint256) {\n return TOTAL_WEIGHTS_SLOT.load();\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function getGovernorWeights(address[] calldata governors) external view returns (uint256[] memory weights) {\n weights = _getGovernorWeights(governors);\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function getGovernorWeight(address governor) external view returns (uint256 weight) {\n weight = _getGovernorWeight(governor);\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function sumGovernorsWeight(\n address[] calldata governors\n ) external view nonDuplicate(governors) returns (uint256 sum) {\n sum = _sumGovernorsWeight(governors);\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function totalBridgeOperators() external view returns (uint256) {\n return _getBridgeOperatorSet().length();\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function isBridgeOperator(address addr) external view returns (bool) {\n return _getBridgeOperatorSet().contains(addr);\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function getBridgeOperators() external view returns (address[] memory) {\n return _getBridgeOperators();\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function getGovernors() external view returns (address[] memory) {\n return _getGovernors();\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function getBridgeOperatorOf(address[] memory governors) public view returns (address[] memory bridgeOperators) {\n uint256 length = governors.length;\n bridgeOperators = new address[](length);\n\n mapping(address => BridgeOperatorInfo) storage _gorvernorToBridgeOperator = _getGovernorToBridgeOperatorInfo();\n for (uint256 i; i < length; ) {\n bridgeOperators[i] = _gorvernorToBridgeOperator[governors[i]].addr;\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function getGovernorsOf(address[] calldata bridgeOperators) external view returns (address[] memory governors) {\n uint256 length = bridgeOperators.length;\n governors = new address[](length);\n mapping(address => address) storage _governorOf = _getGovernorOf();\n\n for (uint256 i; i < length; ) {\n governors[i] = _governorOf[bridgeOperators[i]];\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function getFullBridgeOperatorInfos()\n external\n view\n returns (address[] memory governors, address[] memory bridgeOperators, uint256[] memory weights)\n {\n governors = _getGovernors();\n bridgeOperators = getBridgeOperatorOf(governors);\n weights = _getGovernorWeights(governors);\n }\n\n /**\n * @inheritdoc IBridgeManager\n */\n function getBridgeOperatorWeight(address bridgeOperator) external view returns (uint256 weight) {\n mapping(address => address) storage _governorOf = _getGovernorOf();\n mapping(address => BridgeOperatorInfo) storage _governorToBridgeOperatorInfo = _getGovernorToBridgeOperatorInfo();\n weight = _governorToBridgeOperatorInfo[_governorOf[bridgeOperator]].voteWeight;\n }\n\n /**\n * @inheritdoc IQuorum\n */\n function minimumVoteWeight() public view virtual returns (uint256) {\n return (NUMERATOR_SLOT.mul(TOTAL_WEIGHTS_SLOT.load()) + DENOMINATOR_SLOT.load() - 1) / DENOMINATOR_SLOT.load();\n }\n\n /**\n * @inheritdoc IQuorum\n */\n function getThreshold() external view virtual returns (uint256 num_, uint256 denom_) {\n return (NUMERATOR_SLOT.load(), DENOMINATOR_SLOT.load());\n }\n\n /**\n * @inheritdoc IQuorum\n */\n function checkThreshold(uint256 _voteWeight) external view virtual returns (bool) {\n return _voteWeight * DENOMINATOR_SLOT.load() >= NUMERATOR_SLOT.mul(TOTAL_WEIGHTS_SLOT.load());\n }\n\n /**\n * @dev Internal function to add bridge operators.\n *\n * This function adds the specified `bridgeOperators` to the bridge operator set and establishes the associated mappings.\n *\n * Requirements:\n * - The caller must have the necessary permission to add bridge operators.\n * - The lengths of `voteWeights`, `governors`, and `bridgeOperators` arrays must be equal.\n *\n * @param voteWeights An array of uint256 values representing the vote weights for each bridge operator.\n * @param governors An array of addresses representing the governors for each bridge operator.\n * @return addeds An array of boolean values indicating whether each bridge operator was successfully added.\n */\n function _addBridgeOperators(\n uint96[] memory voteWeights,\n address[] memory governors,\n address[] memory bridgeOperators\n ) internal nonDuplicate(governors.extend(bridgeOperators)) returns (bool[] memory addeds) {\n uint256 length = bridgeOperators.length;\n if (!(length == voteWeights.length && length == governors.length)) revert ErrLengthMismatch(msg.sig);\n addeds = new bool[](length);\n // simply skip add operations if inputs are empty.\n if (length == 0) return addeds;\n\n EnumerableSet.AddressSet storage _governorSet = _getGovernorsSet();\n mapping(address => address) storage _governorOf = _getGovernorOf();\n EnumerableSet.AddressSet storage _bridgeOperatorSet = _getBridgeOperatorSet();\n mapping(address => BridgeOperatorInfo) storage _governorToBridgeOperatorInfo = _getGovernorToBridgeOperatorInfo();\n\n address governor;\n address bridgeOperator;\n uint256 accumulatedWeight;\n BridgeOperatorInfo memory bridgeOperatorInfo;\n\n for (uint256 i; i < length; ) {\n governor = governors[i];\n bridgeOperator = bridgeOperators[i];\n\n _requireNonZeroAddress(governor);\n _requireNonZeroAddress(bridgeOperator);\n if (voteWeights[i] == 0) revert ErrInvalidVoteWeight(msg.sig);\n\n addeds[i] = !(_governorSet.contains(governor) ||\n _governorSet.contains(bridgeOperator) ||\n _bridgeOperatorSet.contains(governor) ||\n _bridgeOperatorSet.contains(bridgeOperator));\n\n if (addeds[i]) {\n _governorSet.add(governor);\n _bridgeOperatorSet.add(bridgeOperator);\n _governorOf[bridgeOperator] = governor;\n bridgeOperatorInfo.addr = bridgeOperator;\n accumulatedWeight += bridgeOperatorInfo.voteWeight = voteWeights[i];\n _governorToBridgeOperatorInfo[governor] = bridgeOperatorInfo;\n }\n\n unchecked {\n ++i;\n }\n }\n\n TOTAL_WEIGHTS_SLOT.addAssign(accumulatedWeight);\n\n _notifyRegisters(IBridgeManagerCallback.onBridgeOperatorsAdded.selector, abi.encode(bridgeOperators, addeds));\n\n emit BridgeOperatorsAdded(addeds, voteWeights, governors, bridgeOperators);\n }\n\n /**\n * @dev Internal function to remove bridge operators.\n *\n * This function removes the specified `bridgeOperators` from the bridge operator set and related mappings.\n *\n * Requirements:\n * - The caller must have the necessary permission to remove bridge operators.\n *\n * @param bridgeOperators An array of addresses representing the bridge operators to be removed.\n * @return removeds An array of boolean values indicating whether each bridge operator was successfully removed.\n */\n function _removeBridgeOperators(\n address[] memory bridgeOperators\n ) internal nonDuplicate(bridgeOperators) returns (bool[] memory removeds) {\n uint256 length = bridgeOperators.length;\n removeds = new bool[](length);\n // simply skip remove operations if inputs are empty.\n if (length == 0) return removeds;\n\n mapping(address => address) storage _governorOf = _getGovernorOf();\n EnumerableSet.AddressSet storage _governorSet = _getGovernorsSet();\n EnumerableSet.AddressSet storage _bridgeOperatorSet = _getBridgeOperatorSet();\n mapping(address => BridgeOperatorInfo) storage _governorToBridgeOperatorInfo = _getGovernorToBridgeOperatorInfo();\n\n address governor;\n address bridgeOperator;\n uint256 accumulatedWeight;\n BridgeOperatorInfo memory bridgeOperatorInfo;\n\n for (uint256 i; i < length; ) {\n bridgeOperator = bridgeOperators[i];\n governor = _governorOf[bridgeOperator];\n\n _requireNonZeroAddress(governor);\n _requireNonZeroAddress(bridgeOperator);\n\n bridgeOperatorInfo = _governorToBridgeOperatorInfo[governor];\n if (bridgeOperatorInfo.addr != bridgeOperator) revert ErrInvalidArguments(msg.sig);\n\n removeds[i] = _bridgeOperatorSet.contains(bridgeOperator) && _governorSet.contains(governor);\n if (removeds[i]) {\n _governorSet.remove(governor);\n _bridgeOperatorSet.remove(bridgeOperator);\n\n delete _governorOf[bridgeOperator];\n delete _governorToBridgeOperatorInfo[governor];\n accumulatedWeight += bridgeOperatorInfo.voteWeight;\n }\n\n unchecked {\n ++i;\n }\n }\n\n TOTAL_WEIGHTS_SLOT.subAssign(accumulatedWeight);\n\n _notifyRegisters(IBridgeManagerCallback.onBridgeOperatorsRemoved.selector, abi.encode(bridgeOperators, removeds));\n\n emit BridgeOperatorsRemoved(removeds, bridgeOperators);\n }\n\n /**\n * @dev Sets threshold and returns the old one.\n *\n * Emits the `ThresholdUpdated` event.\n *\n */\n function _setThreshold(\n uint256 numerator,\n uint256 denominator\n ) internal virtual returns (uint256 previousNum, uint256 previousDenom) {\n if (numerator > denominator) revert ErrInvalidThreshold(msg.sig);\n\n previousNum = NUMERATOR_SLOT.load();\n previousDenom = DENOMINATOR_SLOT.load();\n NUMERATOR_SLOT.store(numerator);\n DENOMINATOR_SLOT.store(denominator);\n\n emit ThresholdUpdated(NONCE_SLOT.postIncrement(), numerator, denominator, previousNum, previousDenom);\n }\n\n /**\n * @dev Internal function to get all bridge operators.\n * @return bridgeOperators An array containing all the registered bridge operator addresses.\n */\n function _getBridgeOperators() internal view returns (address[] memory) {\n return _getBridgeOperatorSet().values();\n }\n\n /**\n * @dev Internal function to get all governors.\n * @return governors An array containing all the registered governor addresses.\n */\n function _getGovernors() internal view returns (address[] memory) {\n return _getGovernorsSet().values();\n }\n\n /**\n * @dev Internal function to get the vote weights of a given array of governors.\n * @param governors An array containing the addresses of governors.\n * @return weights An array containing the vote weights of the corresponding governors.\n */\n function _getGovernorWeights(address[] memory governors) internal view returns (uint256[] memory weights) {\n uint256 length = governors.length;\n weights = new uint256[](length);\n mapping(address => BridgeOperatorInfo) storage _governorToBridgeOperatorInfo = _getGovernorToBridgeOperatorInfo();\n for (uint256 i; i < length; ) {\n weights[i] = _governorToBridgeOperatorInfo[governors[i]].voteWeight;\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @dev Internal function to calculate the sum of vote weights for a given array of governors.\n * @param governors An array containing the addresses of governors to calculate the sum of vote weights.\n * @return sum The total sum of vote weights for the provided governors.\n * @notice The input array `governors` must contain unique addresses to avoid duplicate calculations.\n */\n function _sumGovernorsWeight(address[] memory governors) internal view nonDuplicate(governors) returns (uint256 sum) {\n uint256 length = _getBridgeOperatorSet().length();\n mapping(address => BridgeOperatorInfo) storage _governorToBridgeOperatorInfo = _getGovernorToBridgeOperatorInfo();\n\n for (uint256 i; i < length; ) {\n sum += _governorToBridgeOperatorInfo[governors[i]].voteWeight;\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @dev Internal function to require that the caller has governor role access.\n * @param addr The address to check for governor role access.\n * @dev If the address does not have governor role access (vote weight is zero), a revert with the corresponding error message is triggered.\n */\n function _requireGovernor(address addr) internal view {\n if (_getGovernorWeight(addr) == 0) {\n revert ErrUnauthorized(msg.sig, RoleAccess.GOVERNOR);\n }\n }\n\n /**\n * @dev Internal function to retrieve the vote weight of a specific governor.\n * @param governor The address of the governor to get the vote weight for.\n * @return voteWeight The vote weight of the specified governor.\n */\n function _getGovernorWeight(address governor) internal view returns (uint256) {\n return _getGovernorToBridgeOperatorInfo()[governor].voteWeight;\n }\n\n /**\n * @dev Internal function to access the address set of bridge operators.\n * @return bridgeOperators the storage address set.\n */\n function _getBridgeOperatorSet() internal pure returns (EnumerableSet.AddressSet storage bridgeOperators) {\n assembly (\"memory-safe\") {\n bridgeOperators.slot := BRIDGE_OPERATOR_SET_SLOT\n }\n }\n\n /**\n * @dev Internal function to access the address set of bridge operators.\n * @return governors the storage address set.\n */\n function _getGovernorsSet() internal pure returns (EnumerableSet.AddressSet storage governors) {\n assembly (\"memory-safe\") {\n governors.slot := GOVERNOR_SET_SLOT\n }\n }\n\n /**\n * @dev Internal function to access the mapping from governor => BridgeOperatorInfo.\n * @return governorToBridgeOperatorInfo the mapping from governor => BridgeOperatorInfo.\n */\n function _getGovernorToBridgeOperatorInfo()\n internal\n pure\n returns (mapping(address => BridgeOperatorInfo) storage governorToBridgeOperatorInfo)\n {\n assembly (\"memory-safe\") {\n governorToBridgeOperatorInfo.slot := GOVERNOR_TO_BRIDGE_OPERATOR_INFO_SLOT\n }\n }\n\n /**\n * @dev Internal function to access the mapping from bridge operator => governor.\n * @return governorOf the mapping from bridge operator => governor.\n */\n function _getGovernorOf() internal pure returns (mapping(address => address) storage governorOf) {\n assembly (\"memory-safe\") {\n governorOf.slot := GOVENOR_OF_SLOT\n }\n }\n}\n" + }, + "contracts/extensions/bridge-operator-governance/BridgeManagerCallbackRegister.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { EnumerableSet } from \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport { IBridgeManagerCallbackRegister } from \"../../interfaces/bridge/IBridgeManagerCallbackRegister.sol\";\nimport { IBridgeManagerCallback } from \"../../interfaces/bridge/IBridgeManagerCallback.sol\";\nimport { IdentityGuard } from \"../../utils/IdentityGuard.sol\";\n\n/**\n * @title BridgeManagerCallbackRegister\n * @dev A contract that manages callback registrations and execution for a bridge.\n */\nabstract contract BridgeManagerCallbackRegister is IdentityGuard, IBridgeManagerCallbackRegister {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n /**\n * @dev Storage slot for the address set of callback registers.\n * @dev Value is equal to keccak256(\"@ronin.dpos.gateway.BridgeAdmin.callbackRegisters.slot\") - 1.\n */\n bytes32 private constant CALLBACK_REGISTERS_SLOT = 0x5da136eb38f8d8e354915fc8a767c0dc81d49de5fb65d5477122a82ddd976240;\n\n constructor(address[] memory callbackRegisters) payable {\n _registerCallbacks(callbackRegisters);\n }\n\n /**\n * @inheritdoc IBridgeManagerCallbackRegister\n */\n function registerCallbacks(address[] calldata registers) external onlySelfCall returns (bool[] memory registereds) {\n registereds = _registerCallbacks(registers);\n }\n\n /**\n * @inheritdoc IBridgeManagerCallbackRegister\n */\n function unregisterCallbacks(\n address[] calldata registers\n ) external onlySelfCall returns (bool[] memory unregistereds) {\n unregistereds = _unregisterCallbacks(registers);\n }\n\n /**\n * @inheritdoc IBridgeManagerCallbackRegister\n */\n function getCallbackRegisters() external view returns (address[] memory registers) {\n registers = _getCallbackRegisters().values();\n }\n\n /**\n * @dev Internal function to register multiple callbacks with the bridge.\n * @param registers The array of callback addresses to register.\n * @return registereds An array indicating the success status of each registration.\n */\n function _registerCallbacks(\n address[] memory registers\n ) internal nonDuplicate(registers) returns (bool[] memory registereds) {\n uint256 length = registers.length;\n registereds = new bool[](length);\n if (length == 0) return registereds;\n\n EnumerableSet.AddressSet storage _callbackRegisters = _getCallbackRegisters();\n address register;\n bytes4 callbackInterface = type(IBridgeManagerCallback).interfaceId;\n\n for (uint256 i; i < length; ) {\n register = registers[i];\n\n _requireHasCode(register);\n _requireSupportsInterface(register, callbackInterface);\n\n registereds[i] = _callbackRegisters.add(register);\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @dev Internal function to unregister multiple callbacks from the bridge.\n * @param registers The array of callback addresses to unregister.\n * @return unregistereds An array indicating the success status of each unregistration.\n */\n function _unregisterCallbacks(\n address[] memory registers\n ) internal nonDuplicate(registers) returns (bool[] memory unregistereds) {\n uint256 length = registers.length;\n unregistereds = new bool[](length);\n EnumerableSet.AddressSet storage _callbackRegisters = _getCallbackRegisters();\n\n for (uint256 i; i < length; ) {\n unregistereds[i] = _callbackRegisters.remove(registers[i]);\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @dev Internal function to notify all registered callbacks with the provided function signature and data.\n * @param callbackFnSig The function signature of the callback method.\n * @param inputs The data to pass to the callback method.\n */\n function _notifyRegisters(bytes4 callbackFnSig, bytes memory inputs) internal {\n address[] memory registers = _getCallbackRegisters().values();\n uint256 length = registers.length;\n if (length == 0) return;\n\n bool[] memory statuses = new bool[](length);\n bytes[] memory returnDatas = new bytes[](length);\n bytes memory callData = abi.encodePacked(callbackFnSig, inputs);\n\n for (uint256 i; i < length; ) {\n (statuses[i], returnDatas[i]) = registers[i].call(callData);\n\n unchecked {\n ++i;\n }\n }\n\n emit Notified(callData, registers, statuses, returnDatas);\n }\n\n /**\n * @dev Internal function to retrieve the address set of callback registers.\n * @return callbackRegisters The storage reference to the callback registers.\n */\n function _getCallbackRegisters() internal pure returns (EnumerableSet.AddressSet storage callbackRegisters) {\n assembly (\"memory-safe\") {\n callbackRegisters.slot := CALLBACK_REGISTERS_SLOT\n }\n }\n}\n" + }, + "contracts/extensions/bridge-operator-governance/BridgeTrackingHelper.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract BridgeTrackingHelper {\n /// @dev Event emited when the bridge tracking contract tracks the invalid data, cause malform in sharing bridge reward.\n event BridgeTrackingIncorrectlyResponded();\n\n /**\n * @dev Internal function to validate the bridge tracking response for a given set of ballots.\n * @param totalBallot The total number of ballots available for the tracking response.\n * @param totalVote The total number of votes recorded in the tracking response.\n * @param ballots An array containing the individual ballot counts in the tracking response.\n * @return valid A boolean indicating whether the bridge tracking response is valid or not.\n * @notice The function checks if each individual ballot count is not greater than the total votes recorded.\n * @notice It also verifies that the sum of all individual ballot counts does not exceed the total available ballots.\n */\n function _isValidBridgeTrackingResponse(\n uint256 totalBallot,\n uint256 totalVote,\n uint256[] memory ballots\n ) internal pure returns (bool valid) {\n valid = true;\n uint256 sumBallot;\n uint256 length = ballots.length;\n\n unchecked {\n for (uint256 i; i < length; ++i) {\n if (ballots[i] > totalVote) {\n valid = false;\n break;\n }\n\n sumBallot += ballots[i];\n }\n }\n\n valid = valid && (sumBallot <= totalBallot);\n }\n}\n" + }, + "contracts/extensions/collections/HasContracts.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { HasProxyAdmin } from \"./HasProxyAdmin.sol\";\nimport \"../../interfaces/collections/IHasContracts.sol\";\nimport { IdentityGuard } from \"../../utils/IdentityGuard.sol\";\nimport { ErrUnexpectedInternalCall } from \"../../utils/CommonErrors.sol\";\n\n/**\n * @title HasContracts\n * @dev A contract that provides functionality to manage multiple contracts with different roles.\n */\nabstract contract HasContracts is HasProxyAdmin, IHasContracts, IdentityGuard {\n /// @dev value is equal to keccak256(\"@ronin.dpos.collections.HasContracts.slot\") - 1\n bytes32 private constant _STORAGE_SLOT = 0xdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb;\n\n /**\n * @dev Modifier to restrict access to functions only to contracts with a specific role.\n * @param contractType The contract type that allowed to call\n */\n modifier onlyContract(ContractType contractType) virtual {\n _requireContract(contractType);\n _;\n }\n\n /**\n * @inheritdoc IHasContracts\n */\n function setContract(ContractType contractType, address addr) external virtual onlyAdmin {\n _requireHasCode(addr);\n _setContract(contractType, addr);\n }\n\n /**\n * @inheritdoc IHasContracts\n */\n function getContract(ContractType contractType) public view returns (address contract_) {\n contract_ = _getContractMap()[uint8(contractType)];\n if (contract_ == address(0)) revert ErrContractTypeNotFound(contractType);\n }\n\n /**\n * @dev Internal function to set the address of a contract with a specific role.\n * @param contractType The contract type of the contract to set.\n * @param addr The address of the contract to set.\n */\n function _setContract(ContractType contractType, address addr) internal virtual {\n _getContractMap()[uint8(contractType)] = addr;\n emit ContractUpdated(contractType, addr);\n }\n\n /**\n * @dev Internal function to access the mapping of contract addresses with roles.\n * @return contracts_ The mapping of contract addresses with roles.\n */\n function _getContractMap() private pure returns (mapping(uint8 => address) storage contracts_) {\n assembly {\n contracts_.slot := _STORAGE_SLOT\n }\n }\n\n /**\n * @dev Internal function to check if the calling contract has a specific role.\n * @param contractType The contract type that the calling contract must have.\n * @dev Throws an error if the calling contract does not have the specified role.\n */\n function _requireContract(ContractType contractType) private view {\n if (msg.sender != getContract(contractType)) {\n revert ErrUnexpectedInternalCall(msg.sig, contractType, msg.sender);\n }\n }\n}\n" + }, + "contracts/extensions/collections/HasProxyAdmin.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/StorageSlot.sol\";\nimport \"../../utils/CommonErrors.sol\";\n\nabstract contract HasProxyAdmin {\n // bytes32(uint256(keccak256(\"eip1967.proxy.admin\")) - 1));\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n modifier onlyAdmin() {\n _requireAdmin();\n _;\n }\n\n /**\n * @dev Returns proxy admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n function _requireAdmin() internal view {\n if (msg.sender != _getAdmin()) revert ErrUnauthorized(msg.sig, RoleAccess.ADMIN);\n }\n}\n" + }, + "contracts/extensions/consumers/GlobalConfigConsumer.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nabstract contract GlobalConfigConsumer {\n /// @dev The addition amount of gas sending along in external calls. Total gas stipend is added with default 2300 gas.\n uint256 public constant DEFAULT_ADDITION_GAS = 1200;\n /// @dev The length of a period in second.\n uint256 public constant PERIOD_DURATION = 1 days;\n}\n" + }, + "contracts/extensions/consumers/PercentageConsumer.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract PercentageConsumer {\n uint256 internal constant _MAX_PERCENTAGE = 100_00;\n}\n" + }, + "contracts/extensions/forwarder/Forwarder.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/access/AccessControlEnumerable.sol\";\nimport { ErrorHandler } from \"../../libraries/ErrorHandler.sol\";\n\ncontract Forwarder is AccessControlEnumerable {\n using ErrorHandler for bool;\n\n /**\n * @dev Error thrown when an invalid forward value is provided.\n */\n error ErrInvalidForwardValue();\n\n /// @dev Only user with moderator role can invoke {functionCall} method to forward the call to the target.\n bytes32 public constant MODERATOR_ROLE = keccak256(\"MODERATOR_ROLE\");\n\n /**\n * @dev The target contracts must be registerred by the admin before called to. The admin can register the targets at\n * the contract construction or by assigning {TARGET_ROLE} to the target addresses.\n */\n bytes32 public constant TARGET_ROLE = keccak256(\"TARGET_ROLE\");\n\n /**\n * @dev Initializes the forwarder with an initial target address and a contract admin.\n */\n constructor(address[] memory _targets, address _admin, address _moderator) payable {\n for (uint _i = 0; _i < _targets.length; ) {\n _setupRole(TARGET_ROLE, _targets[_i]);\n\n unchecked {\n ++_i;\n }\n }\n _setupRole(DEFAULT_ADMIN_ROLE, _admin);\n _setupRole(MODERATOR_ROLE, _moderator);\n }\n\n modifier validTarget(address _target) {\n _checkRole(TARGET_ROLE, _target);\n _;\n }\n\n /**\n * @dev Receives RON transfer from all addresses.\n */\n fallback() external payable {}\n\n /**\n * @dev Receives RON transfer from all addresses.\n */\n receive() external payable {}\n\n /**\n * @dev Forwards the encoded call specified by `_data` to the target. The forwarder attachs `_val` value\n * from the forwarder contract and sends along with the call.\n *\n * Requirements:\n * - Only target with {TARGET_ROLE} can be called to.\n * - Only user with {MODERATOR_ROLE} can call this method.\n */\n function functionCall(\n address _target,\n bytes memory _data,\n uint256 _val\n ) external payable validTarget(_target) onlyRole(MODERATOR_ROLE) {\n if (_val > address(this).balance) revert ErrInvalidForwardValue();\n _call(_target, _data, _val);\n }\n\n /**\n * @dev Forwards the current call to `target`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _call(address _target, bytes memory _data, uint256 _value) internal {\n (bool _success, bytes memory _res) = _target.call{ value: _value }(_data);\n _success.handleRevert(bytes4(_data), _res);\n }\n}\n" + }, + "contracts/extensions/GatewayV2.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/security/Pausable.sol\";\nimport \"../interfaces/IQuorum.sol\";\nimport \"./collections/HasProxyAdmin.sol\";\n\nabstract contract GatewayV2 is HasProxyAdmin, Pausable, IQuorum {\n uint256 internal _num;\n uint256 internal _denom;\n\n address private ______deprecated;\n uint256 public nonce;\n\n address public emergencyPauser;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[49] private ______gap;\n\n /**\n * @dev Grant emergency pauser role for `_addr`.\n */\n function setEmergencyPauser(address _addr) external onlyAdmin {\n emergencyPauser = _addr;\n }\n\n /**\n * @inheritdoc IQuorum\n */\n function getThreshold() external view virtual returns (uint256 num_, uint256 denom_) {\n return (_num, _denom);\n }\n\n /**\n * @inheritdoc IQuorum\n */\n function checkThreshold(uint256 _voteWeight) external view virtual returns (bool) {\n return _voteWeight * _denom >= _num * _getTotalWeight();\n }\n\n /**\n * @inheritdoc IQuorum\n */\n function setThreshold(\n uint256 _numerator,\n uint256 _denominator\n ) external virtual onlyAdmin returns (uint256, uint256) {\n return _setThreshold(_numerator, _denominator);\n }\n\n /**\n * @dev Triggers paused state.\n */\n function pause() external {\n _requireAuth();\n _pause();\n }\n\n /**\n * @dev Triggers unpaused state.\n */\n function unpause() external {\n _requireAuth();\n _unpause();\n }\n\n /**\n * @inheritdoc IQuorum\n */\n function minimumVoteWeight() public view virtual returns (uint256) {\n return _minimumVoteWeight(_getTotalWeight());\n }\n\n /**\n * @dev Sets threshold and returns the old one.\n *\n * Emits the `ThresholdUpdated` event.\n *\n */\n function _setThreshold(\n uint256 _numerator,\n uint256 _denominator\n ) internal virtual returns (uint256 _previousNum, uint256 _previousDenom) {\n if (_numerator > _denominator) revert ErrInvalidThreshold(msg.sig);\n _previousNum = _num;\n _previousDenom = _denom;\n _num = _numerator;\n _denom = _denominator;\n unchecked {\n emit ThresholdUpdated(nonce++, _numerator, _denominator, _previousNum, _previousDenom);\n }\n }\n\n /**\n * @dev Returns minimum vote weight.\n */\n function _minimumVoteWeight(uint256 _totalWeight) internal view virtual returns (uint256) {\n return (_num * _totalWeight + _denom - 1) / _denom;\n }\n\n /**\n * @dev Internal method to check method caller.\n *\n * Requirements:\n *\n * - The method caller must be admin or pauser.\n *\n */\n function _requireAuth() private view {\n if (!(msg.sender == _getAdmin() || msg.sender == emergencyPauser)) {\n revert ErrUnauthorized(msg.sig, RoleAccess.ADMIN);\n }\n }\n\n /**\n * @dev Returns the total weight.\n */\n function _getTotalWeight() internal view virtual returns (uint256);\n}\n" + }, + "contracts/extensions/GovernanceAdmin.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../extensions/sequential-governance/CoreGovernance.sol\";\nimport \"../extensions/collections/HasContracts.sol\";\nimport \"../interfaces/IRoninTrustedOrganization.sol\";\nimport { ErrorHandler } from \"../libraries/ErrorHandler.sol\";\nimport { IdentityGuard } from \"../utils/IdentityGuard.sol\";\nimport { HasGovernanceAdminDeprecated, HasBridgeDeprecated } from \"../utils/DeprecatedSlots.sol\";\n\nabstract contract GovernanceAdmin is\n CoreGovernance,\n IdentityGuard,\n HasContracts,\n HasGovernanceAdminDeprecated,\n HasBridgeDeprecated\n{\n using ErrorHandler for bool;\n\n uint256 public roninChainId;\n /// @dev Domain separator\n bytes32 public DOMAIN_SEPARATOR;\n\n constructor(uint256 _roninChainId, address _roninTrustedOrganizationContract) {\n roninChainId = _roninChainId;\n\n /*\n * DOMAIN_SEPARATOR = keccak256(\n * abi.encode(\n * keccak256(\"EIP712Domain(string name,string version,bytes32 salt)\"),\n * keccak256(\"GovernanceAdmin\"), // name hash\n * keccak256(\"2\"), // version hash\n * keccak256(abi.encode(\"RONIN_GOVERNANCE_ADMIN\", _roninChainId)) // salt\n * )\n */\n assembly {\n let ptr := mload(0x40)\n\n // See abi.encode implementation: https://github.com/axieinfinity/ronin/blob/569ebd5a782da5601c6aba22799dc9b4afd39da9/accounts/abi/argument.go#L227-L267\n mstore(ptr, 0x40) // offset bytes\n mstore(add(ptr, 0x20), _roninChainId)\n mstore(add(ptr, 0x40), 0x16) // \"RONIN_GOVERNANCE_ADMIN\".length\n mstore(add(ptr, 0x60), 0x524f4e494e5f474f5645524e414e43455f41444d494e00000000000000000000) // bytes(\"RONIN_GOVERNANCE_ADMIN\")\n let salt := keccak256(ptr, 0x80) // keccak256(abi.encode(\"RONIN_GOVERNANCE_ADMIN\", _roninChainId))\n\n mstore(ptr, 0x599a80fcaa47b95e2323ab4d34d34e0cc9feda4b843edafcc30c7bdf60ea15bf) // keccak256(\"EIP712Domain(string name,string version,bytes32 salt)\")\n mstore(add(ptr, 0x20), 0x7e7935007966eb860f4a2ee3dcc9fd53fb3205ce2aa86b0126d4893d4d4c14b9) // keccak256(\"GovernanceAdmin\")\n mstore(add(ptr, 0x40), 0x2a80e1ef1d7842f27f2e6be0972bb708b9a135c38860dbe73c27c3486c34f4de) // keccak256(\"3\")\n mstore(add(ptr, 0x60), salt)\n sstore(DOMAIN_SEPARATOR.slot, keccak256(ptr, 0x80))\n }\n\n _setContract(ContractType.RONIN_TRUSTED_ORGANIZATION, _roninTrustedOrganizationContract);\n }\n\n /**\n * @inheritdoc IHasContracts\n */\n function setContract(ContractType contractType, address addr) external virtual override onlySelfCall {\n _requireHasCode(addr);\n _setContract(contractType, addr);\n }\n\n /**\n * @dev Sets the expiry duration for a new proposal.\n *\n * Requirements:\n * - Only allowing self-call to this method, since this contract does not have admin.\n *\n */\n function setProposalExpiryDuration(uint256 _expiryDuration) external onlySelfCall {\n _setProposalExpiryDuration(_expiryDuration);\n }\n\n /**\n * @dev Returns the current implementation of `_proxy`.\n *\n * Requirements:\n * - This contract must be the admin of `_proxy`.\n *\n */\n function getProxyImplementation(address _proxy) external view returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"implementation()\")) == 0x5c60da1b\n bytes4 _selector = 0x5c60da1b;\n (bool _success, bytes memory _returndata) = _proxy.staticcall(abi.encodeWithSelector(_selector));\n _success.handleRevert(_selector, _returndata);\n return abi.decode(_returndata, (address));\n }\n\n /**\n * @dev Returns the proposal expiry duration.\n */\n function getProposalExpiryDuration() external view returns (uint256) {\n return super._getProposalExpiryDuration();\n }\n\n /**\n * @dev Returns the current admin of `_proxy`.\n *\n * Requirements:\n * - This contract must be the admin of `_proxy`.\n *\n */\n function getProxyAdmin(address _proxy) external view returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"admin()\")) == 0xf851a440\n bytes4 _selector = 0xf851a440;\n (bool _success, bytes memory _returndata) = _proxy.staticcall(abi.encodeWithSelector(_selector));\n _success.handleRevert(_selector, _returndata);\n return abi.decode(_returndata, (address));\n }\n\n /**\n * @dev Changes the admin of `_proxy` to `newAdmin`.\n *\n * Requirements:\n * - This contract must be the current admin of `_proxy`.\n *\n */\n function changeProxyAdmin(address _proxy, address _newAdmin) external onlySelfCall {\n // bytes4(keccak256(\"changeAdmin(address)\"))\n bytes4 _selector = 0x8f283970;\n (bool _success, bytes memory _returndata) = _proxy.call(abi.encodeWithSelector(_selector, _newAdmin));\n _success.handleRevert(_selector, _returndata);\n }\n\n /**\n * @dev Override `CoreGovernance-_getMinimumVoteWeight`.\n */\n function _getMinimumVoteWeight() internal view virtual override returns (uint256) {\n bytes4 _selector = IQuorum.minimumVoteWeight.selector;\n (bool _success, bytes memory _returndata) = getContract(ContractType.RONIN_TRUSTED_ORGANIZATION).staticcall(\n abi.encodeWithSelector(\n // TransparentUpgradeableProxyV2.functionDelegateCall.selector,\n 0x4bb5274a,\n abi.encodeWithSelector(_selector)\n )\n );\n _success.handleRevert(_selector, _returndata);\n return abi.decode(_returndata, (uint256));\n }\n\n /**\n * @dev Override `CoreGovernance-_getTotalWeights`.\n */\n function _getTotalWeights() internal view virtual override returns (uint256) {\n bytes4 _selector = IRoninTrustedOrganization.totalWeights.selector;\n (bool _success, bytes memory _returndata) = getContract(ContractType.RONIN_TRUSTED_ORGANIZATION).staticcall(\n abi.encodeWithSelector(\n // TransparentUpgradeableProxyV2.functionDelegateCall.selector,\n 0x4bb5274a,\n abi.encodeWithSelector(_selector)\n )\n );\n _success.handleRevert(_selector, _returndata);\n return abi.decode(_returndata, (uint256));\n }\n}\n" + }, + "contracts/extensions/MinimumWithdrawal.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./collections/HasProxyAdmin.sol\";\nimport \"../libraries/Transfer.sol\";\n\nabstract contract MinimumWithdrawal is HasProxyAdmin {\n /// @dev Throwed when the ERC20 withdrawal quantity is less than the minimum threshold.\n error ErrQueryForTooSmallQuantity();\n\n /// @dev Emitted when the minimum thresholds are updated\n event MinimumThresholdsUpdated(address[] tokens, uint256[] threshold);\n\n /// @dev Mapping from token address => minimum thresholds\n mapping(address => uint256) public minimumThreshold;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[50] private ______gap;\n\n /**\n * @dev Sets the minimum thresholds to withdraw.\n *\n * Requirements:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `MinimumThresholdsUpdated` event.\n *\n */\n function setMinimumThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) external virtual onlyAdmin {\n if (_tokens.length == 0) revert ErrEmptyArray();\n _setMinimumThresholds(_tokens, _thresholds);\n }\n\n /**\n * @dev Sets minimum thresholds.\n *\n * Requirements:\n * - The array lengths are equal.\n *\n * Emits the `MinimumThresholdsUpdated` event.\n *\n */\n function _setMinimumThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) internal virtual {\n if (_tokens.length != _thresholds.length) revert ErrLengthMismatch(msg.sig);\n\n for (uint256 _i; _i < _tokens.length; ) {\n minimumThreshold[_tokens[_i]] = _thresholds[_i];\n\n unchecked {\n ++_i;\n }\n }\n emit MinimumThresholdsUpdated(_tokens, _thresholds);\n }\n\n /**\n * @dev Checks whether the request is larger than or equal to the minimum threshold.\n */\n function _checkWithdrawal(Transfer.Request calldata _request) internal view {\n if (_request.info.erc == Token.Standard.ERC20 && _request.info.quantity < minimumThreshold[_request.tokenAddr]) {\n revert ErrQueryForTooSmallQuantity();\n }\n }\n}\n" + }, + "contracts/extensions/RONTransferHelper.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nabstract contract RONTransferHelper {\n /// @dev Error of sender has insufficient balance.\n error ErrInsufficientBalance(bytes4 msgSig, uint256 currentBalance, uint256 sendAmount);\n /// @dev Error of recipient not accepting RON when transfer RON.\n error ErrRecipientRevert(bytes4 msgSig);\n\n /**\n * @dev See `_sendRON`.\n * Reverts if the recipient does not receive RON.\n */\n function _transferRON(address payable recipient, uint256 amount) internal {\n if (!_sendRON(recipient, amount)) revert ErrRecipientRevert(msg.sig);\n }\n\n /**\n * @dev Send `amount` RON to the address `recipient`.\n * Returns whether the recipient receives RON or not.\n * Reverts once the contract balance is insufficient.\n *\n * Note: consider using `ReentrancyGuard` before calling this function.\n *\n */\n function _sendRON(address payable recipient, uint256 amount) internal returns (bool success) {\n if (address(this).balance < amount) revert ErrInsufficientBalance(msg.sig, address(this).balance, amount);\n return _unsafeSendRON(recipient, amount);\n }\n\n /**\n * @dev Unsafe send `amount` RON to the address `recipient`. If the sender's balance is insufficient,\n * the call does not revert.\n *\n * Note:\n * - Does not assert whether the balance of sender is sufficient.\n * - Does not assert whether the recipient accepts RON.\n * - Consider using `ReentrancyGuard` before calling this function.\n *\n */\n function _unsafeSendRON(address payable recipient, uint256 amount) internal returns (bool success) {\n (success, ) = recipient.call{ value: amount }(\"\");\n }\n\n /**\n * @dev Same purpose with {_unsafeSendRONLimitGas(address,uin256)} but containing gas limit stipend forwarded in the call.\n */\n function _unsafeSendRONLimitGas(\n address payable recipient,\n uint256 amount,\n uint256 gas\n ) internal returns (bool success) {\n (success, ) = recipient.call{ value: amount, gas: gas }(\"\");\n }\n}\n" + }, + "contracts/extensions/sequential-governance/CoreGovernance.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../../libraries/Proposal.sol\";\nimport \"../../libraries/GlobalProposal.sol\";\nimport \"../../utils/CommonErrors.sol\";\nimport \"../../libraries/Ballot.sol\";\nimport \"../../interfaces/consumers/ChainTypeConsumer.sol\";\nimport \"../../interfaces/consumers/SignatureConsumer.sol\";\nimport \"../../interfaces/consumers/VoteStatusConsumer.sol\";\n\nabstract contract CoreGovernance is SignatureConsumer, VoteStatusConsumer, ChainTypeConsumer {\n using Proposal for Proposal.ProposalDetail;\n\n /**\n * @dev Error thrown when attempting to interact with a finalized vote.\n */\n error ErrVoteIsFinalized();\n\n /**\n * @dev Error thrown when the current proposal is not completed.\n */\n error ErrCurrentProposalIsNotCompleted();\n\n struct ProposalVote {\n VoteStatus status;\n bytes32 hash;\n uint256 againstVoteWeight; // Total weight of against votes\n uint256 forVoteWeight; // Total weight of for votes\n address[] forVoteds; // Array of addresses voting for\n address[] againstVoteds; // Array of addresses voting against\n uint256 expiryTimestamp;\n mapping(address => Signature) sig;\n mapping(address => bool) voted;\n }\n\n /// @dev Emitted when a proposal is created\n event ProposalCreated(\n uint256 indexed chainId,\n uint256 indexed round,\n bytes32 indexed proposalHash,\n Proposal.ProposalDetail proposal,\n address creator\n );\n /// @dev Emitted when the proposal is voted\n event ProposalVoted(bytes32 indexed proposalHash, address indexed voter, Ballot.VoteType support, uint256 weight);\n /// @dev Emitted when the proposal is approved\n event ProposalApproved(bytes32 indexed proposalHash);\n /// @dev Emitted when the vote is reject\n event ProposalRejected(bytes32 indexed proposalHash);\n /// @dev Emitted when the vote is expired\n event ProposalExpired(bytes32 indexed proposalHash);\n /// @dev Emitted when the proposal is executed\n event ProposalExecuted(bytes32 indexed proposalHash, bool[] successCalls, bytes[] returnDatas);\n /// @dev Emitted when the proposal expiry duration is changed.\n event ProposalExpiryDurationChanged(uint256 indexed duration);\n\n /// @dev Mapping from chain id => vote round\n /// @notice chain id = 0 for global proposal\n mapping(uint256 => uint256) public round;\n /// @dev Mapping from chain id => vote round => proposal vote\n mapping(uint256 => mapping(uint256 => ProposalVote)) public vote;\n\n uint256 internal _proposalExpiryDuration;\n\n constructor(uint256 _expiryDuration) {\n _setProposalExpiryDuration(_expiryDuration);\n }\n\n /**\n * @dev Creates new voting round by calculating the `_round` number of chain `_chainId`.\n * Increases the `_round` number if the previous one is not expired. Delete the previous proposal\n * if it is expired and not increase the `_round`.\n */\n function _createVotingRound(uint256 _chainId) internal returns (uint256 _round) {\n _round = round[_chainId];\n // Skip checking for the first ever round\n if (_round == 0) {\n _round = round[_chainId] = 1;\n } else {\n ProposalVote storage _latestProposalVote = vote[_chainId][_round];\n bool _isExpired = _tryDeleteExpiredVotingRound(_latestProposalVote);\n // Skip increasing round number if the latest round is expired, allow the vote to be overridden\n if (!_isExpired) {\n if (_latestProposalVote.status == VoteStatus.Pending) revert ErrCurrentProposalIsNotCompleted();\n unchecked {\n _round = ++round[_chainId];\n }\n }\n }\n }\n\n /**\n * @dev Saves new round voting for the proposal `_proposalHash` of chain `_chainId`.\n */\n function _saveVotingRound(ProposalVote storage _vote, bytes32 _proposalHash, uint256 _expiryTimestamp) internal {\n _vote.hash = _proposalHash;\n _vote.expiryTimestamp = _expiryTimestamp;\n }\n\n /**\n * @dev Proposes for a new proposal.\n *\n * Requirements:\n * - The chain id is not equal to 0.\n *\n * Emits the `ProposalCreated` event.\n *\n */\n function _proposeProposal(\n uint256 chainId,\n uint256 expiryTimestamp,\n address[] memory targets,\n uint256[] memory values,\n bytes[] memory calldatas,\n uint256[] memory gasAmounts,\n address creator\n ) internal virtual returns (Proposal.ProposalDetail memory proposal) {\n if (chainId == 0) revert ErrInvalidChainId(msg.sig, 0, block.chainid);\n uint256 round_ = _createVotingRound(chainId);\n\n proposal = Proposal.ProposalDetail(round_, chainId, expiryTimestamp, targets, values, calldatas, gasAmounts);\n proposal.validate(_proposalExpiryDuration);\n\n bytes32 proposalHash = proposal.hash();\n _saveVotingRound(vote[chainId][round_], proposalHash, expiryTimestamp);\n emit ProposalCreated(chainId, round_, proposalHash, proposal, creator);\n }\n\n /**\n * @dev Proposes proposal struct.\n *\n * Requirements:\n * - The chain id is not equal to 0.\n * - The proposal nonce is equal to the new round.\n *\n * Emits the `ProposalCreated` event.\n *\n */\n function _proposeProposalStruct(\n Proposal.ProposalDetail memory proposal,\n address creator\n ) internal virtual returns (uint256 round_) {\n uint256 chainId = proposal.chainId;\n if (chainId == 0) revert ErrInvalidChainId(msg.sig, 0, block.chainid);\n proposal.validate(_proposalExpiryDuration);\n\n bytes32 proposalHash = proposal.hash();\n round_ = _createVotingRound(chainId);\n _saveVotingRound(vote[chainId][round_], proposalHash, proposal.expiryTimestamp);\n if (round_ != proposal.nonce) revert ErrInvalidProposalNonce(msg.sig);\n emit ProposalCreated(chainId, round_, proposalHash, proposal, creator);\n }\n\n /**\n * @dev Casts vote for the proposal with data and returns whether the voting is done.\n *\n * Requirements:\n * - The proposal nonce is equal to the round.\n * - The vote is not finalized.\n * - The voter has not voted for the round.\n *\n * Emits the `ProposalVoted` event. Emits the `ProposalApproved`, `ProposalExecuted` or `ProposalRejected` once the\n * proposal is approved, executed or rejected.\n *\n */\n function _castVote(\n Proposal.ProposalDetail memory proposal,\n Ballot.VoteType support,\n uint256 minimumForVoteWeight,\n uint256 minimumAgainstVoteWeight,\n address voter,\n Signature memory signature,\n uint256 voterWeight\n ) internal virtual returns (bool done) {\n uint256 chainId = proposal.chainId;\n uint256 round_ = proposal.nonce;\n ProposalVote storage _vote = vote[chainId][round_];\n\n if (_tryDeleteExpiredVotingRound(_vote)) {\n return true;\n }\n\n if (round[proposal.chainId] != round_) revert ErrInvalidProposalNonce(msg.sig);\n if (_vote.status != VoteStatus.Pending) revert ErrVoteIsFinalized();\n if (_voted(_vote, voter)) revert ErrAlreadyVoted(voter);\n\n _vote.voted[voter] = true;\n // Stores the signature if it is not empty\n if (signature.r > 0 || signature.s > 0 || signature.v > 0) {\n _vote.sig[voter] = signature;\n }\n emit ProposalVoted(_vote.hash, voter, support, voterWeight);\n\n uint256 _forVoteWeight;\n uint256 _againstVoteWeight;\n if (support == Ballot.VoteType.For) {\n _vote.forVoteds.push(voter);\n _forVoteWeight = _vote.forVoteWeight += voterWeight;\n } else if (support == Ballot.VoteType.Against) {\n _vote.againstVoteds.push(voter);\n _againstVoteWeight = _vote.againstVoteWeight += voterWeight;\n } else revert ErrUnsupportedVoteType(msg.sig);\n\n if (_forVoteWeight >= minimumForVoteWeight) {\n done = true;\n _vote.status = VoteStatus.Approved;\n emit ProposalApproved(_vote.hash);\n _tryExecute(_vote, proposal);\n } else if (_againstVoteWeight >= minimumAgainstVoteWeight) {\n done = true;\n _vote.status = VoteStatus.Rejected;\n emit ProposalRejected(_vote.hash);\n }\n }\n\n /**\n * @dev When the contract is on Ronin chain, checks whether the proposal is expired and delete it if is expired.\n *\n * Emits the event `ProposalExpired` if the vote is expired.\n *\n * Note: This function assumes the vote `_proposalVote` is already created, consider verifying the vote's existence\n * before or it will emit an unexpected event of `ProposalExpired`.\n */\n function _tryDeleteExpiredVotingRound(ProposalVote storage proposalVote) internal returns (bool isExpired) {\n isExpired =\n _getChainType() == ChainType.RoninChain &&\n proposalVote.status == VoteStatus.Pending &&\n proposalVote.expiryTimestamp <= block.timestamp;\n\n if (isExpired) {\n emit ProposalExpired(proposalVote.hash);\n\n for (uint256 _i; _i < proposalVote.forVoteds.length; ) {\n delete proposalVote.voted[proposalVote.forVoteds[_i]];\n delete proposalVote.sig[proposalVote.forVoteds[_i]];\n\n unchecked {\n ++_i;\n }\n }\n for (uint256 _i; _i < proposalVote.againstVoteds.length; ) {\n delete proposalVote.voted[proposalVote.againstVoteds[_i]];\n delete proposalVote.sig[proposalVote.againstVoteds[_i]];\n\n unchecked {\n ++_i;\n }\n }\n delete proposalVote.status;\n delete proposalVote.hash;\n delete proposalVote.againstVoteWeight;\n delete proposalVote.forVoteWeight;\n delete proposalVote.forVoteds;\n delete proposalVote.againstVoteds;\n delete proposalVote.expiryTimestamp;\n }\n }\n\n /**\n * @dev Executes the proposal and update the vote status once the proposal is executable.\n */\n function _tryExecute(ProposalVote storage vote_, Proposal.ProposalDetail memory proposal) internal {\n if (proposal.executable()) {\n vote_.status = VoteStatus.Executed;\n (bool[] memory _successCalls, bytes[] memory _returnDatas) = proposal.execute();\n emit ProposalExecuted(vote_.hash, _successCalls, _returnDatas);\n }\n }\n\n /**\n * @dev Sets the expiry duration for a new proposal.\n */\n function _setProposalExpiryDuration(uint256 expiryDuration) internal {\n _proposalExpiryDuration = expiryDuration;\n emit ProposalExpiryDurationChanged(expiryDuration);\n }\n\n /**\n * @dev Returns the expiry duration for a new proposal.\n */\n function _getProposalExpiryDuration() internal view returns (uint256) {\n return _proposalExpiryDuration;\n }\n\n /**\n * @dev Returns whether the voter casted for the proposal.\n */\n function _voted(ProposalVote storage vote_, address voter) internal view returns (bool) {\n return vote_.voted[voter];\n }\n\n /**\n * @dev Returns total weight from validators.\n */\n function _getTotalWeights() internal view virtual returns (uint256);\n\n /**\n * @dev Returns minimum vote to pass a proposal.\n */\n function _getMinimumVoteWeight() internal view virtual returns (uint256);\n\n /**\n * @dev Returns current context is running on whether Ronin chain or on mainchain.\n */\n function _getChainType() internal view virtual returns (ChainType);\n}\n" + }, + "contracts/extensions/sequential-governance/GlobalCoreGovernance.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../../libraries/Proposal.sol\";\nimport \"../../libraries/GlobalProposal.sol\";\nimport \"./CoreGovernance.sol\";\n\nabstract contract GlobalCoreGovernance is CoreGovernance {\n using Proposal for Proposal.ProposalDetail;\n using GlobalProposal for GlobalProposal.GlobalProposalDetail;\n\n mapping(GlobalProposal.TargetOption => address) internal _targetOptionsMap;\n\n /// @dev Emitted when a proposal is created\n event GlobalProposalCreated(\n uint256 indexed round,\n bytes32 indexed proposalHash,\n Proposal.ProposalDetail proposal,\n bytes32 globalProposalHash,\n GlobalProposal.GlobalProposalDetail globalProposal,\n address creator\n );\n\n /// @dev Emitted when the target options are updated\n event TargetOptionUpdated(GlobalProposal.TargetOption indexed targetOption, address indexed addr);\n\n constructor(GlobalProposal.TargetOption[] memory targetOptions, address[] memory addrs) {\n _updateTargetOption(GlobalProposal.TargetOption.BridgeManager, address(this));\n _updateManyTargetOption(targetOptions, addrs);\n }\n\n /**\n * @dev Proposes for a global proposal.\n *\n * Emits the `GlobalProposalCreated` event.\n *\n */\n function _proposeGlobal(\n uint256 expiryTimestamp,\n GlobalProposal.TargetOption[] calldata targetOptions,\n uint256[] memory values,\n bytes[] memory calldatas,\n uint256[] memory gasAmounts,\n address creator\n ) internal virtual {\n uint256 round_ = _createVotingRound(0);\n GlobalProposal.GlobalProposalDetail memory globalProposal = GlobalProposal.GlobalProposalDetail(\n round_,\n expiryTimestamp,\n targetOptions,\n values,\n calldatas,\n gasAmounts\n );\n Proposal.ProposalDetail memory proposal = globalProposal.intoProposalDetail(\n _resolveTargets({ targetOptions: targetOptions, strict: true })\n );\n proposal.validate(_proposalExpiryDuration);\n\n bytes32 proposalHash = proposal.hash();\n _saveVotingRound(vote[0][round_], proposalHash, expiryTimestamp);\n emit GlobalProposalCreated(round_, proposalHash, proposal, globalProposal.hash(), globalProposal, creator);\n }\n\n /**\n * @dev Proposes global proposal struct.\n *\n * Requirements:\n * - The proposal nonce is equal to the new round.\n *\n * Emits the `GlobalProposalCreated` event.\n *\n */\n function _proposeGlobalStruct(\n GlobalProposal.GlobalProposalDetail memory globalProposal,\n address creator\n ) internal virtual returns (Proposal.ProposalDetail memory proposal) {\n proposal = globalProposal.intoProposalDetail(\n _resolveTargets({ targetOptions: globalProposal.targetOptions, strict: true })\n );\n proposal.validate(_proposalExpiryDuration);\n\n bytes32 proposalHash = proposal.hash();\n uint256 round_ = _createVotingRound(0);\n _saveVotingRound(vote[0][round_], proposalHash, globalProposal.expiryTimestamp);\n\n if (round_ != proposal.nonce) revert ErrInvalidProposalNonce(msg.sig);\n emit GlobalProposalCreated(round_, proposalHash, proposal, globalProposal.hash(), globalProposal, creator);\n }\n\n /**\n * @dev Returns corresponding address of target options. Return address(0) on non-existent target.\n */\n function resolveTargets(\n GlobalProposal.TargetOption[] calldata targetOptions\n ) external view returns (address[] memory targets) {\n return _resolveTargets({ targetOptions: targetOptions, strict: false });\n }\n\n /**\n * @dev Internal helper of {resolveTargets}.\n *\n * @param strict When the param is set to `true`, revert on non-existent target.\n */\n function _resolveTargets(\n GlobalProposal.TargetOption[] memory targetOptions,\n bool strict\n ) internal view returns (address[] memory targets) {\n targets = new address[](targetOptions.length);\n\n for (uint256 i; i < targetOptions.length; ) {\n targets[i] = _targetOptionsMap[targetOptions[i]];\n if (strict && targets[i] == address(0)) revert ErrInvalidArguments(msg.sig);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @dev Updates list of `targetOptions` to `targets`.\n *\n * Requirement:\n * - Only allow self-call through proposal.\n * */\n function updateManyTargetOption(\n GlobalProposal.TargetOption[] memory targetOptions,\n address[] memory targets\n ) external {\n // HACK: Cannot reuse the existing library due to too deep stack\n if (msg.sender != address(this)) revert ErrOnlySelfCall(msg.sig);\n _updateManyTargetOption(targetOptions, targets);\n }\n\n /**\n * @dev Updates list of `targetOptions` to `targets`.\n */\n function _updateManyTargetOption(\n GlobalProposal.TargetOption[] memory targetOptions,\n address[] memory targets\n ) internal {\n for (uint256 i; i < targetOptions.length; ) {\n if (targets[i] == address(this)) revert ErrInvalidArguments(msg.sig);\n _updateTargetOption(targetOptions[i], targets[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @dev Updates `targetOption` to `target`.\n *\n * Requirement:\n * - Emit a `TargetOptionUpdated` event.\n */\n function _updateTargetOption(GlobalProposal.TargetOption targetOption, address target) internal {\n _targetOptionsMap[targetOption] = target;\n emit TargetOptionUpdated(targetOption, target);\n }\n}\n" + }, + "contracts/extensions/sequential-governance/governance-proposal/CommonGovernanceProposal.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../CoreGovernance.sol\";\n\nabstract contract CommonGovernanceProposal is CoreGovernance {\n using Proposal for Proposal.ProposalDetail;\n\n /**\n * @dev Error thrown when an invalid proposal is encountered.\n * @param actual The actual value of the proposal.\n * @param expected The expected value of the proposal.\n */\n error ErrInvalidProposal(bytes32 actual, bytes32 expected);\n\n /**\n * @dev Casts votes by signatures.\n *\n * Note: This method does not verify the proposal hash with the vote hash. Please consider checking it before.\n *\n */\n function _castVotesBySignatures(\n Proposal.ProposalDetail memory _proposal,\n Ballot.VoteType[] calldata _supports,\n Signature[] calldata _signatures,\n bytes32 _forDigest,\n bytes32 _againstDigest\n ) internal {\n if (!(_supports.length != 0 && _supports.length == _signatures.length)) revert ErrLengthMismatch(msg.sig);\n\n uint256 _minimumForVoteWeight = _getMinimumVoteWeight();\n uint256 _minimumAgainstVoteWeight = _getTotalWeights() - _minimumForVoteWeight + 1;\n\n address _lastSigner;\n address _signer;\n Signature calldata _sig;\n bool _hasValidVotes;\n for (uint256 _i; _i < _signatures.length; ) {\n _sig = _signatures[_i];\n\n if (_supports[_i] == Ballot.VoteType.For) {\n _signer = ECDSA.recover(_forDigest, _sig.v, _sig.r, _sig.s);\n } else if (_supports[_i] == Ballot.VoteType.Against) {\n _signer = ECDSA.recover(_againstDigest, _sig.v, _sig.r, _sig.s);\n } else revert ErrUnsupportedVoteType(msg.sig);\n\n if (_lastSigner >= _signer) revert ErrInvalidOrder(msg.sig);\n _lastSigner = _signer;\n\n uint256 _weight = _getWeight(_signer);\n if (_weight > 0) {\n _hasValidVotes = true;\n if (\n _castVote(_proposal, _supports[_i], _minimumForVoteWeight, _minimumAgainstVoteWeight, _signer, _sig, _weight)\n ) {\n return;\n }\n }\n\n unchecked {\n ++_i;\n }\n }\n\n if (!_hasValidVotes) revert ErrInvalidSignatures(msg.sig);\n }\n\n /**\n * @dev Returns the voted signatures for the proposals.\n *\n * Note: The signatures can be empty in case the proposal is voted on the current network.\n *\n */\n function _getProposalSignatures(\n uint256 _chainId,\n uint256 _round\n )\n internal\n view\n returns (address[] memory _voters, Ballot.VoteType[] memory _supports, Signature[] memory _signatures)\n {\n ProposalVote storage _vote = vote[_chainId][_round];\n\n uint256 _forLength = _vote.forVoteds.length;\n uint256 _againstLength = _vote.againstVoteds.length;\n uint256 _voterLength = _forLength + _againstLength;\n\n _supports = new Ballot.VoteType[](_voterLength);\n _signatures = new Signature[](_voterLength);\n _voters = new address[](_voterLength);\n for (uint256 _i; _i < _forLength; ) {\n _supports[_i] = Ballot.VoteType.For;\n _signatures[_i] = vote[_chainId][_round].sig[_vote.forVoteds[_i]];\n _voters[_i] = _vote.forVoteds[_i];\n\n unchecked {\n ++_i;\n }\n }\n for (uint256 _i; _i < _againstLength; ) {\n _supports[_i + _forLength] = Ballot.VoteType.Against;\n _signatures[_i + _forLength] = vote[_chainId][_round].sig[_vote.againstVoteds[_i]];\n _voters[_i + _forLength] = _vote.againstVoteds[_i];\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @dev Returns whether the voter `_voter` casted vote for the proposal.\n */\n function _proposalVoted(uint256 _chainId, uint256 _round, address _voter) internal view returns (bool) {\n return _voted(vote[_chainId][_round], _voter);\n }\n\n /**\n * @dev Returns the weight of a governor.\n */\n function _getWeight(address _governor) internal view virtual returns (uint256);\n}\n" + }, + "contracts/extensions/sequential-governance/governance-proposal/GlobalGovernanceProposal.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../../../libraries/Proposal.sol\";\nimport \"../GlobalCoreGovernance.sol\";\nimport \"./CommonGovernanceProposal.sol\";\n\nabstract contract GlobalGovernanceProposal is GlobalCoreGovernance, CommonGovernanceProposal {\n using Proposal for Proposal.ProposalDetail;\n using GlobalProposal for GlobalProposal.GlobalProposalDetail;\n\n /**\n * @dev Proposes and votes by signature.\n */\n function _proposeGlobalProposalStructAndCastVotes(\n GlobalProposal.GlobalProposalDetail calldata globalProposal,\n Ballot.VoteType[] calldata supports_,\n Signature[] calldata signatures,\n bytes32 domainSeparator,\n address creator\n ) internal returns (Proposal.ProposalDetail memory proposal) {\n proposal = _proposeGlobalStruct(globalProposal, creator);\n bytes32 _globalProposalHash = globalProposal.hash();\n _castVotesBySignatures(\n proposal,\n supports_,\n signatures,\n ECDSA.toTypedDataHash(domainSeparator, Ballot.hash(_globalProposalHash, Ballot.VoteType.For)),\n ECDSA.toTypedDataHash(domainSeparator, Ballot.hash(_globalProposalHash, Ballot.VoteType.Against))\n );\n }\n\n /**\n * @dev Proposes a global proposal struct and casts votes by signature.\n */\n function _castGlobalProposalBySignatures(\n GlobalProposal.GlobalProposalDetail calldata globalProposal,\n Ballot.VoteType[] calldata supports_,\n Signature[] calldata signatures,\n bytes32 domainSeparator\n ) internal {\n Proposal.ProposalDetail memory _proposal = globalProposal.intoProposalDetail(\n _resolveTargets({ targetOptions: globalProposal.targetOptions, strict: true })\n );\n\n bytes32 proposalHash = _proposal.hash();\n if (vote[0][_proposal.nonce].hash != proposalHash)\n revert ErrInvalidProposal(proposalHash, vote[0][_proposal.nonce].hash);\n\n bytes32 globalProposalHash = globalProposal.hash();\n _castVotesBySignatures(\n _proposal,\n supports_,\n signatures,\n ECDSA.toTypedDataHash(domainSeparator, Ballot.hash(globalProposalHash, Ballot.VoteType.For)),\n ECDSA.toTypedDataHash(domainSeparator, Ballot.hash(globalProposalHash, Ballot.VoteType.Against))\n );\n }\n\n /**\n * @dev See {CommonGovernanceProposal-_getProposalSignatures}\n */\n function getGlobalProposalSignatures(\n uint256 round_\n ) external view returns (address[] memory voters, Ballot.VoteType[] memory supports_, Signature[] memory signatures) {\n return _getProposalSignatures(0, round_);\n }\n\n /**\n * @dev See {CommonGovernanceProposal-_proposalVoted}\n */\n function globalProposalVoted(uint256 round_, address voter) external view returns (bool) {\n return _proposalVoted(0, round_, voter);\n }\n}\n" + }, + "contracts/extensions/sequential-governance/governance-proposal/GovernanceProposal.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../CoreGovernance.sol\";\nimport \"./CommonGovernanceProposal.sol\";\n\nabstract contract GovernanceProposal is CoreGovernance, CommonGovernanceProposal {\n using Proposal for Proposal.ProposalDetail;\n\n /**\n * @dev Proposes a proposal struct and casts votes by signature.\n */\n function _proposeProposalStructAndCastVotes(\n Proposal.ProposalDetail calldata _proposal,\n Ballot.VoteType[] calldata _supports,\n Signature[] calldata _signatures,\n bytes32 _domainSeparator,\n address _creator\n ) internal {\n _proposeProposalStruct(_proposal, _creator);\n bytes32 _proposalHash = _proposal.hash();\n _castVotesBySignatures(\n _proposal,\n _supports,\n _signatures,\n ECDSA.toTypedDataHash(_domainSeparator, Ballot.hash(_proposalHash, Ballot.VoteType.For)),\n ECDSA.toTypedDataHash(_domainSeparator, Ballot.hash(_proposalHash, Ballot.VoteType.Against))\n );\n }\n\n /**\n * @dev Proposes a proposal struct and casts votes by signature.\n */\n function _castProposalBySignatures(\n Proposal.ProposalDetail calldata _proposal,\n Ballot.VoteType[] calldata _supports,\n Signature[] calldata _signatures,\n bytes32 _domainSeparator\n ) internal {\n bytes32 _proposalHash = _proposal.hash();\n\n if (vote[_proposal.chainId][_proposal.nonce].hash != _proposalHash) {\n revert ErrInvalidProposal(_proposalHash, vote[_proposal.chainId][_proposal.nonce].hash);\n }\n\n _castVotesBySignatures(\n _proposal,\n _supports,\n _signatures,\n ECDSA.toTypedDataHash(_domainSeparator, Ballot.hash(_proposalHash, Ballot.VoteType.For)),\n ECDSA.toTypedDataHash(_domainSeparator, Ballot.hash(_proposalHash, Ballot.VoteType.Against))\n );\n }\n\n /**\n * @dev See `castProposalVoteForCurrentNetwork`.\n */\n function _castProposalVoteForCurrentNetwork(\n address _voter,\n Proposal.ProposalDetail memory _proposal,\n Ballot.VoteType _support\n ) internal {\n if (_proposal.chainId != block.chainid) revert ErrInvalidChainId(msg.sig, _proposal.chainId, block.chainid);\n\n bytes32 proposalHash = _proposal.hash();\n if (vote[_proposal.chainId][_proposal.nonce].hash != proposalHash)\n revert ErrInvalidProposal(proposalHash, vote[_proposal.chainId][_proposal.nonce].hash);\n\n uint256 _minimumForVoteWeight = _getMinimumVoteWeight();\n uint256 _minimumAgainstVoteWeight = _getTotalWeights() - _minimumForVoteWeight + 1;\n Signature memory _emptySignature;\n _castVote(\n _proposal,\n _support,\n _minimumForVoteWeight,\n _minimumAgainstVoteWeight,\n _voter,\n _emptySignature,\n _getWeight(_voter)\n );\n }\n\n /**\n * @dev See {CommonGovernanceProposal-_getProposalSignatures}\n */\n function getProposalSignatures(\n uint256 _chainId,\n uint256 _round\n )\n external\n view\n returns (address[] memory _voters, Ballot.VoteType[] memory _supports, Signature[] memory _signatures)\n {\n return _getProposalSignatures(_chainId, _round);\n }\n\n /**\n * @dev See {CommonGovernanceProposal-_proposalVoted}\n */\n function proposalVoted(uint256 _chainId, uint256 _round, address _voter) external view returns (bool) {\n return _proposalVoted(_chainId, _round, _voter);\n }\n}\n" + }, + "contracts/extensions/sequential-governance/governance-relay/CommonGovernanceRelay.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../CoreGovernance.sol\";\n\nabstract contract CommonGovernanceRelay is CoreGovernance {\n using Proposal for Proposal.ProposalDetail;\n using GlobalProposal for GlobalProposal.GlobalProposalDetail;\n\n /**\n * @dev Relays votes by signatures.\n *\n * @notice Does not store the voter signature into storage.\n *\n */\n function _relayVotesBySignatures(\n Proposal.ProposalDetail memory _proposal,\n Ballot.VoteType[] calldata _supports,\n Signature[] calldata _signatures,\n bytes32 _forDigest,\n bytes32 _againstDigest\n ) internal {\n if (!(_supports.length > 0 && _supports.length == _signatures.length)) revert ErrLengthMismatch(msg.sig);\n\n uint256 _forVoteCount;\n uint256 _againstVoteCount;\n address[] memory _forVoteSigners = new address[](_signatures.length);\n address[] memory _againstVoteSigners = new address[](_signatures.length);\n\n {\n address _signer;\n address _lastSigner;\n Ballot.VoteType _support;\n Signature calldata _sig;\n\n for (uint256 _i; _i < _signatures.length; ) {\n _sig = _signatures[_i];\n _support = _supports[_i];\n\n if (_support == Ballot.VoteType.For) {\n _signer = ECDSA.recover(_forDigest, _sig.v, _sig.r, _sig.s);\n _forVoteSigners[_forVoteCount++] = _signer;\n } else if (_support == Ballot.VoteType.Against) {\n _signer = ECDSA.recover(_againstDigest, _sig.v, _sig.r, _sig.s);\n _againstVoteSigners[_againstVoteCount++] = _signer;\n } else revert ErrUnsupportedVoteType(msg.sig);\n\n if (_lastSigner >= _signer) revert ErrInvalidOrder(msg.sig);\n _lastSigner = _signer;\n\n unchecked {\n ++_i;\n }\n }\n }\n\n assembly {\n mstore(_forVoteSigners, _forVoteCount)\n mstore(_againstVoteSigners, _againstVoteCount)\n }\n\n ProposalVote storage _vote = vote[_proposal.chainId][_proposal.nonce];\n uint256 _minimumForVoteWeight = _getMinimumVoteWeight();\n uint256 _totalForVoteWeight = _sumWeights(_forVoteSigners);\n if (_totalForVoteWeight >= _minimumForVoteWeight) {\n if (_totalForVoteWeight == 0) revert ErrInvalidVoteWeight(msg.sig);\n _vote.status = VoteStatus.Approved;\n emit ProposalApproved(_vote.hash);\n _tryExecute(_vote, _proposal);\n return;\n }\n\n uint256 _minimumAgainstVoteWeight = _getTotalWeights() - _minimumForVoteWeight + 1;\n uint256 _totalAgainstVoteWeight = _sumWeights(_againstVoteSigners);\n if (_totalAgainstVoteWeight >= _minimumAgainstVoteWeight) {\n if (_totalAgainstVoteWeight == 0) revert ErrInvalidVoteWeight(msg.sig);\n _vote.status = VoteStatus.Rejected;\n emit ProposalRejected(_vote.hash);\n return;\n }\n\n revert ErrRelayFailed(msg.sig);\n }\n\n /**\n * @dev Returns the weight of the governor list.\n */\n function _sumWeights(address[] memory _governors) internal view virtual returns (uint256);\n}\n" + }, + "contracts/extensions/sequential-governance/governance-relay/GlobalGovernanceRelay.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../GlobalCoreGovernance.sol\";\nimport \"./CommonGovernanceRelay.sol\";\n\nabstract contract GlobalGovernanceRelay is CommonGovernanceRelay, GlobalCoreGovernance {\n using GlobalProposal for GlobalProposal.GlobalProposalDetail;\n\n /**\n * @dev Returns whether the voter `_voter` casted vote for the proposal.\n */\n function globalProposalRelayed(uint256 _round) external view returns (bool) {\n return vote[0][_round].status != VoteStatus.Pending;\n }\n\n /**\n * @dev Relays voted global proposal.\n *\n * Requirements:\n * - The relay proposal is finalized.\n *\n */\n function _relayGlobalProposal(\n GlobalProposal.GlobalProposalDetail calldata globalProposal,\n Ballot.VoteType[] calldata supports_,\n Signature[] calldata signatures,\n bytes32 domainSeparator,\n address creator\n ) internal {\n Proposal.ProposalDetail memory _proposal = _proposeGlobalStruct(globalProposal, creator);\n bytes32 globalProposalHash = globalProposal.hash();\n _relayVotesBySignatures(\n _proposal,\n supports_,\n signatures,\n ECDSA.toTypedDataHash(domainSeparator, Ballot.hash(globalProposalHash, Ballot.VoteType.For)),\n ECDSA.toTypedDataHash(domainSeparator, Ballot.hash(globalProposalHash, Ballot.VoteType.Against))\n );\n }\n}\n" + }, + "contracts/extensions/sequential-governance/governance-relay/GovernanceRelay.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../CoreGovernance.sol\";\nimport \"./CommonGovernanceRelay.sol\";\n\nabstract contract GovernanceRelay is CoreGovernance, CommonGovernanceRelay {\n using Proposal for Proposal.ProposalDetail;\n using GlobalProposal for GlobalProposal.GlobalProposalDetail;\n\n /**\n * @dev Relays voted proposal.\n *\n * Requirements:\n * - The relay proposal is finalized.\n *\n */\n function _relayProposal(\n Proposal.ProposalDetail calldata _proposal,\n Ballot.VoteType[] calldata _supports,\n Signature[] calldata _signatures,\n bytes32 _domainSeparator,\n address _creator\n ) internal {\n _proposeProposalStruct(_proposal, _creator);\n bytes32 _proposalHash = _proposal.hash();\n _relayVotesBySignatures(\n _proposal,\n _supports,\n _signatures,\n ECDSA.toTypedDataHash(_domainSeparator, Ballot.hash(_proposalHash, Ballot.VoteType.For)),\n ECDSA.toTypedDataHash(_domainSeparator, Ballot.hash(_proposalHash, Ballot.VoteType.Against))\n );\n }\n}\n" + }, + "contracts/extensions/TransparentUpgradeableProxyV2.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\ncontract TransparentUpgradeableProxyV2 is TransparentUpgradeableProxy {\n constructor(\n address _logic,\n address admin_,\n bytes memory _data\n ) payable TransparentUpgradeableProxy(_logic, admin_, _data) {}\n\n /**\n * @dev Calls a function from the current implementation as specified by `_data`, which should be an encoded function call.\n *\n * Requirements:\n * - Only the admin can call this function.\n *\n * Note: The proxy admin is not allowed to interact with the proxy logic through the fallback function to avoid\n * triggering some unexpected logic. This is to allow the administrator to explicitly call the proxy, please consider\n * reviewing the encoded data `_data` and the method which is called before using this.\n *\n */\n function functionDelegateCall(bytes memory _data) public payable ifAdmin {\n address _addr = _implementation();\n assembly {\n let _result := delegatecall(gas(), _addr, add(_data, 32), mload(_data), 0, 0)\n returndatacopy(0, 0, returndatasize())\n switch _result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n}\n" + }, + "contracts/extensions/version-control/ConditionalImplementControl.sol": { + "content": "/// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { ERC1967Upgrade } from \"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\";\nimport { IConditionalImplementControl } from \"../../interfaces/version-control/IConditionalImplementControl.sol\";\nimport { ErrorHandler } from \"../../libraries/ErrorHandler.sol\";\nimport { AddressArrayUtils } from \"../../libraries/AddressArrayUtils.sol\";\nimport { ErrOnlySelfCall, IdentityGuard } from \"../../utils/IdentityGuard.sol\";\n\n/**\n * @title ConditionalImplementControl\n * @dev A contract that allows conditional version control of contract implementations.\n */\nabstract contract ConditionalImplementControl is IConditionalImplementControl, IdentityGuard, ERC1967Upgrade {\n using ErrorHandler for bool;\n using AddressArrayUtils for address[];\n\n /**\n * @dev address of the proxy that delegates to this contract.\n * @notice immutable variables are directly stored in contract code.\n * ensuring no storage writes are required.\n * The values of immutable variables remain fixed and cannot be modified,\n * regardless of any interactions, including delegations.\n */\n address public immutable PROXY_STORAGE;\n /**\n * @dev The address of the new implementation.\n */\n address public immutable NEW_IMPL;\n /**\n * @dev The address of the previous implementation.\n */\n address public immutable PREV_IMPL;\n\n /**\n * @dev Modifier that executes the function when conditions are met.\n */\n modifier whenConditionsAreMet() virtual {\n _;\n if (_isConditionMet()) {\n try this.selfUpgrade{ gas: _gasStipenedNoGrief() }() {} catch {}\n }\n }\n\n /**\n * @dev Modifier that only allows delegate calls from the admin proxy storage.\n */\n modifier onlyDelegateFromProxyStorage() virtual {\n _requireDelegateFromProxyStorage();\n _;\n }\n\n /**\n * @dev Modifier that only allows contracts with code.\n * @param addr The address of the contract to check.\n */\n modifier onlyContract(address addr) {\n _requireHasCode(addr);\n _;\n }\n\n /**\n * @dev Constructs the ConditionalImplementControl contract.\n * @param proxyStorage The address of the proxy that is allowed to delegate to this contract.\n * @param prevImpl The address of the current contract implementation.\n * @param newImpl The address of the new contract implementation.\n */\n constructor(\n address proxyStorage,\n address prevImpl,\n address newImpl\n ) onlyContract(proxyStorage) onlyContract(prevImpl) onlyContract(newImpl) {\n address[] memory addrs = new address[](3);\n addrs[0] = proxyStorage;\n addrs[1] = prevImpl;\n addrs[2] = newImpl;\n if (addrs.hasDuplicate()) revert AddressArrayUtils.ErrDuplicated(msg.sig);\n\n PROXY_STORAGE = proxyStorage;\n NEW_IMPL = newImpl;\n PREV_IMPL = prevImpl;\n }\n\n /**\n * @dev Fallback function that forwards the call to the current or new contract implementation based on a condition.\n */\n fallback() external payable virtual onlyDelegateFromProxyStorage {\n _fallback();\n }\n\n /**\n * @dev Receive function that forwards the call to the current or new contract implementation based on a condition.\n */\n receive() external payable virtual onlyDelegateFromProxyStorage {\n _fallback();\n }\n\n /**\n * @dev See {IConditionalImplementControl-selfUpgrade}.\n */\n\n function selfUpgrade() external onlyDelegateFromProxyStorage onlySelfCall {\n _upgradeTo(NEW_IMPL);\n }\n\n /**\n * @dev Internal function to get the current version of the contract implementation.\n * @return The address of the current version.\n */\n function _getConditionedImplementation() internal view virtual returns (address) {\n return _isConditionMet() ? NEW_IMPL : PREV_IMPL;\n }\n\n /**\n * @dev Internal function to check if the condition for switching implementation is met.\n * @return the boolean indicating if condition is met.\n */\n function _isConditionMet() internal view virtual returns (bool) {}\n\n /**\n * @dev Logic for fallback function.\n */\n function _fallback() internal virtual {\n bytes memory returnData = _dispatchCall(_getConditionedImplementation());\n assembly {\n return(add(returnData, 0x20), mload(returnData))\n }\n }\n\n /**\n * @dev Internal function to dispatch the call to the specified version.\n * @param impl The address of the version to call.\n * @return returnData The return data of the call.\n */\n function _dispatchCall(address impl) internal virtual whenConditionsAreMet returns (bytes memory returnData) {\n (bool success, bytes memory returnOrRevertData) = impl.delegatecall(msg.data);\n success.handleRevert(msg.sig, returnOrRevertData);\n assembly {\n returnData := returnOrRevertData\n }\n }\n\n /**\n * @dev Internal function to check if the caller is delegating from proxy storage.\n * Throws an error if the current implementation of the proxy storage is not this contract.\n */\n function _requireDelegateFromProxyStorage() private view {\n if (address(this) != PROXY_STORAGE) revert ErrDelegateFromUnknownOrigin(address(this));\n }\n\n /**\n * @dev Internal method to check method caller.\n *\n * Requirements:\n *\n * - The method caller must be this contract.\n *\n */\n function _requireSelfCall() internal view override {\n if (msg.sender != PROXY_STORAGE) revert ErrOnlySelfCall(msg.sig);\n }\n\n /**\n * @dev Suggested gas stipend for contract to call {selfUpgrade} function.\n */\n function _gasStipenedNoGrief() internal pure virtual returns (uint256) {\n // Gas stipend for contract to perform a few read and write operations on storage, but\n // low enough to prevent comsuming gas exhaustively when function call are reverted.\n // Multiply by a small constant (e.g. 2), if needed.\n return 50_000;\n }\n}\n" + }, + "contracts/extensions/WithdrawalLimitation.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./GatewayV2.sol\";\n\nabstract contract WithdrawalLimitation is GatewayV2 {\n /// @dev Error of invalid percentage.\n error ErrInvalidPercentage();\n\n /// @dev Emitted when the high-tier vote weight threshold is updated\n event HighTierVoteWeightThresholdUpdated(\n uint256 indexed nonce,\n uint256 indexed numerator,\n uint256 indexed denominator,\n uint256 previousNumerator,\n uint256 previousDenominator\n );\n /// @dev Emitted when the thresholds for high-tier withdrawals that requires high-tier vote weights are updated\n event HighTierThresholdsUpdated(address[] tokens, uint256[] thresholds);\n /// @dev Emitted when the thresholds for locked withdrawals are updated\n event LockedThresholdsUpdated(address[] tokens, uint256[] thresholds);\n /// @dev Emitted when the fee percentages to unlock withdraw are updated\n event UnlockFeePercentagesUpdated(address[] tokens, uint256[] percentages);\n /// @dev Emitted when the daily limit thresholds are updated\n event DailyWithdrawalLimitsUpdated(address[] tokens, uint256[] limits);\n\n uint256 public constant _MAX_PERCENTAGE = 1_000_000;\n\n uint256 internal _highTierVWNum;\n uint256 internal _highTierVWDenom;\n\n /// @dev Mapping from mainchain token => the amount thresholds for high-tier withdrawals that requires high-tier vote weights\n mapping(address => uint256) public highTierThreshold;\n /// @dev Mapping from mainchain token => the amount thresholds to lock withdrawal\n mapping(address => uint256) public lockedThreshold;\n /// @dev Mapping from mainchain token => unlock fee percentages for unlocker\n /// @notice Values 0-1,000,000 map to 0%-100%\n mapping(address => uint256) public unlockFeePercentages;\n /// @dev Mapping from mainchain token => daily limit amount for withdrawal\n mapping(address => uint256) public dailyWithdrawalLimit;\n /// @dev Mapping from token address => today withdrawal amount\n mapping(address => uint256) public lastSyncedWithdrawal;\n /// @dev Mapping from token address => last date synced to record the `lastSyncedWithdrawal`\n mapping(address => uint256) public lastDateSynced;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[50] private ______gap;\n\n /**\n * @dev Override `GatewayV2-setThreshold`.\n *\n * Requirements:\n * - The high-tier vote weight threshold must equal to or larger than the normal threshold.\n *\n */\n function setThreshold(\n uint256 _numerator,\n uint256 _denominator\n ) external virtual override onlyAdmin returns (uint256 _previousNum, uint256 _previousDenom) {\n (_previousNum, _previousDenom) = _setThreshold(_numerator, _denominator);\n _verifyThresholds();\n }\n\n /**\n * @dev Returns the high-tier vote weight threshold.\n */\n function getHighTierVoteWeightThreshold() external view virtual returns (uint256, uint256) {\n return (_highTierVWNum, _highTierVWDenom);\n }\n\n /**\n * @dev Checks whether the `_voteWeight` passes the high-tier vote weight threshold.\n */\n function checkHighTierVoteWeightThreshold(uint256 _voteWeight) external view virtual returns (bool) {\n return _voteWeight * _highTierVWDenom >= _highTierVWNum * _getTotalWeight();\n }\n\n /**\n * @dev Sets high-tier vote weight threshold and returns the old one.\n *\n * Requirements:\n * - The method caller is admin.\n * - The high-tier vote weight threshold must equal to or larger than the normal threshold.\n *\n * Emits the `HighTierVoteWeightThresholdUpdated` event.\n *\n */\n function setHighTierVoteWeightThreshold(\n uint256 _numerator,\n uint256 _denominator\n ) external virtual onlyAdmin returns (uint256 _previousNum, uint256 _previousDenom) {\n (_previousNum, _previousDenom) = _setHighTierVoteWeightThreshold(_numerator, _denominator);\n _verifyThresholds();\n }\n\n /**\n * @dev Sets the thresholds for high-tier withdrawals that requires high-tier vote weights.\n *\n * Requirements:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `HighTierThresholdsUpdated` event.\n *\n */\n function setHighTierThresholds(\n address[] calldata _tokens,\n uint256[] calldata _thresholds\n ) external virtual onlyAdmin {\n if (_tokens.length == 0) revert ErrEmptyArray();\n _setHighTierThresholds(_tokens, _thresholds);\n }\n\n /**\n * @dev Sets the amount thresholds to lock withdrawal.\n *\n * Requirements:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `LockedThresholdsUpdated` event.\n *\n */\n function setLockedThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) external virtual onlyAdmin {\n if (_tokens.length == 0) revert ErrEmptyArray();\n _setLockedThresholds(_tokens, _thresholds);\n }\n\n /**\n * @dev Sets fee percentages to unlock withdrawal.\n *\n * Requirements:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `UnlockFeePercentagesUpdated` event.\n *\n */\n function setUnlockFeePercentages(\n address[] calldata _tokens,\n uint256[] calldata _percentages\n ) external virtual onlyAdmin {\n if (_tokens.length == 0) revert ErrEmptyArray();\n _setUnlockFeePercentages(_tokens, _percentages);\n }\n\n /**\n * @dev Sets daily limit amounts for the withdrawals.\n *\n * Requirements:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `DailyWithdrawalLimitsUpdated` event.\n *\n */\n function setDailyWithdrawalLimits(address[] calldata _tokens, uint256[] calldata _limits) external virtual onlyAdmin {\n if (_tokens.length == 0) revert ErrEmptyArray();\n _setDailyWithdrawalLimits(_tokens, _limits);\n }\n\n /**\n * @dev Checks whether the withdrawal reaches the limitation.\n */\n function reachedWithdrawalLimit(address _token, uint256 _quantity) external view virtual returns (bool) {\n return _reachedWithdrawalLimit(_token, _quantity);\n }\n\n /**\n * @dev Sets high-tier vote weight threshold and returns the old one.\n *\n * Emits the `HighTierVoteWeightThresholdUpdated` event.\n *\n */\n function _setHighTierVoteWeightThreshold(\n uint256 _numerator,\n uint256 _denominator\n ) internal returns (uint256 _previousNum, uint256 _previousDenom) {\n if (_numerator > _denominator) revert ErrInvalidThreshold(msg.sig);\n\n _previousNum = _highTierVWNum;\n _previousDenom = _highTierVWDenom;\n _highTierVWNum = _numerator;\n _highTierVWDenom = _denominator;\n\n unchecked {\n emit HighTierVoteWeightThresholdUpdated(nonce++, _numerator, _denominator, _previousNum, _previousDenom);\n }\n }\n\n /**\n * @dev Sets the thresholds for high-tier withdrawals that requires high-tier vote weights.\n *\n * Requirements:\n * - The array lengths are equal.\n *\n * Emits the `HighTierThresholdsUpdated` event.\n *\n */\n function _setHighTierThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) internal virtual {\n if (_tokens.length != _thresholds.length) revert ErrLengthMismatch(msg.sig);\n\n for (uint256 _i; _i < _tokens.length; ) {\n highTierThreshold[_tokens[_i]] = _thresholds[_i];\n\n unchecked {\n ++_i;\n }\n }\n emit HighTierThresholdsUpdated(_tokens, _thresholds);\n }\n\n /**\n * @dev Sets the amount thresholds to lock withdrawal.\n *\n * Requirements:\n * - The array lengths are equal.\n *\n * Emits the `LockedThresholdsUpdated` event.\n *\n */\n function _setLockedThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) internal virtual {\n if (_tokens.length != _thresholds.length) revert ErrLengthMismatch(msg.sig);\n\n for (uint256 _i; _i < _tokens.length; ) {\n lockedThreshold[_tokens[_i]] = _thresholds[_i];\n\n unchecked {\n ++_i;\n }\n }\n emit LockedThresholdsUpdated(_tokens, _thresholds);\n }\n\n /**\n * @dev Sets fee percentages to unlock withdrawal.\n *\n * Requirements:\n * - The array lengths are equal.\n * - The percentage is equal to or less than 100_000.\n *\n * Emits the `UnlockFeePercentagesUpdated` event.\n *\n */\n function _setUnlockFeePercentages(address[] calldata _tokens, uint256[] calldata _percentages) internal virtual {\n if (_tokens.length != _percentages.length) revert ErrLengthMismatch(msg.sig);\n\n for (uint256 _i; _i < _tokens.length; ) {\n if (_percentages[_i] > _MAX_PERCENTAGE) revert ErrInvalidPercentage();\n\n unlockFeePercentages[_tokens[_i]] = _percentages[_i];\n\n unchecked {\n ++_i;\n }\n }\n emit UnlockFeePercentagesUpdated(_tokens, _percentages);\n }\n\n /**\n * @dev Sets daily limit amounts for the withdrawals.\n *\n * Requirements:\n * - The array lengths are equal.\n *\n * Emits the `DailyWithdrawalLimitsUpdated` event.\n *\n */\n function _setDailyWithdrawalLimits(address[] calldata _tokens, uint256[] calldata _limits) internal virtual {\n if (_tokens.length != _limits.length) revert ErrLengthMismatch(msg.sig);\n\n for (uint256 _i; _i < _tokens.length; ) {\n dailyWithdrawalLimit[_tokens[_i]] = _limits[_i];\n\n unchecked {\n ++_i;\n }\n }\n emit DailyWithdrawalLimitsUpdated(_tokens, _limits);\n }\n\n /**\n * @dev Checks whether the withdrawal reaches the daily limitation.\n *\n * Requirements:\n * - The daily withdrawal threshold should not apply for locked withdrawals.\n *\n */\n function _reachedWithdrawalLimit(address _token, uint256 _quantity) internal view virtual returns (bool) {\n if (_lockedWithdrawalRequest(_token, _quantity)) {\n return false;\n }\n\n uint256 _currentDate = block.timestamp / 1 days;\n if (_currentDate > lastDateSynced[_token]) {\n return dailyWithdrawalLimit[_token] <= _quantity;\n } else {\n return dailyWithdrawalLimit[_token] <= lastSyncedWithdrawal[_token] + _quantity;\n }\n }\n\n /**\n * @dev Record withdrawal token.\n */\n function _recordWithdrawal(address _token, uint256 _quantity) internal virtual {\n uint256 _currentDate = block.timestamp / 1 days;\n if (_currentDate > lastDateSynced[_token]) {\n lastDateSynced[_token] = _currentDate;\n lastSyncedWithdrawal[_token] = _quantity;\n } else {\n lastSyncedWithdrawal[_token] += _quantity;\n }\n }\n\n /**\n * @dev Returns whether the withdrawal request is locked or not.\n */\n function _lockedWithdrawalRequest(address _token, uint256 _quantity) internal view virtual returns (bool) {\n return lockedThreshold[_token] <= _quantity;\n }\n\n /**\n * @dev Computes fee percentage.\n */\n function _computeFeePercentage(uint256 _amount, uint256 _percentage) internal view virtual returns (uint256) {\n return (_amount * _percentage) / _MAX_PERCENTAGE;\n }\n\n /**\n * @dev Returns high-tier vote weight.\n */\n function _highTierVoteWeight(uint256 _totalWeight) internal view virtual returns (uint256) {\n return (_highTierVWNum * _totalWeight + _highTierVWDenom - 1) / _highTierVWDenom;\n }\n\n /**\n * @dev Validates whether the high-tier vote weight threshold is larger than the normal threshold.\n */\n function _verifyThresholds() internal view {\n if (_num * _highTierVWDenom > _highTierVWNum * _denom) revert ErrInvalidThreshold(msg.sig);\n }\n}\n" + }, + "contracts/interfaces/bridge/events/IBridgeManagerEvents.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IBridgeManagerEvents {\n /**\n * @dev The structure representing information about a bridge operator.\n * @param addr The address of the bridge operator.\n * @param voteWeight The vote weight assigned to the bridge operator.\n */\n struct BridgeOperatorInfo {\n address addr;\n uint96 voteWeight;\n }\n\n /**\n * @dev Emitted when new bridge operators are added.\n * @param statuses The array of boolean values represents whether the corresponding bridge operator is added successfully.\n * @param voteWeights The array of vote weights assigned to the added bridge operators.\n * @param governors The array of addresses representing the governors associated with the added bridge operators.\n * @param bridgeOperators The array of addresses representing the added bridge operators.\n */\n event BridgeOperatorsAdded(bool[] statuses, uint96[] voteWeights, address[] governors, address[] bridgeOperators);\n\n /**\n * @dev Emitted when bridge operators are removed.\n * @param statuses The array of boolean values representing the statuses of the removed bridge operators.\n * @param bridgeOperators The array of addresses representing the removed bridge operators.\n */\n event BridgeOperatorsRemoved(bool[] statuses, address[] bridgeOperators);\n\n /**\n * @dev Emitted when a bridge operator is updated.\n * @param governor The address of the governor initiating the update.\n * @param fromBridgeOperator The address of the bridge operator being updated.\n * @param toBridgeOperator The updated address of the bridge operator.\n */\n event BridgeOperatorUpdated(\n address indexed governor,\n address indexed fromBridgeOperator,\n address indexed toBridgeOperator\n );\n}\n" + }, + "contracts/interfaces/bridge/events/IBridgeRewardEvents.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IBridgeRewardEvents {\n /**\n * @dev Reward-related information for a bridge operator.\n * @param claimed The amount of rewards claimed by the bridge operator.\n * @param slashed The amount of rewards that have been slashed from the bridge operator.\n */\n struct BridgeRewardInfo {\n uint256 claimed;\n uint256 slashed;\n }\n\n /**\n * @dev Emitted when RON are safely received as rewards in the contract.\n * @param from The address of the sender who transferred RON tokens as rewards.\n * @param balanceBefore The balance of the contract before receiving the RON tokens.\n * @param amount The amount of RON received.\n */\n event SafeReceived(address indexed from, uint256 balanceBefore, uint256 amount);\n /// @dev Event emitted when the reward per period config is updated.\n event UpdatedRewardPerPeriod(uint256 newRewardPerPeriod);\n /// @dev Event emitted when the reward of the `operator` is scattered with `amount`.\n event BridgeRewardScattered(uint256 indexed period, address operator, uint256 amount);\n /// @dev Event emitted when the reward of the `operator` is slashed with `amount`.\n event BridgeRewardSlashed(uint256 indexed period, address operator, uint256 amount);\n /// @dev Event emitted when the reward of the `operator` is scattered with `amount` but failed to transfer.\n event BridgeRewardScatterFailed(uint256 indexed period, address operator, uint256 amount);\n /// @dev Event emitted when the requesting period to sync is too far.\n event BridgeRewardSyncTooFarPeriod(uint256 requestingPeriod, uint256 latestPeriod);\n}\n" + }, + "contracts/interfaces/bridge/events/IBridgeSlashEvents.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IBridgeSlashEvents {\n /**\n * @dev Enumeration representing the slashing tiers for bridge operators.\n */\n enum Tier {\n Tier0,\n Tier1,\n Tier2\n }\n\n /**\n * @dev Struct representing the status of a bridge operator.\n */\n struct BridgeSlashInfo {\n uint128 slashUntilPeriod;\n uint128 newlyAddedAtPeriod;\n }\n\n /**\n * @dev Event emitted when a bridge operator is slashed.\n * @param tier The slash tier of the operator.\n * @param bridgeOperator The address of the slashed bridge operator.\n * @param period The period in which the operator is slashed.\n * @param slashUntilPeriod The period until which the operator is penalized.\n */\n event Slashed(Tier indexed tier, address indexed bridgeOperator, uint256 indexed period, uint256 slashUntilPeriod);\n\n /**\n * @dev Emitted when a removal request is made for a bridge operator.\n * @param period The period for which the removal request is made.\n * @param bridgeOperator The address of the bridge operator being requested for removal.\n */\n event RemovalRequested(uint256 indexed period, address indexed bridgeOperator);\n}\n" + }, + "contracts/interfaces/bridge/IBridgeManager.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { IBridgeManagerEvents } from \"./events/IBridgeManagerEvents.sol\";\n\n/**\n * @title IBridgeManager\n * @dev The interface for managing bridge operators.\n */\ninterface IBridgeManager is IBridgeManagerEvents {\n /**\n * @dev The domain separator used for computing hash digests in the contract.\n */\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n /**\n * @dev Returns the total number of bridge operators.\n * @return The total number of bridge operators.\n */\n function totalBridgeOperators() external view returns (uint256);\n\n /**\n * @dev Checks if the given address is a bridge operator.\n * @param addr The address to check.\n * @return A boolean indicating whether the address is a bridge operator.\n */\n function isBridgeOperator(address addr) external view returns (bool);\n\n /**\n * @dev Retrieves the full information of all registered bridge operators.\n *\n * This external function allows external callers to obtain the full information of all the registered bridge operators.\n * The returned arrays include the addresses of governors, bridge operators, and their corresponding vote weights.\n *\n * @return governors An array of addresses representing the governors of each bridge operator.\n * @return bridgeOperators An array of addresses representing the registered bridge operators.\n * @return weights An array of uint256 values representing the vote weights of each bridge operator.\n *\n * Note: The length of each array will be the same, and the order of elements corresponds to the same bridge operator.\n *\n * Example Usage:\n * ```\n * (address[] memory governors, address[] memory bridgeOperators, uint256[] memory weights) = getFullBridgeOperatorInfos();\n * for (uint256 i = 0; i < bridgeOperators.length; i++) {\n * // Access individual information for each bridge operator.\n * address governor = governors[i];\n * address bridgeOperator = bridgeOperators[i];\n * uint256 weight = weights[i];\n * // ... (Process or use the information as required) ...\n * }\n * ```\n *\n */\n function getFullBridgeOperatorInfos()\n external\n view\n returns (address[] memory governors, address[] memory bridgeOperators, uint256[] memory weights);\n\n /**\n * @dev Returns total weights of the governor list.\n */\n function sumGovernorsWeight(address[] calldata governors) external view returns (uint256 sum);\n\n /**\n * @dev Returns total weights.\n */\n function getTotalWeights() external view returns (uint256);\n\n /**\n * @dev Returns an array of all bridge operators.\n * @return An array containing the addresses of all bridge operators.\n */\n function getBridgeOperators() external view returns (address[] memory);\n\n /**\n * @dev Returns an array of bridge operators correspoding to governor addresses.\n * @return bridgeOperators_ An array containing the addresses of all bridge operators.\n */\n function getBridgeOperatorOf(address[] calldata gorvernors) external view returns (address[] memory bridgeOperators_);\n\n /**\n * @dev Retrieves the governors corresponding to a given array of bridge operators.\n * This external function allows external callers to obtain the governors associated with a given array of bridge operators.\n * The function takes an input array `bridgeOperators` containing bridge operator addresses and returns an array of corresponding governors.\n * @param bridgeOperators An array of bridge operator addresses for which governors are to be retrieved.\n * @return governors An array of addresses representing the governors corresponding to the provided bridge operators.\n */\n function getGovernorsOf(address[] calldata bridgeOperators) external view returns (address[] memory governors);\n\n /**\n * @dev External function to retrieve the vote weight of a specific governor.\n * @param governor The address of the governor to get the vote weight for.\n * @return voteWeight The vote weight of the specified governor.\n */\n function getGovernorWeight(address governor) external view returns (uint256);\n\n /**\n * @dev External function to retrieve the vote weight of a specific bridge operator.\n * @param bridgeOperator The address of the bridge operator to get the vote weight for.\n * @return weight The vote weight of the specified bridge operator.\n */\n function getBridgeOperatorWeight(address bridgeOperator) external view returns (uint256 weight);\n\n /**\n * @dev Returns the weights of a list of governor addresses.\n */\n function getGovernorWeights(address[] calldata governors) external view returns (uint256[] memory weights);\n\n /**\n * @dev Returns an array of all governors.\n * @return An array containing the addresses of all governors.\n */\n function getGovernors() external view returns (address[] memory);\n\n /**\n * @dev Adds multiple bridge operators.\n * @param governors An array of addresses of hot/cold wallets for bridge operator to update their node address.\n * @param bridgeOperators An array of addresses representing the bridge operators to add.\n * @return addeds An array of booleans indicating whether each bridge operator was added successfully.\n *\n * Note: return boolean array `addeds` indicates whether a group (voteWeight, governor, operator) are recorded.\n * It is expected that FE/BE staticcall to the function first to get the return values and handle it correctly.\n * Governors are expected to see the outcome of this function and decide if they want to vote for the proposal or not.\n *\n * Example Usage:\n * Making an `eth_call` in ethers.js\n * ```\n * const {addeds} = await bridgeManagerContract.callStatic.addBridgeOperators(\n * voteWeights,\n * governors,\n * bridgeOperators,\n * // overriding the caller to the contract itself since we use `onlySelfCall` guard\n * {from: bridgeManagerContract.address}\n * )\n * const filteredOperators = bridgeOperators.filter((_, index) => addeds[index]);\n * const filteredWeights = weights.filter((_, index) => addeds[index]);\n * const filteredGovernors = governors.filter((_, index) => addeds[index]);\n * // ... (Process or use the information as required) ...\n * ```\n */\n function addBridgeOperators(\n uint96[] calldata voteWeights,\n address[] calldata governors,\n address[] calldata bridgeOperators\n ) external returns (bool[] memory addeds);\n\n /**\n * @dev Removes multiple bridge operators.\n * @param bridgeOperators An array of addresses representing the bridge operators to remove.\n * @return removeds An array of booleans indicating whether each bridge operator was removed successfully.\n *\n * * Note: return boolean array `removeds` indicates whether a group (voteWeight, governor, operator) are recorded.\n * It is expected that FE/BE staticcall to the function first to get the return values and handle it correctly.\n * Governors are expected to see the outcome of this function and decide if they want to vote for the proposal or not.\n *\n * Example Usage:\n * Making an `eth_call` in ethers.js\n * ```\n * const {removeds} = await bridgeManagerContract.callStatic.removeBridgeOperators(\n * bridgeOperators,\n * // overriding the caller to the contract itself since we use `onlySelfCall` guard\n * {from: bridgeManagerContract.address}\n * )\n * const filteredOperators = bridgeOperators.filter((_, index) => removeds[index]);\n * // ... (Process or use the information as required) ...\n * ```\n */\n function removeBridgeOperators(address[] calldata bridgeOperators) external returns (bool[] memory removeds);\n\n /**\n * @dev Governor updates their corresponding governor and/or operator address.\n * Requirements:\n * - The caller must the governor of the operator that is requested changes.\n * @param bridgeOperator The address of the bridge operator to update.\n */\n function updateBridgeOperator(address bridgeOperator) external;\n}\n" + }, + "contracts/interfaces/bridge/IBridgeManagerCallback.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { IERC165 } from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\n\n/**\n * @title IBridgeManagerCallback\n * @dev Interface for the callback functions to be implemented by the Bridge Manager contract.\n */\ninterface IBridgeManagerCallback is IERC165 {\n /**\n * @dev Handles the event when bridge operators are added.\n * @param bridgeOperators The addresses of the bridge operators.\n * @param addeds The corresponding boolean values indicating whether the operators were added or not.\n * @return selector The selector of the function being called.\n */\n function onBridgeOperatorsAdded(\n address[] memory bridgeOperators,\n bool[] memory addeds\n ) external returns (bytes4 selector);\n\n /**\n * @dev Handles the event when bridge operators are removed.\n * @param bridgeOperators The addresses of the bridge operators.\n * @param removeds The corresponding boolean values indicating whether the operators were removed or not.\n * @return selector The selector of the function being called.\n */\n function onBridgeOperatorsRemoved(\n address[] memory bridgeOperators,\n bool[] memory removeds\n ) external returns (bytes4 selector);\n\n /**\n * @dev Handles the event when a bridge operator is updated.\n * @param currentBridgeOperator The address of the current bridge operator.\n * @param newbridgeOperator The new address of the bridge operator.\n * @return selector The selector of the function being called.\n */\n function onBridgeOperatorUpdated(\n address currentBridgeOperator,\n address newbridgeOperator\n ) external returns (bytes4 selector);\n}\n" + }, + "contracts/interfaces/bridge/IBridgeManagerCallbackRegister.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IBridgeManagerCallbackRegister {\n /**\n * @dev Emitted when the contract notifies multiple registers with statuses and return data.\n */\n event Notified(bytes callData, address[] registers, bool[] statuses, bytes[] returnDatas);\n\n /**\n * @dev Retrieves the addresses of registered callbacks.\n * @return registers An array containing the addresses of registered callbacks.\n */\n function getCallbackRegisters() external view returns (address[] memory registers);\n\n /**\n * @dev Registers multiple callbacks with the bridge.\n * @param registers The array of callback addresses to register.\n * @return registereds An array indicating the success status of each registration.\n */\n function registerCallbacks(address[] calldata registers) external returns (bool[] memory registereds);\n\n /**\n * @dev Unregisters multiple callbacks from the bridge.\n * @param registers The array of callback addresses to unregister.\n * @return unregistereds An array indicating the success status of each unregistration.\n */\n function unregisterCallbacks(address[] calldata registers) external returns (bool[] memory unregistereds);\n}\n" + }, + "contracts/interfaces/bridge/IBridgeReward.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport { IBridgeRewardEvents } from \"./events/IBridgeRewardEvents.sol\";\n\ninterface IBridgeReward is IBridgeRewardEvents {\n /**\n * @dev This function allows bridge operators to manually synchronize the reward for a given period length.\n * @param periodLength The length of the reward period for which synchronization is requested.\n */\n function syncReward(uint256 periodLength) external;\n\n /**\n * @dev Receives RON from any address.\n */\n function receiveRON() external payable;\n\n /**\n * @dev Invoke calculate and transfer reward to operators based on their performance.\n *\n * Requirements:\n * - This method is only called once each period.\n * - The caller must be the bridge tracking contract or a bridge operator.\n */\n function execSyncReward(\n address[] calldata operators,\n uint256[] calldata ballots,\n uint256 totalBallot,\n uint256 totalVote,\n uint256 period\n ) external;\n\n /**\n * @dev Retrieve the total amount of rewards that have been topped up in the contract.\n * @return totalRewardToppedUp The total rewards topped up value.\n */\n function getTotalRewardToppedUp() external view returns (uint256);\n\n /**\n * @dev Retrieve the total amount of rewards that have been scattered to bridge operators in the contract.\n * @return totalRewardScattered The total rewards scattered value.\n */\n function getTotalRewardScattered() external view returns (uint256);\n\n /**\n * @dev Getter for all bridge operators per period.\n */\n function getRewardPerPeriod() external view returns (uint256);\n\n /**\n * @dev External function to retrieve the latest rewarded period in the contract.\n * @return latestRewardedPeriod The latest rewarded period value.\n */\n function getLatestRewardedPeriod() external view returns (uint256);\n\n /**\n * @dev Setter for all bridge operators per period.\n */\n function setRewardPerPeriod(uint256 rewardPerPeriod) external;\n}\n" + }, + "contracts/interfaces/bridge/IBridgeSlash.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { IBridgeSlashEvents } from \"./events/IBridgeSlashEvents.sol\";\n\n/**\n * @title IBridgeSlash\n * @dev Interface for the BridgeSlash contract to manage slashing functionality for bridge operators.\n */\ninterface IBridgeSlash is IBridgeSlashEvents {\n /**\n * @dev Slashes the unavailability of bridge operators during a specific period.\n * @param period The period to slash the bridge operators for.\n */\n function execSlashBridgeOperators(\n address[] calldata operators,\n uint256[] calldata ballots,\n uint256 totalBallot,\n uint256 totalVote,\n uint256 period\n ) external returns (bool slashed);\n\n /**\n * @dev Returns the penalize durations for the specified bridge operators.\n * @param bridgeOperators The addresses of the bridge operators.\n * @return untilPeriods The penalized periods for the bridge operators.\n */\n function getSlashUntilPeriodOf(address[] calldata bridgeOperators) external returns (uint256[] memory untilPeriods);\n\n /**\n * @dev Retrieves the added periods of the specified bridge operators.\n * @param bridgeOperators An array of bridge operator addresses.\n * @return addedPeriods An array of uint256 values representing the added periods for each bridge operator.\n */\n function getAddedPeriodOf(address[] calldata bridgeOperators) external view returns (uint256[] memory addedPeriods);\n\n /**\n * @dev Gets the slash tier based on the given ballot and total ballots.\n * @param ballot The ballot count for a bridge operator.\n * @param totalVote The total vote count for the period.\n * @return tier The slash tier.\n */\n function getSlashTier(uint256 ballot, uint256 totalVote) external pure returns (Tier tier);\n\n /**\n * @dev Retrieve the penalty durations for different slash tiers.\n * @return penaltyDurations The array of penalty durations for each slash tier.\n */\n function getPenaltyDurations() external pure returns (uint256[] memory penaltyDurations);\n\n /**\n * @dev Returns the penalty duration for Tier 1 slashing.\n * @return The duration in period number for Tier 1 slashing.\n */\n function TIER_1_PENALTY_DURATION() external view returns (uint256);\n\n /**\n * @dev Returns the penalty duration for Tier 2 slashing.\n * @return The duration in period number for Tier 2 slashing.\n */\n function TIER_2_PENALTY_DURATION() external view returns (uint256);\n\n /**\n * @dev Returns the threshold duration for removing bridge operators.\n * @return The duration in period number that exceeds which a bridge operator will be removed.\n */\n function REMOVE_DURATION_THRESHOLD() external view returns (uint256);\n\n /**\n * @dev External function to retrieve the value of the minimum vote threshold to execute slashing rule.\n * @return minimumVoteThreshold The minimum vote threshold value.\n */\n function MINIMUM_VOTE_THRESHOLD() external view returns (uint256);\n}\n" + }, + "contracts/interfaces/bridge/IBridgeTracking.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IBridgeTracking {\n struct Request {\n VoteKind kind;\n uint256 id;\n }\n\n enum VoteKind {\n Deposit,\n Withdrawal,\n MainchainWithdrawal\n }\n\n event ExternalCallFailed(address indexed to, bytes4 indexed msgSig, bytes reason);\n\n /**\n * @dev Returns the block that allow incomming mutable call.\n */\n function startedAtBlock() external view returns (uint256);\n\n /**\n * @dev Returns the total number of votes at the specific period `_period`.\n */\n function totalVote(uint256 _period) external view returns (uint256);\n\n /**\n * @dev Returns the total number of ballots at the specific period `_period`.\n */\n function totalBallot(uint256 _period) external view returns (uint256);\n\n /**\n * @dev Returns the total number of ballots of bridge operators at the specific period `_period`.\n */\n function getManyTotalBallots(\n uint256 _period,\n address[] calldata _bridgeOperators\n ) external view returns (uint256[] memory);\n\n /**\n * @dev Returns the total number of ballots of a bridge operator at the specific period `_period`.\n */\n function totalBallotOf(uint256 _period, address _bridgeOperator) external view returns (uint256);\n\n /**\n * @dev Handles the request once it is approved.\n *\n * Requirements:\n * - The method caller is the bridge contract.\n *\n */\n function handleVoteApproved(VoteKind _kind, uint256 _requestId) external;\n\n /**\n * @dev Records vote for a receipt and a operator.\n *\n * Requirements:\n * - The method caller is the bridge contract.\n *\n */\n function recordVote(VoteKind _kind, uint256 _requestId, address _operator) external;\n}\n" + }, + "contracts/interfaces/collections/IHasContracts.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport { ContractType } from \"../../utils/ContractType.sol\";\n\ninterface IHasContracts {\n /// @dev Error of invalid role.\n error ErrContractTypeNotFound(ContractType contractType);\n\n /// @dev Emitted when a contract is updated.\n event ContractUpdated(ContractType indexed contractType, address indexed addr);\n\n /**\n * @dev Returns the address of a contract with a specific role.\n * Throws an error if no contract is set for the specified role.\n *\n * @param contractType The role of the contract to retrieve.\n * @return contract_ The address of the contract with the specified role.\n */\n function getContract(ContractType contractType) external view returns (address contract_);\n\n /**\n * @dev Sets the address of a contract with a specific role.\n * Emits the event {ContractUpdated}.\n * @param contractType The role of the contract to set.\n * @param addr The address of the contract to set.\n */\n function setContract(ContractType contractType, address addr) external;\n}\n" + }, + "contracts/interfaces/consumers/ChainTypeConsumer.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface ChainTypeConsumer {\n enum ChainType {\n RoninChain,\n Mainchain\n }\n}\n" + }, + "contracts/interfaces/consumers/MappedTokenConsumer.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../../libraries/Token.sol\";\n\ninterface MappedTokenConsumer {\n struct MappedToken {\n Token.Standard erc;\n address tokenAddr;\n }\n}\n" + }, + "contracts/interfaces/consumers/PeriodWrapperConsumer.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface PeriodWrapperConsumer {\n struct PeriodWrapper {\n // Inner value.\n uint256 inner;\n // Last period number that the info updated.\n uint256 lastPeriod;\n }\n}\n" + }, + "contracts/interfaces/consumers/SignatureConsumer.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface SignatureConsumer {\n struct Signature {\n uint8 v;\n bytes32 r;\n bytes32 s;\n }\n}\n" + }, + "contracts/interfaces/consumers/VoteStatusConsumer.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface VoteStatusConsumer {\n enum VoteStatus {\n Pending,\n Approved,\n Executed,\n Rejected,\n Expired\n }\n}\n" + }, + "contracts/interfaces/consumers/WeightedAddressConsumer.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface WeightedAddressConsumer {\n struct WeightedAddress {\n address addr;\n uint256 weight;\n }\n}\n" + }, + "contracts/interfaces/IBridge.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IBridge {\n /**\n * @dev Replaces the old bridge operator list by the new one.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emitted the event `BridgeOperatorsReplaced`.\n *\n */\n function replaceBridgeOperators(address[] calldata) external;\n\n /**\n * @dev Returns the bridge operator list.\n */\n function getBridgeOperators() external view returns (address[] memory);\n}\n" + }, + "contracts/interfaces/IBridgeAdminProposal.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { BridgeOperatorsBallot } from \"../libraries/BridgeOperatorsBallot.sol\";\n\ninterface IBridgeAdminProposal {\n /// @dev Emitted when the bridge operators are approved.\n event BridgeOperatorsApproved(uint256 period, uint256 epoch, address[] operators);\n\n /**\n * @dev Returns the last voted block of the bridge voter.\n */\n function lastVotedBlock(address bridgeVoter) external view returns (uint256);\n\n /**\n * @dev Returns the synced bridge operator set info.\n */\n function lastSyncedBridgeOperatorSetInfo()\n external\n view\n returns (BridgeOperatorsBallot.BridgeOperatorSet memory bridgeOperatorSetInfo);\n}\n" + }, + "contracts/interfaces/IERC20Mintable.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.2;\n\ninterface IERC20Mintable {\n function mint(address _to, uint256 _value) external returns (bool _success);\n}\n" + }, + "contracts/interfaces/IERC721Mintable.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IERC721Mintable {\n function mint(address _to, uint256 _tokenId) external returns (bool);\n}\n" + }, + "contracts/interfaces/IMainchainGatewayV2.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./IWETH.sol\";\nimport \"./consumers/SignatureConsumer.sol\";\nimport \"./consumers/MappedTokenConsumer.sol\";\nimport \"../libraries/Transfer.sol\";\n\ninterface IMainchainGatewayV2 is SignatureConsumer, MappedTokenConsumer {\n /**\n * @dev Error indicating that a query was made for an approved withdrawal.\n */\n error ErrQueryForApprovedWithdrawal();\n\n /**\n * @dev Error indicating that the daily withdrawal limit has been reached.\n */\n error ErrReachedDailyWithdrawalLimit();\n\n /**\n * @dev Error indicating that a query was made for a processed withdrawal.\n */\n error ErrQueryForProcessedWithdrawal();\n\n /**\n * @dev Error indicating that a query was made for insufficient vote weight.\n */\n error ErrQueryForInsufficientVoteWeight();\n\n /// @dev Emitted when the deposit is requested\n event DepositRequested(bytes32 receiptHash, Transfer.Receipt receipt);\n /// @dev Emitted when the assets are withdrawn\n event Withdrew(bytes32 receiptHash, Transfer.Receipt receipt);\n /// @dev Emitted when the tokens are mapped\n event TokenMapped(address[] mainchainTokens, address[] roninTokens, Token.Standard[] standards);\n /// @dev Emitted when the wrapped native token contract is updated\n event WrappedNativeTokenContractUpdated(IWETH weth);\n /// @dev Emitted when the withdrawal is locked\n event WithdrawalLocked(bytes32 receiptHash, Transfer.Receipt receipt);\n /// @dev Emitted when the withdrawal is unlocked\n event WithdrawalUnlocked(bytes32 receiptHash, Transfer.Receipt receipt);\n\n /**\n * @dev Returns the domain seperator.\n */\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n /**\n * @dev Returns deposit count.\n */\n function depositCount() external view returns (uint256);\n\n /**\n * @dev Sets the wrapped native token contract.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `WrappedNativeTokenContractUpdated` event.\n *\n */\n function setWrappedNativeTokenContract(IWETH _wrappedToken) external;\n\n /**\n * @dev Returns whether the withdrawal is locked.\n */\n function withdrawalLocked(uint256 withdrawalId) external view returns (bool);\n\n /**\n * @dev Returns the withdrawal hash.\n */\n function withdrawalHash(uint256 withdrawalId) external view returns (bytes32);\n\n /**\n * @dev Locks the assets and request deposit.\n */\n function requestDepositFor(Transfer.Request calldata _request) external payable;\n\n /**\n * @dev Withdraws based on the receipt and the validator signatures.\n * Returns whether the withdrawal is locked.\n *\n * Emits the `Withdrew` once the assets are released.\n *\n */\n function submitWithdrawal(\n Transfer.Receipt memory _receipt,\n Signature[] memory _signatures\n ) external returns (bool _locked);\n\n /**\n * @dev Approves a specific withdrawal.\n *\n * Requirements:\n * - The method caller is a validator.\n *\n * Emits the `Withdrew` once the assets are released.\n *\n */\n function unlockWithdrawal(Transfer.Receipt calldata _receipt) external;\n\n /**\n * @dev Maps mainchain tokens to Ronin network.\n *\n * Requirement:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `TokenMapped` event.\n *\n */\n function mapTokens(\n address[] calldata _mainchainTokens,\n address[] calldata _roninTokens,\n Token.Standard[] calldata _standards\n ) external;\n\n /**\n * @dev Maps mainchain tokens to Ronin network and sets thresholds.\n *\n * Requirement:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `TokenMapped` event.\n *\n */\n function mapTokensAndThresholds(\n address[] calldata _mainchainTokens,\n address[] calldata _roninTokens,\n Token.Standard[] calldata _standards,\n uint256[][4] calldata _thresholds\n ) external;\n\n /**\n * @dev Returns token address on Ronin network.\n * Note: Reverts for unsupported token.\n */\n function getRoninToken(address _mainchainToken) external view returns (MappedToken memory _token);\n}\n" + }, + "contracts/interfaces/IMaintenance.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface IMaintenance {\n /**\n * @dev Error thrown when attempting to schedule an already scheduled event.\n */\n error ErrAlreadyScheduled();\n\n /**\n * @dev Error thrown when referring to a non-existent schedule.\n */\n error ErrUnexistedSchedule();\n\n /**\n * @dev Error thrown when the end block of a schedule is out of range.\n */\n error ErrEndBlockOutOfRange();\n\n /**\n * @dev Error thrown when the start block of a schedule is out of range.\n */\n error ErrStartBlockOutOfRange();\n\n /**\n * @dev Error thrown when attempting to initiate maintenance while already in maintenance mode.\n */\n error ErrAlreadyOnMaintenance();\n\n /**\n * @dev Error thrown when attempting an action before the cooldown period has ended.\n */\n error ErrCooldownTimeNotYetEnded();\n\n /**\n * @dev Error thrown when the total number of schedules exceeds the limit.\n */\n error ErrTotalOfSchedulesExceeded();\n\n /**\n * @dev Error thrown when an invalid maintenance duration is specified.\n */\n error ErrInvalidMaintenanceDuration();\n\n /**\n * @dev Error thrown when an invalid maintenance duration configuration is provided.\n */\n error ErrInvalidMaintenanceDurationConfig();\n\n /**\n * @dev Error thrown when an invalid offset is specified to start the schedule configurations.\n */\n error ErrInvalidOffsetToStartScheduleConfigs();\n\n struct Schedule {\n uint256 from;\n uint256 to;\n uint256 lastUpdatedBlock;\n uint256 requestTimestamp;\n }\n\n /// @dev Emitted when a maintenance is scheduled.\n event MaintenanceScheduled(address indexed consensusAddr, Schedule);\n /// @dev Emitted when a schedule of maintenance is cancelled.\n event MaintenanceScheduleCancelled(address indexed consensusAddr);\n /// @dev Emitted when the maintenance config is updated.\n event MaintenanceConfigUpdated(\n uint256 minMaintenanceDurationInBlock,\n uint256 maxMaintenanceDurationInBlock,\n uint256 minOffsetToStartSchedule,\n uint256 maxOffsetToStartSchedule,\n uint256 maxSchedules,\n uint256 cooldownSecsToMaintain\n );\n\n /**\n * @dev Returns whether the validator `_consensusAddr` maintained at the block number `_block`.\n */\n function checkMaintained(address _consensusAddr, uint256 _block) external view returns (bool);\n\n /**\n * @dev Returns whether the validator `_consensusAddr` maintained in the inclusive range [`_fromBlock`, `_toBlock`] of blocks.\n */\n function checkMaintainedInBlockRange(\n address _consensusAddr,\n uint256 _fromBlock,\n uint256 _toBlock\n ) external view returns (bool);\n\n /**\n * @dev Returns the bool array indicating the validators maintained at block number `_block` or not.\n */\n function checkManyMaintained(address[] calldata _addrList, uint256 _block) external view returns (bool[] memory);\n\n /**\n * @dev Returns a bool array indicating the validators maintained in the inclusive range [`_fromBlock`, `_toBlock`] of blocks or not.\n */\n function checkManyMaintainedInBlockRange(\n address[] calldata _addrList,\n uint256 _fromBlock,\n uint256 _toBlock\n ) external view returns (bool[] memory);\n\n /**\n * @dev Returns whether the validator `_consensusAddr` has scheduled.\n */\n function checkScheduled(address _consensusAddr) external view returns (bool);\n\n /**\n * @dev Returns whether the validator `_consensusAddr`\n */\n function checkCooldownEnds(address _consensusAddr) external view returns (bool);\n\n /**\n * @dev Returns the detailed schedule of the validator `_consensusAddr`.\n */\n function getSchedule(address _consensusAddr) external view returns (Schedule memory);\n\n /**\n * @dev Returns the total of current schedules.\n */\n function totalSchedules() external view returns (uint256 _count);\n\n /**\n * @dev Sets the duration restriction, start time restriction, and max allowed for maintenance.\n *\n * Requirements:\n * - The method caller is admin.\n * - The max duration is larger than the min duration.\n * - The max offset is larger than the min offset.\n *\n * Emits the event `MaintenanceConfigUpdated`.\n *\n */\n function setMaintenanceConfig(\n uint256 _minMaintenanceDurationInBlock,\n uint256 _maxMaintenanceDurationInBlock,\n uint256 _minOffsetToStartSchedule,\n uint256 _maxOffsetToStartSchedule,\n uint256 _maxSchedules,\n uint256 _cooldownSecsToMaintain\n ) external;\n\n /**\n * @dev Returns the min duration for maintenance in block.\n */\n function minMaintenanceDurationInBlock() external view returns (uint256);\n\n /**\n * @dev Returns the max duration for maintenance in block.\n */\n function maxMaintenanceDurationInBlock() external view returns (uint256);\n\n /**\n * @dev The offset to the min block number that the schedule can start\n */\n function minOffsetToStartSchedule() external view returns (uint256);\n\n /**\n * @dev The offset to the max block number that the schedule can start\n */\n function maxOffsetToStartSchedule() external view returns (uint256);\n\n /**\n * @dev Returns the max number of scheduled maintenances.\n */\n function maxSchedules() external view returns (uint256);\n\n /**\n * @dev Schedules for maintenance from `_startedAtBlock` to `_startedAtBlock`.\n *\n * Requirements:\n * - The candidate `_consensusAddr` is the block producer.\n * - The method caller is candidate admin of the candidate `_consensusAddr`.\n * - The candidate `_consensusAddr` has no schedule yet or the previous is done.\n * - The total number of schedules is not larger than `maxSchedules()`.\n * - The start block must be at least `minOffsetToStartSchedule()` and at most `maxOffsetToStartSchedule()` blocks from the current block.\n * - The end block is larger than the start block.\n * - The scheduled duration is larger than the `minMaintenanceDurationInBlock()` and less than the `maxMaintenanceDurationInBlock()`.\n * - The start block is at the start of an epoch.\n * - The end block is at the end of an epoch.\n *\n * Emits the event `MaintenanceScheduled`.\n *\n */\n function schedule(address _consensusAddr, uint256 _startedAtBlock, uint256 _endedAtBlock) external;\n\n /**\n * @dev Cancel the schedule of maintenance for the `_consensusAddr`.\n *\n * Requirements:\n * - The candidate `_consensusAddr` is the block producer.\n * - The method caller is candidate admin of the candidate `_consensusAddr`.\n * - A schedule for the `_consensusAddr` must be existent and not executed yet.\n *\n * Emits the event `MaintenanceScheduleCancelled`.\n */\n function cancelSchedule(address _consensusAddr) external;\n}\n" + }, + "contracts/interfaces/IPauseTarget.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IPauseTarget {\n function pause() external;\n\n function unpause() external;\n\n function paused() external returns (bool);\n}\n" + }, + "contracts/interfaces/IQuorum.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IQuorum {\n /// @dev Emitted when the threshold is updated\n event ThresholdUpdated(\n uint256 indexed nonce,\n uint256 indexed numerator,\n uint256 indexed denominator,\n uint256 previousNumerator,\n uint256 previousDenominator\n );\n\n /**\n * @dev Returns the threshold.\n */\n function getThreshold() external view returns (uint256 _num, uint256 _denom);\n\n /**\n * @dev Checks whether the `_voteWeight` passes the threshold.\n */\n function checkThreshold(uint256 _voteWeight) external view returns (bool);\n\n /**\n * @dev Returns the minimum vote weight to pass the threshold.\n */\n function minimumVoteWeight() external view returns (uint256);\n\n /**\n * @dev Sets the threshold.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `ThresholdUpdated` event.\n *\n */\n function setThreshold(\n uint256 _numerator,\n uint256 _denominator\n ) external returns (uint256 _previousNum, uint256 _previousDenom);\n}\n" + }, + "contracts/interfaces/IRoninGatewayV2.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../libraries/Transfer.sol\";\nimport \"./consumers/MappedTokenConsumer.sol\";\n\ninterface IRoninGatewayV2 is MappedTokenConsumer {\n /**\n * @dev Error thrown when attempting to withdraw funds that have already been migrated.\n */\n error ErrWithdrawalsMigrated();\n\n /**\n * @dev Error thrown when an invalid trusted threshold is specified.\n */\n error ErrInvalidTrustedThreshold();\n\n /**\n * @dev Error thrown when attempting to withdraw funds that have already been withdrawn on the mainchain.\n */\n error ErrWithdrawnOnMainchainAlready();\n\n /// @dev Emitted when the assets are depositted\n event Deposited(bytes32 receiptHash, Transfer.Receipt receipt);\n /// @dev Emitted when the withdrawal is requested\n event WithdrawalRequested(bytes32 receiptHash, Transfer.Receipt);\n /// @dev Emitted when the assets are withdrawn on mainchain\n event MainchainWithdrew(bytes32 receiptHash, Transfer.Receipt receipt);\n /// @dev Emitted when the withdrawal signatures is requested\n event WithdrawalSignaturesRequested(bytes32 receiptHash, Transfer.Receipt);\n /// @dev Emitted when the tokens are mapped\n event TokenMapped(address[] roninTokens, address[] mainchainTokens, uint256[] chainIds, Token.Standard[] standards);\n /// @dev Emitted when the threshold is updated\n event TrustedThresholdUpdated(\n uint256 indexed nonce,\n uint256 indexed numerator,\n uint256 indexed denominator,\n uint256 previousNumerator,\n uint256 previousDenominator\n );\n /// @dev Emitted when a deposit is voted\n event DepositVoted(address indexed bridgeOperator, uint256 indexed id, uint256 indexed chainId, bytes32 receiptHash);\n\n /**\n * @dev Returns withdrawal count.\n */\n function withdrawalCount() external view returns (uint256);\n\n /**\n * @dev Returns withdrawal signatures.\n */\n function getWithdrawalSignatures(\n uint256 _withdrawalId,\n address[] calldata _validators\n ) external view returns (bytes[] memory);\n\n /**\n * @dev Deposits based on the receipt.\n *\n * Requirements:\n * - The method caller is a validator.\n *\n * Emits the `Deposited` once the assets are released.\n *\n * @notice The assets will be transferred whenever the valid call passes the quorum threshold.\n *\n */\n function depositFor(Transfer.Receipt calldata _receipt) external;\n\n /**\n * @dev Marks the withdrawals are done on mainchain and returns the boolean array indicating whether the withdrawal\n * vote is already done before.\n *\n * Requirements:\n * - The method caller is a validator.\n *\n * Emits the `MainchainWithdrew` once the valid call passes the quorum threshold.\n *\n * @notice Not reverting to avoid unnecessary failed transactions because the validators can send transactions at the\n * same time.\n *\n */\n function tryBulkAcknowledgeMainchainWithdrew(uint256[] calldata _withdrawalIds) external returns (bool[] memory);\n\n /**\n * @dev Tries bulk deposits based on the receipts and returns the boolean array indicating whether the deposit vote\n * is already done before. Reverts if the deposit is invalid or is voted by the validator again.\n *\n * Requirements:\n * - The method caller is a validator.\n *\n * Emits the `Deposited` once the assets are released.\n *\n * @notice The assets will be transferred whenever the valid call for the receipt passes the quorum threshold. Not\n * reverting to avoid unnecessary failed transactions because the validators can send transactions at the same time.\n *\n */\n function tryBulkDepositFor(Transfer.Receipt[] calldata _receipts) external returns (bool[] memory);\n\n /**\n * @dev Locks the assets and request withdrawal.\n *\n * Emits the `WithdrawalRequested` event.\n *\n */\n function requestWithdrawalFor(Transfer.Request calldata _request, uint256 _chainId) external;\n\n /**\n * @dev Bulk requests withdrawals.\n *\n * Emits the `WithdrawalRequested` events.\n *\n */\n function bulkRequestWithdrawalFor(Transfer.Request[] calldata _requests, uint256 _chainId) external;\n\n /**\n * @dev Requests withdrawal signatures for a specific withdrawal.\n *\n * Emits the `WithdrawalSignaturesRequested` event.\n *\n */\n function requestWithdrawalSignatures(uint256 _withdrawalId) external;\n\n /**\n * @dev Submits withdrawal signatures.\n *\n * Requirements:\n * - The method caller is a validator.\n *\n */\n function bulkSubmitWithdrawalSignatures(uint256[] calldata _withdrawals, bytes[] calldata _signatures) external;\n\n /**\n * @dev Maps Ronin tokens to mainchain networks.\n *\n * Requirement:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `TokenMapped` event.\n *\n */\n function mapTokens(\n address[] calldata _roninTokens,\n address[] calldata _mainchainTokens,\n uint256[] calldata chainIds,\n Token.Standard[] calldata _standards\n ) external;\n\n /**\n * @dev Returns whether the deposit is casted by the voter.\n */\n function depositVoted(uint256 _chainId, uint256 _depositId, address _voter) external view returns (bool);\n\n /**\n * @dev Returns whether the mainchain withdrew is casted by the voter.\n */\n function mainchainWithdrewVoted(uint256 _withdrawalId, address _voter) external view returns (bool);\n\n /**\n * @dev Returns whether the withdrawal is done on mainchain.\n */\n function mainchainWithdrew(uint256 _withdrawalId) external view returns (bool);\n\n /**\n * @dev Returns mainchain token address.\n * Reverts for unsupported token.\n */\n function getMainchainToken(address _roninToken, uint256 _chainId) external view returns (MappedToken memory _token);\n}\n" + }, + "contracts/interfaces/IRoninGovernanceAdmin.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../utils/CommonErrors.sol\";\n\ninterface IRoninGovernanceAdmin {\n /// @dev Emitted when an emergency exit poll is created.\n event EmergencyExitPollCreated(\n bytes32 _voteHash,\n address _consensusAddr,\n address _recipientAfterUnlockedFund,\n uint256 _requestedAt,\n uint256 _expiredAt\n );\n /// @dev Emitted when an emergency exit poll is approved.\n event EmergencyExitPollApproved(bytes32 _voteHash);\n /// @dev Emitted when an emergency exit poll is expired.\n event EmergencyExitPollExpired(bytes32 _voteHash);\n /// @dev Emitted when an emergency exit poll is voted.\n event EmergencyExitPollVoted(bytes32 indexed _voteHash, address indexed _voter);\n\n /**\n * @dev Create a vote to agree that an emergency exit is valid and should return the locked funds back.a\n *\n * Requirements:\n * - The method caller is validator contract.\n *\n */\n function createEmergencyExitPoll(\n address _consensusAddr,\n address _recipientAfterUnlockedFund,\n uint256 _requestedAt,\n uint256 _expiredAt\n ) external;\n}\n" + }, + "contracts/interfaces/IRoninTrustedOrganization.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IQuorum.sol\";\n\ninterface IRoninTrustedOrganization is IQuorum {\n /**\n * @dev Error indicating that a query for a duplicate entry was made.\n */\n error ErrQueryForDupplicated();\n\n /**\n * @dev Error indicating that a query was made for a non-existent consensus address.\n */\n error ErrQueryForNonExistentConsensusAddress();\n\n /**\n * @dev Error indicating that a bridge voter has already been added.\n * @param voter The address of the bridge voter that is already added.\n */\n error ErrBridgeVoterIsAlreadyAdded(address voter);\n\n /**\n * @dev Error indicating that a governor address has already been added.\n * @param addr The address of the governor that is already added.\n */\n error ErrGovernorAddressIsAlreadyAdded(address addr);\n\n /**\n * @dev Error indicating that a consensus address is not added.\n * @param addr The address of the consensus contract that is not added.\n */\n error ErrConsensusAddressIsNotAdded(address addr);\n\n /**\n * @dev Error indicating that a consensus address is already added.\n * @param addr The address of the consensus contract that is already added.\n */\n error ErrConsensusAddressIsAlreadyAdded(address addr);\n\n struct TrustedOrganization {\n // Address of the validator that produces block, e.g. block.coinbase. This is so-called validator address.\n address consensusAddr;\n // Address to voting proposal\n address governor;\n // Address to voting bridge operators\n address bridgeVoter;\n // Its Weight\n uint256 weight;\n // The block that the organization was added\n uint256 addedBlock;\n }\n\n /// @dev Emitted when the trusted organization is added.\n event TrustedOrganizationsAdded(TrustedOrganization[] orgs);\n /// @dev Emitted when the trusted organization is updated.\n event TrustedOrganizationsUpdated(TrustedOrganization[] orgs);\n /// @dev Emitted when the trusted organization is removed.\n event TrustedOrganizationsRemoved(address[] orgs);\n\n /**\n * @dev Adds a list of addresses into the trusted organization.\n *\n * Requirements:\n * - The weights should larger than 0.\n * - The method caller is admin.\n * - The field `addedBlock` should be blank.\n *\n * Emits the event `TrustedOrganizationAdded` once an organization is added.\n *\n */\n function addTrustedOrganizations(TrustedOrganization[] calldata) external;\n\n /**\n * @dev Updates weights for a list of existent trusted organization.\n *\n * Requirements:\n * - The weights should larger than 0.\n * - The method caller is admin.\n *\n * Emits the `TrustedOrganizationUpdated` event.\n *\n */\n function updateTrustedOrganizations(TrustedOrganization[] calldata _list) external;\n\n /**\n * @dev Removes a list of addresses from the trusted organization.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `TrustedOrganizationRemoved` once an organization is removed.\n *\n * @param _consensusAddrs The list of consensus addresses linked to corresponding trusted organization that to be removed.\n */\n function removeTrustedOrganizations(address[] calldata _consensusAddrs) external;\n\n /**\n * @dev Returns total weights.\n */\n function totalWeights() external view returns (uint256);\n\n /**\n * @dev Returns the weight of a consensus.\n */\n function getConsensusWeight(address _consensusAddr) external view returns (uint256);\n\n /**\n * @dev Returns the weight of a governor.\n */\n function getGovernorWeight(address _governor) external view returns (uint256);\n\n /**\n * @dev Returns the weight of a bridge voter.\n */\n function getBridgeVoterWeight(address _addr) external view returns (uint256);\n\n /**\n * @dev Returns the weights of a list of consensus addresses.\n */\n function getConsensusWeights(address[] calldata _list) external view returns (uint256[] memory);\n\n /**\n * @dev Returns the weights of a list of governor addresses.\n */\n function getGovernorWeights(address[] calldata _list) external view returns (uint256[] memory);\n\n /**\n * @dev Returns the weights of a list of bridge voter addresses.\n */\n function getBridgeVoterWeights(address[] calldata _list) external view returns (uint256[] memory);\n\n /**\n * @dev Returns total weights of the consensus list.\n */\n function sumConsensusWeights(address[] calldata _list) external view returns (uint256 _res);\n\n /**\n * @dev Returns total weights of the governor list.\n */\n function sumGovernorWeights(address[] calldata _list) external view returns (uint256 _res);\n\n /**\n * @dev Returns total weights of the bridge voter list.\n */\n function sumBridgeVoterWeights(address[] calldata _list) external view returns (uint256 _res);\n\n /**\n * @dev Returns the trusted organization at `_index`.\n */\n function getTrustedOrganizationAt(uint256 _index) external view returns (TrustedOrganization memory);\n\n /**\n * @dev Returns the number of trusted organizations.\n */\n function countTrustedOrganizations() external view returns (uint256);\n\n /**\n * @dev Returns all of the trusted organizations.\n */\n function getAllTrustedOrganizations() external view returns (TrustedOrganization[] memory);\n\n /**\n * @dev Returns the trusted organization by consensus address.\n *\n * Reverts once the consensus address is non-existent.\n */\n function getTrustedOrganization(address _consensusAddr) external view returns (TrustedOrganization memory);\n}\n" + }, + "contracts/interfaces/IStakingVesting.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface IStakingVesting {\n /**\n * @dev Error thrown when attempting to send a bonus that has already been sent.\n */\n error ErrBonusAlreadySent();\n\n /// @dev Emitted when the block bonus for block producer is transferred.\n event BonusTransferred(\n uint256 indexed blockNumber,\n address indexed recipient,\n uint256 blockProducerAmount,\n uint256 bridgeOperatorAmount\n );\n /// @dev Emitted when the transfer of block bonus for block producer is failed.\n event BonusTransferFailed(\n uint256 indexed blockNumber,\n address indexed recipient,\n uint256 blockProducerAmount,\n uint256 bridgeOperatorAmount,\n uint256 contractBalance\n );\n /// @dev Emitted when the block bonus for block producer is updated\n event BlockProducerBonusPerBlockUpdated(uint256);\n /// @dev Emitted when the block bonus for bridge operator is updated\n event BridgeOperatorBonusPerBlockUpdated(uint256);\n\n /**\n * @dev Returns the bonus amount for the block producer at `_block`.\n */\n function blockProducerBlockBonus(uint256 _block) external view returns (uint256);\n\n /**\n * @dev Returns the bonus amount for the bridge validator at `_block`.\n */\n function bridgeOperatorBlockBonus(uint256 _block) external view returns (uint256);\n\n /**\n * @dev Receives RON from any address.\n */\n function receiveRON() external payable;\n\n /**\n * @dev Returns the last block number that the staking vesting is sent.\n */\n function lastBlockSendingBonus() external view returns (uint256);\n\n /**\n * @dev Transfers the staking vesting for the block producer and the bridge operator whenever a new block is mined.\n *\n * Requirements:\n * - The method caller must be validator contract.\n * - The method must be called only once per block.\n *\n * Emits the event `BonusTransferred` or `BonusTransferFailed`.\n *\n * Notes:\n * - The method does not revert when the contract balance is insufficient to send bonus. This assure the submit reward method\n * will not be reverted, and the underlying nodes does not hang.\n *\n * @param _forBlockProducer Indicates whether requesting the bonus for the block procucer, in case of being in jail or relevance.\n * @param _forBridgeOperator Indicates whether requesting the bonus for the bridge operator.\n *\n * @return _success Whether the transfer is successfully. This returns false mostly because this contract is out of balance.\n * @return _blockProducerBonus The amount of bonus actually sent for the block producer, returns 0 when the transfer is failed.\n * @return _bridgeOperatorBonus The amount of bonus actually sent for the bridge operator, returns 0 when the transfer is failed.\n *\n */\n function requestBonus(\n bool _forBlockProducer,\n bool _forBridgeOperator\n ) external returns (bool _success, uint256 _blockProducerBonus, uint256 _bridgeOperatorBonus);\n\n /**\n * @dev Sets the bonus amount per block for block producer.\n *\n * Emits the event `BlockProducerBonusPerBlockUpdated`.\n *\n * Requirements:\n * - The method caller is admin.\n *\n */\n function setBlockProducerBonusPerBlock(uint256 _amount) external;\n\n /**\n * @dev Sets the bonus amount per block for bridge operator.\n *\n * Emits the event `BridgeOperatorBonusPerBlockUpdated`.\n *\n * Requirements:\n * - The method caller is admin.\n *\n */\n function setBridgeOperatorBonusPerBlock(uint256 _amount) external;\n}\n" + }, + "contracts/interfaces/IWETH.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IWETH {\n function deposit() external payable;\n\n function withdraw(uint256 _wad) external;\n\n function balanceOf(address) external view returns (uint256);\n}\n" + }, + "contracts/interfaces/slash-indicator/IBaseSlash.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface IBaseSlash {\n enum SlashType {\n UNKNOWN,\n UNAVAILABILITY_TIER_1,\n UNAVAILABILITY_TIER_2,\n DOUBLE_SIGNING,\n BRIDGE_VOTING,\n BRIDGE_OPERATOR_MISSING_VOTE_TIER_1,\n BRIDGE_OPERATOR_MISSING_VOTE_TIER_2,\n UNAVAILABILITY_TIER_3\n }\n\n /// @dev Emitted when the validator is slashed.\n event Slashed(address indexed validator, SlashType slashType, uint256 period);\n}\n" + }, + "contracts/interfaces/slash-indicator/ICreditScore.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface ICreditScore {\n /**\n * @dev Error thrown when an invalid credit score configuration is provided.\n */\n error ErrInvalidCreditScoreConfig();\n\n /**\n * @dev Error thrown when an invalid cut-off percentage configuration is provided.\n */\n error ErrInvalidCutOffPercentageConfig();\n\n /**\n * @dev Error thrown when the caller's credit score is insufficient to bail out a situation.\n */\n error ErrInsufficientCreditScoreToBailOut();\n\n /**\n * @dev Error thrown when a validator has previously bailed out.\n */\n error ErrValidatorHasBailedOutPreviously();\n\n /**\n * @dev Error thrown when the caller must be jailed in the current period.\n */\n error ErrCallerMustBeJailedInTheCurrentPeriod();\n\n /// @dev Emitted when the configs to credit score is updated. See the method `setCreditScoreConfigs` for param details.\n event CreditScoreConfigsUpdated(\n uint256 gainCreditScore,\n uint256 maxCreditScore,\n uint256 bailOutCostMultiplier,\n uint256 cutOffPercentageAfterBailout\n );\n /// @dev Emitted the credit score of validators is updated.\n event CreditScoresUpdated(address[] validators, uint256[] creditScores);\n /// @dev Emitted when a validator bailed out of jail.\n event BailedOut(address indexed validator, uint256 period, uint256 usedCreditScore);\n\n /**\n * @dev Updates the credit score for the validators.\n *\n * Requirements:\n * - Only validator contract can call this method.\n * - This method is only called at the end of each period.\n *\n * Emits the event `CreditScoresUpdated`.\n *\n */\n function updateCreditScores(address[] calldata _validators, uint256 _period) external;\n\n /**\n * @dev Resets the credit score for the revoked validators.\n *\n * Requirements:\n * - Only validator contract can call this method.\n * - This method is only called at the end of each period.\n *\n * Emits the event `CreditScoresUpdated`.\n *\n */\n function execResetCreditScores(address[] calldata _validators) external;\n\n /**\n * @dev A slashed validator use this method to get out of jail.\n *\n * Requirements:\n * - The `_consensusAddr` must be a validator.\n * - Only validator's admin can call this method.\n *\n * Emits the event `BailedOut`.\n *\n */\n function bailOut(address _consensusAddr) external;\n\n /**\n * @dev Sets the configs to credit score.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `CreditScoreConfigsUpdated`.\n *\n * @param _gainScore The score to gain per period.\n * @param _maxScore The max number of credit score that a validator can hold.\n * @param _bailOutMultiplier The number that will be multiplied with the remaining jailed time to get the cost of bailing out.\n * @param _cutOffPercentage The percentage of reward that the block producer will be cut off from until the end of the period after bailing out.\n *\n */\n function setCreditScoreConfigs(\n uint256 _gainScore,\n uint256 _maxScore,\n uint256 _bailOutMultiplier,\n uint256 _cutOffPercentage\n ) external;\n\n /**\n * @dev Returns the configs related to credit score.\n *\n * @return _gainCreditScore The score to gain per period.\n * @return _maxCreditScore The max number of credit score that a validator can hold.\n * @return _bailOutCostMultiplier The number that will be multiplied with the remaining jailed time to get the cost of bailing out.\n * @return _cutOffPercentageAfterBailout The percentage of reward that the block producer will be cut off from until the end of the period after bailing out.\n *\n */\n function getCreditScoreConfigs()\n external\n view\n returns (\n uint256 _gainCreditScore,\n uint256 _maxCreditScore,\n uint256 _bailOutCostMultiplier,\n uint256 _cutOffPercentageAfterBailout\n );\n\n /**\n * @dev Returns the current credit score of the validator.\n */\n function getCreditScore(address _validator) external view returns (uint256);\n\n /**\n * @dev Returns the current credit score of a list of validators.\n */\n function getManyCreditScores(address[] calldata _validators) external view returns (uint256[] memory _resultList);\n\n /**\n * @dev Returns the whether the `_validator` has been bailed out at the `_period`.\n */\n function checkBailedOutAtPeriod(address _validator, uint256 _period) external view returns (bool);\n}\n" + }, + "contracts/interfaces/slash-indicator/ISlashBridgeOperator.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IBaseSlash.sol\";\n\ninterface ISlashBridgeOperator is IBaseSlash {\n /**\n * @dev Error thrown when invalid ratios are provided.\n */\n error ErrInvalidRatios();\n\n /**\n * @dev Emitted when the configs to slash bridge operator is updated. See the method\n * `getBridgeOperatorSlashingConfigs` for param details.\n */\n event BridgeOperatorSlashingConfigsUpdated(\n uint256 missingVotesRatioTier1,\n uint256 missingVotesRatioTier2,\n uint256 jailDurationForMissingVotesRatioTier2,\n uint256 skipBridgeOperatorSlashingThreshold\n );\n\n /**\n * @dev Acknowledges bridge operator slash and emit `Slashed` event correspondingly.\n * @param _tier The tier of the slash, in value of {1, 2}, corresponding to `SlashType.BRIDGE_OPERATOR_MISSING_VOTE_TIER_1`\n * and `SlashType.BRIDGE_OPERATOR_MISSING_VOTE_TIER_2`\n *\n * Requirements:\n * - Only validator contract can invoke this method.\n * - Should be called only at the end of period.\n * - Should be called only when there is slash of bridge operator.\n *\n * Emits the event `Slashed`.\n */\n function execSlashBridgeOperator(address _consensusAddr, uint256 _tier, uint256 _period) external;\n\n /**\n * @dev Returns the configs related to bridge operator slashing.\n *\n * @return _missingVotesRatioTier1 The bridge reward will be deprecated if (s)he missed more than this ratio.\n * @return _missingVotesRatioTier2 The bridge reward and mining reward will be deprecated and the corresponding\n * block producer will be put in jail if (s)he misses more than this ratio.\n * @return _jailDurationForMissingVotesRatioTier2 The number of blocks to jail the corresponding block producer when\n * its bridge operator is slashed tier-2.\n * @return _skipBridgeOperatorSlashingThreshold The threshold to skip slashing the bridge operator in case the total\n * number of votes in the bridge is too small.\n *\n */\n function getBridgeOperatorSlashingConfigs()\n external\n view\n returns (\n uint256 _missingVotesRatioTier1,\n uint256 _missingVotesRatioTier2,\n uint256 _jailDurationForMissingVotesRatioTier2,\n uint256 _skipBridgeOperatorSlashingThreshold\n );\n\n /**\n * @dev Sets the configs to slash bridge operators.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `BridgeOperatorSlashingConfigsUpdated`.\n *\n * @param _ratioTier1 The bridge reward will be deprecated if (s)he missed more than this ratio. Values 0-10,000 map\n * to 0%-100%.\n * @param _ratioTier2 The bridge reward and mining reward will be deprecated and the corresponding block producer will\n * be put in jail if (s)he misses more than this ratio. Values 0-10,000 map to 0%-100%.\n * @param _jailDurationTier2 The number of blocks to jail the corresponding block producer when its bridge operator is\n * slashed tier-2.\n * @param _skipSlashingThreshold The threshold to skip slashing the bridge operator in case the total number of votes\n * in the bridge is too small.\n *\n */\n function setBridgeOperatorSlashingConfigs(\n uint256 _ratioTier1,\n uint256 _ratioTier2,\n uint256 _jailDurationTier2,\n uint256 _skipSlashingThreshold\n ) external;\n}\n" + }, + "contracts/interfaces/slash-indicator/ISlashBridgeVoting.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IBaseSlash.sol\";\n\ninterface ISlashBridgeVoting is IBaseSlash {\n /**\n * @dev Error thrown when an invalid slash is encountered.\n */\n error ErrInvalidSlash();\n\n /**\n * @dev Emitted when the configs to slash bridge voting is updated. See the method `getBridgeVotingSlashingConfigs` for param\n * details.\n */\n event BridgeVotingSlashingConfigsUpdated(uint256 bridgeVotingThreshold, uint256 bridgeVotingSlashAmount);\n\n /**\n * @dev Slashes for bridge voter governance.\n *\n * Emits the event `Slashed`.\n */\n function slashBridgeVoting(address _consensusAddr) external;\n\n /**\n * @dev Returns the configs related to bridge voting slashing.\n *\n * @return _bridgeVotingThreshold The threshold to slash when a trusted organization does not vote for bridge\n * operators.\n * @return _bridgeVotingSlashAmount The amount of RON to slash bridge voting.\n *\n */\n function getBridgeVotingSlashingConfigs()\n external\n view\n returns (uint256 _bridgeVotingThreshold, uint256 _bridgeVotingSlashAmount);\n\n /**\n * @dev Sets the configs to slash bridge voting.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `BridgeVotingSlashingConfigsUpdated`.\n *\n * @param _threshold The threshold to slash when a trusted organization does not vote for bridge operators.\n * @param _slashAmount The amount of RON to slash bridge voting.\n *\n */\n function setBridgeVotingSlashingConfigs(uint256 _threshold, uint256 _slashAmount) external;\n}\n" + }, + "contracts/interfaces/slash-indicator/ISlashDoubleSign.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IBaseSlash.sol\";\n\ninterface ISlashDoubleSign is IBaseSlash {\n /**\n * @dev Error thrown when evidence has already been submitted.\n */\n error ErrEvidenceAlreadySubmitted();\n\n /**\n * @dev Emitted when the configs to slash double sign is updated. See the method `getDoubleSignSlashingConfigs`\n * for param details.\n */\n event DoubleSignSlashingConfigsUpdated(\n uint256 slashDoubleSignAmount,\n uint256 doubleSigningJailUntilBlock,\n uint256 doubleSigningOffsetLimitBlock\n );\n\n /**\n * @dev Slashes for double signing.\n *\n * Requirements:\n * - The method caller is coinbase.\n *\n * Emits the event `Slashed` if the double signing evidence of the two headers valid.\n */\n function slashDoubleSign(address _validatorAddr, bytes calldata _header1, bytes calldata _header2) external;\n\n /**\n * @dev Returns the configs related to block producer slashing.\n *\n * @return _slashDoubleSignAmount The amount of RON to slash double sign.\n * @return _doubleSigningJailUntilBlock The block number that the punished validator will be jailed until, due to\n * double signing.\n * @param _doubleSigningOffsetLimitBlock The number of block that the current block is at most far from the double\n * signing block.\n *\n */\n function getDoubleSignSlashingConfigs()\n external\n view\n returns (\n uint256 _slashDoubleSignAmount,\n uint256 _doubleSigningJailUntilBlock,\n uint256 _doubleSigningOffsetLimitBlock\n );\n\n /**\n * @dev Sets the configs to slash block producers.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `DoubleSignSlashingConfigsUpdated`.\n *\n * @param _slashAmount The amount of RON to slash double sign.\n * @param _jailUntilBlock The block number that the punished validator will be jailed until, due to double signing.\n * @param _doubleSigningOffsetLimitBlock The number of block that the current block is at most far from the double\n * signing block.\n *\n */\n function setDoubleSignSlashingConfigs(\n uint256 _slashAmount,\n uint256 _jailUntilBlock,\n uint256 _doubleSigningOffsetLimitBlock\n ) external;\n}\n" + }, + "contracts/interfaces/slash-indicator/ISlashIndicator.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./ISlashDoubleSign.sol\";\nimport \"./ISlashBridgeVoting.sol\";\nimport \"./ISlashBridgeOperator.sol\";\nimport \"./ISlashUnavailability.sol\";\nimport \"./ICreditScore.sol\";\n\ninterface ISlashIndicator is\n ISlashDoubleSign,\n ISlashBridgeVoting,\n ISlashBridgeOperator,\n ISlashUnavailability,\n ICreditScore\n{}\n" + }, + "contracts/interfaces/slash-indicator/ISlashUnavailability.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IBaseSlash.sol\";\n\ninterface ISlashUnavailability is IBaseSlash {\n /**\n * @dev Error thrown when attempting to slash a validator twice or slash more than one validator in one block.\n */\n error ErrCannotSlashAValidatorTwiceOrSlashMoreThanOneValidatorInOneBlock();\n\n /**\n * @dev Emitted when the configs to slash bridge operator is updated. See the method `getUnavailabilitySlashingConfigs`\n * for param details.\n */\n event UnavailabilitySlashingConfigsUpdated(\n uint256 unavailabilityTier1Threshold,\n uint256 unavailabilityTier2Threshold,\n uint256 slashAmountForUnavailabilityTier2Threshold,\n uint256 jailDurationForUnavailabilityTier2Threshold\n );\n\n /**\n * @dev Returns the last block that a block producer is slashed for unavailability.\n */\n function lastUnavailabilitySlashedBlock() external view returns (uint256);\n\n /**\n * @dev Slashes for unavailability by increasing the counter of block producer `_consensusAddr`.\n *\n * Requirements:\n * - The method caller is coinbase.\n *\n * Emits the event `Slashed` when the threshold is reached.\n *\n */\n function slashUnavailability(address _consensusAddr) external;\n\n /**\n * @dev Returns the current unavailability indicator of a block producer.\n */\n function currentUnavailabilityIndicator(address _validator) external view returns (uint256);\n\n /**\n * @dev Returns the unavailability indicator in the period `_period` of a block producer.\n */\n function getUnavailabilityIndicator(address _validator, uint256 _period) external view returns (uint256);\n\n /**\n * @dev Returns the configs related to block producer slashing.\n *\n * @return _unavailabilityTier1Threshold The mining reward will be deprecated, if (s)he missed more than this\n * threshold. This threshold is applied for tier-1 and tier-3 slash.\n * @return _unavailabilityTier2Threshold The mining reward will be deprecated, (s)he will be put in jailed, and will\n * be deducted self-staking if (s)he misses more than this threshold. This threshold is applied for tier-2 slash.\n * @return _slashAmountForUnavailabilityTier2Threshold The amount of RON to deduct from self-staking of a block\n * producer when (s)he is slashed with tier-2 or tier-3.\n * @return _jailDurationForUnavailabilityTier2Threshold The number of blocks to jail a block producer when (s)he is\n * slashed with tier-2 or tier-3.\n *\n */\n function getUnavailabilitySlashingConfigs()\n external\n view\n returns (\n uint256 _unavailabilityTier1Threshold,\n uint256 _unavailabilityTier2Threshold,\n uint256 _slashAmountForUnavailabilityTier2Threshold,\n uint256 _jailDurationForUnavailabilityTier2Threshold\n );\n\n /**\n * @dev Sets the configs to slash block producers.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `BridgeOperatorSlashingConfigsUpdated`.\n *\n * @param _tier1Threshold The mining reward will be deprecated, if (s)he missed more than this threshold.\n * @param _tier2Threshold The mining reward will be deprecated, (s)he will be put in jailed, and will be deducted\n * self-staking if (s)he misses more than this threshold.\n * @param _slashAmountForTier2Threshold The amount of RON to deduct from self-staking of a block producer when (s)he\n * is slashed tier-2.\n * @param _jailDurationForTier2Threshold The number of blocks to jail a block producer when (s)he is slashed tier-2.\n *\n */\n function setUnavailabilitySlashingConfigs(\n uint256 _tier1Threshold,\n uint256 _tier2Threshold,\n uint256 _slashAmountForTier2Threshold,\n uint256 _jailDurationForTier2Threshold\n ) external;\n}\n" + }, + "contracts/interfaces/staking/IBaseStaking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface IBaseStaking {\n struct PoolDetail {\n // Address of the pool i.e. consensus address of the validator\n address addr;\n // Pool admin address\n address admin;\n // Self-staking amount\n uint256 stakingAmount;\n // Total number of RON staking for the pool\n uint256 stakingTotal;\n // Mapping from delegator => delegating amount\n mapping(address => uint256) delegatingAmount;\n // Mapping from delegator => the last timestamp that delegator staked\n mapping(address => uint256) lastDelegatingTimestamp;\n }\n\n /// @dev Emitted when the minium number of seconds to undelegate is updated.\n event CooldownSecsToUndelegateUpdated(uint256 minSecs);\n /// @dev Emitted when the number of seconds that a candidate must wait to be revoked.\n event WaitingSecsToRevokeUpdated(uint256 secs);\n\n /// @dev Error of cannot transfer RON.\n error ErrCannotTransferRON();\n /// @dev Error of receiving zero message value.\n error ErrZeroValue();\n /// @dev Error of pool admin is not allowed to call.\n error ErrPoolAdminForbidden();\n /// @dev Error of no one is allowed to call but the pool's admin.\n error ErrOnlyPoolAdminAllowed();\n /// @dev Error of admin of any active pool cannot delegate.\n error ErrAdminOfAnyActivePoolForbidden(address admin);\n /// @dev Error of querying inactive pool.\n error ErrInactivePool(address poolAddr);\n /// @dev Error of length of input arrays are not of the same.\n error ErrInvalidArrays();\n\n /**\n * @dev Returns whether the `_poolAdminAddr` is currently active.\n */\n function isAdminOfActivePool(address _poolAdminAddr) external view returns (bool);\n\n /**\n * @dev Returns the consensus address corresponding to the pool admin.\n */\n function getPoolAddressOf(address _poolAdminAddr) external view returns (address);\n\n /**\n * @dev Returns the staking pool detail.\n */\n function getPoolDetail(address) external view returns (address _admin, uint256 _stakingAmount, uint256 _stakingTotal);\n\n /**\n * @dev Returns the self-staking amounts of the pools.\n */\n function getManySelfStakings(address[] calldata) external view returns (uint256[] memory);\n\n /**\n * @dev Returns The cooldown time in seconds to undelegate from the last timestamp (s)he delegated.\n */\n function cooldownSecsToUndelegate() external view returns (uint256);\n\n /**\n * @dev Returns the number of seconds that a candidate must wait for the renounce request gets affected.\n */\n function waitingSecsToRevoke() external view returns (uint256);\n\n /**\n * @dev Sets the cooldown time in seconds to undelegate from the last timestamp (s)he delegated.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `CooldownSecsToUndelegateUpdated`.\n *\n */\n function setCooldownSecsToUndelegate(uint256 _cooldownSecs) external;\n\n /**\n * @dev Sets the number of seconds that a candidate must wait to be revoked.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `WaitingSecsToRevokeUpdated`.\n *\n */\n function setWaitingSecsToRevoke(uint256 _secs) external;\n}\n" + }, + "contracts/interfaces/staking/ICandidateStaking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IRewardPool.sol\";\n\ninterface ICandidateStaking is IRewardPool {\n /// @dev Emitted when the minimum staking amount for being a validator is updated.\n event MinValidatorStakingAmountUpdated(uint256 threshold);\n /// @dev Emitted when the commission rate range is updated.\n event CommissionRateRangeUpdated(uint256 minRate, uint256 maxRate);\n\n /// @dev Emitted when the pool admin staked for themself.\n event Staked(address indexed consensuAddr, uint256 amount);\n /// @dev Emitted when the pool admin unstaked the amount of RON from themself.\n event Unstaked(address indexed consensuAddr, uint256 amount);\n\n /// @dev Emitted when the validator pool is approved.\n event PoolApproved(address indexed validator, address indexed admin);\n /// @dev Emitted when the validator pool is deprecated.\n event PoolsDeprecated(address[] validator);\n /// @dev Emitted when the staking amount transfer failed.\n event StakingAmountTransferFailed(\n address indexed validator,\n address indexed admin,\n uint256 amount,\n uint256 contractBalance\n );\n /// @dev Emitted when the staking amount deducted failed, e.g. when the validator gets slashed.\n event StakingAmountDeductFailed(\n address indexed validator,\n address indexed recipient,\n uint256 amount,\n uint256 contractBalance\n );\n\n /// @dev Error of cannot transfer RON to specified target.\n error ErrCannotInitTransferRON(address addr, string extraInfo);\n /// @dev Error of three interaction addresses must be of the same in applying for validator candidate.\n error ErrThreeInteractionAddrsNotEqual();\n /// @dev Error of unstaking zero amount.\n error ErrUnstakeZeroAmount();\n /// @dev Error of invalid staking amount left after deducted.\n error ErrStakingAmountLeft();\n /// @dev Error of insufficient staking amount for unstaking.\n error ErrInsufficientStakingAmount();\n /// @dev Error of unstaking too early.\n error ErrUnstakeTooEarly();\n /// @dev Error of setting commission rate exceeds max allowed.\n error ErrInvalidCommissionRate();\n\n /**\n * @dev Returns the minimum threshold for being a validator candidate.\n */\n function minValidatorStakingAmount() external view returns (uint256);\n\n /**\n * @dev Returns the commission rate range that the candidate can set.\n */\n function getCommissionRateRange() external view returns (uint256 _minRange, uint256 _maxRange);\n\n /**\n * @dev Sets the minimum threshold for being a validator candidate.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `MinValidatorStakingAmountUpdated` event.\n *\n */\n function setMinValidatorStakingAmount(uint256) external;\n\n /**\n * @dev Sets the commission rate range that a candidate can set.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `CommissionRateRangeUpdated` event.\n *\n */\n function setCommissionRateRange(uint256 _minRate, uint256 _maxRate) external;\n\n /**\n * @dev Proposes a candidate to become a validator.\n *\n * Requirements:\n * - The method caller is able to receive RON.\n * - The treasury is able to receive RON.\n * - The amount is larger than or equal to the minimum validator staking amount `minValidatorStakingAmount()`.\n *\n * Emits the event `PoolApproved`.\n *\n * @param _candidateAdmin the candidate admin will be stored in the validator contract, used for calling function that affects\n * to its candidate, e.g. scheduling maintenance.\n *\n */\n function applyValidatorCandidate(\n address _candidateAdmin,\n address _consensusAddr,\n address payable _treasuryAddr,\n uint256 _commissionRate\n ) external payable;\n\n /**\n * @dev Deprecates the pool.\n * - Deduct self-staking amount of the pool admin to zero.\n * - Transfer the deducted amount to the pool admin.\n * - Deactivate the pool admin address in the mapping of active pool admins\n *\n * Requirements:\n * - The method caller is validator contract.\n *\n * Emits the event `PoolsDeprecated` and `Unstaked` events.\n * Emits the event `StakingAmountTransferFailed` if the contract cannot transfer RON back to the pool admin.\n *\n */\n function execDeprecatePools(address[] calldata _pools, uint256 _period) external;\n\n /**\n * @dev Self-delegates to the validator candidate `_consensusAddr`.\n *\n * Requirements:\n * - The consensus address is a validator candidate.\n * - The method caller is the pool admin.\n * - The `msg.value` is larger than 0.\n *\n * Emits the event `Staked`.\n *\n */\n function stake(address _consensusAddr) external payable;\n\n /**\n * @dev Unstakes from the validator candidate `_consensusAddr` for `_amount`.\n *\n * Requirements:\n * - The consensus address is a validator candidate.\n * - The method caller is the pool admin.\n *\n * Emits the event `Unstaked`.\n *\n */\n function unstake(address _consensusAddr, uint256 _amount) external;\n\n /**\n * @dev Pool admin requests update validator commission rate. The request will be forwarded to the candidate manager\n * contract, and the value is getting updated in {ICandidateManager-execRequestUpdateCommissionRate}.\n *\n * Requirements:\n * - The consensus address is a validator candidate.\n * - The method caller is the pool admin.\n * - The `_effectiveDaysOnwards` must be equal to or larger than the {CandidateManager-_minEffectiveDaysOnwards}.\n * - The `_rate` must be in range of [0_00; 100_00].\n *\n * Emits the event `CommissionRateUpdated`.\n *\n */\n function requestUpdateCommissionRate(\n address _consensusAddr,\n uint256 _effectiveDaysOnwards,\n uint256 _commissionRate\n ) external;\n\n /**\n * @dev Renounces being a validator candidate and takes back the delegating/staking amount.\n *\n * Requirements:\n * - The consensus address is a validator candidate.\n * - The method caller is the pool admin.\n *\n */\n function requestRenounce(address _consensusAddr) external;\n\n /**\n * @dev Renounces being a validator candidate and takes back the delegating/staking amount.\n *\n * Requirements:\n * - The consensus address is a validator candidate.\n * - The method caller is the pool admin.\n *\n */\n function requestEmergencyExit(address _consensusAddr) external;\n}\n" + }, + "contracts/interfaces/staking/IDelegatorStaking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IRewardPool.sol\";\n\ninterface IDelegatorStaking is IRewardPool {\n /// @dev Emitted when the delegator staked for a validator candidate.\n event Delegated(address indexed delegator, address indexed consensuAddr, uint256 amount);\n /// @dev Emitted when the delegator unstaked from a validator candidate.\n event Undelegated(address indexed delegator, address indexed consensuAddr, uint256 amount);\n\n /// @dev Error of undelegating zero amount.\n error ErrUndelegateZeroAmount();\n /// @dev Error of undelegating insufficient amount.\n error ErrInsufficientDelegatingAmount();\n /// @dev Error of undelegating too early.\n error ErrUndelegateTooEarly();\n\n /**\n * @dev Stakes for a validator candidate `_consensusAddr`.\n *\n * Requirements:\n * - The consensus address is a validator candidate.\n * - The method caller is not the pool admin.\n *\n * Emits the `Delegated` event.\n *\n */\n function delegate(address _consensusAddr) external payable;\n\n /**\n * @dev Unstakes from a validator candidate `_consensusAddr` for `_amount`.\n *\n * Requirements:\n * - The method caller is not the pool admin.\n *\n * Emits the `Undelegated` event.\n *\n */\n function undelegate(address _consensusAddr, uint256 _amount) external;\n\n /**\n * @dev Bulk unstakes from a list of candidates.\n *\n * Requirements:\n * - The method caller is not the pool admin.\n *\n * Emits the events `Undelegated`.\n *\n */\n function bulkUndelegate(address[] calldata _consensusAddrs, uint256[] calldata _amounts) external;\n\n /**\n * @dev Unstakes an amount of RON from the `_consensusAddrSrc` and stake for `_consensusAddrDst`.\n *\n * Requirements:\n * - The method caller is not the pool admin.\n * - The consensus address `_consensusAddrDst` is a validator candidate.\n *\n * Emits the `Undelegated` event and the `Delegated` event.\n *\n */\n function redelegate(address _consensusAddrSrc, address _consensusAddrDst, uint256 _amount) external;\n\n /**\n * @dev Returns the claimable reward of the user `_user`.\n */\n function getRewards(\n address _user,\n address[] calldata _poolAddrList\n ) external view returns (uint256[] memory _rewards);\n\n /**\n * @dev Claims the reward of method caller.\n *\n * Emits the `RewardClaimed` event.\n *\n */\n function claimRewards(address[] calldata _consensusAddrList) external returns (uint256 _amount);\n\n /**\n * @dev Claims the rewards and delegates them to the consensus address.\n *\n * Requirements:\n * - The method caller is not the pool admin.\n * - The consensus address `_consensusAddrDst` is a validator candidate.\n *\n * Emits the `RewardClaimed` event and the `Delegated` event.\n *\n */\n function delegateRewards(\n address[] calldata _consensusAddrList,\n address _consensusAddrDst\n ) external returns (uint256 _amount);\n}\n" + }, + "contracts/interfaces/staking/IRewardPool.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../interfaces/consumers/PeriodWrapperConsumer.sol\";\n\ninterface IRewardPool is PeriodWrapperConsumer {\n struct UserRewardFields {\n // Recorded reward amount.\n uint256 debited;\n // The last accumulated of the amount rewards per share (one unit staking) that the info updated.\n uint256 aRps;\n // Lowest staking amount in the period.\n uint256 lowestAmount;\n // Last period number that the info updated.\n uint256 lastPeriod;\n }\n\n struct PoolFields {\n // Accumulated of the amount rewards per share (one unit staking).\n uint256 aRps;\n // The staking total to share reward of the current period.\n PeriodWrapper shares;\n }\n\n /// @dev Emitted when the fields to calculate pending reward for the user is updated.\n event UserRewardUpdated(address indexed poolAddr, address indexed user, uint256 debited);\n /// @dev Emitted when the user claimed their reward\n event RewardClaimed(address indexed poolAddr, address indexed user, uint256 amount);\n\n /// @dev Emitted when the pool shares are updated\n event PoolSharesUpdated(uint256 indexed period, address indexed poolAddr, uint256 shares);\n /// @dev Emitted when the pools are updated\n event PoolsUpdated(uint256 indexed period, address[] poolAddrs, uint256[] aRps, uint256[] shares);\n /// @dev Emitted when the contract fails when updating the pools\n event PoolsUpdateFailed(uint256 indexed period, address[] poolAddrs, uint256[] rewards);\n /// @dev Emitted when the contract fails when updating the pools that already set\n event PoolsUpdateConflicted(uint256 indexed period, address[] poolAddrs);\n\n /// @dev Error of invalid pool share.\n error ErrInvalidPoolShare();\n\n /**\n * @dev Returns the reward amount that user claimable.\n */\n function getReward(address _poolAddr, address _user) external view returns (uint256);\n\n /**\n * @dev Returns the staking amount of an user.\n */\n function getStakingAmount(address _poolAddr, address _user) external view returns (uint256);\n\n /**\n * @dev Returns the staking amounts of the users.\n */\n function getManyStakingAmounts(\n address[] calldata _poolAddrs,\n address[] calldata _userList\n ) external view returns (uint256[] memory);\n\n /**\n * @dev Returns the total staking amount of all users for a pool.\n */\n function getStakingTotal(address _poolAddr) external view returns (uint256);\n\n /**\n * @dev Returns the total staking amounts of all users for the pools `_poolAddrs`.\n */\n function getManyStakingTotals(address[] calldata _poolAddrs) external view returns (uint256[] memory);\n}\n" + }, + "contracts/interfaces/staking/IStaking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IBaseStaking.sol\";\nimport \"./ICandidateStaking.sol\";\nimport \"./IDelegatorStaking.sol\";\n\ninterface IStaking is IRewardPool, IBaseStaking, ICandidateStaking, IDelegatorStaking {\n /**\n * @dev Records the amount of rewards `_rewards` for the pools `_consensusAddrs`.\n *\n * Requirements:\n * - The method caller must be validator contract.\n *\n * Emits the event `PoolsUpdated` once the contract recorded the rewards successfully.\n * Emits the event `PoolsUpdateFailed` once the input array lengths are not equal.\n * Emits the event `PoolsUpdateConflicted` when there are some pools which already updated in the period.\n *\n * Note: This method should be called once at the period ending.\n *\n */\n function execRecordRewards(\n address[] calldata _consensusAddrs,\n uint256[] calldata _rewards,\n uint256 _period\n ) external payable;\n\n /**\n * @dev Deducts from staking amount of the validator `_consensusAddr` for `_amount`.\n *\n * Requirements:\n * - The method caller must be validator contract.\n *\n * Emits the event `Unstaked`.\n *\n */\n function execDeductStakingAmount(\n address _consensusAddr,\n uint256 _amount\n ) external returns (uint256 _actualDeductingAmount);\n}\n" + }, + "contracts/interfaces/validator/ICandidateManager.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface ICandidateManager {\n struct ValidatorCandidate {\n // Admin of the candidate\n address admin;\n // Address of the validator that produces block, e.g. block.coinbase. This is so-called validator address.\n address consensusAddr;\n // Address that receives mining reward of the validator\n address payable treasuryAddr;\n // Address of the bridge operator corresponding to the candidate\n address ______deprecatedbridgeOperatorAddr;\n // The percentage of reward that validators can be received, the rest goes to the delegators.\n // Values in range [0; 100_00] stands for 0-100%\n uint256 commissionRate;\n // The timestamp that scheduled to revoke the candidate (no schedule=0)\n uint256 revokingTimestamp;\n // The deadline that the candidate must top up staking amount to keep it larger than or equal to the threshold (no deadline=0)\n uint256 topupDeadline;\n }\n\n struct CommissionSchedule {\n // The timestamp that the commission schedule gets affected (no schedule=0).\n uint256 effectiveTimestamp;\n // The new commission rate. Value is in range [0; 100_00], stands for 0-100%\n uint256 commissionRate;\n }\n\n /// @dev Emitted when the maximum number of validator candidates is updated.\n event MaxValidatorCandidateUpdated(uint256 threshold);\n /// @dev Emitted when the min offset to the effective date of commission rate change is updated.\n event MinEffectiveDaysOnwardsUpdated(uint256 numOfDays);\n /// @dev Emitted when the validator candidate is granted.\n event CandidateGranted(address indexed consensusAddr, address indexed treasuryAddr, address indexed admin);\n /// @dev Emitted when the revoking timestamp of a candidate is updated.\n event CandidateRevokingTimestampUpdated(address indexed consensusAddr, uint256 revokingTimestamp);\n /// @dev Emitted when the topup deadline of a candidate is updated.\n event CandidateTopupDeadlineUpdated(address indexed consensusAddr, uint256 topupDeadline);\n /// @dev Emitted when the validator candidate is revoked.\n event CandidatesRevoked(address[] consensusAddrs);\n\n /// @dev Emitted when a schedule for updating commission rate is set.\n event CommissionRateUpdateScheduled(address indexed consensusAddr, uint256 effectiveTimestamp, uint256 rate);\n /// @dev Emitted when the commission rate of a validator is updated.\n event CommissionRateUpdated(address indexed consensusAddr, uint256 rate);\n\n /// @dev Error of exceeding maximum number of candidates.\n error ErrExceedsMaxNumberOfCandidate();\n /// @dev Error of querying for already existent candidate.\n error ErrExistentCandidate();\n /// @dev Error of querying for non-existent candidate.\n error ErrNonExistentCandidate();\n /// @dev Error of candidate admin already exists.\n error ErrExistentCandidateAdmin(address _candidateAdminAddr);\n /// @dev Error of treasury already exists.\n error ErrExistentTreasury(address _treasuryAddr);\n /// @dev Error of invalid commission rate.\n error ErrInvalidCommissionRate();\n /// @dev Error of invalid effective days onwards.\n error ErrInvalidEffectiveDaysOnwards();\n /// @dev Error of invalid min effective days onwards.\n error ErrInvalidMinEffectiveDaysOnwards();\n /// @dev Error of already requested revoking candidate before.\n error ErrAlreadyRequestedRevokingCandidate();\n /// @dev Error of commission change schedule exists.\n error ErrAlreadyRequestedUpdatingCommissionRate();\n /// @dev Error of trusted org cannot renounce.\n error ErrTrustedOrgCannotRenounce();\n\n /**\n * @dev Returns the maximum number of validator candidate.\n */\n function maxValidatorCandidate() external view returns (uint256);\n\n /**\n * @dev Returns the minimum number of days to the effective date of commission rate change.\n */\n function minEffectiveDaysOnwards() external view returns (uint256);\n\n /**\n * @dev Sets the maximum number of validator candidate.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `MaxValidatorCandidateUpdated` event.\n *\n */\n function setMaxValidatorCandidate(uint256) external;\n\n /**\n * @dev Sets the minimum number of days to the effective date of commision rate change.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `MinEffectiveDaysOnwardsUpdated` event.\n *\n */\n function setMinEffectiveDaysOnwards(uint256 _numOfDays) external;\n\n /**\n * @dev Grants a validator candidate.\n *\n * Requirements:\n * - The method caller is staking contract.\n *\n * Emits the event `CandidateGranted`.\n *\n */\n function execApplyValidatorCandidate(\n address _admin,\n address _consensusAddr,\n address payable _treasuryAddr,\n uint256 _commissionRate\n ) external;\n\n /**\n * @dev Requests to revoke a validator candidate in next `_secsLeft` seconds.\n *\n * Requirements:\n * - The method caller is staking contract.\n *\n * Emits the event `CandidateRevokingTimestampUpdated`.\n *\n */\n function execRequestRenounceCandidate(address, uint256 _secsLeft) external;\n\n /**\n * @dev Fallback function of `CandidateStaking-requestUpdateCommissionRate`.\n *\n * Requirements:\n * - The method caller is the staking contract.\n * - The `_effectiveTimestamp` must be the beginning of a UTC day, and at least from 7 days onwards\n * - The `_rate` must be in range of [0_00; 100_00].\n *\n * Emits the event `CommissionRateUpdateScheduled`.\n *\n */\n function execRequestUpdateCommissionRate(address _consensusAddr, uint256 _effectiveTimestamp, uint256 _rate) external;\n\n /**\n * @dev Returns whether the address is a validator (candidate).\n */\n function isValidatorCandidate(address _addr) external view returns (bool);\n\n /**\n * @dev Returns the validator candidate.\n */\n function getValidatorCandidates() external view returns (address[] memory);\n\n /**\n * @dev Returns all candidate info.\n */\n function getCandidateInfos() external view returns (ValidatorCandidate[] memory);\n\n /**\n * @dev Returns the info of a candidate.\n */\n function getCandidateInfo(address _candidate) external view returns (ValidatorCandidate memory);\n\n /**\n * @dev Returns whether the address is the candidate admin.\n */\n function isCandidateAdmin(address _candidate, address _admin) external view returns (bool);\n\n /**\n * @dev Returns the schedule of changing commission rate of a candidate address.\n */\n function getCommissionChangeSchedule(address _candidate) external view returns (CommissionSchedule memory);\n}\n" + }, + "contracts/interfaces/validator/ICoinbaseExecution.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./ISlashingExecution.sol\";\n\ninterface ICoinbaseExecution is ISlashingExecution {\n enum BlockRewardDeprecatedType {\n UNKNOWN,\n UNAVAILABILITY,\n AFTER_BAILOUT\n }\n\n /// @dev Emitted when the validator set is updated\n event ValidatorSetUpdated(uint256 indexed period, address[] consensusAddrs);\n /// @dev Emitted when the bridge operator set is updated, to mirror the in-jail and maintaining status of the validator.\n event BlockProducerSetUpdated(uint256 indexed period, uint256 indexed epoch, address[] consensusAddrs);\n /// @dev Emitted when the bridge operator set is updated.\n event BridgeOperatorSetUpdated(uint256 indexed period, uint256 indexed epoch, address[] bridgeOperators);\n\n /// @dev Emitted when the reward of the block producer is deprecated.\n event BlockRewardDeprecated(\n address indexed coinbaseAddr,\n uint256 rewardAmount,\n BlockRewardDeprecatedType deprecatedType\n );\n /// @dev Emitted when the block reward is submitted.\n event BlockRewardSubmitted(address indexed coinbaseAddr, uint256 submittedAmount, uint256 bonusAmount);\n\n /// @dev Emitted when the block producer reward is distributed.\n event MiningRewardDistributed(address indexed consensusAddr, address indexed recipient, uint256 amount);\n /// @dev Emitted when the contract fails when distributing the block producer reward.\n event MiningRewardDistributionFailed(\n address indexed consensusAddr,\n address indexed recipient,\n uint256 amount,\n uint256 contractBalance\n );\n\n /// @dev Emitted when the bridge operator reward is distributed.\n event BridgeOperatorRewardDistributed(\n address indexed consensusAddr,\n address indexed bridgeOperator,\n address indexed recipientAddr,\n uint256 amount\n );\n /// @dev Emitted when the contract fails when distributing the bridge operator reward.\n event BridgeOperatorRewardDistributionFailed(\n address indexed consensusAddr,\n address indexed bridgeOperator,\n address indexed recipient,\n uint256 amount,\n uint256 contractBalance\n );\n\n /// @dev Emitted when the amount of RON reward is distributed to staking contract.\n event StakingRewardDistributed(uint256 totalAmount, address[] consensusAddrs, uint256[] amounts);\n /// @dev Emitted when the contracts fails when distributing the amount of RON to the staking contract.\n event StakingRewardDistributionFailed(\n uint256 totalAmount,\n address[] consensusAddrs,\n uint256[] amounts,\n uint256 contractBalance\n );\n\n /// @dev Emitted when the epoch is wrapped up.\n event WrappedUpEpoch(uint256 indexed periodNumber, uint256 indexed epochNumber, bool periodEnding);\n\n /// @dev Error of method caller must be coinbase\n error ErrCallerMustBeCoinbase();\n /// @dev Error of only allowed at the end of epoch\n error ErrAtEndOfEpochOnly();\n /// @dev Error of query for already wrapped up epoch\n error ErrAlreadyWrappedEpoch();\n\n /**\n * @dev Submits reward of the current block.\n *\n * Requirements:\n * - The method caller is coinbase.\n *\n * Emits the event `MiningRewardDeprecated` if the coinbase is slashed or no longer be a block producer.\n * Emits the event `BlockRewardSubmitted` for the valid call.\n *\n */\n function submitBlockReward() external payable;\n\n /**\n * @dev Wraps up the current epoch.\n *\n * Requirements:\n * - The method must be called when the current epoch is ending.\n * - The epoch is not wrapped yet.\n * - The method caller is coinbase.\n *\n * Emits the event `MiningRewardDistributed` when some validator has reward distributed.\n * Emits the event `StakingRewardDistributed` when some staking pool has reward distributed.\n * Emits the event `BlockProducerSetUpdated` when the epoch is wrapped up.\n * Emits the event `BridgeOperatorSetUpdated` when the epoch is wrapped up at period ending.\n * Emits the event `ValidatorSetUpdated` when the epoch is wrapped up at period ending, and the validator set gets updated.\n * Emits the event `WrappedUpEpoch`.\n *\n */\n function wrapUpEpoch() external payable;\n}\n" + }, + "contracts/interfaces/validator/IEmergencyExit.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface IEmergencyExit {\n /// @dev Emitted when the fund is locked from an emergency exit request\n event EmergencyExitRequested(address indexed consensusAddr, uint256 lockedAmount);\n /// @dev Emitted when the fund that locked from an emergency exit request is transferred to the recipient.\n event EmergencyExitLockedFundReleased(\n address indexed consensusAddr,\n address indexed recipient,\n uint256 unlockedAmount\n );\n /// @dev Emitted when the fund that locked from an emergency exit request is failed to transferred back.\n event EmergencyExitLockedFundReleasingFailed(\n address indexed consensusAddr,\n address indexed recipient,\n uint256 unlockedAmount,\n uint256 contractBalance\n );\n\n /// @dev Emitted when the emergency exit locked amount is updated.\n event EmergencyExitLockedAmountUpdated(uint256 amount);\n /// @dev Emitted when the emergency expiry duration is updated.\n event EmergencyExpiryDurationUpdated(uint256 amount);\n\n /// @dev Error of already requested emergency exit before.\n error ErrAlreadyRequestedEmergencyExit();\n\n /**\n * @dev Returns the amount of RON to lock from a consensus address.\n */\n function emergencyExitLockedAmount() external returns (uint256);\n\n /**\n * @dev Returns the duration that an emergency request is expired and the fund will be recycled.\n */\n function emergencyExpiryDuration() external returns (uint256);\n\n /**\n * @dev Sets the amount of RON to lock from a consensus address.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `EmergencyExitLockedAmountUpdated`.\n *\n */\n function setEmergencyExitLockedAmount(uint256 _emergencyExitLockedAmount) external;\n\n /**\n * @dev Sets the duration that an emergency request is expired and the fund will be recycled.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `EmergencyExpiryDurationUpdated`.\n *\n */\n function setEmergencyExpiryDuration(uint256 _emergencyExpiryDuration) external;\n\n /**\n * @dev Unlocks fund for emergency exit request.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `EmergencyExitLockedFundReleased` if the fund is successfully unlocked.\n * Emits the event `EmergencyExitLockedFundReleasingFailed` if the fund is failed to unlock.\n *\n */\n function execReleaseLockedFundForEmergencyExitRequest(address _consensusAddr, address payable _recipient) external;\n\n /**\n * @dev Fallback function of `IStaking-requestEmergencyExit`.\n *\n * Requirements:\n * - The method caller is staking contract.\n *\n */\n function execEmergencyExit(address _consensusAddr, uint256 _secLeftToRevoke) external;\n}\n" + }, + "contracts/interfaces/validator/info-fragments/ICommonInfo.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IJailingInfo.sol\";\nimport \"./ITimingInfo.sol\";\nimport \"./IValidatorInfoV2.sol\";\n\ninterface ICommonInfo is ITimingInfo, IJailingInfo, IValidatorInfoV2 {\n struct EmergencyExitInfo {\n uint256 lockedAmount;\n // The timestamp that this locked amount will be recycled to staking vesting contract\n uint256 recyclingAt;\n }\n\n /// @dev Emitted when the deprecated reward is withdrawn.\n event DeprecatedRewardRecycled(address indexed recipientAddr, uint256 amount);\n /// @dev Emitted when the deprecated reward withdrawal is failed\n event DeprecatedRewardRecycleFailed(address indexed recipientAddr, uint256 amount, uint256 balance);\n\n /// @dev Error thrown when receives RON from neither staking vesting contract nor staking contract\n error ErrUnauthorizedReceiveRON();\n /// @dev Error thrown when queries for a non existent info.\n error NonExistentRecyclingInfo();\n\n /**\n * @dev Returns the total deprecated reward, which includes reward that is not sent for slashed validators and unsastified bridge operators\n */\n function totalDeprecatedReward() external view returns (uint256);\n\n /**\n * @dev Returns the emergency exit request.\n */\n function getEmergencyExitInfo(address _consensusAddr) external view returns (EmergencyExitInfo memory);\n}\n" + }, + "contracts/interfaces/validator/info-fragments/IJailingInfo.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface IJailingInfo {\n /**\n * @dev Returns whether the validator are put in jail (cannot join the set of validators) during the current period.\n */\n function checkJailed(address) external view returns (bool);\n\n /**\n * @dev Returns whether the validator are put in jail and the number of block and epoch that he still is in the jail.\n */\n function getJailedTimeLeft(\n address _addr\n ) external view returns (bool isJailed_, uint256 blockLeft_, uint256 epochLeft_);\n\n /**\n * @dev Returns whether the validator are put in jail (cannot join the set of validators) at a specific block.\n */\n function checkJailedAtBlock(address _addr, uint256 _blockNum) external view returns (bool);\n\n /**\n * @dev Returns whether the validator are put in jail at a specific block and the number of block and epoch that he still is in the jail.\n */\n function getJailedTimeLeftAtBlock(\n address _addr,\n uint256 _blockNum\n ) external view returns (bool isJailed_, uint256 blockLeft_, uint256 epochLeft_);\n\n /**\n * @dev Returns whether the validators are put in jail (cannot join the set of validators) during the current period.\n */\n function checkManyJailed(address[] calldata) external view returns (bool[] memory);\n\n /**\n * @dev Returns whether the incoming reward of the block producer is deprecated during the current period.\n */\n function checkMiningRewardDeprecated(address _blockProducer) external view returns (bool);\n\n /**\n * @dev Returns whether the incoming reward of the block producer is deprecated during a specific period.\n */\n function checkMiningRewardDeprecatedAtPeriod(address _blockProducer, uint256 _period) external view returns (bool);\n}\n" + }, + "contracts/interfaces/validator/info-fragments/ITimingInfo.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface ITimingInfo {\n /**\n * @dev Returns the block that validator set was updated.\n */\n function getLastUpdatedBlock() external view returns (uint256);\n\n /**\n * @dev Returns the number of blocks in a epoch.\n */\n function numberOfBlocksInEpoch() external view returns (uint256 _numberOfBlocks);\n\n /**\n * @dev Returns the epoch index from the block number.\n */\n function epochOf(uint256 _block) external view returns (uint256);\n\n /**\n * @dev Returns whether the epoch ending is at the block number `_block`.\n */\n function epochEndingAt(uint256 _block) external view returns (bool);\n\n /**\n * @dev Tries to get the period index from the epoch number.\n */\n function tryGetPeriodOfEpoch(uint256 _epoch) external view returns (bool _filled, uint256 _periodNumber);\n\n /**\n * @dev Returns whether the period ending at the current block number.\n */\n function isPeriodEnding() external view returns (bool);\n\n /**\n * @dev Returns the period index from the current block.\n */\n function currentPeriod() external view returns (uint256);\n\n /**\n * @dev Returns the block number that the current period starts at.\n */\n function currentPeriodStartAtBlock() external view returns (uint256);\n}\n" + }, + "contracts/interfaces/validator/info-fragments/IValidatorInfo.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../../libraries/EnumFlags.sol\";\n\ninterface IValidatorInfo {\n /**\n * @dev Error thrown when an invalid maximum prioritized validator number is provided.\n */\n error ErrInvalidMaxPrioritizedValidatorNumber();\n\n /// @dev Emitted when the number of max validator is updated.\n event MaxValidatorNumberUpdated(uint256);\n /// @dev Emitted when the number of reserved slots for prioritized validators is updated.\n event MaxPrioritizedValidatorNumberUpdated(uint256);\n\n /**\n * @dev Returns the maximum number of validators in the epoch.\n */\n function maxValidatorNumber() external view returns (uint256 _maximumValidatorNumber);\n\n /**\n * @dev Returns the number of reserved slots for prioritized validators.\n */\n function maxPrioritizedValidatorNumber() external view returns (uint256 _maximumPrioritizedValidatorNumber);\n\n /**\n * @dev Returns the current validator list.\n */\n function getValidators()\n external\n view\n returns (\n address[] memory _validatorList,\n address[] memory _bridgeOperators,\n EnumFlags.ValidatorFlag[] memory _flags\n );\n\n /**\n * @dev Returns whether the address is either a bridge operator or a block producer.\n */\n function isValidator(address _addr) external view returns (bool);\n\n /**\n * @dev Returns the current block producer list.\n */\n function getBlockProducers() external view returns (address[] memory);\n\n /**\n * @dev Returns whether the address is block producer or not.\n */\n function isBlockProducer(address _addr) external view returns (bool);\n\n /**\n * @dev Returns total numbers of the block producers.\n */\n function totalBlockProducers() external view returns (uint256);\n\n /**\n * @dev Returns the current on-working bridge operator list.\n * @param bridgeOperatorList The list of working bridge operators.\n * @param validatorList The list of corresponding validators.\n */\n function getBridgeOperators()\n external\n view\n returns (address[] memory bridgeOperatorList, address[] memory validatorList);\n\n /**\n * @dev Returns the bridge operator list corresponding to validator address list.\n */\n function getBridgeOperatorsOf(\n address[] memory _validatorAddrs\n ) external view returns (address[] memory bridgeOperatorList);\n\n /**\n * @dev Returns whether the address is bridge operator.\n */\n function isBridgeOperator(address _addr) external view returns (bool isOperator);\n\n /**\n * @dev Returns whether the consensus address is operating the bridge or not.\n */\n function isOperatingBridge(address _consensusAddr) external view returns (bool);\n\n /**\n * @dev Returns total numbers of the bridge operators.\n */\n function totalBridgeOperators() external view returns (uint256);\n\n /**\n * @dev Updates the max validator number\n *\n * Requirements:\n * - The method caller is admin\n *\n * Emits the event `MaxValidatorNumberUpdated`\n *\n */\n function setMaxValidatorNumber(uint256 _maxValidatorNumber) external;\n\n /**\n * @dev Updates the number of reserved slots for prioritized validators\n *\n * Requirements:\n * - The method caller is admin\n *\n * Emits the event `MaxPrioritizedValidatorNumberUpdated`\n *\n */\n function setMaxPrioritizedValidatorNumber(uint256 _maxPrioritizedValidatorNumber) external;\n}\n" + }, + "contracts/interfaces/validator/info-fragments/IValidatorInfoV2.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../../libraries/EnumFlags.sol\";\n\ninterface IValidatorInfoV2 {\n /**\n * @dev Error thrown when an invalid maximum prioritized validator number is provided.\n */\n error ErrInvalidMaxPrioritizedValidatorNumber();\n\n /// @dev Emitted when the number of max validator is updated.\n event MaxValidatorNumberUpdated(uint256);\n /// @dev Emitted when the number of reserved slots for prioritized validators is updated.\n event MaxPrioritizedValidatorNumberUpdated(uint256);\n\n /**\n * @dev Returns the maximum number of validators in the epoch.\n */\n function maxValidatorNumber() external view returns (uint256 _maximumValidatorNumber);\n\n /**\n * @dev Returns the number of reserved slots for prioritized validators.\n */\n function maxPrioritizedValidatorNumber() external view returns (uint256 _maximumPrioritizedValidatorNumber);\n\n /**\n * @dev Returns the current validator list.\n */\n function getValidators() external view returns (address[] memory _validatorList);\n\n /**\n * @dev Returns the current block producer list.\n */\n function getBlockProducers() external view returns (address[] memory);\n\n /**\n * @dev Returns whether the address is block producer or not.\n */\n function isBlockProducer(address _addr) external view returns (bool);\n\n /**\n * @dev Returns total numbers of the block producers.\n */\n function totalBlockProducers() external view returns (uint256);\n\n /**\n * @dev Updates the max validator number\n *\n * Requirements:\n * - The method caller is admin\n *\n * Emits the event `MaxValidatorNumberUpdated`\n *\n */\n function setMaxValidatorNumber(uint256 _maxValidatorNumber) external;\n\n /**\n * @dev Updates the number of reserved slots for prioritized validators\n *\n * Requirements:\n * - The method caller is admin\n *\n * Emits the event `MaxPrioritizedValidatorNumberUpdated`\n *\n */\n function setMaxPrioritizedValidatorNumber(uint256 _maxPrioritizedValidatorNumber) external;\n}\n" + }, + "contracts/interfaces/validator/IRoninValidatorSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./ICandidateManager.sol\";\nimport \"./info-fragments/ICommonInfo.sol\";\nimport \"./ICoinbaseExecution.sol\";\nimport \"./ISlashingExecution.sol\";\nimport \"./IEmergencyExit.sol\";\n\ninterface IRoninValidatorSet is\n ICandidateManager,\n ICommonInfo,\n ISlashingExecution,\n ICoinbaseExecution,\n IEmergencyExit\n{}\n" + }, + "contracts/interfaces/validator/ISlashingExecution.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface ISlashingExecution {\n /// @dev Emitted when the validator is punished.\n event ValidatorPunished(\n address indexed consensusAddr,\n uint256 indexed period,\n uint256 jailedUntil,\n uint256 deductedStakingAmount,\n bool blockProducerRewardDeprecated,\n bool bridgeOperatorRewardDeprecated\n );\n /// @dev Emitted when the validator get out of jail by bailout.\n event ValidatorUnjailed(address indexed validator, uint256 period);\n\n /// @dev Error of cannot bailout due to high tier slash.\n error ErrCannotBailout(address validator);\n\n /**\n * @dev Finalize the slash request from slash indicator contract.\n *\n * Requirements:\n * - The method caller is slash indicator contract.\n *\n * Emits the event `ValidatorPunished`.\n *\n */\n function execSlash(\n address _validatorAddr,\n uint256 _newJailedUntil,\n uint256 _slashAmount,\n bool _cannotBailout\n ) external;\n\n /**\n * @dev Finalize the bailout request from slash indicator contract.\n *\n * Requirements:\n * - The method caller is slash indicator contract.\n *\n * Emits the event `ValidatorUnjailed`.\n *\n */\n function execBailOut(address _validatorAddr, uint256 _period) external;\n}\n" + }, + "contracts/interfaces/version-control/IConditionalImplementControl.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IConditionalImplementControl {\n /// @dev Error when contract which delegate to this contract is not compatible with ERC1967\n error ErrDelegateFromUnknownOrigin(address addr);\n\n /**\n * @dev Executes the selfUpgrade function, upgrading to the new contract implementation.\n */\n function selfUpgrade() external;\n}\n" + }, + "contracts/libraries/AddressArrayUtils.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\nlibrary AddressArrayUtils {\n /**\n * @dev Error thrown when a duplicated element is detected in an array.\n * @param msgSig The function signature that invoke the error.\n */\n error ErrDuplicated(bytes4 msgSig);\n\n /**\n * @dev Returns whether or not there's a duplicate. Runs in O(n^2).\n * @param A Array to search\n * @return Returns true if duplicate, false otherwise\n */\n function hasDuplicate(address[] memory A) internal pure returns (bool) {\n if (A.length == 0) {\n return false;\n }\n unchecked {\n for (uint256 i = 0; i < A.length - 1; i++) {\n for (uint256 j = i + 1; j < A.length; j++) {\n if (A[i] == A[j]) {\n return true;\n }\n }\n }\n }\n return false;\n }\n\n /**\n * @dev Returns whether two arrays of addresses are equal or not.\n */\n function isEqual(address[] memory _this, address[] memory _other) internal pure returns (bool yes_) {\n // Hashing two arrays and compare their hash\n assembly {\n let _thisHash := keccak256(add(_this, 32), mul(mload(_this), 32))\n let _otherHash := keccak256(add(_other, 32), mul(mload(_other), 32))\n yes_ := eq(_thisHash, _otherHash)\n }\n }\n\n /**\n * @dev Return the concatenated array from a and b.\n */\n function extend(address[] memory a, address[] memory b) internal pure returns (address[] memory c) {\n uint256 lengthA = a.length;\n uint256 lengthB = b.length;\n unchecked {\n c = new address[](lengthA + lengthB);\n }\n uint256 i;\n for (; i < lengthA; ) {\n c[i] = a[i];\n unchecked {\n ++i;\n }\n }\n for (uint256 j; j < lengthB; ) {\n c[i] = b[j];\n unchecked {\n ++i;\n ++j;\n }\n }\n }\n}\n" + }, + "contracts/libraries/Ballot.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\n\nlibrary Ballot {\n using ECDSA for bytes32;\n\n enum VoteType {\n For,\n Against\n }\n\n // keccak256(\"Ballot(bytes32 proposalHash,uint8 support)\");\n bytes32 private constant BALLOT_TYPEHASH = 0xd900570327c4c0df8dd6bdd522b7da7e39145dd049d2fd4602276adcd511e3c2;\n\n function hash(bytes32 _proposalHash, VoteType _support) internal pure returns (bytes32 digest) {\n // return keccak256(abi.encode(BALLOT_TYPEHASH, _proposalHash, _support));\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, BALLOT_TYPEHASH)\n mstore(add(ptr, 0x20), _proposalHash)\n mstore(add(ptr, 0x40), _support)\n digest := keccak256(ptr, 0x60)\n }\n }\n}\n" + }, + "contracts/libraries/BridgeOperatorsBallot.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"../utils/CommonErrors.sol\";\n\nlibrary BridgeOperatorsBallot {\n /**\n * @dev Error thrown when an invalid order of the bridge operator is detected.\n */\n error ErrInvalidOrderOfBridgeOperator();\n\n struct BridgeOperatorSet {\n uint256 period;\n uint256 epoch;\n address[] operators;\n }\n\n // keccak256(\"BridgeOperatorsBallot(uint256 period,uint256 epoch,address[] operators)\");\n bytes32 public constant BRIDGE_OPERATORS_BALLOT_TYPEHASH =\n 0xd679a49e9e099fa9ed83a5446aaec83e746b03ec6723d6f5efb29d37d7f0b78a;\n\n /**\n * @dev Verifies whether the ballot is valid or not.\n *\n * Requirements:\n * - The ballot is not for an empty operator set.\n * - The operator address list is in order.\n *\n */\n function verifyBallot(BridgeOperatorSet calldata _ballot) internal pure {\n if (_ballot.operators.length == 0) revert ErrEmptyArray();\n\n address _addr = _ballot.operators[0];\n for (uint _i = 1; _i < _ballot.operators.length; ) {\n if (_addr >= _ballot.operators[_i]) revert ErrInvalidOrderOfBridgeOperator();\n _addr = _ballot.operators[_i];\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @dev Returns hash of the ballot.\n */\n function hash(BridgeOperatorSet memory self) internal pure returns (bytes32 digest_) {\n bytes32 operatorsHash;\n address[] memory operators = self.operators;\n\n // return keccak256(abi.encode(BRIDGE_OPERATORS_BALLOT_TYPEHASH, _ballot.period, _ballot.epoch, _operatorsHash));\n assembly {\n operatorsHash := keccak256(add(operators, 32), mul(mload(operators), 32))\n let ptr := mload(0x40)\n mstore(ptr, BRIDGE_OPERATORS_BALLOT_TYPEHASH)\n mstore(add(ptr, 0x20), mload(self)) // _ballot.period\n mstore(add(ptr, 0x40), mload(add(self, 0x20))) // _ballot.epoch\n mstore(add(ptr, 0x60), operatorsHash)\n digest_ := keccak256(ptr, 0x80)\n }\n }\n}\n" + }, + "contracts/libraries/EmergencyExitBallot.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\n\nlibrary EmergencyExitBallot {\n // keccak256(\"EmergencyExitBallot(address consensusAddress,address recipientAfterUnlockedFund,uint256 requestedAt,uint256 expiredAt)\");\n bytes32 private constant EMERGENCY_EXIT_BALLOT_TYPEHASH =\n 0x697acba4deaf1a718d8c2d93e42860488cb7812696f28ca10eed17bac41e7027;\n\n /**\n * @dev Returns hash of the ballot.\n */\n function hash(\n address _consensusAddress,\n address _recipientAfterUnlockedFund,\n uint256 _requestedAt,\n uint256 _expiredAt\n ) internal pure returns (bytes32 digest) {\n /*\n * return\n * keccak256(\n * abi.encode(\n * EMERGENCY_EXIT_BALLOT_TYPEHASH,\n * _consensusAddress,\n * _recipientAfterUnlockedFund,\n * _requestedAt,\n * _expiredAt\n * )\n * );\n */\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, EMERGENCY_EXIT_BALLOT_TYPEHASH)\n mstore(add(ptr, 0x20), _consensusAddress)\n mstore(add(ptr, 0x40), _recipientAfterUnlockedFund)\n mstore(add(ptr, 0x60), _requestedAt)\n mstore(add(ptr, 0x80), _expiredAt)\n digest := keccak256(ptr, 0xa0)\n }\n }\n}\n" + }, + "contracts/libraries/EnumFlags.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This library implements checking flag of an enumerated value.\n * The originated idea is inherited from [Enum.HashFlag(Enum)](https://learn.microsoft.com/en-us/dotnet/api/system.enum.hasflag?view=net-6.0) method of C#.\n */\nlibrary EnumFlags {\n enum ValidatorFlag {\n None, // bit(00)\n BlockProducer, // bit(01)\n DeprecatedBridgeOperator, // bit(10)\n Both // bit(11)\n }\n\n function isNone(ValidatorFlag _value) internal pure returns (bool) {\n return uint8(_value) == 0;\n }\n\n /**\n * @dev Checks if `_value` has `_flag`.\n */\n function hasFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (bool) {\n return (uint8(_value) & uint8(_flag)) != 0;\n }\n\n /**\n * @dev Calculate new value of `_value` after adding `_flag`.\n */\n function addFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (ValidatorFlag) {\n return ValidatorFlag(uint8(_value) | uint8(_flag));\n }\n\n /**\n * @dev Calculate new value of `_value` after remove `_flag`.\n */\n function removeFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (ValidatorFlag) {\n return ValidatorFlag(uint8(_value) & ~uint8(_flag));\n }\n}\n" + }, + "contracts/libraries/ErrorHandler.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { ErrProxyCallFailed } from \"../utils/CommonErrors.sol\";\n\nlibrary ErrorHandler {\n /// @notice handle low level call revert if call failed,\n /// If extcall return empty bytes, reverts with custom error.\n /// @param status Status of external call\n /// @param callSig function signature of the calldata\n /// @param returnOrRevertData bytes result from external call\n function handleRevert(bool status, bytes4 callSig, bytes memory returnOrRevertData) internal pure {\n // Get the function signature of current context\n bytes4 msgSig = msg.sig;\n assembly {\n if iszero(status) {\n // Load the length of bytes array\n let revertLength := mload(returnOrRevertData)\n // Check if length != 0 => revert following reason from external call\n if iszero(iszero(revertLength)) {\n // Start of revert data bytes. The 0x20 offset is always the same.\n revert(add(returnOrRevertData, 0x20), revertLength)\n }\n\n // Load free memory pointer\n let ptr := mload(0x40)\n // Store 4 bytes the function selector of ErrProxyCallFailed(msg.sig, callSig)\n // Equivalent to revert ErrProxyCallFailed(bytes4,bytes4)\n mstore(ptr, 0x8e3eda2b)\n // Store 4 bytes of msgSig parameter in the next slot\n mstore(add(ptr, 0x20), msgSig)\n // Store 4 bytes of callSig parameter in the next slot\n mstore(add(ptr, 0x40), callSig)\n // Revert 68 bytes of error starting from 0x1c\n revert(add(ptr, 0x1c), 0x44)\n }\n }\n }\n}\n" + }, + "contracts/libraries/GlobalProposal.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./Proposal.sol\";\n\nlibrary GlobalProposal {\n /**\n * @dev Error thrown when attempting to interact with an unsupported target.\n */\n error ErrUnsupportedTarget(bytes32 proposalHash, uint256 targetNumber);\n\n enum TargetOption {\n /* 0 */ BridgeManager,\n /* 1 */ GatewayContract,\n /* 2 */ BridgeReward,\n /* 3 */ BridgeSlash\n }\n\n struct GlobalProposalDetail {\n // Nonce to make sure proposals are executed in order\n uint256 nonce;\n uint256 expiryTimestamp;\n TargetOption[] targetOptions;\n uint256[] values;\n bytes[] calldatas;\n uint256[] gasAmounts;\n }\n\n // keccak256(\"GlobalProposalDetail(uint256 nonce,uint256 expiryTimestamp,uint8[] targetOptions,uint256[] values,bytes[] calldatas,uint256[] gasAmounts)\");\n bytes32 public constant TYPE_HASH = 0x1463f426c05aff2c1a7a0957a71c9898bc8b47142540538e79ee25ee91141350;\n\n /**\n * @dev Returns struct hash of the proposal.\n */\n function hash(GlobalProposalDetail memory self) internal pure returns (bytes32 digest_) {\n uint256[] memory values = self.values;\n TargetOption[] memory targets = self.targetOptions;\n bytes32[] memory calldataHashList = new bytes32[](self.calldatas.length);\n uint256[] memory gasAmounts = self.gasAmounts;\n\n for (uint256 i; i < calldataHashList.length; ) {\n calldataHashList[i] = keccak256(self.calldatas[i]);\n\n unchecked {\n ++i;\n }\n }\n\n /*\n * return\n * keccak256(\n * abi.encode(\n * TYPE_HASH,\n * _proposal.nonce,\n * _proposal.expiryTimestamp,\n * _targetsHash,\n * _valuesHash,\n * _calldatasHash,\n * _gasAmountsHash\n * )\n * );\n */\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, TYPE_HASH)\n mstore(add(ptr, 0x20), mload(self)) // _proposal.nonce\n mstore(add(ptr, 0x40), mload(add(self, 0x20))) // _proposal.expiryTimestamp\n\n let arrayHashed\n arrayHashed := keccak256(add(targets, 32), mul(mload(targets), 32)) // targetsHash\n mstore(add(ptr, 0x60), arrayHashed)\n arrayHashed := keccak256(add(values, 32), mul(mload(values), 32)) // _valuesHash\n mstore(add(ptr, 0x80), arrayHashed)\n arrayHashed := keccak256(add(calldataHashList, 32), mul(mload(calldataHashList), 32)) // _calldatasHash\n mstore(add(ptr, 0xa0), arrayHashed)\n arrayHashed := keccak256(add(gasAmounts, 32), mul(mload(gasAmounts), 32)) // _gasAmountsHash\n mstore(add(ptr, 0xc0), arrayHashed)\n digest_ := keccak256(ptr, 0xe0)\n }\n }\n\n /**\n * @dev Converts into the normal proposal.\n */\n function intoProposalDetail(\n GlobalProposalDetail memory self,\n address[] memory targets\n ) internal pure returns (Proposal.ProposalDetail memory detail_) {\n detail_.nonce = self.nonce;\n detail_.expiryTimestamp = self.expiryTimestamp;\n detail_.chainId = 0;\n detail_.targets = new address[](self.targetOptions.length);\n detail_.values = self.values;\n detail_.calldatas = self.calldatas;\n detail_.gasAmounts = self.gasAmounts;\n\n for (uint256 i; i < self.targetOptions.length; ) {\n detail_.targets[i] = targets[i];\n unchecked {\n ++i;\n }\n }\n }\n}\n" + }, + "contracts/libraries/IsolatedGovernance.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../interfaces/consumers/VoteStatusConsumer.sol\";\nimport \"../utils/CommonErrors.sol\";\n\nlibrary IsolatedGovernance {\n struct Vote {\n VoteStatusConsumer.VoteStatus status;\n bytes32 finalHash;\n /// @dev Mapping from voter => receipt hash\n mapping(address => bytes32) voteHashOf;\n /// @dev The timestamp that voting is expired (no expiration=0)\n uint256 expiredAt;\n /// @dev The timestamp that voting is created\n uint256 createdAt;\n /// @dev The list of voters\n address[] voters;\n }\n\n /**\n * @dev Casts vote for the receipt with the receipt hash `_hash`.\n *\n * Requirements:\n * - The voter has not voted for the round.\n *\n */\n function castVote(Vote storage _v, address _voter, bytes32 _hash) internal {\n if (_v.expiredAt > 0 && _v.expiredAt <= block.timestamp) {\n _v.status = VoteStatusConsumer.VoteStatus.Expired;\n }\n\n if (voted(_v, _voter)) revert ErrAlreadyVoted(_voter);\n\n _v.voteHashOf[_voter] = _hash;\n _v.voters.push(_voter);\n }\n\n /**\n * @dev Updates vote with the requirement of minimum vote weight.\n */\n function syncVoteStatus(\n Vote storage _v,\n uint256 _minimumVoteWeight,\n uint256 _votedWeightForHash,\n bytes32 _hash\n ) internal returns (VoteStatusConsumer.VoteStatus _status) {\n if (_votedWeightForHash >= _minimumVoteWeight && _v.status == VoteStatusConsumer.VoteStatus.Pending) {\n _v.status = VoteStatusConsumer.VoteStatus.Approved;\n _v.finalHash = _hash;\n }\n\n return _v.status;\n }\n\n /**\n * @dev Returns the list of vote's addresses that voted for the hash `_hash`.\n */\n function filterByHash(Vote storage _v, bytes32 _hash) internal view returns (address[] memory _voters) {\n uint256 _count;\n _voters = new address[](_v.voters.length);\n\n unchecked {\n for (uint _i; _i < _voters.length; ++_i) {\n address _voter = _v.voters[_i];\n if (_v.voteHashOf[_voter] == _hash) {\n _voters[_count++] = _voter;\n }\n }\n }\n\n assembly {\n mstore(_voters, _count)\n }\n }\n\n /**\n * @dev Returns whether the voter casted for the proposal.\n */\n function voted(Vote storage _v, address _voter) internal view returns (bool) {\n return _v.voteHashOf[_voter] != bytes32(0);\n }\n}\n" + }, + "contracts/libraries/Math.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\nlibrary Math {\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a >= b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns whether the number `c` is in range of [a; b].\n */\n function inRange(uint256 c, uint256 a, uint256 b) internal pure returns (bool) {\n return a <= c && c <= b;\n }\n\n /**\n * @dev Returns whether two inclusive ranges [x1;x2] and [y1;y2] overlap.\n */\n function twoRangeOverlap(uint256 x1, uint256 x2, uint256 y1, uint256 y2) internal pure returns (bool) {\n return x1 <= y2 && y1 <= x2;\n }\n\n /**\n * @dev Returns value of a + b; in case result is larger than upperbound, upperbound is returned.\n */\n function addWithUpperbound(uint256 a, uint256 b, uint256 upperbound) internal pure returns (uint256) {\n return min(a + b, upperbound);\n }\n\n /**\n * @dev Returns value of a - b; in case of negative result, 0 is returned.\n */\n function subNonNegative(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a - b : 0;\n }\n\n /**\n * @dev Returns value of `a + zeroable` if zerobale is not 0; otherwise, return 0.\n */\n function addIfNonZero(uint256 a, uint256 zeroable) internal pure returns (uint256) {\n return zeroable != 0 ? a + zeroable : 0;\n }\n}\n" + }, + "contracts/libraries/Proposal.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { ErrInvalidChainId, ErrLengthMismatch } from \"../utils/CommonErrors.sol\";\n\nlibrary Proposal {\n /**\n * @dev Error thrown when there is insufficient gas to execute a function.\n */\n error ErrInsufficientGas(bytes32 proposalHash);\n\n /**\n * @dev Error thrown when an invalid expiry timestamp is provided.\n */\n error ErrInvalidExpiryTimestamp();\n\n struct ProposalDetail {\n // Nonce to make sure proposals are executed in order\n uint256 nonce;\n // Value 0: all chain should run this proposal\n // Other values: only specifc chain has to execute\n uint256 chainId;\n uint256 expiryTimestamp;\n address[] targets;\n uint256[] values;\n bytes[] calldatas;\n uint256[] gasAmounts;\n }\n\n // keccak256(\"ProposalDetail(uint256 nonce,uint256 chainId,uint256 expiryTimestamp,address[] targets,uint256[] values,bytes[] calldatas,uint256[] gasAmounts)\");\n bytes32 public constant TYPE_HASH = 0xd051578048e6ff0bbc9fca3b65a42088dbde10f36ca841de566711087ad9b08a;\n\n /**\n * @dev Validates the proposal.\n */\n function validate(ProposalDetail memory _proposal, uint256 _maxExpiryDuration) internal view {\n if (\n !(_proposal.targets.length > 0 &&\n _proposal.targets.length == _proposal.values.length &&\n _proposal.targets.length == _proposal.calldatas.length &&\n _proposal.targets.length == _proposal.gasAmounts.length)\n ) {\n revert ErrLengthMismatch(msg.sig);\n }\n\n if (_proposal.expiryTimestamp > block.timestamp + _maxExpiryDuration) {\n revert ErrInvalidExpiryTimestamp();\n }\n }\n\n /**\n * @dev Returns struct hash of the proposal.\n */\n function hash(ProposalDetail memory _proposal) internal pure returns (bytes32 digest_) {\n uint256[] memory _values = _proposal.values;\n address[] memory _targets = _proposal.targets;\n bytes32[] memory _calldataHashList = new bytes32[](_proposal.calldatas.length);\n uint256[] memory _gasAmounts = _proposal.gasAmounts;\n\n for (uint256 _i; _i < _calldataHashList.length; ) {\n _calldataHashList[_i] = keccak256(_proposal.calldatas[_i]);\n\n unchecked {\n ++_i;\n }\n }\n\n // return\n // keccak256(\n // abi.encode(\n // TYPE_HASH,\n // _proposal.nonce,\n // _proposal.chainId,\n // _targetsHash,\n // _valuesHash,\n // _calldatasHash,\n // _gasAmountsHash\n // )\n // );\n // /\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, TYPE_HASH)\n mstore(add(ptr, 0x20), mload(_proposal)) // _proposal.nonce\n mstore(add(ptr, 0x40), mload(add(_proposal, 0x20))) // _proposal.chainId\n mstore(add(ptr, 0x60), mload(add(_proposal, 0x40))) // expiry timestamp\n\n let arrayHashed\n arrayHashed := keccak256(add(_targets, 32), mul(mload(_targets), 32)) // targetsHash\n mstore(add(ptr, 0x80), arrayHashed)\n arrayHashed := keccak256(add(_values, 32), mul(mload(_values), 32)) // _valuesHash\n mstore(add(ptr, 0xa0), arrayHashed)\n arrayHashed := keccak256(add(_calldataHashList, 32), mul(mload(_calldataHashList), 32)) // _calldatasHash\n mstore(add(ptr, 0xc0), arrayHashed)\n arrayHashed := keccak256(add(_gasAmounts, 32), mul(mload(_gasAmounts), 32)) // _gasAmountsHash\n mstore(add(ptr, 0xe0), arrayHashed)\n digest_ := keccak256(ptr, 0x100)\n }\n }\n\n /**\n * @dev Returns whether the proposal is executable for the current chain.\n *\n * @notice Does not check whether the call result is successful or not. Please use `execute` instead.\n *\n */\n function executable(ProposalDetail memory _proposal) internal view returns (bool _result) {\n return _proposal.chainId == 0 || _proposal.chainId == block.chainid;\n }\n\n /**\n * @dev Executes the proposal.\n */\n function execute(\n ProposalDetail memory _proposal\n ) internal returns (bool[] memory _successCalls, bytes[] memory _returnDatas) {\n if (!executable(_proposal)) revert ErrInvalidChainId(msg.sig, _proposal.chainId, block.chainid);\n\n _successCalls = new bool[](_proposal.targets.length);\n _returnDatas = new bytes[](_proposal.targets.length);\n for (uint256 _i = 0; _i < _proposal.targets.length; ) {\n if (gasleft() <= _proposal.gasAmounts[_i]) revert ErrInsufficientGas(hash(_proposal));\n\n (_successCalls[_i], _returnDatas[_i]) = _proposal.targets[_i].call{\n value: _proposal.values[_i],\n gas: _proposal.gasAmounts[_i]\n }(_proposal.calldatas[_i]);\n\n unchecked {\n ++_i;\n }\n }\n }\n}\n" + }, + "contracts/libraries/Token.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport \"../interfaces/IWETH.sol\";\n\nlibrary Token {\n /// @dev Error indicating that the provided information is invalid.\n error ErrInvalidInfo();\n\n /// @dev Error indicating that the minting of ERC20 tokens has failed.\n error ErrERC20MintingFailed();\n\n /// @dev Error indicating that the minting of ERC721 tokens has failed.\n error ErrERC721MintingFailed();\n\n /// @dev Error indicating that an unsupported standard is encountered.\n error ErrUnsupportedStandard();\n\n /**\n * @dev Error indicating that the `transfer` has failed.\n * @param tokenInfo Info of the token including ERC standard, id or quantity.\n * @param to Receiver of the token value.\n * @param token Address of the token.\n */\n error ErrTokenCouldNotTransfer(Info tokenInfo, address to, address token);\n\n /**\n * @dev Error indicating that the `transferFrom` has failed.\n * @param tokenInfo Info of the token including ERC standard, id or quantity.\n * @param from Owner of the token value.\n * @param to Receiver of the token value.\n * @param token Address of the token.\n */\n error ErrTokenCouldNotTransferFrom(Info tokenInfo, address from, address to, address token);\n\n enum Standard {\n ERC20,\n ERC721\n }\n\n struct Info {\n Standard erc;\n // For ERC20: the id must be 0 and the quantity is larger than 0.\n // For ERC721: the quantity must be 0.\n uint256 id;\n uint256 quantity;\n }\n\n // keccak256(\"TokenInfo(uint8 erc,uint256 id,uint256 quantity)\");\n bytes32 public constant INFO_TYPE_HASH = 0x1e2b74b2a792d5c0f0b6e59b037fa9d43d84fbb759337f0112fcc15ca414fc8d;\n\n /**\n * @dev Returns token info struct hash.\n */\n function hash(Info memory _info) internal pure returns (bytes32 digest) {\n // keccak256(abi.encode(INFO_TYPE_HASH, _info.erc, _info.id, _info.quantity))\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, INFO_TYPE_HASH)\n mstore(add(ptr, 0x20), mload(_info)) // _info.erc\n mstore(add(ptr, 0x40), mload(add(_info, 0x20))) // _info.id\n mstore(add(ptr, 0x60), mload(add(_info, 0x40))) // _info.quantity\n digest := keccak256(ptr, 0x80)\n }\n }\n\n /**\n * @dev Validates the token info.\n */\n function validate(Info memory _info) internal pure {\n if (\n !((_info.erc == Standard.ERC20 && _info.quantity > 0 && _info.id == 0) ||\n (_info.erc == Standard.ERC721 && _info.quantity == 0))\n ) revert ErrInvalidInfo();\n }\n\n /**\n * @dev Transfer asset from.\n *\n * Requirements:\n * - The `_from` address must approve for the contract using this library.\n *\n */\n function transferFrom(Info memory _info, address _from, address _to, address _token) internal {\n bool _success;\n bytes memory _data;\n if (_info.erc == Standard.ERC20) {\n (_success, _data) = _token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, _from, _to, _info.quantity));\n _success = _success && (_data.length == 0 || abi.decode(_data, (bool)));\n } else if (_info.erc == Standard.ERC721) {\n // bytes4(keccak256(\"transferFrom(address,address,uint256)\"))\n (_success, ) = _token.call(abi.encodeWithSelector(0x23b872dd, _from, _to, _info.id));\n } else revert ErrUnsupportedStandard();\n\n if (!_success) revert ErrTokenCouldNotTransferFrom(_info, _from, _to, _token);\n }\n\n /**\n * @dev Transfers ERC721 token and returns the result.\n */\n function tryTransferERC721(address _token, address _to, uint256 _id) internal returns (bool _success) {\n (_success, ) = _token.call(abi.encodeWithSelector(IERC721.transferFrom.selector, address(this), _to, _id));\n }\n\n /**\n * @dev Transfers ERC20 token and returns the result.\n */\n function tryTransferERC20(address _token, address _to, uint256 _quantity) internal returns (bool _success) {\n bytes memory _data;\n (_success, _data) = _token.call(abi.encodeWithSelector(IERC20.transfer.selector, _to, _quantity));\n _success = _success && (_data.length == 0 || abi.decode(_data, (bool)));\n }\n\n /**\n * @dev Transfer assets from current address to `_to` address.\n */\n function transfer(Info memory _info, address _to, address _token) internal {\n bool _success;\n if (_info.erc == Standard.ERC20) {\n _success = tryTransferERC20(_token, _to, _info.quantity);\n } else if (_info.erc == Standard.ERC721) {\n _success = tryTransferERC721(_token, _to, _info.id);\n } else revert ErrUnsupportedStandard();\n\n if (!_success) revert ErrTokenCouldNotTransfer(_info, _to, _token);\n }\n\n /**\n * @dev Tries minting and transfering assets.\n *\n * @notice Prioritizes transfer native token if the token is wrapped.\n *\n */\n function handleAssetTransfer(\n Info memory _info,\n address payable _to,\n address _token,\n IWETH _wrappedNativeToken\n ) internal {\n bool _success;\n if (_token == address(_wrappedNativeToken)) {\n // Try sending the native token before transferring the wrapped token\n if (!_to.send(_info.quantity)) {\n _wrappedNativeToken.deposit{ value: _info.quantity }();\n transfer(_info, _to, _token);\n }\n } else if (_info.erc == Token.Standard.ERC20) {\n uint256 _balance = IERC20(_token).balanceOf(address(this));\n\n if (_balance < _info.quantity) {\n // bytes4(keccak256(\"mint(address,uint256)\"))\n (_success, ) = _token.call(abi.encodeWithSelector(0x40c10f19, address(this), _info.quantity - _balance));\n if (!_success) revert ErrERC20MintingFailed();\n }\n\n transfer(_info, _to, _token);\n } else if (_info.erc == Token.Standard.ERC721) {\n if (!tryTransferERC721(_token, _to, _info.id)) {\n // bytes4(keccak256(\"mint(address,uint256)\"))\n (_success, ) = _token.call(abi.encodeWithSelector(0x40c10f19, _to, _info.id));\n if (!_success) revert ErrERC721MintingFailed();\n }\n } else revert ErrUnsupportedStandard();\n }\n\n struct Owner {\n address addr;\n address tokenAddr;\n uint256 chainId;\n }\n\n // keccak256(\"TokenOwner(address addr,address tokenAddr,uint256 chainId)\");\n bytes32 public constant OWNER_TYPE_HASH = 0x353bdd8d69b9e3185b3972e08b03845c0c14a21a390215302776a7a34b0e8764;\n\n /**\n * @dev Returns ownership struct hash.\n */\n function hash(Owner memory _owner) internal pure returns (bytes32 digest) {\n // keccak256(abi.encode(OWNER_TYPE_HASH, _owner.addr, _owner.tokenAddr, _owner.chainId))\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, OWNER_TYPE_HASH)\n mstore(add(ptr, 0x20), mload(_owner)) // _owner.addr\n mstore(add(ptr, 0x40), mload(add(_owner, 0x20))) // _owner.tokenAddr\n mstore(add(ptr, 0x60), mload(add(_owner, 0x40))) // _owner.chainId\n digest := keccak256(ptr, 0x80)\n }\n }\n}\n" + }, + "contracts/libraries/Transfer.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"./Token.sol\";\n\nlibrary Transfer {\n using ECDSA for bytes32;\n\n enum Kind {\n Deposit,\n Withdrawal\n }\n\n struct Request {\n // For deposit request: Recipient address on Ronin network\n // For withdrawal request: Recipient address on mainchain network\n address recipientAddr;\n // Token address to deposit/withdraw\n // Value 0: native token\n address tokenAddr;\n Token.Info info;\n }\n\n /**\n * @dev Converts the transfer request into the deposit receipt.\n */\n function into_deposit_receipt(\n Request memory _request,\n address _requester,\n uint256 _id,\n address _roninTokenAddr,\n uint256 _roninChainId\n ) internal view returns (Receipt memory _receipt) {\n _receipt.id = _id;\n _receipt.kind = Kind.Deposit;\n _receipt.mainchain.addr = _requester;\n _receipt.mainchain.tokenAddr = _request.tokenAddr;\n _receipt.mainchain.chainId = block.chainid;\n _receipt.ronin.addr = _request.recipientAddr;\n _receipt.ronin.tokenAddr = _roninTokenAddr;\n _receipt.ronin.chainId = _roninChainId;\n _receipt.info = _request.info;\n }\n\n /**\n * @dev Converts the transfer request into the withdrawal receipt.\n */\n function into_withdrawal_receipt(\n Request memory _request,\n address _requester,\n uint256 _id,\n address _mainchainTokenAddr,\n uint256 _mainchainId\n ) internal view returns (Receipt memory _receipt) {\n _receipt.id = _id;\n _receipt.kind = Kind.Withdrawal;\n _receipt.ronin.addr = _requester;\n _receipt.ronin.tokenAddr = _request.tokenAddr;\n _receipt.ronin.chainId = block.chainid;\n _receipt.mainchain.addr = _request.recipientAddr;\n _receipt.mainchain.tokenAddr = _mainchainTokenAddr;\n _receipt.mainchain.chainId = _mainchainId;\n _receipt.info = _request.info;\n }\n\n struct Receipt {\n uint256 id;\n Kind kind;\n Token.Owner mainchain;\n Token.Owner ronin;\n Token.Info info;\n }\n\n // keccak256(\"Receipt(uint256 id,uint8 kind,TokenOwner mainchain,TokenOwner ronin,TokenInfo info)TokenInfo(uint8 erc,uint256 id,uint256 quantity)TokenOwner(address addr,address tokenAddr,uint256 chainId)\");\n bytes32 public constant TYPE_HASH = 0xb9d1fe7c9deeec5dc90a2f47ff1684239519f2545b2228d3d91fb27df3189eea;\n\n /**\n * @dev Returns token info struct hash.\n */\n function hash(Receipt memory _receipt) internal pure returns (bytes32 digest) {\n bytes32 hashedReceiptMainchain = Token.hash(_receipt.mainchain);\n bytes32 hashedReceiptRonin = Token.hash(_receipt.ronin);\n bytes32 hashedReceiptInfo = Token.hash(_receipt.info);\n\n /*\n * return\n * keccak256(\n * abi.encode(\n * TYPE_HASH,\n * _receipt.id,\n * _receipt.kind,\n * Token.hash(_receipt.mainchain),\n * Token.hash(_receipt.ronin),\n * Token.hash(_receipt.info)\n * )\n * );\n */\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, TYPE_HASH)\n mstore(add(ptr, 0x20), mload(_receipt)) // _receipt.id\n mstore(add(ptr, 0x40), mload(add(_receipt, 0x20))) // _receipt.kind\n mstore(add(ptr, 0x60), hashedReceiptMainchain)\n mstore(add(ptr, 0x80), hashedReceiptRonin)\n mstore(add(ptr, 0xa0), hashedReceiptInfo)\n digest := keccak256(ptr, 0xc0)\n }\n }\n\n /**\n * @dev Returns the receipt digest.\n */\n function receiptDigest(bytes32 _domainSeparator, bytes32 _receiptHash) internal pure returns (bytes32) {\n return _domainSeparator.toTypedDataHash(_receiptHash);\n }\n}\n" + }, + "contracts/mainchain/MainchainBridgeManager.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { CoreGovernance } from \"../extensions/sequential-governance/CoreGovernance.sol\";\nimport { GlobalCoreGovernance, GlobalGovernanceRelay } from \"../extensions/sequential-governance/governance-relay/GlobalGovernanceRelay.sol\";\nimport { GovernanceRelay } from \"../extensions/sequential-governance/governance-relay/GovernanceRelay.sol\";\nimport { ContractType, BridgeManager } from \"../extensions/bridge-operator-governance/BridgeManager.sol\";\nimport { Ballot } from \"../libraries/Ballot.sol\";\nimport { Proposal } from \"../libraries/Proposal.sol\";\nimport { GlobalProposal } from \"../libraries/GlobalProposal.sol\";\nimport \"../utils/CommonErrors.sol\";\n\ncontract MainchainBridgeManager is BridgeManager, GovernanceRelay, GlobalGovernanceRelay {\n uint256 private constant DEFAULT_EXPIRY_DURATION = 1 << 255;\n\n constructor(\n uint256 num,\n uint256 denom,\n uint256 roninChainId,\n address bridgeContract,\n address[] memory callbackRegisters,\n address[] memory bridgeOperators,\n address[] memory governors,\n uint96[] memory voteWeights,\n GlobalProposal.TargetOption[] memory targetOptions,\n address[] memory targets\n )\n payable\n CoreGovernance(DEFAULT_EXPIRY_DURATION)\n GlobalCoreGovernance(targetOptions, targets)\n BridgeManager(num, denom, roninChainId, bridgeContract, callbackRegisters, bridgeOperators, governors, voteWeights)\n {}\n\n /**\n * @dev See `GovernanceRelay-_relayProposal`.\n *\n * Requirements:\n * - The method caller is governor.\n */\n function relayProposal(\n Proposal.ProposalDetail calldata proposal,\n Ballot.VoteType[] calldata supports_,\n Signature[] calldata signatures\n ) external onlyGovernor {\n _relayProposal(proposal, supports_, signatures, DOMAIN_SEPARATOR, msg.sender);\n }\n\n /**\n * @dev See `GovernanceRelay-_relayGlobalProposal`.\n *\n * Requirements:\n * - The method caller is governor.\n */\n function relayGlobalProposal(\n GlobalProposal.GlobalProposalDetail calldata globalProposal,\n Ballot.VoteType[] calldata supports_,\n Signature[] calldata signatures\n ) external onlyGovernor {\n _relayGlobalProposal({\n globalProposal: globalProposal,\n supports_: supports_,\n signatures: signatures,\n domainSeparator: DOMAIN_SEPARATOR,\n creator: msg.sender\n });\n }\n\n /**\n * @dev Internal function to retrieve the minimum vote weight required for governance actions.\n * @return minimumVoteWeight The minimum vote weight required for governance actions.\n */\n function _getMinimumVoteWeight() internal view override returns (uint256) {\n return minimumVoteWeight();\n }\n\n /**\n * @dev Returns the expiry duration for a new proposal.\n */\n function getProposalExpiryDuration() external view returns (uint256) {\n return _getProposalExpiryDuration();\n }\n\n /**\n * @dev Internal function to retrieve the total weights of all governors.\n * @return totalWeights The total weights of all governors combined.\n */\n function _getTotalWeights() internal view override returns (uint256) {\n return getTotalWeights();\n }\n\n /**\n * @dev Internal function to calculate the sum of weights for a given array of governors.\n * @param governors An array containing the addresses of governors to calculate the sum of weights.\n * @return sumWeights The sum of weights for the provided governors.\n */\n function _sumWeights(address[] memory governors) internal view override returns (uint256) {\n return _sumGovernorsWeight(governors);\n }\n\n /**\n * @dev Internal function to retrieve the chain type of the contract.\n * @return chainType The chain type, indicating the type of the chain the contract operates on (e.g., Mainchain).\n */\n function _getChainType() internal pure override returns (ChainType) {\n return ChainType.Mainchain;\n }\n}\n" + }, + "contracts/mainchain/MainchainGatewayV2.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/access/AccessControlEnumerable.sol\";\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport { IBridgeManager } from \"../interfaces/bridge/IBridgeManager.sol\";\nimport { IBridgeManagerCallback } from \"../interfaces/bridge/IBridgeManagerCallback.sol\";\nimport { HasContracts, ContractType } from \"../extensions/collections/HasContracts.sol\";\nimport \"../extensions/WithdrawalLimitation.sol\";\nimport \"../libraries/Transfer.sol\";\nimport \"../interfaces/IMainchainGatewayV2.sol\";\n\ncontract MainchainGatewayV2 is\n WithdrawalLimitation,\n Initializable,\n AccessControlEnumerable,\n IMainchainGatewayV2,\n HasContracts\n{\n using Token for Token.Info;\n using Transfer for Transfer.Request;\n using Transfer for Transfer.Receipt;\n\n /// @dev Withdrawal unlocker role hash\n bytes32 public constant WITHDRAWAL_UNLOCKER_ROLE = keccak256(\"WITHDRAWAL_UNLOCKER_ROLE\");\n\n /// @dev Wrapped native token address\n IWETH public wrappedNativeToken;\n /// @dev Ronin network id\n uint256 public roninChainId;\n /// @dev Total deposit\n uint256 public depositCount;\n /// @dev Domain seperator\n bytes32 internal _domainSeparator;\n /// @dev Mapping from mainchain token => token address on Ronin network\n mapping(address => MappedToken) internal _roninToken;\n /// @dev Mapping from withdrawal id => withdrawal hash\n mapping(uint256 => bytes32) public withdrawalHash;\n /// @dev Mapping from withdrawal id => locked\n mapping(uint256 => bool) public withdrawalLocked;\n\n /// @custom:deprecated Previously `_bridgeOperatorAddedBlock` (mapping(address => uint256))\n uint256 private ______deprecatedBridgeOperatorAddedBlock;\n /// @custom:deprecated Previously `_bridgeOperators` (uint256[])\n uint256 private ______deprecatedBridgeOperators;\n\n fallback() external payable {\n _fallback();\n }\n\n receive() external payable {\n _fallback();\n }\n\n /**\n * @dev Initializes contract storage.\n */\n function initialize(\n address _roleSetter,\n IWETH _wrappedToken,\n uint256 _roninChainId,\n uint256 _numerator,\n uint256 _highTierVWNumerator,\n uint256 _denominator,\n // _addresses[0]: mainchainTokens\n // _addresses[1]: roninTokens\n // _addresses[2]: withdrawalUnlockers\n address[][3] calldata _addresses,\n // _thresholds[0]: highTierThreshold\n // _thresholds[1]: lockedThreshold\n // _thresholds[2]: unlockFeePercentages\n // _thresholds[3]: dailyWithdrawalLimit\n uint256[][4] calldata _thresholds,\n Token.Standard[] calldata _standards\n ) external payable virtual initializer {\n _setupRole(DEFAULT_ADMIN_ROLE, _roleSetter);\n roninChainId = _roninChainId;\n\n _setWrappedNativeTokenContract(_wrappedToken);\n _updateDomainSeparator();\n _setThreshold(_numerator, _denominator);\n _setHighTierVoteWeightThreshold(_highTierVWNumerator, _denominator);\n _verifyThresholds();\n\n if (_addresses[0].length > 0) {\n // Map mainchain tokens to ronin tokens\n _mapTokens(_addresses[0], _addresses[1], _standards);\n // Sets thresholds based on the mainchain tokens\n _setHighTierThresholds(_addresses[0], _thresholds[0]);\n _setLockedThresholds(_addresses[0], _thresholds[1]);\n _setUnlockFeePercentages(_addresses[0], _thresholds[2]);\n _setDailyWithdrawalLimits(_addresses[0], _thresholds[3]);\n }\n\n // Grant role for withdrawal unlocker\n for (uint256 _i; _i < _addresses[2].length; ) {\n _grantRole(WITHDRAWAL_UNLOCKER_ROLE, _addresses[2][_i]);\n\n unchecked {\n ++_i;\n }\n }\n }\n\n function initializeV2(address bridgeManagerContract) external reinitializer(2) {\n _setContract(ContractType.BRIDGE_MANAGER, bridgeManagerContract);\n }\n\n function initializeV3() external reinitializer(3) {\n depositCount = 982;\n }\n\n /**\n * @dev Receives ether without doing anything. Use this function to topup native token.\n */\n function receiveEther() external payable {}\n\n /**\n * @inheritdoc IMainchainGatewayV2\n */\n function DOMAIN_SEPARATOR() external view virtual returns (bytes32) {\n return _domainSeparator;\n }\n\n /**\n * @inheritdoc IMainchainGatewayV2\n */\n function setWrappedNativeTokenContract(IWETH _wrappedToken) external virtual onlyAdmin {\n _setWrappedNativeTokenContract(_wrappedToken);\n }\n\n /**\n * @inheritdoc IMainchainGatewayV2\n */\n function requestDepositFor(Transfer.Request calldata _request) external payable virtual whenNotPaused {\n _requestDepositFor(_request, msg.sender);\n }\n\n /**\n * @inheritdoc IMainchainGatewayV2\n */\n function submitWithdrawal(\n Transfer.Receipt calldata _receipt,\n Signature[] calldata _signatures\n ) external virtual whenNotPaused returns (bool _locked) {\n return _submitWithdrawal(_receipt, _signatures);\n }\n\n /**\n * @inheritdoc IMainchainGatewayV2\n */\n function unlockWithdrawal(Transfer.Receipt calldata _receipt) external onlyRole(WITHDRAWAL_UNLOCKER_ROLE) {\n bytes32 _receiptHash = _receipt.hash();\n if (withdrawalHash[_receipt.id] != _receipt.hash()) {\n revert ErrInvalidReceipt();\n }\n if (!withdrawalLocked[_receipt.id]) {\n revert ErrQueryForApprovedWithdrawal();\n }\n delete withdrawalLocked[_receipt.id];\n emit WithdrawalUnlocked(_receiptHash, _receipt);\n\n address _token = _receipt.mainchain.tokenAddr;\n if (_receipt.info.erc == Token.Standard.ERC20) {\n Token.Info memory _feeInfo = _receipt.info;\n _feeInfo.quantity = _computeFeePercentage(_receipt.info.quantity, unlockFeePercentages[_token]);\n Token.Info memory _withdrawInfo = _receipt.info;\n _withdrawInfo.quantity = _receipt.info.quantity - _feeInfo.quantity;\n\n _feeInfo.handleAssetTransfer(payable(msg.sender), _token, wrappedNativeToken);\n _withdrawInfo.handleAssetTransfer(payable(_receipt.mainchain.addr), _token, wrappedNativeToken);\n } else {\n _receipt.info.handleAssetTransfer(payable(_receipt.mainchain.addr), _token, wrappedNativeToken);\n }\n\n emit Withdrew(_receiptHash, _receipt);\n }\n\n /**\n * @inheritdoc IMainchainGatewayV2\n */\n function mapTokens(\n address[] calldata _mainchainTokens,\n address[] calldata _roninTokens,\n Token.Standard[] calldata _standards\n ) external virtual onlyAdmin {\n if (_mainchainTokens.length == 0) revert ErrEmptyArray();\n _mapTokens(_mainchainTokens, _roninTokens, _standards);\n }\n\n /**\n * @inheritdoc IMainchainGatewayV2\n */\n function mapTokensAndThresholds(\n address[] calldata _mainchainTokens,\n address[] calldata _roninTokens,\n Token.Standard[] calldata _standards,\n // _thresholds[0]: highTierThreshold\n // _thresholds[1]: lockedThreshold\n // _thresholds[2]: unlockFeePercentages\n // _thresholds[3]: dailyWithdrawalLimit\n uint256[][4] calldata _thresholds\n ) external virtual onlyAdmin {\n if (_mainchainTokens.length == 0) revert ErrEmptyArray();\n _mapTokens(_mainchainTokens, _roninTokens, _standards);\n _setHighTierThresholds(_mainchainTokens, _thresholds[0]);\n _setLockedThresholds(_mainchainTokens, _thresholds[1]);\n _setUnlockFeePercentages(_mainchainTokens, _thresholds[2]);\n _setDailyWithdrawalLimits(_mainchainTokens, _thresholds[3]);\n }\n\n /**\n * @inheritdoc IMainchainGatewayV2\n */\n function getRoninToken(address _mainchainToken) public view returns (MappedToken memory _token) {\n _token = _roninToken[_mainchainToken];\n if (_token.tokenAddr == address(0)) revert ErrUnsupportedToken();\n }\n\n /**\n * @dev Maps mainchain tokens to Ronin network.\n *\n * Requirement:\n * - The arrays have the same length.\n *\n * Emits the `TokenMapped` event.\n *\n */\n function _mapTokens(\n address[] calldata _mainchainTokens,\n address[] calldata _roninTokens,\n Token.Standard[] calldata _standards\n ) internal virtual {\n if (!(_mainchainTokens.length == _roninTokens.length && _mainchainTokens.length == _standards.length))\n revert ErrLengthMismatch(msg.sig);\n\n for (uint256 _i; _i < _mainchainTokens.length; ) {\n _roninToken[_mainchainTokens[_i]].tokenAddr = _roninTokens[_i];\n _roninToken[_mainchainTokens[_i]].erc = _standards[_i];\n\n unchecked {\n ++_i;\n }\n }\n\n emit TokenMapped(_mainchainTokens, _roninTokens, _standards);\n }\n\n /**\n * @dev Submits withdrawal receipt.\n *\n * Requirements:\n * - The receipt kind is withdrawal.\n * - The receipt is to withdraw on this chain.\n * - The receipt is not used to withdraw before.\n * - The withdrawal is not reached the limit threshold.\n * - The signer weight total is larger than or equal to the minimum threshold.\n * - The signature signers are in order.\n *\n * Emits the `Withdrew` once the assets are released.\n *\n */\n function _submitWithdrawal(\n Transfer.Receipt calldata _receipt,\n Signature[] memory _signatures\n ) internal virtual returns (bool _locked) {\n uint256 _id = _receipt.id;\n uint256 _quantity = _receipt.info.quantity;\n address _tokenAddr = _receipt.mainchain.tokenAddr;\n\n _receipt.info.validate();\n if (_receipt.kind != Transfer.Kind.Withdrawal) revert ErrInvalidReceiptKind();\n\n if (_receipt.mainchain.chainId != block.chainid) {\n revert ErrInvalidChainId(msg.sig, _receipt.mainchain.chainId, block.chainid);\n }\n\n MappedToken memory _token = getRoninToken(_receipt.mainchain.tokenAddr);\n\n if (!(_token.erc == _receipt.info.erc && _token.tokenAddr == _receipt.ronin.tokenAddr)) revert ErrInvalidReceipt();\n\n if (withdrawalHash[_id] != 0) revert ErrQueryForProcessedWithdrawal();\n\n if (!(_receipt.info.erc == Token.Standard.ERC721 || !_reachedWithdrawalLimit(_tokenAddr, _quantity))) {\n revert ErrReachedDailyWithdrawalLimit();\n }\n\n bytes32 _receiptHash = _receipt.hash();\n bytes32 _receiptDigest = Transfer.receiptDigest(_domainSeparator, _receiptHash);\n\n uint256 _minimumVoteWeight;\n (_minimumVoteWeight, _locked) = _computeMinVoteWeight(_receipt.info.erc, _tokenAddr, _quantity);\n\n {\n bool _passed;\n address _signer;\n address _lastSigner;\n Signature memory _sig;\n uint256 _weight;\n for (uint256 _i; _i < _signatures.length; ) {\n _sig = _signatures[_i];\n _signer = ecrecover(_receiptDigest, _sig.v, _sig.r, _sig.s);\n if (_lastSigner >= _signer) revert ErrInvalidOrder(msg.sig);\n\n _lastSigner = _signer;\n\n _weight += _getWeight(_signer);\n if (_weight >= _minimumVoteWeight) {\n _passed = true;\n break;\n }\n\n unchecked {\n ++_i;\n }\n }\n\n if (!_passed) revert ErrQueryForInsufficientVoteWeight();\n withdrawalHash[_id] = _receiptHash;\n }\n\n if (_locked) {\n withdrawalLocked[_id] = true;\n emit WithdrawalLocked(_receiptHash, _receipt);\n return _locked;\n }\n\n _recordWithdrawal(_tokenAddr, _quantity);\n _receipt.info.handleAssetTransfer(payable(_receipt.mainchain.addr), _tokenAddr, wrappedNativeToken);\n emit Withdrew(_receiptHash, _receipt);\n }\n\n /**\n * @dev Requests deposit made by `_requester` address.\n *\n * Requirements:\n * - The token info is valid.\n * - The `msg.value` is 0 while depositing ERC20 token.\n * - The `msg.value` is equal to deposit quantity while depositing native token.\n *\n * Emits the `DepositRequested` event.\n *\n */\n function _requestDepositFor(Transfer.Request memory _request, address _requester) internal virtual {\n MappedToken memory _token;\n address _weth = address(wrappedNativeToken);\n\n _request.info.validate();\n if (_request.tokenAddr == address(0)) {\n if (_request.info.quantity != msg.value) revert ErrInvalidRequest();\n\n _token = getRoninToken(_weth);\n if (_token.erc != _request.info.erc) revert ErrInvalidTokenStandard();\n\n _request.tokenAddr = _weth;\n } else {\n if (msg.value != 0) revert ErrInvalidRequest();\n\n _token = getRoninToken(_request.tokenAddr);\n if (_token.erc != _request.info.erc) revert ErrInvalidTokenStandard();\n\n _request.info.transferFrom(_requester, address(this), _request.tokenAddr);\n // Withdraw if token is WETH\n if (_weth == _request.tokenAddr) {\n IWETH(_weth).withdraw(_request.info.quantity);\n }\n }\n\n uint256 _depositId = depositCount++;\n Transfer.Receipt memory _receipt = _request.into_deposit_receipt(\n _requester,\n _depositId,\n _token.tokenAddr,\n roninChainId\n );\n\n emit DepositRequested(_receipt.hash(), _receipt);\n }\n\n /**\n * @dev Returns the minimum vote weight for the token.\n */\n function _computeMinVoteWeight(\n Token.Standard _erc,\n address _token,\n uint256 _quantity\n ) internal virtual returns (uint256 _weight, bool _locked) {\n uint256 _totalWeight = _getTotalWeight();\n _weight = _minimumVoteWeight(_totalWeight);\n if (_erc == Token.Standard.ERC20) {\n if (highTierThreshold[_token] <= _quantity) {\n _weight = _highTierVoteWeight(_totalWeight);\n }\n _locked = _lockedWithdrawalRequest(_token, _quantity);\n }\n }\n\n /**\n * @dev Update domain seperator.\n */\n function _updateDomainSeparator() internal {\n /*\n * _domainSeparator = keccak256(\n * abi.encode(\n * keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n * keccak256(\"MainchainGatewayV2\"),\n * keccak256(\"2\"),\n * block.chainid,\n * address(this)\n * )\n * );\n */\n assembly {\n let ptr := mload(0x40)\n // keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\")\n mstore(ptr, 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f)\n // keccak256(\"MainchainGatewayV2\")\n mstore(add(ptr, 0x20), 0x159f52c1e3a2b6a6aad3950adf713516211484e0516dad685ea662a094b7c43b)\n // keccak256(\"2\")\n mstore(add(ptr, 0x40), 0xad7c5bef027816a800da1736444fb58a807ef4c9603b7848673f7e3a68eb14a5)\n mstore(add(ptr, 0x60), chainid())\n mstore(add(ptr, 0x80), address())\n sstore(_domainSeparator.slot, keccak256(ptr, 0xa0))\n }\n }\n\n /**\n * @dev Sets the WETH contract.\n *\n * Emits the `WrappedNativeTokenContractUpdated` event.\n *\n */\n function _setWrappedNativeTokenContract(IWETH _wrapedToken) internal {\n wrappedNativeToken = _wrapedToken;\n emit WrappedNativeTokenContractUpdated(_wrapedToken);\n }\n\n /**\n * @dev Receives ETH from WETH or creates deposit request.\n */\n function _fallback() internal virtual whenNotPaused {\n if (msg.sender != address(wrappedNativeToken)) {\n Transfer.Request memory _request;\n _request.recipientAddr = msg.sender;\n _request.info.quantity = msg.value;\n _requestDepositFor(_request, _request.recipientAddr);\n }\n }\n\n /**\n * @inheritdoc GatewayV2\n */\n function _getTotalWeight() internal view override returns (uint256) {\n return IBridgeManager(getContract(ContractType.BRIDGE_MANAGER)).getTotalWeights();\n }\n\n /**\n * @dev Returns the weight of an address.\n */\n function _getWeight(address _addr) internal view returns (uint256) {\n return IBridgeManager(getContract(ContractType.BRIDGE_MANAGER)).getBridgeOperatorWeight(_addr);\n }\n}\n" + }, + "contracts/mocks/forwarder/MockForwarderTarget.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../extensions/RONTransferHelper.sol\";\n\nimport \"../../utils/CommonErrors.sol\";\n\ncontract MockForwarderTarget is RONTransferHelper {\n address public owner;\n uint256 public data;\n\n event TargetWithdrawn(address indexed _origin, address indexed _caller, address indexed _recipient);\n\n /**\n * @dev Error thrown intentionally for a specific purpose.\n */\n error ErrIntentionally();\n\n modifier onlyOwner() {\n if (msg.sender != owner) revert ErrUnauthorized(msg.sig, RoleAccess.ADMIN);\n _;\n }\n\n fallback() external payable {\n _fallback();\n }\n\n receive() external payable {\n _fallback();\n }\n\n constructor(address _owner, uint256 _data) payable {\n owner = _owner;\n data = _data;\n }\n\n function foo(uint256 _data) external onlyOwner {\n data = _data;\n }\n\n function fooPayable(uint256 _data) external payable onlyOwner {\n data = _data;\n }\n\n function fooSilentRevert() external view onlyOwner {\n revert();\n }\n\n function fooCustomErrorRevert() external view onlyOwner {\n revert ErrIntentionally();\n }\n\n function fooRevert() external view onlyOwner {\n revert(\"MockForwarderContract: revert intentionally\");\n }\n\n function getBalance() external view returns (uint256) {\n return address(this).balance;\n }\n\n function withdrawAll() external onlyOwner {\n emit TargetWithdrawn(tx.origin, msg.sender, msg.sender);\n _transferRON(payable(msg.sender), address(this).balance);\n }\n\n function _fallback() private pure {\n revert(\"MockForwardTarget: hello from fallback\");\n }\n}\n" + }, + "contracts/mocks/libraries/Sorting.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\nlibrary Sorting {\n struct Node {\n uint key;\n uint value;\n }\n\n struct Node3 {\n uint key;\n uint value;\n uint otherKey;\n }\n\n ///////////////////////////////////////////////////////////////////////////////////////\n // VALUE SORTING //\n ///////////////////////////////////////////////////////////////////////////////////////\n\n function sort(uint[] memory data) internal pure returns (uint[] memory) {\n return _quickSort(data, int(0), int(data.length - 1));\n }\n\n function _quickSort(uint[] memory arr, int left, int right) private pure returns (uint[] memory) {\n int i = left;\n int j = right;\n if (i == j) return arr;\n uint pivot = arr[uint(left + (right - left) / 2)];\n while (i <= j) {\n while (arr[uint(i)] > pivot) i++;\n while (pivot > arr[uint(j)]) j--;\n if (i <= j) {\n (arr[uint(i)], arr[uint(j)]) = (arr[uint(j)], arr[uint(i)]);\n i++;\n j--;\n }\n }\n if (left < j) arr = _quickSort(arr, left, j);\n if (i < right) arr = _quickSort(arr, i, right);\n\n return arr;\n }\n\n ///////////////////////////////////////////////////////////////////////////////////////\n // NODE SORTING //\n ///////////////////////////////////////////////////////////////////////////////////////\n\n function sort(address[] memory _keys, uint256[] memory _values) internal pure returns (address[] memory) {\n require(_values.length == _keys.length, \"Sorting: invalid array length\");\n if (_keys.length == 0) {\n return _keys;\n }\n\n Node[] memory _nodes = new Node[](_keys.length);\n for (uint256 _i; _i < _nodes.length; _i++) {\n _nodes[_i] = Node(uint256(uint160(_keys[_i])), _values[_i]);\n }\n _quickSortNodes(_nodes, int(0), int(_nodes.length - 1));\n\n for (uint256 _i; _i < _nodes.length; _i++) {\n _keys[_i] = address(uint160(_nodes[_i].key)); // Casting?\n }\n\n return _keys;\n }\n\n function sort(uint256[] memory keys, uint256[] memory values) internal pure returns (uint256[] memory) {\n require(values.length == keys.length, \"Sorting: invalid array length\");\n if (keys.length == 0) {\n return keys;\n }\n\n Node[] memory _nodes = new Node[](keys.length);\n for (uint256 _i; _i < _nodes.length; _i++) {\n _nodes[_i] = Node(keys[_i], values[_i]);\n }\n _quickSortNodes(_nodes, int(0), int(_nodes.length - 1));\n\n for (uint256 _i; _i < _nodes.length; _i++) {\n keys[_i] = _nodes[_i].key; // Casting?\n }\n\n return keys;\n }\n\n function sortNodes(Node[] memory nodes) internal pure returns (Node[] memory) {\n return _quickSortNodes(nodes, int(0), int(nodes.length - 1));\n }\n\n function _quickSortNodes(Node[] memory nodes, int left, int right) private pure returns (Node[] memory) {\n int i = left;\n int j = right;\n if (i == j) return nodes;\n Node memory pivot = nodes[uint(left + (right - left) / 2)];\n while (i <= j) {\n while (nodes[uint(i)].value > pivot.value) i++;\n while (pivot.value > nodes[uint(j)].value) j--;\n if (i <= j) {\n (nodes[uint(i)], nodes[uint(j)]) = __swapNodes(nodes[uint(i)], nodes[uint(j)]);\n i++;\n j--;\n }\n }\n if (left < j) nodes = _quickSortNodes(nodes, left, j);\n if (i < right) nodes = _quickSortNodes(nodes, i, right);\n\n return nodes;\n }\n\n function _bubbleSortNodes(Node[] memory nodes) private pure returns (Node[] memory) {\n uint length = nodes.length;\n for (uint i = 0; i < length - 1; i++) {\n for (uint j = i + 1; j < length; j++) {\n if (nodes[j].value > nodes[i].value) {\n (nodes[i], nodes[j]) = __swapNodes(nodes[i], nodes[j]);\n }\n }\n }\n return nodes;\n }\n\n function __swapNodes(Node memory x, Node memory y) private pure returns (Node memory, Node memory) {\n Node memory tmp = x;\n (x, y) = (y, tmp);\n return (x, y);\n }\n\n ///////////////////////////////////////////////////////////////////////////////////////\n // NODE3 SORTING //\n ///////////////////////////////////////////////////////////////////////////////////////\n\n function sortWithExternalKeys(\n address[] memory _keys,\n uint256[] memory _values,\n uint256[] memory _otherKeys\n ) internal pure returns (address[] memory keys_, uint256[] memory otherKeys_) {\n require((_values.length == _keys.length) && (_otherKeys.length == _keys.length), \"Sorting: invalid array length\");\n if (_keys.length == 0) {\n return (_keys, _otherKeys);\n }\n\n Node3[] memory _nodes = new Node3[](_keys.length);\n for (uint256 _i; _i < _nodes.length; _i++) {\n _nodes[_i] = Node3(uint256(uint160(_keys[_i])), _values[_i], _otherKeys[_i]);\n }\n _quickSortNode3s(_nodes, int(0), int(_nodes.length - 1));\n\n for (uint256 _i; _i < _nodes.length; _i++) {\n _keys[_i] = address(uint160(_nodes[_i].key)); // Casting?\n }\n\n return (_keys, _otherKeys);\n }\n\n function sortNode3s(Node3[] memory nodes) internal pure returns (Node3[] memory) {\n return _quickSortNode3s(nodes, int(0), int(nodes.length - 1));\n }\n\n function _quickSortNode3s(Node3[] memory nodes, int left, int right) private pure returns (Node3[] memory) {\n int i = left;\n int j = right;\n if (i == j) return nodes;\n Node3 memory pivot = nodes[uint(left + (right - left) / 2)];\n while (i <= j) {\n while (nodes[uint(i)].value > pivot.value) i++;\n while (pivot.value > nodes[uint(j)].value) j--;\n if (i <= j) {\n (nodes[uint(i)], nodes[uint(j)]) = __swapNode3s(nodes[uint(i)], nodes[uint(j)]);\n i++;\n j--;\n }\n }\n if (left < j) nodes = _quickSortNode3s(nodes, left, j);\n if (i < right) nodes = _quickSortNode3s(nodes, i, right);\n\n return nodes;\n }\n\n function _bubbleSortNode3s(Node3[] memory nodes) private pure returns (Node3[] memory) {\n uint length = nodes.length;\n for (uint i = 0; i < length - 1; i++) {\n for (uint j = i + 1; j < length; j++) {\n if (nodes[j].value > nodes[i].value) {\n (nodes[i], nodes[j]) = __swapNode3s(nodes[i], nodes[j]);\n }\n }\n }\n return nodes;\n }\n\n function __swapNode3s(Node3 memory x, Node3 memory y) private pure returns (Node3 memory, Node3 memory) {\n Node3 memory tmp = x;\n (x, y) = (y, tmp);\n return (x, y);\n }\n}\n" + }, + "contracts/mocks/MockBridge.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol\";\nimport \"../interfaces/IBridge.sol\";\n\ncontract MockBridge is IBridge {\n /// @dev Mapping from validator address => last block that the bridge operator is added\n mapping(address => uint256) public bridgeOperatorAddedBlock;\n /// @dev Bridge operators array\n address[] public bridgeOperators;\n\n function replaceBridgeOperators(address[] calldata _list) external {\n address _addr;\n for (uint256 _i = 0; _i < _list.length; _i++) {\n _addr = _list[_i];\n if (bridgeOperatorAddedBlock[_addr] == 0) {\n bridgeOperators.push(_addr);\n }\n bridgeOperatorAddedBlock[_addr] = block.number;\n }\n\n {\n uint256 _i;\n while (_i < bridgeOperators.length) {\n _addr = bridgeOperators[_i];\n if (bridgeOperatorAddedBlock[_addr] < block.number) {\n delete bridgeOperatorAddedBlock[_addr];\n bridgeOperators[_i] = bridgeOperators[bridgeOperators.length - 1];\n bridgeOperators.pop();\n continue;\n }\n _i++;\n }\n }\n }\n\n function getBridgeOperators() external view override returns (address[] memory) {\n return bridgeOperators;\n }\n}\n" + }, + "contracts/mocks/MockGatewayForTracking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../interfaces/bridge/IBridgeTracking.sol\";\nimport \"../extensions/collections/HasContracts.sol\";\nimport { HasBridgeTrackingDeprecated } from \"../utils/DeprecatedSlots.sol\";\n\ncontract MockGatewayForTracking is HasContracts, HasBridgeTrackingDeprecated {\n constructor(address bridgeTrackingContract) {\n _setContract(ContractType.BRIDGE_TRACKING, bridgeTrackingContract);\n }\n\n function sendBallot(IBridgeTracking.VoteKind kind, uint256 id, address[] memory voters) external {\n IBridgeTracking bridgeTrackingContract = IBridgeTracking(getContract(ContractType.BRIDGE_TRACKING));\n for (uint256 i; i < voters.length; i++) {\n bridgeTrackingContract.recordVote(kind, id, voters[i]);\n }\n }\n\n function sendApprovedVote(IBridgeTracking.VoteKind kind, uint256 id) external {\n IBridgeTracking(getContract(ContractType.BRIDGE_TRACKING)).handleVoteApproved(kind, id);\n }\n}\n" + }, + "contracts/mocks/MockPrecompile.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./libraries/Sorting.sol\";\nimport \"../libraries/Math.sol\";\n\ncontract MockPrecompile {\n function sortValidators(\n address[] memory _validators,\n uint256[] memory _weights\n ) public pure returns (address[] memory) {\n return Sorting.sort(_validators, _weights);\n }\n\n function validatingDoubleSignProof(\n address /*consensusAddr*/,\n bytes calldata /*_header1*/,\n bytes calldata /*_header2*/\n ) public pure returns (bool _validEvidence) {\n return true;\n }\n\n function pickValidatorSet(\n address[] memory _candidates,\n uint256[] memory _weights,\n uint256[] memory _trustedWeights,\n uint256 _maxValidatorNumber,\n uint256 _maxPrioritizedValidatorNumber\n ) public pure returns (address[] memory _result) {\n (_result, _trustedWeights) = Sorting.sortWithExternalKeys(_candidates, _weights, _trustedWeights);\n uint256 _newValidatorCount = Math.min(_maxValidatorNumber, _result.length);\n _arrangeValidatorCandidates(_result, _trustedWeights, _newValidatorCount, _maxPrioritizedValidatorNumber);\n }\n\n /**\n * @dev Arranges the sorted candidates to list of validators, by asserting prioritized and non-prioritized candidates\n *\n * @param _candidates A sorted list of candidates\n */\n function _arrangeValidatorCandidates(\n address[] memory _candidates,\n uint256[] memory _trustedWeights,\n uint _newValidatorCount,\n uint _maxPrioritizedValidatorNumber\n ) internal pure {\n address[] memory _waitingCandidates = new address[](_candidates.length);\n uint _waitingCounter;\n uint _prioritySlotCounter;\n\n for (uint _i = 0; _i < _candidates.length; _i++) {\n if (_trustedWeights[_i] > 0 && _prioritySlotCounter < _maxPrioritizedValidatorNumber) {\n _candidates[_prioritySlotCounter++] = _candidates[_i];\n continue;\n }\n _waitingCandidates[_waitingCounter++] = _candidates[_i];\n }\n\n _waitingCounter = 0;\n for (uint _i = _prioritySlotCounter; _i < _newValidatorCount; _i++) {\n _candidates[_i] = _waitingCandidates[_waitingCounter++];\n }\n\n assembly {\n mstore(_candidates, _newValidatorCount)\n }\n }\n}\n" + }, + "contracts/mocks/MockSlashIndicatorExtended.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./MockPrecompile.sol\";\nimport \"../ronin/slash-indicator/SlashIndicator.sol\";\nimport \"../interfaces/validator/IRoninValidatorSet.sol\";\n\ncontract MockSlashIndicatorExtended is SlashIndicator, MockPrecompile {\n function slashFelony(address _validatorAddr) external {\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execSlash(_validatorAddr, 0, 0, false);\n }\n\n function slashMisdemeanor(address _validatorAddr) external {\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execSlash(_validatorAddr, 0, 0, false);\n }\n\n function _pcValidateEvidence(\n address _consensusAddr,\n bytes calldata _header1,\n bytes calldata _header2\n ) internal pure override returns (bool _validEvidence) {\n return validatingDoubleSignProof(_consensusAddr, _header1, _header2);\n }\n}\n" + }, + "contracts/mocks/MockStaking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../extensions/consumers/GlobalConfigConsumer.sol\";\nimport \"../ronin/staking/RewardCalculation.sol\";\n\ncontract MockStaking is RewardCalculation, GlobalConfigConsumer {\n /// @dev Mapping from user => staking balance\n mapping(address => uint256) internal _stakingAmount;\n /// @dev Mapping from period number => slashed\n mapping(uint256 => bool) internal _periodSlashed;\n\n uint256 internal _stakingTotal;\n\n uint256 public lastUpdatedPeriod;\n uint256 public pendingReward;\n address public poolAddr;\n\n constructor(address _poolAddr) {\n poolAddr = _poolAddr;\n }\n\n function firstEverWrapup() external {\n delete pendingReward;\n lastUpdatedPeriod = block.timestamp / PERIOD_DURATION + 1;\n }\n\n function endPeriod() external {\n address[] memory _addrs = new address[](1);\n uint256[] memory _rewards = new uint256[](1);\n _addrs[0] = poolAddr;\n _rewards[0] = pendingReward;\n this.execRecordRewards(_addrs, _rewards);\n\n pendingReward = 0;\n lastUpdatedPeriod++;\n }\n\n function increasePeriod() external {\n lastUpdatedPeriod++;\n }\n\n function stake(address _user, uint256 _amount) external {\n uint256 _lastStakingAmount = _stakingAmount[_user];\n uint256 _newStakingAmount = _lastStakingAmount + _amount;\n _syncUserReward(poolAddr, _user, _newStakingAmount);\n _stakingAmount[_user] = _newStakingAmount;\n _stakingTotal += _amount;\n }\n\n function unstake(address _user, uint256 _amount) external {\n uint256 _lastStakingAmount = _stakingAmount[_user];\n uint256 _newStakingAmount = _lastStakingAmount - _amount;\n _syncUserReward(poolAddr, _user, _newStakingAmount);\n _stakingAmount[_user] = _newStakingAmount;\n _stakingTotal -= _amount;\n }\n\n function increaseReward(uint256 _amount) external {\n pendingReward += _amount;\n }\n\n function decreaseReward(uint256 _amount) external {\n pendingReward -= _amount;\n }\n\n function execRecordRewards(address[] calldata _addrList, uint256[] calldata _rewards) external {\n _recordRewards(_addrList, _rewards, _currentPeriod());\n }\n\n function getPeriod() public view returns (uint256) {\n return _currentPeriod();\n }\n\n function claimReward(address _user) external returns (uint256 _amount) {\n _amount = _claimReward(poolAddr, _user, getPeriod());\n }\n\n function getStakingAmount(address, address _user) public view override returns (uint256) {\n return _stakingAmount[_user];\n }\n\n function getManyStakingAmounts(\n address[] calldata _poolAddrs,\n address[] calldata _userList\n ) external view override returns (uint256[] memory) {}\n\n function getStakingTotal(address _addr) public view virtual override returns (uint256) {\n return _addr == poolAddr ? _stakingTotal : 0;\n }\n\n function _currentPeriod() internal view override returns (uint256 _period) {\n return lastUpdatedPeriod;\n }\n\n function getManyStakingTotals(address[] calldata _poolAddr) external view override returns (uint256[] memory) {}\n}\n" + }, + "contracts/mocks/MockTransferFallback.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.9;\n\nimport \"../extensions/RONTransferHelper.sol\";\n\ncontract MockPaymentFallback {\n event SafeReceived(address indexed sender, uint256 value);\n\n /// @dev Fallback function accepts ether transactions.\n receive() external payable {\n emit SafeReceived(msg.sender, msg.value);\n }\n}\n\ncontract MockPaymentFallbackExpensive {\n uint[] public array;\n event SafeReceived(address indexed sender, uint256 value);\n\n constructor() {\n array.push(0);\n }\n\n /// @dev Fallback function accepts ether transactions and set non-zero value to a zero value slot.\n receive() external payable {\n array.push(block.number);\n emit SafeReceived(msg.sender, msg.value);\n }\n}\n\ncontract MockTransfer is RONTransferHelper {\n uint256 public track;\n\n constructor() payable {}\n\n function fooTransfer(address payable _recipient, uint256 _amount, uint256 _gas) external {\n if (_unsafeSendRONLimitGas(_recipient, _amount, _gas)) {\n track++;\n }\n }\n}\n" + }, + "contracts/mocks/precompile-usages/MockPCUPickValidatorSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../precompile-usages/PCUPickValidatorSet.sol\";\n\ncontract MockPCUPickValidatorSet is PCUPickValidatorSet {\n address internal _precompileSortValidatorAddress;\n\n constructor(address _precompile) {\n setPrecompileSortValidatorAddress(_precompile);\n }\n\n function setPrecompileSortValidatorAddress(address _addr) public {\n _precompileSortValidatorAddress = _addr;\n }\n\n function precompilePickValidatorSetAddress() public view override returns (address) {\n return _precompileSortValidatorAddress;\n }\n\n function callPrecompile(\n address[] memory _candidates,\n uint256[] memory _weights,\n uint256[] memory _trustedWeights,\n uint256 _maxValidatorNumber,\n uint256 _maxPrioritizedValidatorNumber\n ) public view returns (address[] memory _result) {\n (_result, ) = _pcPickValidatorSet(\n _candidates,\n _weights,\n _trustedWeights,\n _maxValidatorNumber,\n _maxPrioritizedValidatorNumber\n );\n }\n}\n" + }, + "contracts/mocks/precompile-usages/MockPCUSortValidators.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../precompile-usages/PCUSortValidators.sol\";\n\ncontract MockPCUSortValidators is PCUSortValidators {\n address internal _precompileSortValidatorAddress;\n\n constructor(address _precompile) {\n setPrecompileSortValidatorAddress(_precompile);\n }\n\n function setPrecompileSortValidatorAddress(address _addr) public {\n _precompileSortValidatorAddress = _addr;\n }\n\n function precompileSortValidatorsAddress() public view override returns (address) {\n return _precompileSortValidatorAddress;\n }\n\n function callPrecompile(\n address[] calldata _validators,\n uint256[] calldata _weights\n ) public view returns (address[] memory _result) {\n return _pcSortCandidates(_validators, _weights);\n }\n}\n" + }, + "contracts/mocks/precompile-usages/MockPCUValidateDoubleSign.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../precompile-usages/PCUValidateDoubleSign.sol\";\n\ncontract MockPCUValidateDoubleSign is PCUValidateDoubleSign {\n address internal _precompileValidateDoubleSignAddress;\n\n constructor(address _precompile) {\n setPrecompileValidateDoubleSignAddress(_precompile);\n }\n\n function setPrecompileValidateDoubleSignAddress(address _addr) public {\n _precompileValidateDoubleSignAddress = _addr;\n }\n\n function precompileValidateDoubleSignAddress() public view override returns (address) {\n return _precompileValidateDoubleSignAddress;\n }\n\n function callPrecompile(\n address _consensusAddr,\n bytes calldata _header1,\n bytes calldata _header2\n ) public view returns (bool) {\n return _pcValidateEvidence(_consensusAddr, _header1, _header2);\n }\n}\n" + }, + "contracts/mocks/ronin/MockBridgeManager.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { RoleAccess, ContractType, AddressArrayUtils, IBridgeManager, BridgeManager } from \"../../extensions/bridge-operator-governance/BridgeManager.sol\";\n\ncontract MockBridgeManager is BridgeManager {\n constructor(\n address[] memory bridgeOperators,\n address[] memory governors,\n uint96[] memory voteWeights\n ) payable BridgeManager(0, 0, 0, address(0), _getEmptyAddressArray(), bridgeOperators, governors, voteWeights) {}\n\n function _requireSelfCall() internal view override {}\n\n function _getEmptyAddressArray() internal pure returns (address[] memory arr) {}\n}\n" + }, + "contracts/mocks/ronin/MockBridgeReward.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { IBridgeReward, BridgeReward } from \"../../ronin/gateway/BridgeReward.sol\";\n\ncontract MockBridgeReward is BridgeReward {\n function calcRewardAndCheckSlashedStatus(\n bool isValidTrackingResponse,\n uint256 numBridgeOperators,\n uint256 rewardPerPeriod,\n uint256 ballot,\n uint256 totalBallot,\n uint256 period,\n uint256 slashUntilPeriod\n ) external pure returns (uint256 reward, bool isSlashed) {\n return\n _calcRewardAndCheckSlashedStatus(\n isValidTrackingResponse,\n numBridgeOperators,\n rewardPerPeriod,\n ballot,\n totalBallot,\n period,\n slashUntilPeriod\n );\n }\n\n function calcReward(\n bool isValidTrackingResponse,\n uint256 numBridgeOperators,\n uint256 rewardPerPeriod,\n uint256 ballot,\n uint256 totalBallot\n ) external pure returns (uint256 reward) {\n reward = _calcReward(isValidTrackingResponse, numBridgeOperators, rewardPerPeriod, ballot, totalBallot);\n }\n\n function isValidBridgeTrackingResponse(\n uint256 totalBallot,\n uint256 totalVote,\n uint256[] memory ballots\n ) external pure returns (bool valid) {\n return _isValidBridgeTrackingResponse(totalBallot, totalVote, ballots);\n }\n\n function shouldShareEqually(\n uint256 totalBallot,\n uint256 totalVote,\n uint256[] memory ballots\n ) external returns (bool shareEqually) {\n return _shouldShareEqually(totalBallot, totalVote, ballots);\n }\n\n function shouldSlashedThisPeriod(uint256 period, uint256 slashUntilDuration) external pure returns (bool) {\n return _shouldSlashedThisPeriod(period, slashUntilDuration);\n }\n}\n" + }, + "contracts/mocks/ronin/MockBridgeSlash.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { IBridgeSlash, BridgeSlash } from \"../../ronin/gateway/BridgeSlash.sol\";\n\ncontract MockBridgeSlash is BridgeSlash {\n function calcSlashUntilPeriod(\n Tier tier,\n uint256 period,\n uint256 slashUntilPeriod\n ) external pure returns (uint256 newSlashUntilPeriod) {\n newSlashUntilPeriod = _calcSlashUntilPeriod(tier, period, slashUntilPeriod, _getPenaltyDurations());\n }\n\n function isSlashDurationMetRemovalThreshold(uint256 slashUntilPeriod, uint256 period) external pure returns (bool) {\n return _isSlashDurationMetRemovalThreshold(slashUntilPeriod, period);\n }\n}\n" + }, + "contracts/mocks/ronin/MockBridgeTracking.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n" + }, + "contracts/mocks/ronin/MockRoninBridgeManager.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { RoninBridgeManager } from \"../../ronin/gateway/RoninBridgeManager.sol\";\nimport { GlobalProposal } from \"../../extensions/sequential-governance/governance-proposal/GovernanceProposal.sol\";\n\ncontract MockRoninBridgeManager is RoninBridgeManager {\n constructor(\n uint256 num,\n uint256 denom,\n uint256 roninChainId,\n uint256 expiryDuration,\n address bridgeContract,\n address[] memory callbackRegisters,\n address[] memory bridgeOperators,\n address[] memory governors,\n uint96[] memory voteWeights,\n GlobalProposal.TargetOption[] memory targetOptions,\n address[] memory targets\n )\n RoninBridgeManager(\n num,\n denom,\n roninChainId,\n expiryDuration,\n bridgeContract,\n callbackRegisters,\n bridgeOperators,\n governors,\n voteWeights,\n targetOptions,\n targets\n )\n {}\n}\n" + }, + "contracts/mocks/ronin/MockRoninGatewayV2Extended.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../../ronin/gateway/RoninGatewayV2.sol\";\n\ncontract MockRoninGatewayV2Extended is RoninGatewayV2 {\n /*\n * @dev Returns the vote weight for a deposit based on its corressponding hash.\n */\n function getDepositVoteWeight(\n uint256 _chainId,\n uint256 _depositId,\n bytes32 _hash\n ) external view returns (uint256 totalWeight) {\n totalWeight = _getVoteWeight(depositVote[_chainId][_depositId], _hash);\n }\n\n /**\n * @dev Returns the vote weight for a mainchain withdrew acknowledgement based on its corressponding hash.\n */\n function getMainchainWithdrewVoteWeight(\n uint256 _withdrawalId,\n bytes32 _hash\n ) external view returns (uint256 totalWeight) {\n totalWeight = _getVoteWeight(mainchainWithdrewVote[_withdrawalId], _hash);\n }\n\n /**\n * @dev Returns the vote weight for a withdraw stats based on its corressponding hash.\n */\n function getWithdrawalStatVoteWeight(\n uint256 _withdrawalId,\n bytes32 _hash\n ) external view returns (uint256 totalWeight) {\n totalWeight = _getVoteWeight(withdrawalStatVote[_withdrawalId], _hash);\n }\n}\n" + }, + "contracts/mocks/ronin/MockValidatorContract.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ncontract MockValidatorContract {\n uint256 private _currentPeriod;\n\n function currentPeriod() external view returns (uint256) {\n return _currentPeriod;\n }\n\n function setCurrentPeriod(uint256 period) external {\n _currentPeriod = period;\n }\n}\n" + }, + "contracts/mocks/sorting/MockSorting.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol\";\nimport \"../libraries/Sorting.sol\";\n\ncontract MockSorting {\n uint256[] public data;\n\n function addData(uint256[] memory _data) public {\n for (uint256 i; i < _data.length; i++) {\n data.push(_data[i]);\n }\n }\n\n function sort(uint256[] memory _data) public pure returns (uint256[] memory) {\n return Sorting.sort(_data);\n }\n\n function sortOnStorage() public returns (uint256[] memory, uint256) {\n uint256[] memory _tmpData = data;\n data = Sorting.sort(_tmpData);\n\n return (data, data.length);\n }\n\n function sortAddressesAndValues(\n address[] calldata _addrs,\n uint256[] calldata _values\n ) public pure returns (address[] memory) {\n return Sorting.sort(_addrs, _values);\n }\n}\n" + }, + "contracts/mocks/types/MockTUint256Slot.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { TUint256Slot } from \"../../types/Types.sol\";\n\ncontract MockTUint256Slot {\n TUint256Slot private constant CUSTOM_SLOT_UINT256 =\n TUint256Slot.wrap(keccak256(abi.encode(type(MockTUint256Slot).name)));\n\n uint256 private _primitiveUint256;\n\n function subPrimitive(uint256 val) external view returns (uint256 res) {\n res = _primitiveUint256 - val;\n }\n\n function subCustomSlot(uint256 val) external view returns (uint256 res) {\n res = CUSTOM_SLOT_UINT256.sub(val);\n }\n\n function divCustomSlot(uint256 val) external view returns (uint256 res) {\n res = CUSTOM_SLOT_UINT256.div(val);\n }\n\n function divPrimitive(uint256 val) external view returns (uint256 res) {\n res = _primitiveUint256 / val;\n }\n\n function mulCustomSlot(uint256 val) external view returns (uint256 res) {\n res = CUSTOM_SLOT_UINT256.mul(val);\n }\n\n function mulPrimitive(uint256 val) external view returns (uint256 res) {\n res = _primitiveUint256 * val;\n }\n\n function addPrimitive(uint256 val) external view returns (uint256 res) {\n res = _primitiveUint256 + val;\n }\n\n function addCustomSlot(uint256 val) external view returns (uint256 res) {\n res = CUSTOM_SLOT_UINT256.add(val);\n }\n\n function preIncrementPrimitive() external returns (uint256 res) {\n res = ++_primitiveUint256;\n }\n\n function preIncrementCustomSlot() external returns (uint256 res) {\n res = CUSTOM_SLOT_UINT256.preIncrement();\n }\n\n function postIncrementPrimitive() external returns (uint256 res) {\n res = _primitiveUint256++;\n }\n\n function postIncrementCustomSlot() external returns (uint256 res) {\n res = CUSTOM_SLOT_UINT256.postIncrement();\n }\n\n function preDecrementPrimitive() external returns (uint256 res) {\n res = --_primitiveUint256;\n }\n\n function preDecrementCustomSlot() external returns (uint256 res) {\n res = CUSTOM_SLOT_UINT256.preDecrement();\n }\n\n function postDecrementPrimitive() external returns (uint256 res) {\n res = _primitiveUint256--;\n }\n\n function postDecrementCustomSlot() external returns (uint256 res) {\n res = CUSTOM_SLOT_UINT256.postDecrement();\n }\n\n function setCustomSlot(uint256 val) external returns (uint256 stored) {\n CUSTOM_SLOT_UINT256.store(val);\n stored = CUSTOM_SLOT_UINT256.load();\n }\n\n function setPrimitive(uint256 val) external returns (uint256 stored) {\n _primitiveUint256 = val;\n stored = _primitiveUint256;\n }\n\n function subAssignCustomSlot(uint256 val) external returns (uint256 stored) {\n stored = CUSTOM_SLOT_UINT256.subAssign(val);\n }\n\n function subAssignPrimitive(uint256 val) external returns (uint256 stored) {\n stored = _primitiveUint256 -= val;\n }\n\n function addAssignCustomSlot(uint256 val) external returns (uint256 stored) {\n stored = CUSTOM_SLOT_UINT256.addAssign(val);\n }\n\n function addAssignPrimitive(uint256 val) external returns (uint256 stored) {\n stored = _primitiveUint256 += val;\n }\n\n function getPrimitive() external view returns (uint256) {\n return _primitiveUint256;\n }\n\n function getCustomSlot() external view returns (uint256) {\n return CUSTOM_SLOT_UINT256.load();\n }\n}\n" + }, + "contracts/mocks/utils/version-control/MockActor.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { ErrorHandler } from \"../../../libraries/ErrorHandler.sol\";\n\ncontract MockActor {\n using ErrorHandler for bool;\n\n address private _target;\n\n constructor(address target) {\n _target = target;\n }\n\n fallback() external payable {\n (bool success, bytes memory returnOrRevertData) = _target.call{ value: msg.value }(msg.data);\n success.handleRevert(msg.sig, returnOrRevertData);\n assembly {\n return(add(returnOrRevertData, 0x20), mload(returnOrRevertData))\n }\n }\n}\n" + }, + "contracts/mocks/utils/version-control/MockConditionalImplementControl.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { ConditionalImplementControl } from \"../../../extensions/version-control/ConditionalImplementControl.sol\";\n\ncontract MockConditionalImplementControl is ConditionalImplementControl {\n uint256 public immutable UPGRADED_AT_BLOCK;\n\n constructor(\n address proxyStorage,\n address prevImpl,\n address newImpl,\n uint256 upgradedAtBlock\n ) ConditionalImplementControl(proxyStorage, prevImpl, newImpl) {\n UPGRADED_AT_BLOCK = upgradedAtBlock;\n }\n\n function _isConditionMet() internal view override returns (bool) {\n return block.number >= UPGRADED_AT_BLOCK;\n }\n}\n" + }, + "contracts/mocks/utils/version-control/MockLogic.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface ILogic {\n event Received(uint256 version);\n\n function name() external pure returns (string memory);\n\n function magicNumber() external view returns (uint256);\n\n function get() external view returns (uint256);\n\n function set() external;\n\n function setAndGet() external returns (uint256);\n}\n\nabstract contract MockLogicBase is ILogic {\n uint256 internal _value;\n\n function magicNumber() public view virtual override returns (uint256) {}\n\n receive() external payable virtual {\n emit Received(0);\n }\n\n function get() public view returns (uint256) {\n return _value;\n }\n\n function set() public override {\n _value = magicNumber();\n }\n\n function setAndGet() public returns (uint256) {\n set();\n return get();\n }\n}\n\ncontract MockLogicV1 is MockLogicBase {\n receive() external payable override {\n emit Received(1);\n }\n\n function name() external pure returns (string memory) {\n return \"LogicV1\";\n }\n\n function magicNumber() public pure override returns (uint256) {\n return 1;\n }\n}\n\ncontract MockLogicV2 is MockLogicBase {\n receive() external payable override {\n emit Received(2);\n }\n\n function name() external pure returns (string memory) {\n return \"LogicV2\";\n }\n\n function magicNumber() public pure override returns (uint256) {\n return 2;\n }\n}\n" + }, + "contracts/mocks/utils/version-control/MockLogicValidatorSet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface ILogicValidatorSet {\n event Received(string version);\n\n function wrapUpEpoch() external payable;\n\n function version() external view returns (string memory);\n\n function currentPeriod() external view returns (uint256);\n}\n\nabstract contract MockLogicValidatorSetCore is ILogicValidatorSet {\n uint256 private _lastUpdatedPeriod;\n\n receive() external payable virtual {\n emit Received(\"0\");\n }\n\n function wrapUpEpoch() external payable {\n if (block.number % 100 == 0) {\n _lastUpdatedPeriod += 1;\n }\n }\n\n function currentPeriod() external view returns (uint256) {\n return _lastUpdatedPeriod;\n }\n}\n\ncontract MockLogicValidatorSetV1 is MockLogicValidatorSetCore {\n receive() external payable override {\n emit Received(version());\n }\n\n function version() public pure returns (string memory) {\n return \"V1\";\n }\n}\n\ncontract MockLogicValidatorSetV2 is MockLogicValidatorSetCore {\n receive() external payable override {\n emit Received(version());\n }\n\n function version() public pure returns (string memory) {\n return \"V2\";\n }\n}\n" + }, + "contracts/mocks/validator/MockRoninValidatorSetExtended.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./MockRoninValidatorSetOverridePrecompile.sol\";\nimport \"../../libraries/EnumFlags.sol\";\n\ncontract MockRoninValidatorSetExtended is MockRoninValidatorSetOverridePrecompile {\n bool private _initialized;\n uint256[] internal _epochs;\n\n constructor() {}\n\n function initEpoch() public {\n if (!_initialized) {\n _epochs.push(0);\n _initialized = true;\n }\n }\n\n function endEpoch() external {\n _epochs.push(block.number);\n }\n\n function epochOf(uint256 _block) public view override returns (uint256 _epoch) {\n for (uint256 _i = _epochs.length; _i > 0; _i--) {\n if (_block > _epochs[_i - 1]) {\n return _i;\n }\n }\n }\n\n function epochEndingAt(uint256 _block) public view override(ITimingInfo, TimingStorage) returns (bool) {\n for (uint _i = 0; _i < _epochs.length; _i++) {\n if (_block == _epochs[_i]) {\n return true;\n }\n }\n return false;\n }\n\n function getJailUntils(address[] calldata _addrs) public view returns (uint256[] memory jailUntils_) {\n jailUntils_ = new uint256[](_addrs.length);\n for (uint _i = 0; _i < _addrs.length; _i++) {\n jailUntils_[_i] = _blockProducerJailedBlock[_addrs[_i]];\n }\n }\n\n function addValidators(address[] calldata _addrs) public {\n for (uint _i = 0; _i < _addrs.length; _i++) {\n _validators[_i] = _addrs[_i];\n _validatorMap[_addrs[_i]] = EnumFlags.ValidatorFlag.Both;\n }\n }\n}\n" + }, + "contracts/mocks/validator/MockRoninValidatorSetOverridePrecompile.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../MockPrecompile.sol\";\nimport \"../../ronin/validator/RoninValidatorSet.sol\";\n\ncontract MockRoninValidatorSetOverridePrecompile is RoninValidatorSet, MockPrecompile {\n constructor() {}\n\n function arrangeValidatorCandidates(\n address[] memory _candidates,\n uint256[] memory _trustedWeights,\n uint _newValidatorCount,\n uint _maxPrioritizedValidatorNumber\n ) external pure returns (address[] memory) {\n _arrangeValidatorCandidates(_candidates, _trustedWeights, _newValidatorCount, _maxPrioritizedValidatorNumber);\n return _candidates;\n }\n\n function _pcSortCandidates(\n address[] memory _candidates,\n uint256[] memory _weights\n ) internal pure override returns (address[] memory _result) {\n return sortValidators(_candidates, _weights);\n }\n\n function _pcPickValidatorSet(\n address[] memory _candidates,\n uint256[] memory _weights,\n uint256[] memory _trustedWeights,\n uint256 _maxValidatorNumber,\n uint256 _maxPrioritizedValidatorNumber\n ) internal pure override returns (address[] memory _result, uint256 _newValidatorCount) {\n _result = pickValidatorSet(\n _candidates,\n _weights,\n _trustedWeights,\n _maxValidatorNumber,\n _maxPrioritizedValidatorNumber\n );\n\n _newValidatorCount = _result.length;\n }\n}\n" + }, + "contracts/mocks/validator/MockValidatorSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../interfaces/validator/IRoninValidatorSet.sol\";\nimport \"../../ronin/validator/CandidateManager.sol\";\nimport { HasStakingVestingDeprecated, HasSlashIndicatorDeprecated } from \"../../utils/DeprecatedSlots.sol\";\n\ncontract MockValidatorSet is\n IRoninValidatorSet,\n CandidateManager,\n HasStakingVestingDeprecated,\n HasSlashIndicatorDeprecated\n{\n uint256 internal _lastUpdatedPeriod;\n uint256 internal _numberOfBlocksInEpoch;\n /// @dev Mapping from period number => slashed\n mapping(uint256 => bool) internal _periodSlashed;\n\n constructor(\n address __stakingContract,\n address _slashIndicatorContract,\n address _stakingVestingContract,\n uint256 __maxValidatorCandidate,\n uint256 __numberOfBlocksInEpoch,\n uint256 __minEffectiveDaysOnwards\n ) {\n _setContract(ContractType.STAKING, __stakingContract);\n _setContract(ContractType.SLASH_INDICATOR, _slashIndicatorContract);\n _setContract(ContractType.STAKING_VESTING, _stakingVestingContract);\n _setMaxValidatorCandidate(__maxValidatorCandidate);\n _numberOfBlocksInEpoch = __numberOfBlocksInEpoch;\n _minEffectiveDaysOnwards = __minEffectiveDaysOnwards;\n }\n\n function submitBlockReward() external payable override {}\n\n function wrapUpEpoch() external payable override {\n _syncCandidateSet(_lastUpdatedPeriod + 1);\n _lastUpdatedPeriod = currentPeriod();\n }\n\n function getLastUpdatedBlock() external view override returns (uint256) {}\n\n function checkManyJailed(address[] calldata) external view override returns (bool[] memory) {}\n\n function checkMiningRewardDeprecatedAtPeriod(address, uint256 _period) external view override returns (bool) {}\n\n function checkMiningRewardDeprecated(address) external view override returns (bool) {}\n\n function checkBridgeRewardDeprecatedAtPeriod(\n address _consensusAddr,\n uint256 _period\n ) external view returns (bool _result) {}\n\n function epochOf(uint256 _block) external view override returns (uint256) {}\n\n function getValidators() external view override returns (address[] memory) {}\n\n function epochEndingAt(uint256 _block) external view override returns (bool) {}\n\n function execSlash(\n address _validatorAddr,\n uint256 _newJailedUntil,\n uint256 _slashAmount,\n bool _cannotBailout\n ) external override {}\n\n function execBailOut(address, uint256) external override {}\n\n function setMaxValidatorNumber(uint256 _maxValidatorNumber) external override {}\n\n function setMaxPrioritizedValidatorNumber(uint256 _maxPrioritizedValidatorNumber) external override {}\n\n function maxValidatorNumber() external view override returns (uint256 _maximumValidatorNumber) {}\n\n function maxPrioritizedValidatorNumber()\n external\n view\n override\n returns (uint256 _maximumPrioritizedValidatorNumber)\n {}\n\n function numberOfBlocksInEpoch() public view override returns (uint256) {\n return _numberOfBlocksInEpoch;\n }\n\n function getBlockProducers() external view override returns (address[] memory) {}\n\n function isBlockProducer(address) external pure override returns (bool) {\n return true;\n }\n\n function totalBlockProducers() external view override returns (uint256) {}\n\n function tryGetPeriodOfEpoch(uint256) external view returns (bool, uint256) {}\n\n function isPeriodEnding() public view virtual returns (bool) {\n return currentPeriod() > _lastUpdatedPeriod;\n }\n\n function currentPeriod() public view override returns (uint256) {\n return block.timestamp / 86400;\n }\n\n function checkJailed(address) external view override returns (bool) {}\n\n function getJailedTimeLeft(address) external view override returns (bool, uint256, uint256) {}\n\n function currentPeriodStartAtBlock() external view override returns (uint256) {}\n\n function checkJailedAtBlock(address _addr, uint256 _blockNum) external view override returns (bool) {}\n\n function getJailedTimeLeftAtBlock(\n address _addr,\n uint256 _blockNum\n ) external view override returns (bool isJailed_, uint256 blockLeft_, uint256 epochLeft_) {}\n\n function totalDeprecatedReward() external view override returns (uint256) {}\n\n function execReleaseLockedFundForEmergencyExitRequest(\n address _consensusAddr,\n address payable _recipient\n ) external override {}\n\n function emergencyExitLockedAmount() external override returns (uint256) {}\n\n function emergencyExpiryDuration() external override returns (uint256) {}\n\n function setEmergencyExitLockedAmount(uint256 _emergencyExitLockedAmount) external override {}\n\n function setEmergencyExpiryDuration(uint256 _emergencyExpiryDuration) external override {}\n\n function getEmergencyExitInfo(address _consensusAddr) external view override returns (EmergencyExitInfo memory) {}\n\n function execEmergencyExit(address, uint256) external {}\n\n function isOperatingBridge(address) external view returns (bool) {}\n\n function _emergencyExitLockedFundReleased(address _consensusAddr) internal virtual override returns (bool) {}\n\n function _isTrustedOrg(address _consensusAddr) internal virtual override returns (bool) {}\n}\n" + }, + "contracts/multi-chains/RoninTrustedOrganization.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport \"../libraries/AddressArrayUtils.sol\";\nimport \"../interfaces/IRoninTrustedOrganization.sol\";\nimport \"../extensions/collections/HasProxyAdmin.sol\";\n\ncontract RoninTrustedOrganization is IRoninTrustedOrganization, HasProxyAdmin, Initializable {\n uint256 internal _num;\n uint256 internal _denom;\n uint256 internal _totalWeight;\n uint256 internal _nonce;\n\n /// @dev Mapping from consensus address => weight\n mapping(address => uint256) internal _consensusWeight;\n /// @dev Mapping from governor address => weight\n mapping(address => uint256) internal _governorWeight;\n /// @dev Mapping from bridge voter address => weight\n mapping(address => uint256) internal _bridgeVoterWeight;\n\n /// @dev Mapping from consensus address => added block\n mapping(address => uint256) internal _addedBlock;\n\n /// @dev Consensus array\n address[] internal _consensusList;\n /// @dev Governors array\n address[] internal _governorList;\n /// @dev Bridge voters array\n address[] internal _bridgeVoterList;\n\n /**\n * @dev Initializes the contract storage.\n */\n function initialize(\n TrustedOrganization[] calldata _trustedOrgs,\n uint256 __num,\n uint256 __denom\n ) external initializer {\n if (_trustedOrgs.length > 0) {\n _addTrustedOrganizations(_trustedOrgs);\n }\n _setThreshold(__num, __denom);\n }\n\n /**\n * @inheritdoc IQuorum\n */\n function getThreshold() external view virtual returns (uint256 num_, uint256 denom_) {\n return (_num, _denom);\n }\n\n /**\n * @inheritdoc IQuorum\n */\n function checkThreshold(uint256 _voteWeight) external view virtual returns (bool) {\n return _voteWeight * _denom >= _num * _totalWeight;\n }\n\n /**\n * @inheritdoc IQuorum\n */\n function minimumVoteWeight() external view virtual returns (uint256) {\n return (_num * _totalWeight + _denom - 1) / _denom;\n }\n\n /**\n * @inheritdoc IQuorum\n */\n function setThreshold(\n uint256 _numerator,\n uint256 _denominator\n ) external override onlyAdmin returns (uint256, uint256) {\n return _setThreshold(_numerator, _denominator);\n }\n\n /**\n * @inheritdoc IRoninTrustedOrganization\n */\n function addTrustedOrganizations(TrustedOrganization[] calldata _list) external override onlyAdmin {\n _addTrustedOrganizations(_list);\n }\n\n /**\n * @inheritdoc IRoninTrustedOrganization\n */\n function updateTrustedOrganizations(TrustedOrganization[] calldata _list) external override onlyAdmin {\n if (_list.length == 0) revert ErrEmptyArray();\n for (uint256 _i; _i < _list.length; ) {\n _updateTrustedOrganization(_list[_i]);\n\n unchecked {\n ++_i;\n }\n }\n emit TrustedOrganizationsUpdated(_list);\n }\n\n /**\n * @inheritdoc IRoninTrustedOrganization\n */\n function removeTrustedOrganizations(address[] calldata _list) external override onlyAdmin {\n if (_list.length == 0) revert ErrEmptyArray();\n\n for (uint _i = 0; _i < _list.length; ) {\n _removeTrustedOrganization(_list[_i]);\n\n unchecked {\n ++_i;\n }\n }\n emit TrustedOrganizationsRemoved(_list);\n }\n\n /**\n * @inheritdoc IRoninTrustedOrganization\n */\n function totalWeights() external view virtual returns (uint256) {\n return _totalWeight;\n }\n\n /**\n * @inheritdoc IRoninTrustedOrganization\n */\n function getConsensusWeight(address _consensusAddr) external view returns (uint256) {\n return _consensusWeight[_consensusAddr];\n }\n\n /**\n * @inheritdoc IRoninTrustedOrganization\n */\n function getGovernorWeight(address _governor) external view returns (uint256) {\n return _governorWeight[_governor];\n }\n\n /**\n * @inheritdoc IRoninTrustedOrganization\n */\n function getBridgeVoterWeight(address _addr) external view returns (uint256) {\n return _bridgeVoterWeight[_addr];\n }\n\n /**\n * @inheritdoc IRoninTrustedOrganization\n */\n function getConsensusWeights(address[] calldata _list) external view returns (uint256[] memory _res) {\n _res = new uint256[](_list.length);\n for (uint _i = 0; _i < _res.length; ) {\n _res[_i] = _consensusWeight[_list[_i]];\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IRoninTrustedOrganization\n */\n function getGovernorWeights(address[] calldata _list) external view returns (uint256[] memory _res) {\n _res = new uint256[](_list.length);\n for (uint _i = 0; _i < _res.length; ) {\n _res[_i] = _governorWeight[_list[_i]];\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IRoninTrustedOrganization\n */\n function getBridgeVoterWeights(address[] calldata _list) external view returns (uint256[] memory _res) {\n _res = new uint256[](_list.length);\n for (uint _i = 0; _i < _res.length; ) {\n _res[_i] = _bridgeVoterWeight[_list[_i]];\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IRoninTrustedOrganization\n */\n function sumConsensusWeights(address[] calldata _list) external view returns (uint256 _res) {\n for (uint _i = 0; _i < _list.length; ) {\n _res += _consensusWeight[_list[_i]];\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IRoninTrustedOrganization\n */\n function sumGovernorWeights(address[] calldata _list) external view returns (uint256 _res) {\n for (uint _i = 0; _i < _list.length; ) {\n _res += _governorWeight[_list[_i]];\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IRoninTrustedOrganization\n */\n function sumBridgeVoterWeights(address[] calldata _list) external view returns (uint256 _res) {\n for (uint _i = 0; _i < _list.length; ) {\n _res += _bridgeVoterWeight[_list[_i]];\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IRoninTrustedOrganization\n */\n function countTrustedOrganizations() external view override returns (uint256) {\n return _consensusList.length;\n }\n\n /**\n * @inheritdoc IRoninTrustedOrganization\n */\n function getAllTrustedOrganizations() external view override returns (TrustedOrganization[] memory _list) {\n _list = new TrustedOrganization[](_consensusList.length);\n address _addr;\n for (uint256 _i; _i < _list.length; ) {\n _addr = _consensusList[_i];\n _list[_i].consensusAddr = _addr;\n _list[_i].governor = _governorList[_i];\n _list[_i].bridgeVoter = _bridgeVoterList[_i];\n _list[_i].weight = _consensusWeight[_addr];\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IRoninTrustedOrganization\n */\n function getTrustedOrganization(address _consensusAddr) external view returns (TrustedOrganization memory) {\n for (uint _i = 0; _i < _consensusList.length; ) {\n if (_consensusList[_i] == _consensusAddr) {\n return getTrustedOrganizationAt(_i);\n }\n\n unchecked {\n ++_i;\n }\n }\n revert ErrQueryForNonExistentConsensusAddress();\n }\n\n /**\n * @inheritdoc IRoninTrustedOrganization\n */\n function getTrustedOrganizationAt(uint256 _idx) public view override returns (TrustedOrganization memory) {\n address _addr = _consensusList[_idx];\n return\n TrustedOrganization(\n _addr,\n _governorList[_idx],\n _bridgeVoterList[_idx],\n _consensusWeight[_addr],\n _addedBlock[_addr]\n );\n }\n\n /**\n * @dev Adds a list of trusted organizations.\n */\n function _addTrustedOrganizations(TrustedOrganization[] calldata _list) internal virtual {\n for (uint256 _i; _i < _list.length; ) {\n _addTrustedOrganization(_list[_i]);\n\n unchecked {\n ++_i;\n }\n }\n emit TrustedOrganizationsAdded(_list);\n }\n\n /**\n * @dev Adds a trusted organization.\n *\n * Requirements:\n * - The weight is larger than 0.\n * - The consensus address is not added.\n * - The govenor address is not added.\n * - The bridge voter address is not added.\n *\n */\n function _addTrustedOrganization(TrustedOrganization memory _v) internal virtual {\n if (_v.addedBlock != 0) revert ErrInvalidRequest();\n _sanityCheckTrustedOrganizationData(_v);\n\n if (_consensusWeight[_v.consensusAddr] > 0) revert ErrConsensusAddressIsAlreadyAdded(_v.consensusAddr);\n\n if (_governorWeight[_v.governor] > 0) revert ErrGovernorAddressIsAlreadyAdded(_v.governor);\n\n if (_bridgeVoterWeight[_v.bridgeVoter] > 0) revert ErrBridgeVoterIsAlreadyAdded(_v.bridgeVoter);\n\n _consensusList.push(_v.consensusAddr);\n _consensusWeight[_v.consensusAddr] = _v.weight;\n\n _governorList.push(_v.governor);\n _governorWeight[_v.governor] = _v.weight;\n\n _bridgeVoterList.push(_v.bridgeVoter);\n _bridgeVoterWeight[_v.bridgeVoter] = _v.weight;\n\n _addedBlock[_v.consensusAddr] = block.number;\n\n _totalWeight += _v.weight;\n }\n\n /**\n * @dev Updates a trusted organization.\n *\n * Requirements:\n * - The weight is larger than 0.\n * - The consensus address is already added.\n *\n */\n function _updateTrustedOrganization(TrustedOrganization memory _v) internal virtual {\n _sanityCheckTrustedOrganizationData(_v);\n\n uint256 _weight = _consensusWeight[_v.consensusAddr];\n if (_weight == 0) revert ErrConsensusAddressIsNotAdded(_v.consensusAddr);\n\n uint256 _count = _consensusList.length;\n for (uint256 _i = 0; _i < _count; ) {\n if (_consensusList[_i] == _v.consensusAddr) {\n _totalWeight -= _weight;\n _totalWeight += _v.weight;\n\n if (_governorList[_i] != _v.governor) {\n if (_governorWeight[_v.governor] != 0) revert ErrQueryForDupplicated();\n\n delete _governorWeight[_governorList[_i]];\n _governorList[_i] = _v.governor;\n }\n\n if (_bridgeVoterList[_i] != _v.bridgeVoter) {\n if (_bridgeVoterWeight[_v.bridgeVoter] != 0) revert ErrQueryForDupplicated();\n\n delete _bridgeVoterWeight[_bridgeVoterList[_i]];\n _bridgeVoterList[_i] = _v.bridgeVoter;\n }\n\n _consensusWeight[_v.consensusAddr] = _v.weight;\n _governorWeight[_v.governor] = _v.weight;\n _bridgeVoterWeight[_v.bridgeVoter] = _v.weight;\n return;\n }\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @dev Removes a trusted organization.\n *\n * Requirements:\n * - The consensus address is added.\n *\n */\n function _removeTrustedOrganization(address _addr) internal virtual {\n uint256 _weight = _consensusWeight[_addr];\n if (_weight == 0) revert ErrConsensusAddressIsNotAdded(_addr);\n\n uint256 _index;\n uint256 _count = _consensusList.length;\n for (uint256 _i = 0; _i < _count; ) {\n if (_consensusList[_i] == _addr) {\n _index = _i;\n break;\n }\n\n unchecked {\n ++_i;\n }\n }\n\n _totalWeight -= _weight;\n\n delete _addedBlock[_addr];\n delete _consensusWeight[_addr];\n _consensusList[_index] = _consensusList[_count - 1];\n _consensusList.pop();\n\n delete _governorWeight[_governorList[_index]];\n _governorList[_index] = _governorList[_count - 1];\n _governorList.pop();\n\n delete _bridgeVoterWeight[_bridgeVoterList[_index]];\n _bridgeVoterList[_index] = _bridgeVoterList[_count - 1];\n _bridgeVoterList.pop();\n }\n\n /**\n * @dev Sets threshold and returns the old one.\n *\n * Emits the `ThresholdUpdated` event.\n *\n */\n function _setThreshold(\n uint256 _numerator,\n uint256 _denominator\n ) internal virtual returns (uint256 _previousNum, uint256 _previousDenom) {\n if (_numerator > _denominator) revert ErrInvalidThreshold(msg.sig);\n\n _previousNum = _num;\n _previousDenom = _denom;\n _num = _numerator;\n _denom = _denominator;\n unchecked {\n emit ThresholdUpdated(_nonce++, _numerator, _denominator, _previousNum, _previousDenom);\n }\n }\n\n /**\n * @dev Hook that checks trusted organization's data. Reverts if the requirements are not met.\n *\n * Requirements:\n * - The weight must be larger than 0.\n * - The consensus address, governor address, and bridge voter address are different.\n */\n function _sanityCheckTrustedOrganizationData(TrustedOrganization memory _v) private pure {\n if (_v.weight == 0) revert ErrInvalidVoteWeight(msg.sig);\n\n address[] memory _addresses = new address[](3);\n _addresses[0] = _v.consensusAddr;\n _addresses[1] = _v.governor;\n _addresses[2] = _v.bridgeVoter;\n\n if (AddressArrayUtils.hasDuplicate(_addresses)) revert AddressArrayUtils.ErrDuplicated(msg.sig);\n }\n}\n" + }, + "contracts/precompile-usages/PCUPickValidatorSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./PrecompiledUsage.sol\";\n\nabstract contract PCUPickValidatorSet is PrecompiledUsage {\n /// @dev Gets the address of the precompile of picking validator set\n function precompilePickValidatorSetAddress() public view virtual returns (address) {\n return address(0x68);\n }\n\n /**\n * @dev Sorts and arranges to return a new validator set.\n *\n * Note: The recover process is done by pre-compiled contract. This function is marked as\n * virtual for implementing mocking contract for testing purpose.\n */\n function _pcPickValidatorSet(\n address[] memory _candidates,\n uint256[] memory _weights,\n uint256[] memory _trustedWeights,\n uint256 _maxValidatorNumber,\n uint256 _maxPrioritizedValidatorNumber\n ) internal view virtual returns (address[] memory _result, uint256 _newValidatorCount) {\n address _smc = precompilePickValidatorSetAddress();\n bytes memory _payload = abi.encodeWithSignature(\n \"pickValidatorSet(address[],uint256[],uint256[],uint256,uint256)\",\n _candidates,\n _weights,\n _trustedWeights,\n _maxValidatorNumber,\n _maxPrioritizedValidatorNumber\n );\n bool _success = true;\n\n uint256 _payloadLength = _payload.length;\n uint256 _resultLength = 0x20 * _candidates.length + 0x40;\n\n assembly {\n let _payloadStart := add(_payload, 0x20)\n\n if iszero(staticcall(gas(), _smc, _payloadStart, _payloadLength, _result, _resultLength)) {\n _success := 0\n }\n\n if iszero(returndatasize()) {\n _success := 0\n }\n\n _result := add(_result, 0x20)\n }\n\n if (!_success) revert ErrCallPrecompiled();\n\n _newValidatorCount = _result.length;\n }\n}\n" + }, + "contracts/precompile-usages/PCUSortValidators.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./PrecompiledUsage.sol\";\n\nabstract contract PCUSortValidators is PrecompiledUsage {\n /// @dev Gets the address of the precompile of sorting validators\n function precompileSortValidatorsAddress() public view virtual returns (address) {\n return address(0x66);\n }\n\n /**\n * @dev Sorts candidates descending by their weights by calling precompile contract.\n *\n * Note: This function is marked as virtual for being wrapping in mock contract for testing purpose.\n */\n function _pcSortCandidates(\n address[] memory _candidates,\n uint256[] memory _weights\n ) internal view virtual returns (address[] memory _result) {\n address _smc = precompileSortValidatorsAddress();\n bool _success = true;\n\n bytes memory _payload = abi.encodeWithSignature(\"sortValidators(address[],uint256[])\", _candidates, _weights);\n uint256 _payloadLength = _payload.length;\n uint256 _resultLength = 0x20 * _candidates.length + 0x40;\n\n assembly {\n let _payloadStart := add(_payload, 0x20)\n\n if iszero(staticcall(gas(), _smc, _payloadStart, _payloadLength, _result, _resultLength)) {\n _success := 0\n }\n\n if iszero(returndatasize()) {\n _success := 0\n }\n\n _result := add(_result, 0x20)\n }\n\n if (!_success) revert ErrCallPrecompiled();\n }\n}\n" + }, + "contracts/precompile-usages/PCUValidateDoubleSign.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./PrecompiledUsage.sol\";\n\nabstract contract PCUValidateDoubleSign is PrecompiledUsage {\n /// @dev Gets the address of the precompile of validating double sign evidence\n function precompileValidateDoubleSignAddress() public view virtual returns (address) {\n return address(0x67);\n }\n\n /**\n * @dev Validates the two submitted block header if they are produced by the same address\n *\n * Note: The recover process is done by pre-compiled contract. This function is marked as\n * virtual for implementing mocking contract for testing purpose.\n */\n function _pcValidateEvidence(\n address _consensusAddr,\n bytes calldata _header1,\n bytes calldata _header2\n ) internal view virtual returns (bool _validEvidence) {\n address _smc = precompileValidateDoubleSignAddress();\n bool _success = true;\n\n bytes memory _payload = abi.encodeWithSignature(\n \"validatingDoubleSignProof(address,bytes,bytes)\",\n _consensusAddr,\n _header1,\n _header2\n );\n uint _payloadLength = _payload.length;\n uint[1] memory _output;\n\n assembly {\n let _payloadStart := add(_payload, 0x20)\n if iszero(staticcall(gas(), _smc, _payloadStart, _payloadLength, _output, 0x20)) {\n _success := 0\n }\n\n if iszero(returndatasize()) {\n _success := 0\n }\n }\n\n if (!_success) revert ErrCallPrecompiled();\n return (_output[0] != 0);\n }\n}\n" + }, + "contracts/precompile-usages/PrecompiledUsage.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./PrecompiledUsage.sol\";\n\nabstract contract PrecompiledUsage {\n /// @dev Error of call to precompile fails.\n error ErrCallPrecompiled();\n}\n" + }, + "contracts/ronin/gateway/BridgeReward.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport { Initializable } from \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport { BridgeTrackingHelper } from \"../../extensions/bridge-operator-governance/BridgeTrackingHelper.sol\";\nimport { ContractType, HasContracts } from \"../../extensions/collections/HasContracts.sol\";\nimport { RONTransferHelper } from \"../../extensions/RONTransferHelper.sol\";\nimport { IRoninValidatorSet } from \"../../interfaces/validator/IRoninValidatorSet.sol\";\nimport { IBridgeManager } from \"../../interfaces/bridge/IBridgeManager.sol\";\nimport { IBridgeTracking } from \"../../interfaces/bridge/IBridgeTracking.sol\";\nimport { IBridgeReward } from \"../../interfaces/bridge/IBridgeReward.sol\";\nimport { IBridgeSlash } from \"../../interfaces/bridge/IBridgeSlash.sol\";\nimport { Math } from \"../../libraries/Math.sol\";\nimport { TUint256Slot } from \"../../types/Types.sol\";\nimport { ErrSyncTooFarPeriod, ErrInvalidArguments, ErrLengthMismatch, ErrUnauthorizedCall } from \"../../utils/CommonErrors.sol\";\n\ncontract BridgeReward is IBridgeReward, BridgeTrackingHelper, HasContracts, RONTransferHelper, Initializable {\n /// @dev value is equal to keccak256(\"@ronin.dpos.gateway.BridgeReward.rewardInfo.slot\") - 1\n bytes32 private constant REWARD_INFO_SLOT = 0x518cfd198acbffe95e740cfce1af28a3f7de51f0d784893d3d72c5cc59d7062a;\n /// @dev value is equal to keccak256(\"@ronin.dpos.gateway.BridgeReward.rewardPerPeriod.slot\") - 1\n TUint256Slot private constant REWARD_PER_PERIOD_SLOT =\n TUint256Slot.wrap(0x90f7d557245e5dd9485f463e58974fa7cdc93c0abbd0a1afebb8f9640ec73910);\n /// @dev value is equal to keccak256(\"@ronin.dpos.gateway.BridgeReward.latestRewardedPeriod.slot\") - 1\n TUint256Slot private constant LATEST_REWARDED_PERIOD_SLOT =\n TUint256Slot.wrap(0x2417f25874c1cdc139a787dd21df976d40d767090442b3a2496917ecfc93b619);\n /// @dev value is equal to keccak256(\"@ronin.dpos.gateway.BridgeReward.totalRewardToppedUp.slot\") - 1\n TUint256Slot private constant TOTAL_REWARDS_TOPPED_UP_SLOT =\n TUint256Slot.wrap(0x9a8c9f129792436c37b7bd2d79c56132fc05bf26cc8070794648517c2a0c6c64);\n /// @dev value is equal to keccak256(\"@ronin.dpos.gateway.BridgeReward.totalRewardScattered.slot\") - 1\n TUint256Slot private constant TOTAL_REWARDS_SCATTERED_SLOT =\n TUint256Slot.wrap(0x3663384f6436b31a97d9c9a02f64ab8b73ead575c5b6224fa0800a6bd57f62f4);\n\n address private immutable _self;\n\n constructor() payable {\n _self = address(this);\n _disableInitializers();\n }\n\n function initialize(\n address bridgeManagerContract,\n address bridgeTrackingContract,\n address bridgeSlashContract,\n address validatorSetContract,\n uint256 rewardPerPeriod\n ) external payable initializer {\n _setContract(ContractType.BRIDGE_MANAGER, bridgeManagerContract);\n _setContract(ContractType.BRIDGE_TRACKING, bridgeTrackingContract);\n _setContract(ContractType.BRIDGE_SLASH, bridgeSlashContract);\n _setContract(ContractType.VALIDATOR, validatorSetContract);\n _setRewardPerPeriod(rewardPerPeriod);\n _syncLatestRewardedPeriod();\n _receiveRON();\n }\n\n /**\n * @inheritdoc IBridgeReward\n */\n function receiveRON() external payable {\n _receiveRON();\n }\n\n /**\n * @inheritdoc IBridgeReward\n */\n function syncReward(uint256 periodLength) external {\n if (!_isBridgeOperator(msg.sender)) revert ErrUnauthorizedCall(msg.sig);\n\n uint256 latestRewardedPeriod = getLatestRewardedPeriod();\n uint256 currentPeriod = IRoninValidatorSet(getContract(ContractType.VALIDATOR)).currentPeriod();\n\n if (currentPeriod <= latestRewardedPeriod) revert ErrInvalidArguments(msg.sig);\n if (latestRewardedPeriod + periodLength > currentPeriod) revert ErrInvalidArguments(msg.sig);\n\n LATEST_REWARDED_PERIOD_SLOT.addAssign(periodLength);\n\n address[] memory operators = IBridgeManager(getContract(ContractType.BRIDGE_MANAGER)).getBridgeOperators();\n IBridgeTracking bridgeTrackingContract = IBridgeTracking(getContract(ContractType.BRIDGE_TRACKING));\n\n for (uint256 i = 1; i <= periodLength; ) {\n unchecked {\n _syncReward({\n operators: operators,\n ballots: bridgeTrackingContract.getManyTotalBallots(latestRewardedPeriod, operators),\n totalBallot: bridgeTrackingContract.totalBallot(latestRewardedPeriod),\n totalVote: bridgeTrackingContract.totalVote(latestRewardedPeriod),\n period: latestRewardedPeriod += i\n });\n\n ++i;\n }\n }\n }\n\n /**\n * @inheritdoc IBridgeReward\n */\n function execSyncReward(\n address[] calldata operators,\n uint256[] calldata ballots,\n uint256 totalBallot,\n uint256 totalVote,\n uint256 period\n ) external onlyContract(ContractType.BRIDGE_TRACKING) {\n if (operators.length != ballots.length) revert ErrLengthMismatch(msg.sig);\n if (operators.length == 0) return;\n\n // Only sync the period that is after the latest rewarded period.\n unchecked {\n uint256 latestRewardedPeriod = getLatestRewardedPeriod();\n if (period < latestRewardedPeriod + 1) revert ErrInvalidArguments(msg.sig);\n else if (period > latestRewardedPeriod + 1) revert ErrSyncTooFarPeriod(period, latestRewardedPeriod);\n }\n LATEST_REWARDED_PERIOD_SLOT.store(period);\n\n _syncReward({\n operators: operators,\n ballots: ballots,\n totalBallot: totalBallot,\n totalVote: totalVote,\n period: period\n });\n }\n\n /**\n * @inheritdoc IBridgeReward\n */\n function getTotalRewardToppedUp() external view returns (uint256) {\n return TOTAL_REWARDS_TOPPED_UP_SLOT.load();\n }\n\n /**\n * @inheritdoc IBridgeReward\n */\n function getTotalRewardScattered() external view returns (uint256) {\n return TOTAL_REWARDS_SCATTERED_SLOT.load();\n }\n\n /**\n * @dev Internal function to receive RON tokens as rewards and update the total topped-up rewards amount.\n */\n function _receiveRON() internal {\n // prevent transfer RON directly to logic contract\n if (address(this) == _self) revert ErrUnauthorizedCall(msg.sig);\n\n emit SafeReceived(msg.sender, TOTAL_REWARDS_TOPPED_UP_SLOT.load(), msg.value);\n TOTAL_REWARDS_TOPPED_UP_SLOT.addAssign(msg.value);\n }\n\n /**\n * @dev Internal function to synchronize and distribute rewards to bridge operators for a given period.\n * @param operators An array containing the addresses of bridge operators to receive rewards.\n * @param ballots An array containing the individual ballot counts for each bridge operator.\n * @param totalBallot The total number of available ballots for the period.\n * @param totalVote The total number of votes recorded for the period.\n * @param period The period for which the rewards are being synchronized.\n */\n function _syncReward(\n address[] memory operators,\n uint256[] memory ballots,\n uint256 totalBallot,\n uint256 totalVote,\n uint256 period\n ) internal {\n uint256 numBridgeOperators = operators.length;\n uint256 rewardPerPeriod = getRewardPerPeriod();\n uint256[] memory slashedDurationList = _getSlashInfo(operators);\n // Validate should share the reward equally\n bool shouldShareEqually = _shouldShareEqually(totalBallot, totalVote, ballots);\n\n uint256 reward;\n bool shouldSlash;\n uint256 sumRewards;\n\n for (uint256 i; i < numBridgeOperators; ) {\n (reward, shouldSlash) = _calcRewardAndCheckSlashedStatus({\n shouldShareEqually: shouldShareEqually,\n numBridgeOperators: numBridgeOperators,\n rewardPerPeriod: rewardPerPeriod,\n ballot: ballots[i],\n totalBallot: totalBallot,\n period: period,\n slashUntilPeriod: slashedDurationList[i]\n });\n\n sumRewards += shouldSlash ? 0 : reward;\n _updateRewardAndTransfer({ period: period, operator: operators[i], reward: reward, shouldSlash: shouldSlash });\n\n unchecked {\n ++i;\n }\n }\n\n TOTAL_REWARDS_SCATTERED_SLOT.addAssign(sumRewards);\n }\n\n /**\n * @dev Internal function to synchronize the latest rewarded period based on the current period of the validator set contract.\n * @notice This function is used internally to synchronize the latest rewarded period with the current period of the validator set contract.\n * @notice The `currentPeriod` of the validator set contract is retrieved and stored in the `LATEST_REWARDED_PERIOD_SLOT`.\n * @notice This function ensures that the latest rewarded period is updated to reflect the current period in the validator set contract.\n */\n function _syncLatestRewardedPeriod() internal {\n LATEST_REWARDED_PERIOD_SLOT.store(IRoninValidatorSet(getContract(ContractType.VALIDATOR)).currentPeriod());\n }\n\n /**\n * @dev Returns whether should share the reward equally, in case of bridge tracking returns\n * informed data or there is no ballot in a day.\n *\n * Emit a {BridgeTrackingIncorrectlyResponded} event when in case of incorrect data.\n */\n function _shouldShareEqually(\n uint256 totalBallot,\n uint256 totalVote,\n uint256[] memory ballots\n ) internal returns (bool shareEqually) {\n bool valid = _isValidBridgeTrackingResponse(totalBallot, totalVote, ballots);\n if (!valid) {\n emit BridgeTrackingIncorrectlyResponded();\n }\n\n return !valid || totalBallot == 0;\n }\n\n /**\n * @dev Internal function to calculate the reward for a bridge operator and check its slashing status.\n * @param shouldShareEqually A boolean indicating whether the reward should be shared equally among bridge operators.\n * @param numBridgeOperators The total number of bridge operators for proportional reward calculation.\n * @param rewardPerPeriod The total reward available for the period.\n * @param ballot The individual ballot count of the bridge operator for the period.\n * @param totalBallot The total number of available ballots for the period.\n * @param period The period for which the reward is being calculated.\n * @param slashUntilPeriod The period until which slashing is effective for the bridge operator.\n * @return reward The calculated reward for the bridge operator.\n * @return shouldSlash A boolean indicating whether the bridge operator should be slashed for the current period.\n */\n function _calcRewardAndCheckSlashedStatus(\n bool shouldShareEqually,\n uint256 numBridgeOperators,\n uint256 rewardPerPeriod,\n uint256 ballot,\n uint256 totalBallot,\n uint256 period,\n uint256 slashUntilPeriod\n ) internal pure returns (uint256 reward, bool shouldSlash) {\n shouldSlash = _shouldSlashedThisPeriod(period, slashUntilPeriod);\n reward = _calcReward(shouldShareEqually, numBridgeOperators, rewardPerPeriod, ballot, totalBallot);\n }\n\n /**\n * @dev Internal function to check if a specific period should be considered as slashed based on the slash duration.\n * @param period The period to check if it should be slashed.\n * @param slashDuration The duration until which periods should be considered as slashed.\n * @return shouldSlashed A boolean indicating whether the specified period should be slashed.\n * @notice This function is used internally to determine if a particular period should be marked as slashed based on the slash duration.\n */\n function _shouldSlashedThisPeriod(uint256 period, uint256 slashDuration) internal pure returns (bool) {\n return period <= slashDuration;\n }\n\n /**\n * @dev Internal function to calculate the reward for a bridge operator based on the provided parameters.\n * @param shouldShareEqually A boolean indicating whether the reward should be shared equally among bridge operators.\n * @param numBridgeOperators The total number of bridge operators for proportional reward calculation.\n * @param rewardPerPeriod The total reward available for the period.\n * @param ballot The individual ballot count of the bridge operator for the period.\n * @param totalBallot The total number of available ballots for the period.\n * @return reward The calculated reward for the bridge operator.\n */\n function _calcReward(\n bool shouldShareEqually,\n uint256 numBridgeOperators,\n uint256 rewardPerPeriod,\n uint256 ballot,\n uint256 totalBallot\n ) internal pure returns (uint256 reward) {\n // Shares equally in case the bridge has nothing to vote or bridge tracking response is incorrect\n // Else shares the bridge operators reward proportionally\n reward = shouldShareEqually ? rewardPerPeriod / numBridgeOperators : (rewardPerPeriod * ballot) / totalBallot;\n }\n\n /**\n * @dev Transfer `reward` to a `operator` or only emit event based on the operator `slashed` status.\n */\n function _updateRewardAndTransfer(uint256 period, address operator, uint256 reward, bool shouldSlash) private {\n BridgeRewardInfo storage _iRewardInfo = _getRewardInfo()[operator];\n\n if (shouldSlash) {\n _iRewardInfo.slashed += reward;\n emit BridgeRewardSlashed(period, operator, reward);\n } else {\n _iRewardInfo.claimed += reward;\n if (_unsafeSendRONLimitGas({ recipient: payable(operator), amount: reward, gas: 0 })) {\n emit BridgeRewardScattered(period, operator, reward);\n } else {\n emit BridgeRewardScatterFailed(period, operator, reward);\n }\n }\n }\n\n /**\n * @inheritdoc IBridgeReward\n */\n function getRewardPerPeriod() public view returns (uint256) {\n return REWARD_PER_PERIOD_SLOT.load();\n }\n\n /**\n * @inheritdoc IBridgeReward\n */\n function getLatestRewardedPeriod() public view returns (uint256) {\n return LATEST_REWARDED_PERIOD_SLOT.load();\n }\n\n /**\n * @inheritdoc IBridgeReward\n */\n function setRewardPerPeriod(uint256 rewardPerPeriod) external onlyContract(ContractType.BRIDGE_MANAGER) {\n _setRewardPerPeriod(rewardPerPeriod);\n }\n\n /**\n * @dev Internal function for setting the total reward per period.\n * Emit an {UpdatedRewardPerPeriod} event after set.\n */\n function _setRewardPerPeriod(uint256 rewardPerPeriod) internal {\n REWARD_PER_PERIOD_SLOT.store(rewardPerPeriod);\n emit UpdatedRewardPerPeriod(rewardPerPeriod);\n }\n\n /**\n * @dev Internal helper for querying slash info of a list of operators.\n */\n function _getSlashInfo(address[] memory operatorList) internal returns (uint256[] memory _slashedDuration) {\n return IBridgeSlash(getContract(ContractType.BRIDGE_SLASH)).getSlashUntilPeriodOf(operatorList);\n }\n\n /**\n * @dev Internal helper for querying whether an address is an operator.\n */\n function _isBridgeOperator(address operator) internal view returns (bool) {\n return IBridgeManager(getContract(ContractType.BRIDGE_MANAGER)).isBridgeOperator(operator);\n }\n\n /**\n * @dev Internal function to access the mapping from bridge operator => BridgeRewardInfo.\n * @return rewardInfo the mapping from bridge operator => BridgeRewardInfo.\n */\n function _getRewardInfo() internal pure returns (mapping(address => BridgeRewardInfo) storage rewardInfo) {\n assembly (\"memory-safe\") {\n rewardInfo.slot := REWARD_INFO_SLOT\n }\n }\n}\n" + }, + "contracts/ronin/gateway/BridgeSlash.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.17;\n\nimport { Initializable } from \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport { BridgeTrackingHelper } from \"../../extensions/bridge-operator-governance/BridgeTrackingHelper.sol\";\nimport { IHasContracts, HasContracts } from \"../../extensions/collections/HasContracts.sol\";\nimport { IBridgeSlash } from \"../../interfaces/bridge/IBridgeSlash.sol\";\nimport { IERC165, IBridgeManagerCallback } from \"../../interfaces/bridge/IBridgeManagerCallback.sol\";\nimport { IBridgeTracking } from \"../../interfaces/bridge/IBridgeTracking.sol\";\nimport { IRoninValidatorSet } from \"../../interfaces/validator/IRoninValidatorSet.sol\";\nimport { Math } from \"../../libraries/Math.sol\";\nimport { ContractType } from \"../../utils/ContractType.sol\";\nimport { IdentityGuard } from \"../../utils/IdentityGuard.sol\";\nimport { ErrLengthMismatch } from \"../../utils/CommonErrors.sol\";\n\n/**\n * @title BridgeSlash\n * @dev A contract that implements slashing functionality for bridge operators based on their availability.\n */\ncontract BridgeSlash is\n IBridgeSlash,\n IBridgeManagerCallback,\n BridgeTrackingHelper,\n IdentityGuard,\n Initializable,\n HasContracts\n{\n /// @inheritdoc IBridgeSlash\n uint256 public constant TIER_1_PENALTY_DURATION = 1;\n /// @inheritdoc IBridgeSlash\n uint256 public constant TIER_2_PENALTY_DURATION = 5;\n /// @inheritdoc IBridgeSlash\n uint256 public constant MINIMUM_VOTE_THRESHOLD = 50;\n /// @inheritdoc IBridgeSlash\n uint256 public constant REMOVE_DURATION_THRESHOLD = 30;\n\n /// @dev Tier 1 slashing threshold ratio is 10%\n uint256 private constant TIER_1_THRESHOLD = 10_00;\n /// @dev Tier 2 slashing threshold ratio is 30%\n uint256 private constant TIER_2_THRESHOLD = 30_00;\n /// @dev Max percentage 100%. Values [0; 100_00] reflexes [0; 100%]\n uint256 private constant PERCENTAGE_FRACTION = 100_00;\n /// @dev This value is set to the maximum value of uint128 to indicate a permanent slash duration.\n uint256 private constant SLASH_PERMANENT_DURATION = type(uint128).max;\n /// @dev value is equal to keccak256(\"@ronin.dpos.gateway.BridgeSlash.bridgeSlashInfos.slot\") - 1\n bytes32 private constant BRIDGE_SLASH_INFOS_SLOT = 0xd08d185790a07c7b9b721e2713c8580010a57f31c72c16f6e80b831d0ee45bfe;\n\n /**\n * @dev The modifier verifies if the `totalVote` is non-zero, indicating the presence of ballots for the period.\n * @param totalVote The total number of ballots for the period.\n */\n modifier onlyPeriodHasEnoughVotes(uint256 totalVote) {\n if (totalVote <= MINIMUM_VOTE_THRESHOLD) return;\n _;\n }\n\n constructor() payable {\n _disableInitializers();\n }\n\n function initialize(\n address validatorContract,\n address bridgeManagerContract,\n address bridgeTrackingContract\n ) external initializer {\n _setContract(ContractType.VALIDATOR, validatorContract);\n _setContract(ContractType.BRIDGE_MANAGER, bridgeManagerContract);\n _setContract(ContractType.BRIDGE_TRACKING, bridgeTrackingContract);\n }\n\n /**\n * @inheritdoc IBridgeManagerCallback\n */\n function onBridgeOperatorsAdded(\n address[] calldata bridgeOperators,\n bool[] memory addeds\n ) external onlyContract(ContractType.BRIDGE_MANAGER) returns (bytes4) {\n uint256 length = bridgeOperators.length;\n if (length != addeds.length) revert ErrLengthMismatch(msg.sig);\n if (length == 0) {\n return IBridgeManagerCallback.onBridgeOperatorsAdded.selector;\n }\n\n mapping(address => BridgeSlashInfo) storage _bridgeSlashInfos = _getBridgeSlashInfos();\n uint256 currentPeriod = IRoninValidatorSet(getContract(ContractType.VALIDATOR)).currentPeriod();\n\n for (uint256 i; i < length; ) {\n unchecked {\n if (addeds[i]) {\n _bridgeSlashInfos[bridgeOperators[i]].newlyAddedAtPeriod = uint128(currentPeriod);\n }\n\n ++i;\n }\n }\n\n return IBridgeManagerCallback.onBridgeOperatorsAdded.selector;\n }\n\n /**\n * @inheritdoc IBridgeManagerCallback\n */\n function onBridgeOperatorUpdated(\n address currentBridgeOperator,\n address newBridgeOperator\n ) external onlyContract(ContractType.BRIDGE_MANAGER) returns (bytes4) {\n mapping(address => BridgeSlashInfo) storage _bridgeSlashInfos = _getBridgeSlashInfos();\n\n _bridgeSlashInfos[newBridgeOperator] = _bridgeSlashInfos[currentBridgeOperator];\n delete _bridgeSlashInfos[currentBridgeOperator];\n\n return IBridgeManagerCallback.onBridgeOperatorUpdated.selector;\n }\n\n /**\n * @inheritdoc IBridgeSlash\n */\n function execSlashBridgeOperators(\n address[] memory allBridgeOperators,\n uint256[] memory ballots,\n uint256 totalBallot,\n uint256 totalVote,\n uint256 period\n ) external onlyContract(ContractType.BRIDGE_TRACKING) onlyPeriodHasEnoughVotes(totalVote) returns (bool slashed) {\n uint256 length = allBridgeOperators.length;\n if (length != ballots.length) revert ErrLengthMismatch(msg.sig);\n if (length == 0) return false;\n if (!_isValidBridgeTrackingResponse(totalBallot, totalVote, ballots)) {\n emit BridgeTrackingIncorrectlyResponded();\n return false;\n }\n\n // Get penalty durations for each slash tier.\n uint256[] memory penaltyDurations = _getPenaltyDurations();\n // Get the storage mapping for bridge slash information.\n mapping(address => BridgeSlashInfo) storage _bridgeSlashInfos = _getBridgeSlashInfos();\n\n // Declare variables for iteration.\n BridgeSlashInfo memory status;\n uint256 slashUntilPeriod;\n address bridgeOperator;\n Tier tier;\n\n for (uint256 i; i < length; ) {\n bridgeOperator = allBridgeOperators[i];\n status = _bridgeSlashInfos[bridgeOperator];\n\n // Check if the bridge operator was added before the current period.\n // Bridge operators added in current period will not be slashed.\n if (status.newlyAddedAtPeriod < period) {\n // Determine the slash tier for the bridge operator based on their ballots.\n tier = _getSlashTier(ballots[i], totalVote);\n\n slashUntilPeriod = _calcSlashUntilPeriod(tier, period, status.slashUntilPeriod, penaltyDurations);\n\n // Check if the slash duration exceeds the threshold for removal.\n if (_isSlashDurationMetRemovalThreshold(slashUntilPeriod, period)) {\n slashUntilPeriod = SLASH_PERMANENT_DURATION;\n emit RemovalRequested(period, bridgeOperator);\n }\n\n // Emit the Slashed event if the tier is not Tier 0 and bridge operator will not be removed.\n // Update the slash until period number for the bridge operator if the tier is not Tier 0.\n if (tier != Tier.Tier0) {\n slashed = true;\n\n if (slashUntilPeriod != SLASH_PERMANENT_DURATION) {\n emit Slashed(tier, bridgeOperator, period, slashUntilPeriod);\n }\n\n // Store updated slash until period\n _bridgeSlashInfos[bridgeOperator].slashUntilPeriod = uint128(slashUntilPeriod);\n }\n }\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @inheritdoc IBridgeManagerCallback\n */\n function onBridgeOperatorsRemoved(\n address[] calldata,\n bool[] calldata\n ) external view onlyContract(ContractType.BRIDGE_MANAGER) returns (bytes4) {\n return IBridgeManagerCallback.onBridgeOperatorsAdded.selector;\n }\n\n /**\n * @inheritdoc IERC165\n */\n function supportsInterface(bytes4 interfaceId) external pure returns (bool) {\n return interfaceId == type(IBridgeManagerCallback).interfaceId || interfaceId == type(IERC165).interfaceId;\n }\n\n /**\n * @inheritdoc IBridgeSlash\n */\n function getSlashUntilPeriodOf(\n address[] calldata bridgeOperators\n ) external view returns (uint256[] memory untilPeriods) {\n uint256 length = bridgeOperators.length;\n untilPeriods = new uint256[](length);\n mapping(address => BridgeSlashInfo) storage _bridgeSlashInfos = _getBridgeSlashInfos();\n\n for (uint256 i; i < length; ) {\n untilPeriods[i] = _bridgeSlashInfos[bridgeOperators[i]].slashUntilPeriod;\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @inheritdoc IBridgeSlash\n */\n function getAddedPeriodOf(address[] calldata bridgeOperators) external view returns (uint256[] memory addedPeriods) {\n uint256 length = bridgeOperators.length;\n addedPeriods = new uint256[](length);\n mapping(address => BridgeSlashInfo) storage _bridgeSlashInfos = _getBridgeSlashInfos();\n\n for (uint256 i; i < length; ) {\n addedPeriods[i] = _bridgeSlashInfos[bridgeOperators[i]].newlyAddedAtPeriod;\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @inheritdoc IBridgeSlash\n */\n function getPenaltyDurations() external pure returns (uint256[] memory penaltyDurations) {\n penaltyDurations = _getPenaltyDurations();\n }\n\n /**\n * @inheritdoc IBridgeSlash\n */\n function getSlashTier(uint256 ballot, uint256 totalVote) external pure returns (Tier tier) {\n tier = _getSlashTier(ballot, totalVote);\n }\n\n /**\n * @dev Checks if the slash duration exceeds the threshold for removal and handles it accordingly.\n * @param slashUntilPeriod The slash until period number.\n * @param period The current period.\n * @return met A boolean indicates that the threshold for removal is met.\n */\n function _isSlashDurationMetRemovalThreshold(\n uint256 slashUntilPeriod,\n uint256 period\n ) internal pure returns (bool met) {\n met = slashUntilPeriod - (period - 1) >= REMOVE_DURATION_THRESHOLD;\n }\n\n /**\n * @dev Calculates the slash until period based on the specified tier, current period, and slash until period.\n * @param tier The slash tier representing the severity of the slash.\n * @param period The current period in which the calculation is performed.\n * @param slashUntilPeriod The existing slash until period.\n * @param penaltyDurations An array of penalty durations for each slash tier.\n * @return newSlashUntilPeriod The newly calculated slash until period.\n */\n function _calcSlashUntilPeriod(\n Tier tier,\n uint256 period,\n uint256 slashUntilPeriod,\n uint256[] memory penaltyDurations\n ) internal pure returns (uint256 newSlashUntilPeriod) {\n // Calculate the slash until period number.\n newSlashUntilPeriod = penaltyDurations[uint8(tier)] + Math.max(period - 1, slashUntilPeriod);\n }\n\n /**\n * @dev Internal function to determine the slashing tier based on the given ballot count and total votes.\n * @param ballot The individual ballot count of a bridge operator.\n * @param totalVote The total number of votes recorded for the bridge operator.\n * @return tier The calculated slashing tier for the bridge operator.\n * @notice The `ratio` is calculated as the percentage of uncast votes (totalVote - ballot) relative to the total votes.\n */\n function _getSlashTier(uint256 ballot, uint256 totalVote) internal pure virtual returns (Tier tier) {\n uint256 ratio = ((totalVote - ballot) * PERCENTAGE_FRACTION) / totalVote;\n tier = ratio > TIER_2_THRESHOLD ? Tier.Tier2 : ratio > TIER_1_THRESHOLD ? Tier.Tier1 : Tier.Tier0;\n }\n\n /**\n * @dev Internal function to access the mapping from bridge operator => BridgeSlashInfo.\n * @return bridgeSlashInfos the mapping from bridge operator => BridgeSlashInfo.\n */\n function _getBridgeSlashInfos() internal pure returns (mapping(address => BridgeSlashInfo) storage bridgeSlashInfos) {\n assembly (\"memory-safe\") {\n bridgeSlashInfos.slot := BRIDGE_SLASH_INFOS_SLOT\n }\n }\n\n /**\n * @dev Internal function to retrieve the penalty durations for each slashing tier.\n * @return penaltyDurations An array containing the penalty durations for Tier0, Tier1, and Tier2 in that order.\n */\n function _getPenaltyDurations() internal pure virtual returns (uint256[] memory penaltyDurations) {\n // reserve index 0\n penaltyDurations = new uint256[](3);\n penaltyDurations[uint8(Tier.Tier1)] = TIER_1_PENALTY_DURATION;\n penaltyDurations[uint8(Tier.Tier2)] = TIER_2_PENALTY_DURATION;\n }\n}\n" + }, + "contracts/ronin/gateway/BridgeTracking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport \"../../extensions/collections/HasContracts.sol\";\nimport \"../../interfaces/bridge/IBridgeTracking.sol\";\nimport { IBridgeManager } from \"../../interfaces/bridge/IBridgeManager.sol\";\nimport { IBridgeSlash } from \"../../interfaces/bridge/IBridgeSlash.sol\";\nimport { IBridgeReward } from \"../../interfaces/bridge/IBridgeReward.sol\";\nimport { IRoninValidatorSet } from \"../../interfaces/validator/IRoninValidatorSet.sol\";\nimport { HasBridgeDeprecated, HasValidatorDeprecated } from \"../../utils/DeprecatedSlots.sol\";\n\ncontract BridgeTracking is HasBridgeDeprecated, HasValidatorDeprecated, HasContracts, Initializable, IBridgeTracking {\n struct PeriodVotingMetric {\n /// @dev Total requests that are tracked in the period. This value is 0 until the {_bufferMetric.requests[]} gets added into a period metric.\n uint256 totalRequest;\n uint256 totalBallot;\n mapping(address => uint256) totalBallotOf;\n address[] voters;\n }\n\n struct PeriodVotingMetricTimeWrapper {\n uint256 lastEpoch;\n Request[] requests;\n PeriodVotingMetric data;\n }\n\n struct ReceiptTrackingInfo {\n /// @dev The period that the receipt is approved. Value 0 means the receipt is not approved yet.\n uint256 approvedPeriod;\n /// @dev The address list of voters\n address[] voters;\n /// @dev Mapping from voter => flag indicating the voter casts vote for this receipt\n mapping(address => bool) voted;\n /// @dev The period that the receipt is tracked, i.e. the metric is transferred from buffer to the period. Value 0 means the receipt is currently in buffer or not tracked yet.\n uint256 trackedPeriod;\n }\n\n /// @dev The block that the contract allows incoming mutable calls.\n uint256 internal _startedAtBlock;\n\n /// @dev The temporary info of votes and ballots\n PeriodVotingMetricTimeWrapper internal _bufferMetric;\n /// @dev Mapping from period number => vote stats based on period\n mapping(uint256 => PeriodVotingMetric) internal _periodMetric;\n /// @dev Mapping from vote kind => receipt id => receipt stats\n mapping(VoteKind => mapping(uint256 => ReceiptTrackingInfo)) internal _receiptTrackingInfo;\n /// @dev The latest period that get synced with bridge's slashing and rewarding contract\n uint256 internal _lastSyncPeriod;\n\n modifier skipOnUnstarted() {\n _skipOnUnstarted();\n _;\n }\n\n /**\n * @dev Returns the whole transaction in case the current block is less than start block.\n */\n function _skipOnUnstarted() private view {\n if (block.number < _startedAtBlock) {\n assembly {\n return(0, 0)\n }\n }\n }\n\n constructor() {\n _disableInitializers();\n }\n\n /**\n * @dev Initializes the contract storage.\n */\n function initialize(address bridgeContract, address validatorContract, uint256 startedAtBlock_) external initializer {\n _setContract(ContractType.BRIDGE, bridgeContract);\n _setContract(ContractType.VALIDATOR, validatorContract);\n _startedAtBlock = startedAtBlock_;\n }\n\n function initializeV2() external reinitializer(2) {\n _setContract(ContractType.BRIDGE, ______deprecatedBridge);\n _setContract(ContractType.VALIDATOR, ______deprecatedValidator);\n\n delete ______deprecatedBridge;\n delete ______deprecatedValidator;\n }\n\n function initializeV3(address bridgeManager, address bridgeSlash, address bridgeReward) external reinitializer(3) {\n _setContract(ContractType.BRIDGE_MANAGER, bridgeManager);\n _setContract(ContractType.BRIDGE_SLASH, bridgeSlash);\n _setContract(ContractType.BRIDGE_REWARD, bridgeReward);\n _lastSyncPeriod = IRoninValidatorSet(getContract(ContractType.VALIDATOR)).currentPeriod() - 1;\n }\n\n /**\n * @inheritdoc IBridgeTracking\n */\n function startedAtBlock() external view override returns (uint256) {\n return _startedAtBlock;\n }\n\n /**\n * @inheritdoc IBridgeTracking\n */\n function totalVote(uint256 period) public view override returns (uint256 totalVote_) {\n totalVote_ = _periodMetric[period].totalRequest;\n if (_isBufferCountedForPeriod(period)) {\n totalVote_ += _bufferMetric.requests.length;\n }\n }\n\n /**\n * @inheritdoc IBridgeTracking\n */\n function totalBallot(uint256 period) public view override returns (uint256 totalBallot_) {\n totalBallot_ = _periodMetric[period].totalBallot;\n if (_isBufferCountedForPeriod(period)) {\n totalBallot_ += _bufferMetric.data.totalBallot;\n }\n }\n\n /**\n * @inheritdoc IBridgeTracking\n */\n function getManyTotalBallots(\n uint256 period,\n address[] calldata operators\n ) external view override returns (uint256[] memory _res) {\n _res = _getManyTotalBallots(period, operators);\n }\n\n function _getManyTotalBallots(\n uint256 period,\n address[] memory operators\n ) internal view returns (uint256[] memory res) {\n uint256 length = operators.length;\n res = new uint256[](length);\n bool isBufferCounted = _isBufferCountedForPeriod(period);\n for (uint i = 0; i < length; ) {\n res[i] = _totalBallotOf(period, operators[i], isBufferCounted);\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @inheritdoc IBridgeTracking\n */\n function totalBallotOf(uint256 period, address bridgeOperator) public view override returns (uint256) {\n return _totalBallotOf(period, bridgeOperator, _isBufferCountedForPeriod(period));\n }\n\n /**\n * @inheritdoc IBridgeTracking\n */\n function handleVoteApproved(\n VoteKind kind,\n uint256 requestId\n ) external override onlyContract(ContractType.BRIDGE) skipOnUnstarted {\n ReceiptTrackingInfo storage _receiptInfo = _receiptTrackingInfo[kind][requestId];\n\n // Only records for the receipt which not approved\n if (_receiptInfo.approvedPeriod == 0) {\n _trySyncBuffer();\n uint256 currentPeriod = IRoninValidatorSet(getContract(ContractType.VALIDATOR)).currentPeriod();\n _receiptInfo.approvedPeriod = currentPeriod;\n\n Request storage _bufferRequest = _bufferMetric.requests.push();\n _bufferRequest.kind = kind;\n _bufferRequest.id = requestId;\n\n address[] storage _voters = _receiptInfo.voters;\n for (uint i = 0; i < _voters.length; ) {\n _increaseBallot(kind, requestId, _voters[i], currentPeriod);\n\n unchecked {\n ++i;\n }\n }\n\n delete _receiptInfo.voters;\n }\n }\n\n /**\n * @inheritdoc IBridgeTracking\n */\n function recordVote(\n VoteKind kind,\n uint256 requestId,\n address operator\n ) external override onlyContract(ContractType.BRIDGE) skipOnUnstarted {\n uint256 period = IRoninValidatorSet(getContract(ContractType.VALIDATOR)).currentPeriod();\n _trySyncBuffer();\n ReceiptTrackingInfo storage _receiptInfo = _receiptTrackingInfo[kind][requestId];\n\n // When the vote is not approved yet, the voters are saved in the receipt info, and not increase ballot metric.\n // The ballot metric will be increased later in the {handleVoteApproved} method.\n if (_receiptInfo.approvedPeriod == 0) {\n _receiptInfo.voters.push(operator);\n return;\n }\n\n _increaseBallot(kind, requestId, operator, period);\n\n uint256 lastSyncPeriod = _lastSyncPeriod;\n // When switching to new period, wrap up vote info, then slash and distribute reward accordingly.\n if (lastSyncPeriod < period) {\n _lastSyncPeriod = period;\n\n address[] memory allOperators = IBridgeManager(getContract(ContractType.BRIDGE_MANAGER)).getBridgeOperators();\n uint256[] memory ballots = _getManyTotalBallots(lastSyncPeriod, allOperators);\n\n uint256 totalVote_ = totalVote(lastSyncPeriod);\n uint256 totalBallot_ = totalBallot(lastSyncPeriod);\n\n address bridgeSlashContract = getContract(ContractType.BRIDGE_SLASH);\n (bool success, bytes memory returnOrRevertData) = bridgeSlashContract.call(\n abi.encodeCall(\n IBridgeSlash.execSlashBridgeOperators,\n (allOperators, ballots, totalBallot_, totalVote_, lastSyncPeriod)\n )\n );\n if (!success) {\n emit ExternalCallFailed(\n bridgeSlashContract,\n IBridgeSlash.execSlashBridgeOperators.selector,\n returnOrRevertData\n );\n }\n\n address bridgeRewardContract = getContract(ContractType.BRIDGE_REWARD);\n (success, returnOrRevertData) = bridgeRewardContract.call(\n abi.encodeCall(IBridgeReward.execSyncReward, (allOperators, ballots, totalBallot_, totalVote_, lastSyncPeriod))\n );\n if (!success) {\n emit ExternalCallFailed(bridgeRewardContract, IBridgeReward.execSyncReward.selector, returnOrRevertData);\n }\n }\n }\n\n /**\n * @dev Increases the ballot for the operator at a period.\n */\n function _increaseBallot(VoteKind kind, uint256 requestId, address operator, uint256 currentPeriod) internal {\n ReceiptTrackingInfo storage _receiptInfo = _receiptTrackingInfo[kind][requestId];\n if (_receiptInfo.voted[operator]) {\n return;\n }\n\n _receiptInfo.voted[operator] = true;\n\n uint256 trackedPeriod = _receiptInfo.trackedPeriod;\n\n // Do not increase ballot for receipt that is neither in the buffer, nor in the most current tracked period.\n // If the receipt is not tracked in a period, increase metric in buffer.\n unchecked {\n if (trackedPeriod == 0) {\n if (_bufferMetric.data.totalBallotOf[operator] == 0) {\n _bufferMetric.data.voters.push(operator);\n }\n _bufferMetric.data.totalBallot++;\n _bufferMetric.data.totalBallotOf[operator]++;\n }\n // If the receipt is tracked in the most current tracked period, increase metric in the period.\n else if (trackedPeriod == currentPeriod) {\n PeriodVotingMetric storage _metric = _periodMetric[trackedPeriod];\n _metric.totalBallot++;\n _metric.totalBallotOf[operator]++;\n }\n }\n }\n\n /**\n * @dev See `totalBallotOf`.\n */\n function _totalBallotOf(\n uint256 period,\n address operator,\n bool mustCountLastStats\n ) internal view returns (uint256 _totalBallot) {\n _totalBallot = _periodMetric[period].totalBallotOf[operator];\n if (mustCountLastStats) {\n _totalBallot += _bufferMetric.data.totalBallotOf[operator];\n }\n }\n\n /**\n * @dev Syncs period stats. Move all data from the buffer metric to the period metric.\n *\n * Requirements:\n * - The epoch after the buffer epoch is wrapped up.\n */\n function _trySyncBuffer() internal {\n IRoninValidatorSet validatorContract = IRoninValidatorSet(getContract(ContractType.VALIDATOR));\n uint256 currentEpoch = validatorContract.epochOf(block.number);\n if (_bufferMetric.lastEpoch < currentEpoch) {\n (, uint256 trackedPeriod) = validatorContract.tryGetPeriodOfEpoch(_bufferMetric.lastEpoch + 1);\n _bufferMetric.lastEpoch = currentEpoch;\n\n // Copy numbers of totals\n PeriodVotingMetric storage _metric = _periodMetric[trackedPeriod];\n _metric.totalRequest += _bufferMetric.requests.length;\n _metric.totalBallot += _bufferMetric.data.totalBallot;\n\n // Copy voters info and voters' ballot\n for (uint i = 0; i < _bufferMetric.data.voters.length; ) {\n address voter = _bufferMetric.data.voters[i];\n _metric.totalBallotOf[voter] += _bufferMetric.data.totalBallotOf[voter];\n delete _bufferMetric.data.totalBallotOf[voter]; // need to manually delete each element, due to mapping\n\n unchecked {\n ++i;\n }\n }\n\n // Mark all receipts in the buffer as tracked. Keep total number of receipts and delete receipt details.\n for (uint i = 0; i < _bufferMetric.requests.length; ) {\n Request storage _bufferRequest = _bufferMetric.requests[i];\n ReceiptTrackingInfo storage _receiptInfo = _receiptTrackingInfo[_bufferRequest.kind][_bufferRequest.id];\n _receiptInfo.trackedPeriod = trackedPeriod;\n\n unchecked {\n ++i;\n }\n }\n\n delete _bufferMetric.requests;\n delete _bufferMetric.data;\n }\n }\n\n /**\n * @dev Returns whether the buffer stats must be counted or not.\n */\n function _isBufferCountedForPeriod(uint256 queriedPeriod) internal view returns (bool) {\n IRoninValidatorSet validatorContract = IRoninValidatorSet(getContract(ContractType.VALIDATOR));\n uint256 currentEpoch = validatorContract.epochOf(block.number);\n (bool filled, uint256 periodOfNextTemporaryEpoch) = validatorContract.tryGetPeriodOfEpoch(\n _bufferMetric.lastEpoch + 1\n );\n return filled && queriedPeriod == periodOfNextTemporaryEpoch && _bufferMetric.lastEpoch < currentEpoch;\n }\n}\n" + }, + "contracts/ronin/gateway/PauseEnforcer.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/access/AccessControlEnumerable.sol\";\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport \"../../interfaces/IPauseTarget.sol\";\n\ncontract PauseEnforcer is AccessControlEnumerable, Initializable {\n /**\n * @dev Error thrown when the target is already on paused state.\n */\n error ErrTargetIsOnPaused();\n\n /**\n * @dev Error thrown when the target is not on paused state.\n */\n error ErrTargetIsNotOnPaused();\n\n /**\n * @dev Error thrown when the contract is not on emergency pause.\n */\n error ErrNotOnEmergencyPause();\n\n bytes32 public constant SENTRY_ROLE = keccak256(\"SENTRY_ROLE\");\n\n /// @dev The contract that can be paused or unpaused by the SENTRY_ROLE.\n IPauseTarget public target;\n /// @dev Indicating whether or not the target contract is paused in emergency mode.\n bool public emergency;\n\n /// @dev Emitted when the emergency ppause is triggered by `account`.\n event EmergencyPaused(address account);\n /// @dev Emitted when the emergency unpause is triggered by `account`.\n event EmergencyUnpaused(address account);\n /// @dev Emitted when the target is changed.\n event TargetChanged(IPauseTarget target);\n\n modifier onEmergency() {\n if (!emergency) revert ErrNotOnEmergencyPause();\n\n _;\n }\n\n modifier targetPaused() {\n if (!target.paused()) revert ErrTargetIsOnPaused();\n\n _;\n }\n\n modifier targetNotPaused() {\n if (target.paused()) revert ErrTargetIsNotOnPaused();\n\n _;\n }\n\n constructor() {\n _disableInitializers();\n }\n\n /**\n * @dev Initializes the contract storage.\n */\n function initialize(IPauseTarget _target, address _admin, address[] memory _sentries) external initializer {\n _changeTarget(_target);\n _setupRole(DEFAULT_ADMIN_ROLE, _admin);\n for (uint _i; _i < _sentries.length; ) {\n _grantRole(SENTRY_ROLE, _sentries[_i]);\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @dev Grants the SENTRY_ROLE to the specified address.\n */\n function grantSentry(address _sentry) external onlyRole(DEFAULT_ADMIN_ROLE) {\n _grantRole(SENTRY_ROLE, _sentry);\n }\n\n /**\n * @dev Revokes the SENTRY_ROLE from the specified address.\n */\n function revokeSentry(address _sentry) external onlyRole(DEFAULT_ADMIN_ROLE) {\n _revokeRole(SENTRY_ROLE, _sentry);\n }\n\n /**\n * @dev Triggers a pause on the target contract.\n *\n * Requirements:\n * - Only be called by accounts with the SENTRY_ROLE,\n * - The target contract is not already paused.\n */\n function triggerPause() external onlyRole(SENTRY_ROLE) targetNotPaused {\n emergency = true;\n target.pause();\n emit EmergencyPaused(msg.sender);\n }\n\n /**\n * @dev Triggers an unpause on the target contract.\n *\n * Requirements:\n * - Only be called by accounts with the SENTRY_ROLE,\n * - The target contract is already paused.\n * - The target contract is paused in emergency mode.\n */\n function triggerUnpause() external onlyRole(SENTRY_ROLE) onEmergency targetPaused {\n emergency = false;\n target.unpause();\n emit EmergencyUnpaused(msg.sender);\n }\n\n /**\n * @dev Setter for `target`.\n *\n * Requirements:\n * - Only admin can call this method.\n */\n function changeTarget(IPauseTarget _target) external onlyRole(DEFAULT_ADMIN_ROLE) {\n _changeTarget(_target);\n }\n\n /**\n * @dev Internal helper for setting value to `target`.\n */\n function _changeTarget(IPauseTarget _target) internal {\n target = _target;\n emit TargetChanged(_target);\n }\n}\n" + }, + "contracts/ronin/gateway/RoninBridgeManager.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { ContractType, RoleAccess, ErrUnauthorized, BridgeManager } from \"../../extensions/bridge-operator-governance/BridgeManager.sol\";\nimport { Ballot, GlobalProposal, Proposal, GovernanceProposal } from \"../../extensions/sequential-governance/governance-proposal/GovernanceProposal.sol\";\nimport { CoreGovernance, GlobalCoreGovernance, GlobalGovernanceProposal } from \"../../extensions/sequential-governance/governance-proposal/GlobalGovernanceProposal.sol\";\nimport { VoteStatusConsumer } from \"../../interfaces/consumers/VoteStatusConsumer.sol\";\nimport { ErrQueryForEmptyVote } from \"../../utils/CommonErrors.sol\";\n\ncontract RoninBridgeManager is BridgeManager, GovernanceProposal, GlobalGovernanceProposal {\n constructor(\n uint256 num,\n uint256 denom,\n uint256 roninChainId,\n uint256 expiryDuration,\n address bridgeContract,\n address[] memory callbackRegisters,\n address[] memory bridgeOperators,\n address[] memory governors,\n uint96[] memory voteWeights,\n GlobalProposal.TargetOption[] memory targetOptions,\n address[] memory targets\n )\n payable\n CoreGovernance(expiryDuration)\n GlobalCoreGovernance(targetOptions, targets)\n BridgeManager(num, denom, roninChainId, bridgeContract, callbackRegisters, bridgeOperators, governors, voteWeights)\n {}\n\n /**\n * CURRENT NETWORK\n */\n\n /**\n * @dev See `CoreGovernance-_proposeProposal`.\n *\n * Requirements:\n * - The method caller is governor.\n *\n */\n function propose(\n uint256 _chainId,\n uint256 _expiryTimestamp,\n address[] calldata _targets,\n uint256[] calldata _values,\n bytes[] calldata _calldatas,\n uint256[] calldata _gasAmounts\n ) external onlyGovernor {\n _proposeProposal(_chainId, _expiryTimestamp, _targets, _values, _calldatas, _gasAmounts, msg.sender);\n }\n\n /**\n * @dev See `GovernanceProposal-_proposeProposalStructAndCastVotes`.\n *\n * Requirements:\n * - The method caller is governor.\n * - The proposal is for the current network.\n *\n */\n function proposeProposalStructAndCastVotes(\n Proposal.ProposalDetail calldata _proposal,\n Ballot.VoteType[] calldata _supports,\n Signature[] calldata _signatures\n ) external onlyGovernor {\n _proposeProposalStructAndCastVotes(_proposal, _supports, _signatures, DOMAIN_SEPARATOR, msg.sender);\n }\n\n /**\n * @dev Proposes and casts vote for a proposal on the current network.\n *\n * Requirements:\n * - The method caller is governor.\n * - The proposal is for the current network.\n *\n */\n function proposeProposalForCurrentNetwork(\n uint256 expiryTimestamp,\n address[] calldata targets,\n uint256[] calldata values,\n bytes[] calldata calldatas,\n uint256[] calldata gasAmounts,\n Ballot.VoteType support\n ) external onlyGovernor {\n address _voter = msg.sender;\n Proposal.ProposalDetail memory _proposal = _proposeProposal({\n chainId: block.chainid,\n expiryTimestamp: expiryTimestamp,\n targets: targets,\n values: values,\n calldatas: calldatas,\n gasAmounts: gasAmounts,\n creator: _voter\n });\n _castProposalVoteForCurrentNetwork(_voter, _proposal, support);\n }\n\n /**\n * @dev Casts vote for a proposal on the current network.\n *\n * Requirements:\n * - The method caller is governor.\n *\n */\n function castProposalVoteForCurrentNetwork(\n Proposal.ProposalDetail calldata proposal,\n Ballot.VoteType support\n ) external onlyGovernor {\n _castProposalVoteForCurrentNetwork(msg.sender, proposal, support);\n }\n\n /**\n * @dev See `GovernanceProposal-_castProposalBySignatures`.\n */\n function castProposalBySignatures(\n Proposal.ProposalDetail calldata proposal,\n Ballot.VoteType[] calldata supports_,\n Signature[] calldata signatures\n ) external {\n _castProposalBySignatures(proposal, supports_, signatures, DOMAIN_SEPARATOR);\n }\n\n /**\n * GLOBAL NETWORK\n */\n\n /**\n * @dev See `CoreGovernance-_proposeGlobal`.\n *\n * Requirements:\n * - The method caller is governor.\n *\n */\n function proposeGlobal(\n uint256 expiryTimestamp,\n GlobalProposal.TargetOption[] calldata targetOptions,\n uint256[] calldata values,\n bytes[] calldata calldatas,\n uint256[] calldata gasAmounts\n ) external onlyGovernor {\n _proposeGlobal({\n expiryTimestamp: expiryTimestamp,\n targetOptions: targetOptions,\n values: values,\n calldatas: calldatas,\n gasAmounts: gasAmounts,\n creator: msg.sender\n });\n }\n\n /**\n * @dev See `GovernanceProposal-_proposeGlobalProposalStructAndCastVotes`.\n *\n * Requirements:\n * - The method caller is governor.\n *\n */\n function proposeGlobalProposalStructAndCastVotes(\n GlobalProposal.GlobalProposalDetail calldata globalProposal,\n Ballot.VoteType[] calldata supports_,\n Signature[] calldata signatures\n ) external onlyGovernor {\n _proposeGlobalProposalStructAndCastVotes({\n globalProposal: globalProposal,\n supports_: supports_,\n signatures: signatures,\n domainSeparator: DOMAIN_SEPARATOR,\n creator: msg.sender\n });\n }\n\n /**\n * @dev See `GovernanceProposal-_castGlobalProposalBySignatures`.\n */\n function castGlobalProposalBySignatures(\n GlobalProposal.GlobalProposalDetail calldata globalProposal,\n Ballot.VoteType[] calldata supports_,\n Signature[] calldata signatures\n ) external {\n _castGlobalProposalBySignatures({\n globalProposal: globalProposal,\n supports_: supports_,\n signatures: signatures,\n domainSeparator: DOMAIN_SEPARATOR\n });\n }\n\n /**\n * COMMON METHODS\n */\n\n /**\n * @dev Deletes the expired proposal by its chainId and nonce, without creating a new proposal.\n *\n * Requirements:\n * - The proposal is already created.\n *\n */\n function deleteExpired(uint256 _chainId, uint256 _round) external {\n ProposalVote storage _vote = vote[_chainId][_round];\n if (_vote.hash == 0) revert ErrQueryForEmptyVote();\n\n _tryDeleteExpiredVotingRound(_vote);\n }\n\n /**\n * @dev Returns the expiry duration for a new proposal.\n */\n function getProposalExpiryDuration() external view returns (uint256) {\n return _getProposalExpiryDuration();\n }\n\n /**\n * @dev Internal function to get the chain type of the contract.\n * @return The chain type, indicating the type of the chain the contract operates on (e.g., RoninChain).\n */\n function _getChainType() internal pure override returns (ChainType) {\n return ChainType.RoninChain;\n }\n\n /**\n * @dev Internal function to get the total weights of all governors.\n * @return The total weights of all governors combined.\n */\n function _getTotalWeights() internal view virtual override returns (uint256) {\n return getTotalWeights();\n }\n\n /**\n * @dev Internal function to get the minimum vote weight required for governance actions.\n * @return The minimum vote weight required for governance actions.\n */\n function _getMinimumVoteWeight() internal view virtual override returns (uint256) {\n return minimumVoteWeight();\n }\n\n /**\n * @dev Internal function to get the vote weight of a specific governor.\n * @param _governor The address of the governor to get the vote weight for.\n * @return The vote weight of the specified governor.\n */\n function _getWeight(address _governor) internal view virtual override returns (uint256) {\n return _getGovernorWeight(_governor);\n }\n}\n" + }, + "contracts/ronin/gateway/RoninGatewayV2.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/access/AccessControlEnumerable.sol\";\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport \"../../extensions/GatewayV2.sol\";\nimport \"../../extensions/collections/HasContracts.sol\";\nimport \"../../extensions/MinimumWithdrawal.sol\";\nimport \"../../interfaces/IERC20Mintable.sol\";\nimport \"../../interfaces/IERC721Mintable.sol\";\nimport \"../../interfaces/bridge/IBridgeTracking.sol\";\nimport \"../../interfaces/IRoninGatewayV2.sol\";\nimport \"../../interfaces/IRoninTrustedOrganization.sol\";\nimport \"../../interfaces/consumers/VoteStatusConsumer.sol\";\nimport \"../../interfaces/validator/IRoninValidatorSet.sol\";\nimport \"../../libraries/IsolatedGovernance.sol\";\nimport \"../../interfaces/bridge/IBridgeManager.sol\";\n\ncontract RoninGatewayV2 is\n GatewayV2,\n Initializable,\n MinimumWithdrawal,\n AccessControlEnumerable,\n VoteStatusConsumer,\n IRoninGatewayV2,\n HasContracts\n{\n using Token for Token.Info;\n using Transfer for Transfer.Request;\n using Transfer for Transfer.Receipt;\n using IsolatedGovernance for IsolatedGovernance.Vote;\n\n /// @dev Withdrawal unlocker role hash\n bytes32 public constant WITHDRAWAL_MIGRATOR = keccak256(\"WITHDRAWAL_MIGRATOR\");\n\n /// @dev Flag indicating whether the withdrawal migrate progress is done\n bool public withdrawalMigrated;\n /// @dev Total withdrawal\n uint256 public withdrawalCount;\n /// @dev Mapping from chain id => deposit id => deposit vote\n mapping(uint256 => mapping(uint256 => IsolatedGovernance.Vote)) public depositVote;\n /// @dev Mapping from withdrawal id => mainchain withdrew vote\n mapping(uint256 => IsolatedGovernance.Vote) public mainchainWithdrewVote;\n /// @dev Mapping from withdrawal id => withdrawal receipt\n mapping(uint256 => Transfer.Receipt) public withdrawal;\n /// @dev Mapping from withdrawal id => validator address => signatures\n mapping(uint256 => mapping(address => bytes)) internal _withdrawalSig;\n /// @dev Mapping from token address => chain id => mainchain token address\n mapping(address => mapping(uint256 => MappedToken)) internal _mainchainToken;\n\n /// @custom:deprecated Previously `_validatorContract` (non-zero value)\n address private ____deprecated0;\n /// @custom:deprecated Previously `_bridgeTrackingContract` (non-zero value)\n address private ____deprecated1;\n\n /// @dev Mapping from withdrawal id => vote for recording withdrawal stats\n mapping(uint256 => IsolatedGovernance.Vote) public withdrawalStatVote;\n\n /// @custom:deprecated Previously `_trustedOrgContract` (non-zero value)\n address private ____deprecated2;\n\n uint256 internal _trustedNum;\n uint256 internal _trustedDenom;\n\n fallback() external payable {\n _fallback();\n }\n\n receive() external payable {\n _fallback();\n }\n\n modifier onlyBridgeOperator() {\n _requireBridgeOperator();\n _;\n }\n\n /**\n * @dev Reverts if the method caller is not bridge operator.\n */\n function _requireBridgeOperator() internal view {\n if (!IBridgeManager(getContract(ContractType.BRIDGE_MANAGER)).isBridgeOperator(msg.sender))\n revert ErrUnauthorized(msg.sig, RoleAccess.__DEPRECATED_BRIDGE_OPERATOR);\n }\n\n /**\n * @dev Initializes contract storage.\n */\n function initialize(\n address _roleSetter,\n uint256 _numerator,\n uint256 _denominator,\n uint256 _trustedNumerator,\n uint256 _trustedDenominator,\n address[] calldata _withdrawalMigrators,\n // _packedAddresses[0]: roninTokens\n // _packedAddresses[1]: mainchainTokens\n address[][2] calldata _packedAddresses,\n // _packedNumbers[0]: chainIds\n // _packedNumbers[1]: minimumThresholds\n uint256[][2] calldata _packedNumbers,\n Token.Standard[] calldata _standards\n ) external virtual initializer {\n _setupRole(DEFAULT_ADMIN_ROLE, _roleSetter);\n _setThreshold(_numerator, _denominator);\n _setTrustedThreshold(_trustedNumerator, _trustedDenominator);\n if (_packedAddresses[0].length > 0) {\n _mapTokens(_packedAddresses[0], _packedAddresses[1], _packedNumbers[0], _standards);\n _setMinimumThresholds(_packedAddresses[0], _packedNumbers[1]);\n }\n\n for (uint256 _i; _i < _withdrawalMigrators.length; ) {\n _grantRole(WITHDRAWAL_MIGRATOR, _withdrawalMigrators[_i]);\n\n unchecked {\n ++_i;\n }\n }\n }\n\n function initializeV2() external reinitializer(2) {\n _setContract(ContractType.VALIDATOR, ____deprecated0);\n _setContract(ContractType.BRIDGE_TRACKING, ____deprecated1);\n _setContract(ContractType.RONIN_TRUSTED_ORGANIZATION, ____deprecated2);\n delete ____deprecated0;\n delete ____deprecated1;\n delete ____deprecated2;\n }\n\n function initializeV3(address bridgeAdmin) external reinitializer(3) {\n _setContract(ContractType.BRIDGE_MANAGER, bridgeAdmin);\n }\n\n /**\n * @dev Migrates withdrawals.\n *\n * Requirements:\n * - The method caller is the migrator.\n * - The arrays have the same length and its length larger than 0.\n *\n */\n function migrateWithdrawals(\n Transfer.Request[] calldata _requests,\n address[] calldata _requesters\n ) external onlyRole(WITHDRAWAL_MIGRATOR) {\n if (withdrawalMigrated) revert ErrWithdrawalsMigrated();\n if (!(_requesters.length == _requests.length && _requests.length > 0)) revert ErrLengthMismatch(msg.sig);\n\n for (uint256 _i; _i < _requests.length; ) {\n MappedToken memory _token = getMainchainToken(_requests[_i].tokenAddr, 1);\n if (_requests[_i].info.erc != _token.erc) revert ErrInvalidTokenStandard();\n\n _storeAsReceipt(_requests[_i], 1, _requesters[_i], _token.tokenAddr);\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @dev Mark the migration as done.\n */\n function markWithdrawalMigrated() external {\n if (!(hasRole(DEFAULT_ADMIN_ROLE, msg.sender) || hasRole(WITHDRAWAL_MIGRATOR, msg.sender))) {\n revert ErrUnauthorized(msg.sig, RoleAccess.WITHDRAWAL_MIGRATOR);\n }\n if (withdrawalMigrated) revert ErrWithdrawalsMigrated();\n\n withdrawalMigrated = true;\n }\n\n /**\n * @inheritdoc IRoninGatewayV2\n */\n function getWithdrawalSignatures(\n uint256 _withdrawalId,\n address[] calldata _validators\n ) external view returns (bytes[] memory _signatures) {\n _signatures = new bytes[](_validators.length);\n for (uint256 _i = 0; _i < _validators.length; ) {\n _signatures[_i] = _withdrawalSig[_withdrawalId][_validators[_i]];\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IRoninGatewayV2\n */\n function depositFor(Transfer.Receipt calldata _receipt) external whenNotPaused onlyBridgeOperator {\n address _sender = msg.sender;\n _depositFor(_receipt, _sender, minimumVoteWeight());\n IBridgeTracking(getContract(ContractType.BRIDGE_TRACKING)).recordVote(\n IBridgeTracking.VoteKind.Deposit,\n _receipt.id,\n _sender\n );\n }\n\n /**\n * @inheritdoc IRoninGatewayV2\n */\n function tryBulkAcknowledgeMainchainWithdrew(\n uint256[] calldata _withdrawalIds\n ) external onlyBridgeOperator returns (bool[] memory _executedReceipts) {\n address _governor = msg.sender;\n uint256 _minVoteWeight = minimumVoteWeight();\n\n uint256 _withdrawalId;\n _executedReceipts = new bool[](_withdrawalIds.length);\n IBridgeTracking _bridgeTrackingContract = IBridgeTracking(getContract(ContractType.BRIDGE_TRACKING));\n for (uint256 _i; _i < _withdrawalIds.length; ) {\n _withdrawalId = _withdrawalIds[_i];\n _bridgeTrackingContract.recordVote(IBridgeTracking.VoteKind.MainchainWithdrawal, _withdrawalId, _governor);\n if (mainchainWithdrew(_withdrawalId)) {\n _executedReceipts[_i] = true;\n } else {\n IsolatedGovernance.Vote storage _vote = mainchainWithdrewVote[_withdrawalId];\n Transfer.Receipt memory _withdrawal = withdrawal[_withdrawalId];\n bytes32 _hash = _withdrawal.hash();\n VoteStatus _status = _castIsolatedVote(_vote, _governor, _minVoteWeight, _hash);\n if (_status == VoteStatus.Approved) {\n _vote.status = VoteStatus.Executed;\n _bridgeTrackingContract.handleVoteApproved(IBridgeTracking.VoteKind.MainchainWithdrawal, _withdrawalId);\n emit MainchainWithdrew(_hash, _withdrawal);\n }\n }\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IRoninGatewayV2\n */\n function tryBulkDepositFor(\n Transfer.Receipt[] calldata _receipts\n ) external whenNotPaused onlyBridgeOperator returns (bool[] memory _executedReceipts) {\n address _sender = msg.sender;\n\n Transfer.Receipt memory _receipt;\n _executedReceipts = new bool[](_receipts.length);\n uint256 _minVoteWeight = minimumVoteWeight();\n IBridgeTracking _bridgeTrackingContract = IBridgeTracking(getContract(ContractType.BRIDGE_TRACKING));\n for (uint256 _i; _i < _receipts.length; ) {\n _receipt = _receipts[_i];\n _bridgeTrackingContract.recordVote(IBridgeTracking.VoteKind.Deposit, _receipt.id, _sender);\n if (depositVote[_receipt.mainchain.chainId][_receipt.id].status == VoteStatus.Executed) {\n _executedReceipts[_i] = true;\n } else {\n _depositFor(_receipt, _sender, _minVoteWeight);\n }\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IRoninGatewayV2\n */\n function requestWithdrawalFor(Transfer.Request calldata _request, uint256 _chainId) external whenNotPaused {\n _requestWithdrawalFor(_request, msg.sender, _chainId);\n }\n\n /**\n * @inheritdoc IRoninGatewayV2\n */\n function bulkRequestWithdrawalFor(Transfer.Request[] calldata _requests, uint256 _chainId) external whenNotPaused {\n if (_requests.length == 0) revert ErrEmptyArray();\n\n for (uint256 _i; _i < _requests.length; ) {\n _requestWithdrawalFor(_requests[_i], msg.sender, _chainId);\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IRoninGatewayV2\n */\n function requestWithdrawalSignatures(uint256 _withdrawalId) external whenNotPaused {\n if (mainchainWithdrew(_withdrawalId)) revert ErrWithdrawnOnMainchainAlready();\n\n Transfer.Receipt memory _receipt = withdrawal[_withdrawalId];\n if (_receipt.ronin.chainId != block.chainid) {\n revert ErrInvalidChainId(msg.sig, _receipt.ronin.chainId, block.chainid);\n }\n\n emit WithdrawalSignaturesRequested(_receipt.hash(), _receipt);\n }\n\n /**\n * @inheritdoc IRoninGatewayV2\n */\n function bulkSubmitWithdrawalSignatures(\n uint256[] calldata _withdrawals,\n bytes[] calldata _signatures\n ) external whenNotPaused onlyBridgeOperator {\n address _validator = msg.sender;\n\n if (!(_withdrawals.length > 0 && _withdrawals.length == _signatures.length)) {\n revert ErrLengthMismatch(msg.sig);\n }\n\n uint256 _minVoteWeight = minimumVoteWeight();\n\n uint256 _id;\n IBridgeTracking _bridgeTrackingContract = IBridgeTracking(getContract(ContractType.BRIDGE_TRACKING));\n for (uint256 _i; _i < _withdrawals.length; ) {\n _id = _withdrawals[_i];\n _withdrawalSig[_id][_validator] = _signatures[_i];\n _bridgeTrackingContract.recordVote(IBridgeTracking.VoteKind.Withdrawal, _id, _validator);\n\n IsolatedGovernance.Vote storage _proposal = withdrawalStatVote[_id];\n VoteStatus _status = _castIsolatedVote(_proposal, _validator, _minVoteWeight, bytes32(_id));\n if (_status == VoteStatus.Approved) {\n _proposal.status = VoteStatus.Executed;\n _bridgeTrackingContract.handleVoteApproved(IBridgeTracking.VoteKind.Withdrawal, _id);\n }\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IRoninGatewayV2\n */\n function mapTokens(\n address[] calldata _roninTokens,\n address[] calldata _mainchainTokens,\n uint256[] calldata _chainIds,\n Token.Standard[] calldata _standards\n ) external onlyAdmin {\n if (_roninTokens.length == 0) revert ErrLengthMismatch(msg.sig);\n _mapTokens(_roninTokens, _mainchainTokens, _chainIds, _standards);\n }\n\n /**\n * @inheritdoc IRoninGatewayV2\n */\n function depositVoted(uint256 _chainId, uint256 _depositId, address _voter) external view returns (bool) {\n return depositVote[_chainId][_depositId].voted(_voter);\n }\n\n /**\n * @inheritdoc IRoninGatewayV2\n */\n function mainchainWithdrewVoted(uint256 _withdrawalId, address _voter) external view returns (bool) {\n return mainchainWithdrewVote[_withdrawalId].voted(_voter);\n }\n\n /**\n * @inheritdoc IRoninGatewayV2\n */\n function mainchainWithdrew(uint256 _withdrawalId) public view returns (bool) {\n return mainchainWithdrewVote[_withdrawalId].status == VoteStatus.Executed;\n }\n\n /**\n * @inheritdoc IRoninGatewayV2\n */\n function getMainchainToken(address _roninToken, uint256 _chainId) public view returns (MappedToken memory _token) {\n _token = _mainchainToken[_roninToken][_chainId];\n if (_token.tokenAddr == address(0)) revert ErrUnsupportedToken();\n }\n\n /**\n * @dev Maps Ronin tokens to mainchain networks.\n *\n * Requirement:\n * - The arrays have the same length.\n *\n * Emits the `TokenMapped` event.\n *\n */\n function _mapTokens(\n address[] calldata _roninTokens,\n address[] calldata _mainchainTokens,\n uint256[] calldata _chainIds,\n Token.Standard[] calldata _standards\n ) internal {\n if (!(_roninTokens.length == _mainchainTokens.length && _roninTokens.length == _chainIds.length))\n revert ErrLengthMismatch(msg.sig);\n\n for (uint256 _i; _i < _roninTokens.length; ) {\n _mainchainToken[_roninTokens[_i]][_chainIds[_i]].tokenAddr = _mainchainTokens[_i];\n _mainchainToken[_roninTokens[_i]][_chainIds[_i]].erc = _standards[_i];\n\n unchecked {\n ++_i;\n }\n }\n\n emit TokenMapped(_roninTokens, _mainchainTokens, _chainIds, _standards);\n }\n\n /**\n * @dev Deposits based on the receipt.\n *\n * Emits the `Deposited` once the assets are released.\n *\n */\n function _depositFor(Transfer.Receipt memory _receipt, address _validator, uint256 _minVoteWeight) internal {\n uint256 _id = _receipt.id;\n _receipt.info.validate();\n if (_receipt.kind != Transfer.Kind.Deposit) revert ErrInvalidReceiptKind();\n\n if (_receipt.ronin.chainId != block.chainid)\n revert ErrInvalidChainId(msg.sig, _receipt.ronin.chainId, block.chainid);\n\n MappedToken memory _token = getMainchainToken(_receipt.ronin.tokenAddr, _receipt.mainchain.chainId);\n\n if (!(_token.erc == _receipt.info.erc && _token.tokenAddr == _receipt.mainchain.tokenAddr))\n revert ErrInvalidReceipt();\n\n IsolatedGovernance.Vote storage _proposal = depositVote[_receipt.mainchain.chainId][_id];\n bytes32 _receiptHash = _receipt.hash();\n VoteStatus _status = _castIsolatedVote(_proposal, _validator, _minVoteWeight, _receiptHash);\n emit DepositVoted(_validator, _id, _receipt.mainchain.chainId, _receiptHash);\n if (_status == VoteStatus.Approved) {\n _proposal.status = VoteStatus.Executed;\n _receipt.info.handleAssetTransfer(payable(_receipt.ronin.addr), _receipt.ronin.tokenAddr, IWETH(address(0)));\n IBridgeTracking(getContract(ContractType.BRIDGE_TRACKING)).handleVoteApproved(\n IBridgeTracking.VoteKind.Deposit,\n _receipt.id\n );\n emit Deposited(_receiptHash, _receipt);\n }\n }\n\n /**\n * @dev Locks the assets and request withdrawal.\n *\n * Requirements:\n * - The token info is valid.\n *\n * Emits the `WithdrawalRequested` event.\n *\n */\n function _requestWithdrawalFor(Transfer.Request calldata _request, address _requester, uint256 _chainId) internal {\n _request.info.validate();\n _checkWithdrawal(_request);\n MappedToken memory _token = getMainchainToken(_request.tokenAddr, _chainId);\n if (_request.info.erc != _token.erc) revert ErrInvalidTokenStandard();\n\n _request.info.transferFrom(_requester, address(this), _request.tokenAddr);\n _storeAsReceipt(_request, _chainId, _requester, _token.tokenAddr);\n }\n\n /**\n * @dev Stores the withdrawal request as a receipt.\n *\n * Emits the `WithdrawalRequested` event.\n *\n */\n function _storeAsReceipt(\n Transfer.Request calldata _request,\n uint256 _chainId,\n address _requester,\n address _mainchainTokenAddr\n ) internal returns (uint256 _withdrawalId) {\n _withdrawalId = withdrawalCount++;\n Transfer.Receipt memory _receipt = _request.into_withdrawal_receipt(\n _requester,\n _withdrawalId,\n _mainchainTokenAddr,\n _chainId\n );\n withdrawal[_withdrawalId] = _receipt;\n emit WithdrawalRequested(_receipt.hash(), _receipt);\n }\n\n /**\n * @dev Don't send me RON.\n */\n function _fallback() internal virtual {\n revert ErrInvalidRequest();\n }\n\n /**\n * @inheritdoc GatewayV2\n */\n function _getTotalWeight() internal view virtual override returns (uint256) {\n return IBridgeManager(getContract(ContractType.BRIDGE_MANAGER)).getTotalWeights();\n }\n\n /**\n * @dev Casts and updates the vote result.\n *\n * Requirements:\n * - The vote is not finalized.\n * - The voter has not voted for the round.\n *\n */\n function _castIsolatedVote(\n IsolatedGovernance.Vote storage _v,\n address _voter,\n uint256 _minVoteWeight,\n bytes32 _hash\n ) internal virtual returns (VoteStatus _status) {\n _v.castVote(_voter, _hash);\n uint256 _totalWeight = _getVoteWeight(_v, _hash);\n return _v.syncVoteStatus(_minVoteWeight, _totalWeight, _hash);\n }\n\n /**\n * @dev Returns the vote weight for a specified hash.\n */\n function _getVoteWeight(\n IsolatedGovernance.Vote storage _v,\n bytes32 _hash\n ) internal view returns (uint256 _totalWeight) {\n (, address[] memory bridgeOperators, uint256[] memory weights) = IBridgeManager(\n getContract(ContractType.BRIDGE_MANAGER)\n ).getFullBridgeOperatorInfos();\n uint256 length = bridgeOperators.length;\n unchecked {\n for (uint _i; _i < length; ++_i) {\n if (_v.voteHashOf[bridgeOperators[_i]] == _hash) {\n _totalWeight += weights[_i];\n }\n }\n }\n }\n\n function setTrustedThreshold(\n uint256 _trustedNumerator,\n uint256 _trustedDenominator\n ) external virtual onlyAdmin returns (uint256, uint256) {\n return _setTrustedThreshold(_trustedNumerator, _trustedDenominator);\n }\n\n /**\n * @dev Returns the threshold about trusted org.\n */\n function getTrustedThreshold() external view virtual returns (uint256 trustedNum_, uint256 trustedDenom_) {\n return (_trustedNum, _trustedDenom);\n }\n\n /**\n * @dev Sets trusted threshold and returns the old one.\n *\n * Emits the `TrustedThresholdUpdated` event.\n *\n */\n function _setTrustedThreshold(\n uint256 _trustedNumerator,\n uint256 _trustedDenominator\n ) internal virtual returns (uint256 _previousTrustedNum, uint256 _previousTrustedDenom) {\n if (_trustedNumerator > _trustedDenominator) revert ErrInvalidTrustedThreshold();\n\n _previousTrustedNum = _num;\n _previousTrustedDenom = _denom;\n _trustedNum = _trustedNumerator;\n _trustedDenom = _trustedDenominator;\n unchecked {\n emit TrustedThresholdUpdated(\n nonce++,\n _trustedNumerator,\n _trustedDenominator,\n _previousTrustedNum,\n _previousTrustedDenom\n );\n }\n }\n\n /**\n * @dev Returns minimum trusted vote weight.\n */\n function _minimumTrustedVoteWeight(uint256 _totalTrustedWeight) internal view virtual returns (uint256) {\n return (_trustedNum * _totalTrustedWeight + _trustedDenom - 1) / _trustedDenom;\n }\n}\n" + }, + "contracts/ronin/Maintenance.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport \"../interfaces/IMaintenance.sol\";\nimport \"../interfaces/validator/IRoninValidatorSet.sol\";\nimport \"../extensions/collections/HasContracts.sol\";\nimport \"../libraries/Math.sol\";\nimport { HasValidatorDeprecated } from \"../utils/DeprecatedSlots.sol\";\nimport { ErrUnauthorized, RoleAccess } from \"../utils/CommonErrors.sol\";\n\ncontract Maintenance is IMaintenance, HasContracts, HasValidatorDeprecated, Initializable {\n using Math for uint256;\n\n /// @dev Mapping from consensus address => maintenance schedule.\n mapping(address => Schedule) internal _schedule;\n\n /// @dev The min duration to maintenance in blocks.\n uint256 public minMaintenanceDurationInBlock;\n /// @dev The max duration to maintenance in blocks.\n uint256 public maxMaintenanceDurationInBlock;\n /// @dev The offset to the min block number that the schedule can start.\n uint256 public minOffsetToStartSchedule;\n /// @dev The offset to the max block number that the schedule can start.\n uint256 public maxOffsetToStartSchedule;\n /// @dev The max number of scheduled maintenances.\n uint256 public maxSchedules;\n /// @dev The cooldown time to request new schedule.\n uint256 public cooldownSecsToMaintain;\n\n constructor() {\n _disableInitializers();\n }\n\n /**\n * @dev Initializes the contract storage.\n */\n function initialize(\n address __validatorContract,\n uint256 _minMaintenanceDurationInBlock,\n uint256 _maxMaintenanceDurationInBlock,\n uint256 _minOffsetToStartSchedule,\n uint256 _maxOffsetToStartSchedule,\n uint256 _maxSchedules,\n uint256 _cooldownSecsToMaintain\n ) external initializer {\n _setContract(ContractType.VALIDATOR, __validatorContract);\n _setMaintenanceConfig(\n _minMaintenanceDurationInBlock,\n _maxMaintenanceDurationInBlock,\n _minOffsetToStartSchedule,\n _maxOffsetToStartSchedule,\n _maxSchedules,\n _cooldownSecsToMaintain\n );\n }\n\n function initializeV2() external reinitializer(2) {\n _setContract(ContractType.VALIDATOR, ______deprecatedValidator);\n delete ______deprecatedValidator;\n }\n\n /**\n * @inheritdoc IMaintenance\n */\n function setMaintenanceConfig(\n uint256 _minMaintenanceDurationInBlock,\n uint256 _maxMaintenanceDurationInBlock,\n uint256 _minOffsetToStartSchedule,\n uint256 _maxOffsetToStartSchedule,\n uint256 _maxSchedules,\n uint256 _cooldownSecsToMaintain\n ) external onlyAdmin {\n _setMaintenanceConfig(\n _minMaintenanceDurationInBlock,\n _maxMaintenanceDurationInBlock,\n _minOffsetToStartSchedule,\n _maxOffsetToStartSchedule,\n _maxSchedules,\n _cooldownSecsToMaintain\n );\n }\n\n /**\n * @inheritdoc IMaintenance\n */\n function schedule(address _consensusAddr, uint256 _startedAtBlock, uint256 _endedAtBlock) external override {\n IRoninValidatorSet _validator = IRoninValidatorSet(getContract(ContractType.VALIDATOR));\n\n if (!_validator.isBlockProducer(_consensusAddr)) revert ErrUnauthorized(msg.sig, RoleAccess.BLOCK_PRODUCER);\n if (!_validator.isCandidateAdmin(_consensusAddr, msg.sender))\n revert ErrUnauthorized(msg.sig, RoleAccess.CANDIDATE_ADMIN);\n if (checkScheduled(_consensusAddr)) revert ErrAlreadyScheduled();\n if (!checkCooldownEnds(_consensusAddr)) revert ErrCooldownTimeNotYetEnded();\n if (totalSchedules() >= maxSchedules) revert ErrTotalOfSchedulesExceeded();\n if (!_startedAtBlock.inRange(block.number + minOffsetToStartSchedule, block.number + maxOffsetToStartSchedule)) {\n revert ErrStartBlockOutOfRange();\n }\n if (_startedAtBlock >= _endedAtBlock) revert ErrStartBlockOutOfRange();\n\n uint256 _maintenanceElapsed = _endedAtBlock - _startedAtBlock + 1;\n\n if (!_maintenanceElapsed.inRange(minMaintenanceDurationInBlock, maxMaintenanceDurationInBlock)) {\n revert ErrInvalidMaintenanceDuration();\n }\n if (!_validator.epochEndingAt(_startedAtBlock - 1)) revert ErrStartBlockOutOfRange();\n if (!_validator.epochEndingAt(_endedAtBlock)) revert ErrEndBlockOutOfRange();\n\n Schedule storage _sSchedule = _schedule[_consensusAddr];\n _sSchedule.from = _startedAtBlock;\n _sSchedule.to = _endedAtBlock;\n _sSchedule.lastUpdatedBlock = block.number;\n _sSchedule.requestTimestamp = block.timestamp;\n emit MaintenanceScheduled(_consensusAddr, _sSchedule);\n }\n\n /**\n * @inheritdoc IMaintenance\n */\n function cancelSchedule(address _consensusAddr) external override {\n if (!IRoninValidatorSet(getContract(ContractType.VALIDATOR)).isCandidateAdmin(_consensusAddr, msg.sender)) {\n revert ErrUnauthorized(msg.sig, RoleAccess.CANDIDATE_ADMIN);\n }\n if (!checkScheduled(_consensusAddr)) revert ErrUnexistedSchedule();\n if (checkMaintained(_consensusAddr, block.number)) revert ErrAlreadyOnMaintenance();\n\n Schedule storage _sSchedule = _schedule[_consensusAddr];\n delete _sSchedule.from;\n delete _sSchedule.to;\n _sSchedule.lastUpdatedBlock = block.number;\n emit MaintenanceScheduleCancelled(_consensusAddr);\n }\n\n /**\n * @inheritdoc IMaintenance\n */\n function getSchedule(address _consensusAddr) external view override returns (Schedule memory) {\n return _schedule[_consensusAddr];\n }\n\n /**\n * @inheritdoc IMaintenance\n */\n function checkManyMaintained(\n address[] calldata _addrList,\n uint256 _block\n ) external view override returns (bool[] memory _resList) {\n _resList = new bool[](_addrList.length);\n for (uint _i = 0; _i < _addrList.length; ) {\n _resList[_i] = checkMaintained(_addrList[_i], _block);\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IMaintenance\n */\n function checkManyMaintainedInBlockRange(\n address[] calldata _addrList,\n uint256 _fromBlock,\n uint256 _toBlock\n ) external view override returns (bool[] memory _resList) {\n _resList = new bool[](_addrList.length);\n for (uint _i = 0; _i < _addrList.length; ) {\n _resList[_i] = _maintainingInBlockRange(_addrList[_i], _fromBlock, _toBlock);\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IMaintenance\n */\n function totalSchedules() public view override returns (uint256 _count) {\n address[] memory _validators = IRoninValidatorSet(getContract(ContractType.VALIDATOR)).getValidators();\n unchecked {\n for (uint _i = 0; _i < _validators.length; _i++) {\n if (checkScheduled(_validators[_i])) {\n _count++;\n }\n }\n }\n }\n\n /**\n * @inheritdoc IMaintenance\n */\n function checkMaintained(address _consensusAddr, uint256 _block) public view override returns (bool) {\n Schedule storage _s = _schedule[_consensusAddr];\n return _s.from <= _block && _block <= _s.to;\n }\n\n /**\n * @inheritdoc IMaintenance\n */\n function checkMaintainedInBlockRange(\n address _consensusAddr,\n uint256 _fromBlock,\n uint256 _toBlock\n ) public view override returns (bool) {\n return _maintainingInBlockRange(_consensusAddr, _fromBlock, _toBlock);\n }\n\n /**\n * @inheritdoc IMaintenance\n */\n function checkScheduled(address _consensusAddr) public view override returns (bool) {\n return block.number <= _schedule[_consensusAddr].to;\n }\n\n /**\n * @inheritdoc IMaintenance\n */\n function checkCooldownEnds(address _consensusAddr) public view override returns (bool) {\n return block.timestamp > _schedule[_consensusAddr].requestTimestamp + cooldownSecsToMaintain;\n }\n\n /**\n * @dev Sets the min block period and max block period to maintenance.\n *\n * Requirements:\n * - The max period is larger than the min period.\n *\n * Emits the event `MaintenanceConfigUpdated`.\n *\n */\n function _setMaintenanceConfig(\n uint256 _minMaintenanceDurationInBlock,\n uint256 _maxMaintenanceDurationInBlock,\n uint256 _minOffsetToStartSchedule,\n uint256 _maxOffsetToStartSchedule,\n uint256 _maxSchedules,\n uint256 _cooldownSecsToMaintain\n ) internal {\n if (_minMaintenanceDurationInBlock >= _maxMaintenanceDurationInBlock) revert ErrInvalidMaintenanceDurationConfig();\n if (_minOffsetToStartSchedule >= _maxOffsetToStartSchedule) revert ErrInvalidOffsetToStartScheduleConfigs();\n\n minMaintenanceDurationInBlock = _minMaintenanceDurationInBlock;\n maxMaintenanceDurationInBlock = _maxMaintenanceDurationInBlock;\n minOffsetToStartSchedule = _minOffsetToStartSchedule;\n maxOffsetToStartSchedule = _maxOffsetToStartSchedule;\n maxSchedules = _maxSchedules;\n cooldownSecsToMaintain = _cooldownSecsToMaintain;\n emit MaintenanceConfigUpdated(\n _minMaintenanceDurationInBlock,\n _maxMaintenanceDurationInBlock,\n _minOffsetToStartSchedule,\n _maxOffsetToStartSchedule,\n _maxSchedules,\n _cooldownSecsToMaintain\n );\n }\n\n /**\n * @dev Check if the validator was maintaining in the current period.\n *\n * Note: This method should be called at the end of the period.\n */\n function _maintainingInBlockRange(\n address _consensusAddr,\n uint256 _fromBlock,\n uint256 _toBlock\n ) private view returns (bool) {\n Schedule storage _s = _schedule[_consensusAddr];\n return Math.twoRangeOverlap(_fromBlock, _toBlock, _s.from, _s.to);\n }\n}\n" + }, + "contracts/ronin/RoninGovernanceAdmin.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../extensions/sequential-governance/governance-proposal/GovernanceProposal.sol\";\nimport \"../extensions/collections/HasContracts.sol\";\nimport \"../extensions/GovernanceAdmin.sol\";\nimport \"../libraries/EmergencyExitBallot.sol\";\nimport { ErrorHandler } from \"../libraries/ErrorHandler.sol\";\nimport { IsolatedGovernance } from \"../libraries/IsolatedGovernance.sol\";\nimport { HasValidatorDeprecated } from \"../utils/DeprecatedSlots.sol\";\nimport \"../interfaces/IRoninTrustedOrganization.sol\";\nimport \"../interfaces/validator/IRoninValidatorSet.sol\";\nimport \"../interfaces/IRoninGovernanceAdmin.sol\";\n\ncontract RoninGovernanceAdmin is\n HasContracts,\n IRoninGovernanceAdmin,\n GovernanceAdmin,\n GovernanceProposal,\n HasValidatorDeprecated\n{\n using ErrorHandler for bool;\n using Proposal for Proposal.ProposalDetail;\n using IsolatedGovernance for IsolatedGovernance.Vote;\n\n /// @dev Mapping from request hash => emergency poll\n mapping(bytes32 => IsolatedGovernance.Vote) internal _emergencyExitPoll;\n\n modifier onlyGovernor() {\n _requireGorvernor();\n _;\n }\n\n constructor(\n uint256 _roninChainId,\n address _roninTrustedOrganizationContract,\n address _validatorContract,\n uint256 _expiryDuration\n ) CoreGovernance(_expiryDuration) GovernanceAdmin(_roninChainId, _roninTrustedOrganizationContract) {\n _setContract(ContractType.VALIDATOR, _validatorContract);\n }\n\n function _requireGorvernor() private view {\n if (_getWeight(msg.sender) == 0) revert ErrUnauthorized(msg.sig, RoleAccess.GOVERNOR);\n }\n\n /**\n * @inheritdoc IHasContracts\n */\n function setContract(\n ContractType contractType,\n address addr\n ) external override(HasContracts, GovernanceAdmin) onlySelfCall {\n _requireHasCode(addr);\n _setContract(contractType, addr);\n }\n\n /**\n * @dev Returns whether the voter casted vote for emergency exit poll.\n */\n function emergencyPollVoted(bytes32 _voteHash, address _voter) external view returns (bool) {\n return _emergencyExitPoll[_voteHash].voted(_voter);\n }\n\n /**\n * @dev See `CoreGovernance-_proposeProposal`.\n *\n * Requirements:\n * - The method caller is governor.\n *\n */\n function propose(\n uint256 _chainId,\n uint256 _expiryTimestamp,\n address[] calldata _targets,\n uint256[] calldata _values,\n bytes[] calldata _calldatas,\n uint256[] calldata _gasAmounts\n ) external onlyGovernor {\n _proposeProposal(_chainId, _expiryTimestamp, _targets, _values, _calldatas, _gasAmounts, msg.sender);\n }\n\n /**\n * @dev See `GovernanceProposal-_proposeProposalStructAndCastVotes`.\n *\n * Requirements:\n * - The method caller is governor.\n * - The proposal is for the current network.\n *\n */\n function proposeProposalStructAndCastVotes(\n Proposal.ProposalDetail calldata _proposal,\n Ballot.VoteType[] calldata _supports,\n Signature[] calldata _signatures\n ) external onlyGovernor {\n _proposeProposalStructAndCastVotes(_proposal, _supports, _signatures, DOMAIN_SEPARATOR, msg.sender);\n }\n\n /**\n * @dev Proposes and casts vote for a proposal on the current network.\n *\n * Requirements:\n * - The method caller is governor.\n * - The proposal is for the current network.\n *\n */\n function proposeProposalForCurrentNetwork(\n uint256 _expiryTimestamp,\n address[] calldata _targets,\n uint256[] calldata _values,\n bytes[] calldata _calldatas,\n uint256[] calldata _gasAmounts,\n Ballot.VoteType _support\n ) external onlyGovernor {\n address _voter = msg.sender;\n Proposal.ProposalDetail memory _proposal = _proposeProposal(\n block.chainid,\n _expiryTimestamp,\n _targets,\n _values,\n _calldatas,\n _gasAmounts,\n _voter\n );\n _castProposalVoteForCurrentNetwork(_voter, _proposal, _support);\n }\n\n /**\n * @dev Casts vote for a proposal on the current network.\n *\n * Requirements:\n * - The method caller is governor.\n *\n */\n function castProposalVoteForCurrentNetwork(\n Proposal.ProposalDetail calldata _proposal,\n Ballot.VoteType _support\n ) external onlyGovernor {\n _castProposalVoteForCurrentNetwork(msg.sender, _proposal, _support);\n }\n\n /**\n * @dev See `GovernanceProposal-_castProposalBySignatures`.\n */\n function castProposalBySignatures(\n Proposal.ProposalDetail calldata _proposal,\n Ballot.VoteType[] calldata _supports,\n Signature[] calldata _signatures\n ) external {\n _castProposalBySignatures(_proposal, _supports, _signatures, DOMAIN_SEPARATOR);\n }\n\n /**\n * @dev Deletes the expired proposal by its chainId and nonce, without creating a new proposal.\n *\n * Requirements:\n * - The proposal is already created.\n *\n */\n function deleteExpired(uint256 _chainId, uint256 _round) external {\n ProposalVote storage _vote = vote[_chainId][_round];\n if (_vote.hash == 0) revert ErrQueryForEmptyVote();\n\n _tryDeleteExpiredVotingRound(_vote);\n }\n\n /**\n * @inheritdoc IRoninGovernanceAdmin\n */\n function createEmergencyExitPoll(\n address _consensusAddr,\n address _recipientAfterUnlockedFund,\n uint256 _requestedAt,\n uint256 _expiredAt\n ) external onlyContract(ContractType.VALIDATOR) {\n bytes32 _hash = EmergencyExitBallot.hash(_consensusAddr, _recipientAfterUnlockedFund, _requestedAt, _expiredAt);\n IsolatedGovernance.Vote storage _v = _emergencyExitPoll[_hash];\n _v.createdAt = block.timestamp;\n _v.expiredAt = _expiredAt;\n emit EmergencyExitPollCreated(_hash, _consensusAddr, _recipientAfterUnlockedFund, _requestedAt, _expiredAt);\n }\n\n /**\n * @dev Votes for an emergency exit. Executes to unlock fund for the emergency exit's requester.\n *\n * Requirements:\n * - The voter is governor.\n * - The voting is existent.\n * - The voting is not expired yet.\n *\n */\n function voteEmergencyExit(\n bytes32 _voteHash,\n address _consensusAddr,\n address _recipientAfterUnlockedFund,\n uint256 _requestedAt,\n uint256 _expiredAt\n ) external onlyGovernor {\n address _voter = msg.sender;\n bytes32 _hash = EmergencyExitBallot.hash(_consensusAddr, _recipientAfterUnlockedFund, _requestedAt, _expiredAt);\n if (_voteHash != _hash) revert ErrInvalidVoteHash();\n\n IsolatedGovernance.Vote storage _v = _emergencyExitPoll[_hash];\n if (_v.createdAt == 0) revert ErrQueryForNonExistentVote();\n if (_v.status == VoteStatus.Expired) revert ErrQueryForExpiredVote();\n\n _v.castVote(_voter, _hash);\n emit EmergencyExitPollVoted(_hash, _voter);\n\n address[] memory _voters = _v.filterByHash(_hash);\n VoteStatus _stt = _v.syncVoteStatus(_getMinimumVoteWeight(), _sumGovernorWeights(_voters), _hash);\n if (_stt == VoteStatus.Approved) {\n _execReleaseLockedFundForEmergencyExitRequest(_consensusAddr, _recipientAfterUnlockedFund);\n emit EmergencyExitPollApproved(_hash);\n _v.status = VoteStatus.Executed;\n } else if (_stt == VoteStatus.Expired) {\n emit EmergencyExitPollExpired(_hash);\n }\n }\n\n /**\n * @dev Returns weight of a govenor.\n */\n function _getWeight(address _governor) internal view virtual override returns (uint256) {\n bytes4 _selector = IRoninTrustedOrganization.getGovernorWeight.selector;\n (bool _success, bytes memory _returndata) = getContract(ContractType.RONIN_TRUSTED_ORGANIZATION).staticcall(\n abi.encodeWithSelector(\n // TransparentUpgradeableProxyV2.functionDelegateCall.selector,\n 0x4bb5274a,\n abi.encodeWithSelector(_selector, _governor)\n )\n );\n _success.handleRevert(_selector, _returndata);\n return abi.decode(_returndata, (uint256));\n }\n\n /**\n * @dev Returns the total weight of a list address of governors.\n */\n function _sumGovernorWeights(address[] memory _governors) internal view virtual returns (uint256) {\n bytes4 _selector = IRoninTrustedOrganization.sumGovernorWeights.selector;\n (bool _success, bytes memory _returndata) = getContract(ContractType.RONIN_TRUSTED_ORGANIZATION).staticcall(\n abi.encodeWithSelector(\n // TransparentUpgradeableProxyV2.functionDelegateCall.selector,\n 0x4bb5274a,\n abi.encodeWithSelector(_selector, _governors)\n )\n );\n\n _success.handleRevert(_selector, _returndata);\n return abi.decode(_returndata, (uint256));\n }\n\n /**\n * @dev Trigger function from validator contract to unlock fund for emeregency exit request.\n */\n function _execReleaseLockedFundForEmergencyExitRequest(\n address _consensusAddr,\n address _recipientAfterUnlockedFund\n ) internal virtual {\n bytes4 _selector = IEmergencyExit.execReleaseLockedFundForEmergencyExitRequest.selector;\n (bool _success, bytes memory _returndata) = getContract(ContractType.VALIDATOR).call(\n abi.encodeWithSelector(\n // TransparentUpgradeableProxyV2.functionDelegateCall.selector,\n 0x4bb5274a,\n abi.encodeWithSelector(_selector, _consensusAddr, _recipientAfterUnlockedFund)\n )\n );\n _success.handleRevert(_selector, _returndata);\n }\n\n /**\n * @dev See `CoreGovernance-_getChainType`.\n */\n function _getChainType() internal pure override returns (ChainType) {\n return ChainType.RoninChain;\n }\n}\n" + }, + "contracts/ronin/slash-indicator/CreditScore.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../interfaces/IMaintenance.sol\";\nimport \"../../interfaces/validator/IRoninValidatorSet.sol\";\nimport \"../../interfaces/slash-indicator/ICreditScore.sol\";\nimport \"../../extensions/collections/HasContracts.sol\";\nimport \"../../extensions/consumers/PercentageConsumer.sol\";\nimport \"../../libraries/Math.sol\";\nimport { HasValidatorDeprecated, HasMaintenanceDeprecated } from \"../../utils/DeprecatedSlots.sol\";\nimport { ErrUnauthorized, RoleAccess } from \"../../utils/CommonErrors.sol\";\n\nabstract contract CreditScore is\n ICreditScore,\n HasContracts,\n HasValidatorDeprecated,\n HasMaintenanceDeprecated,\n PercentageConsumer\n{\n /// @dev Mapping from validator address => period index => whether bailed out before\n mapping(address => mapping(uint256 => bool)) internal _checkBailedOutAtPeriod;\n /// @dev Mapping from validator address => credit score\n mapping(address => uint256) internal _creditScore;\n\n /// @dev The max gained number of credit score per period.\n uint256 internal _gainCreditScore;\n /// @dev The max number of credit score that a validator can hold.\n uint256 internal _maxCreditScore;\n /// @dev The number that will be multiplied with the remaining jailed time to get the cost of bailing out.\n uint256 internal _bailOutCostMultiplier;\n /// @dev The percentage of reward to be cut off from the validator in the rest of the period after bailed out.\n uint256 internal _cutOffPercentageAfterBailout;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[50] private ______gap;\n\n /**\n * @inheritdoc ICreditScore\n */\n function updateCreditScores(\n address[] calldata _validators,\n uint256 _period\n ) external override onlyContract(ContractType.VALIDATOR) {\n IRoninValidatorSet _validatorContract = IRoninValidatorSet(msg.sender);\n uint256 _periodStartAtBlock = _validatorContract.currentPeriodStartAtBlock();\n\n bool[] memory _jaileds = _validatorContract.checkManyJailed(_validators);\n bool[] memory _maintaineds = IMaintenance(getContract(ContractType.MAINTENANCE)).checkManyMaintainedInBlockRange(\n _validators,\n _periodStartAtBlock,\n block.number\n );\n uint256[] memory _updatedCreditScores = new uint256[](_validators.length);\n\n for (uint _i = 0; _i < _validators.length; ) {\n address _validator = _validators[_i];\n\n uint256 _indicator = getUnavailabilityIndicator(_validator, _period);\n bool _isJailedInPeriod = _jaileds[_i];\n bool _isMaintainingInPeriod = _maintaineds[_i];\n\n uint256 _actualGain = (_isJailedInPeriod || _isMaintainingInPeriod)\n ? 0\n : Math.subNonNegative(_gainCreditScore, _indicator);\n\n _creditScore[_validator] = Math.addWithUpperbound(_creditScore[_validator], _actualGain, _maxCreditScore);\n _updatedCreditScores[_i] = _creditScore[_validator];\n unchecked {\n ++_i;\n }\n }\n\n emit CreditScoresUpdated(_validators, _updatedCreditScores);\n }\n\n function execResetCreditScores(\n address[] calldata _validators\n ) external override onlyContract(ContractType.VALIDATOR) {\n uint256[] memory _updatedCreditScores = new uint256[](_validators.length);\n for (uint _i = 0; _i < _validators.length; ) {\n address _validator = _validators[_i];\n delete _creditScore[_validator];\n delete _updatedCreditScores[_i];\n\n unchecked {\n ++_i;\n }\n }\n emit CreditScoresUpdated(_validators, _updatedCreditScores);\n }\n\n /**\n * @inheritdoc ICreditScore\n */\n function bailOut(address _consensusAddr) external override {\n IRoninValidatorSet _validatorContract = IRoninValidatorSet(getContract(ContractType.VALIDATOR));\n if (!_validatorContract.isValidatorCandidate(_consensusAddr))\n revert ErrUnauthorized(msg.sig, RoleAccess.VALIDATOR_CANDIDATE);\n\n if (!_validatorContract.isCandidateAdmin(_consensusAddr, msg.sender))\n revert ErrUnauthorized(msg.sig, RoleAccess.CANDIDATE_ADMIN);\n\n (bool _isJailed, , uint256 _jailedEpochLeft) = _validatorContract.getJailedTimeLeft(_consensusAddr);\n if (!_isJailed) revert ErrCallerMustBeJailedInTheCurrentPeriod();\n\n uint256 _period = _validatorContract.currentPeriod();\n if (_checkBailedOutAtPeriod[_consensusAddr][_period]) revert ErrValidatorHasBailedOutPreviously();\n\n uint256 _score = _creditScore[_consensusAddr];\n uint256 _cost = _jailedEpochLeft * _bailOutCostMultiplier;\n if (_score < _cost) revert ErrInsufficientCreditScoreToBailOut();\n\n _validatorContract.execBailOut(_consensusAddr, _period);\n\n _creditScore[_consensusAddr] -= _cost;\n _setUnavailabilityIndicator(_consensusAddr, _period, 0);\n _checkBailedOutAtPeriod[_consensusAddr][_period] = true;\n emit BailedOut(_consensusAddr, _period, _cost);\n }\n\n /**\n * @inheritdoc ICreditScore\n */\n function setCreditScoreConfigs(\n uint256 _gainScore,\n uint256 _maxScore,\n uint256 _bailOutMultiplier,\n uint256 _cutOffPercentage\n ) external override onlyAdmin {\n _setCreditScoreConfigs(_gainScore, _maxScore, _bailOutMultiplier, _cutOffPercentage);\n }\n\n /**\n * @dev See `ISlashUnavailability`\n */\n function getUnavailabilityIndicator(address _validator, uint256 _period) public view virtual returns (uint256);\n\n /**\n * @inheritdoc ICreditScore\n */\n function getCreditScoreConfigs()\n external\n view\n override\n returns (\n uint256 gainCreditScore_,\n uint256 maxCreditScore_,\n uint256 bailOutCostMultiplier_,\n uint256 cutOffPercentageAfterBailout_\n )\n {\n return (_gainCreditScore, _maxCreditScore, _bailOutCostMultiplier, _cutOffPercentageAfterBailout);\n }\n\n /**\n * @inheritdoc ICreditScore\n */\n function getCreditScore(address _validator) external view override returns (uint256) {\n return _creditScore[_validator];\n }\n\n /**\n * @inheritdoc ICreditScore\n */\n function getManyCreditScores(\n address[] calldata _validators\n ) public view override returns (uint256[] memory _resultList) {\n _resultList = new uint256[](_validators.length);\n\n for (uint _i = 0; _i < _resultList.length; ) {\n _resultList[_i] = _creditScore[_validators[_i]];\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc ICreditScore\n */\n function checkBailedOutAtPeriod(address _validator, uint256 _period) public view virtual override returns (bool) {\n return _checkBailedOutAtPeriod[_validator][_period];\n }\n\n /**\n * @dev See `SlashUnavailability`.\n */\n function _setUnavailabilityIndicator(address _validator, uint256 _period, uint256 _indicator) internal virtual;\n\n /**\n * @dev See `ICreditScore-setCreditScoreConfigs`.\n */\n function _setCreditScoreConfigs(\n uint256 _gainScore,\n uint256 _maxScore,\n uint256 _bailOutMultiplier,\n uint256 _cutOffPercentage\n ) internal {\n if (_gainScore > _maxScore) revert ErrInvalidCreditScoreConfig();\n if (_cutOffPercentage > _MAX_PERCENTAGE) revert ErrInvalidCutOffPercentageConfig();\n\n _gainCreditScore = _gainScore;\n _maxCreditScore = _maxScore;\n _bailOutCostMultiplier = _bailOutMultiplier;\n _cutOffPercentageAfterBailout = _cutOffPercentage;\n emit CreditScoreConfigsUpdated(_gainScore, _maxScore, _bailOutMultiplier, _cutOffPercentage);\n }\n}\n" + }, + "contracts/ronin/slash-indicator/SlashBridgeOperator.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../extensions/consumers/PercentageConsumer.sol\";\nimport \"../../extensions/collections/HasProxyAdmin.sol\";\nimport \"../../interfaces/slash-indicator/ISlashBridgeOperator.sol\";\nimport \"../../extensions/collections/HasContracts.sol\";\nimport { HasValidatorDeprecated } from \"../../utils/DeprecatedSlots.sol\";\n\nabstract contract SlashBridgeOperator is\n ISlashBridgeOperator,\n HasProxyAdmin,\n HasContracts,\n HasValidatorDeprecated,\n PercentageConsumer\n{\n /**\n * @dev The bridge operators will be deprecated reward if (s)he missed more than the ratio.\n * Values 0-10,000 map to 0%-100%.\n */\n uint256 internal _missingVotesRatioTier1;\n /**\n * @dev The bridge operators will be deprecated all rewards including bridge reward and mining reward if (s)he missed\n * more than the ratio. Values 0-10,000 map to 0%-100%.\n */\n uint256 internal _missingVotesRatioTier2;\n /// @dev The number of blocks to jail the corresponding block producer when its bridge operator is slashed tier-2.\n uint256 internal _jailDurationForMissingVotesRatioTier2;\n /// @dev The threshold to skip slashing the bridge operator in case the total number of votes in the bridge is too small.\n uint256 internal _skipBridgeOperatorSlashingThreshold;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[50] private ______gap;\n\n /**\n * @inheritdoc ISlashBridgeOperator\n */\n function getBridgeOperatorSlashingConfigs()\n external\n view\n override\n returns (\n uint256 missingVotesRatioTier1_,\n uint256 missingVotesRatioTier2_,\n uint256 jailDurationForMissingVotesRatioTier2_,\n uint256 skipBridgeOperatorSlashingThreshold_\n )\n {\n return (\n _missingVotesRatioTier1,\n _missingVotesRatioTier2,\n _jailDurationForMissingVotesRatioTier2,\n _skipBridgeOperatorSlashingThreshold\n );\n }\n\n /**\n * @inheritdoc ISlashBridgeOperator\n */\n function setBridgeOperatorSlashingConfigs(\n uint256 _ratioTier1,\n uint256 _ratioTier2,\n uint256 _jailDurationTier2,\n uint256 _skipSlashingThreshold\n ) external override onlyAdmin {\n _setBridgeOperatorSlashingConfigs(_ratioTier1, _ratioTier2, _jailDurationTier2, _skipSlashingThreshold);\n }\n\n /**\n * @inheritdoc ISlashBridgeOperator\n */\n function execSlashBridgeOperator(\n address _consensusAddr,\n uint256 _tier,\n uint256 _period\n ) external onlyContract(ContractType.VALIDATOR) {\n if (_tier == 1) {\n emit Slashed(_consensusAddr, SlashType.BRIDGE_OPERATOR_MISSING_VOTE_TIER_1, _period);\n } else if (_tier == 2) {\n emit Slashed(_consensusAddr, SlashType.BRIDGE_OPERATOR_MISSING_VOTE_TIER_2, _period);\n }\n }\n\n /**\n * @dev See `ISlashBridgeOperator-setBridgeOperatorSlashingConfigs`.\n */\n function _setBridgeOperatorSlashingConfigs(\n uint256 _ratioTier1,\n uint256 _ratioTier2,\n uint256 _jailDurationTier2,\n uint256 _skipSlashingThreshold\n ) internal {\n if (_ratioTier1 > _ratioTier2 || _ratioTier1 > _MAX_PERCENTAGE || _ratioTier2 > _MAX_PERCENTAGE) {\n revert ErrInvalidRatios();\n }\n\n _missingVotesRatioTier1 = _ratioTier1;\n _missingVotesRatioTier2 = _ratioTier2;\n _jailDurationForMissingVotesRatioTier2 = _jailDurationTier2;\n _skipBridgeOperatorSlashingThreshold = _skipSlashingThreshold;\n emit BridgeOperatorSlashingConfigsUpdated(_ratioTier1, _ratioTier2, _jailDurationTier2, _skipSlashingThreshold);\n }\n}\n" + }, + "contracts/ronin/slash-indicator/SlashBridgeVoting.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../libraries/Math.sol\";\nimport { HasValidatorDeprecated, HasTrustedOrgDeprecated, HasGovernanceAdminDeprecated } from \"../../utils/DeprecatedSlots.sol\";\nimport { IBridgeAdminProposal } from \"../../interfaces/IBridgeAdminProposal.sol\";\nimport \"../../interfaces/slash-indicator/ISlashBridgeVoting.sol\";\nimport \"../../interfaces/IRoninTrustedOrganization.sol\";\nimport \"../../interfaces/validator/IRoninValidatorSet.sol\";\nimport \"../../extensions/collections/HasContracts.sol\";\n\n// TODO: remove this from slashing logic of consensus contract\nabstract contract SlashBridgeVoting is\n ISlashBridgeVoting,\n HasContracts,\n HasValidatorDeprecated,\n HasTrustedOrgDeprecated,\n HasGovernanceAdminDeprecated\n{\n /// @dev Mapping from validator address => period index => bridge voting slashed\n mapping(address => mapping(uint256 => bool)) internal _bridgeVotingSlashed;\n /// @dev The threshold to slash when a trusted organization does not vote for bridge operators.\n uint256 internal _bridgeVotingThreshold;\n /// @dev The amount of RON to slash bridge voting.\n uint256 internal _bridgeVotingSlashAmount;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[50] private ______gap;\n\n /**\n * @inheritdoc ISlashBridgeVoting\n */\n function slashBridgeVoting(address _consensusAddr) external onlyAdmin {\n IRoninTrustedOrganization.TrustedOrganization memory _org = IRoninTrustedOrganization(\n getContract(ContractType.RONIN_TRUSTED_ORGANIZATION)\n ).getTrustedOrganization(_consensusAddr);\n uint256 _lastVotedBlock = Math.max(\n IBridgeAdminProposal(getContract(ContractType.BRIDGE_MANAGER)).lastVotedBlock(_org.bridgeVoter),\n _org.addedBlock\n );\n IRoninValidatorSet _validatorContract = IRoninValidatorSet(getContract(ContractType.VALIDATOR));\n uint256 _period = _validatorContract.currentPeriod();\n\n if (block.number - _lastVotedBlock <= _bridgeVotingThreshold || _bridgeVotingSlashed[_consensusAddr][_period])\n revert ErrInvalidSlash();\n\n _bridgeVotingSlashed[_consensusAddr][_period] = true;\n emit Slashed(_consensusAddr, SlashType.BRIDGE_VOTING, _period);\n _validatorContract.execSlash(_consensusAddr, 0, _bridgeVotingSlashAmount, false);\n }\n\n /**\n * @inheritdoc ISlashBridgeVoting\n */\n function getBridgeVotingSlashingConfigs()\n external\n view\n override\n returns (uint256 bridgeVotingThreshold_, uint256 bridgeVotingSlashAmount_)\n {\n return (_bridgeVotingThreshold, _bridgeVotingSlashAmount);\n }\n\n /**\n * @inheritdoc ISlashBridgeVoting\n */\n function setBridgeVotingSlashingConfigs(uint256 _threshold, uint256 _slashAmount) external override onlyAdmin {\n _setBridgeVotingSlashingConfigs(_threshold, _slashAmount);\n }\n\n /**\n * @dev See `ISlashBridgeVoting-setBridgeVotingSlashingConfigs`.\n */\n function _setBridgeVotingSlashingConfigs(uint256 _threshold, uint256 _slashAmount) internal {\n _bridgeVotingThreshold = _threshold;\n _bridgeVotingSlashAmount = _slashAmount;\n emit BridgeVotingSlashingConfigsUpdated(_threshold, _slashAmount);\n }\n}\n" + }, + "contracts/ronin/slash-indicator/SlashDoubleSign.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../interfaces/slash-indicator/ISlashDoubleSign.sol\";\nimport \"../../interfaces/validator/IRoninValidatorSet.sol\";\nimport \"../../precompile-usages/PCUValidateDoubleSign.sol\";\nimport \"../../extensions/collections/HasContracts.sol\";\nimport { HasValidatorDeprecated } from \"../../utils/DeprecatedSlots.sol\";\n\nabstract contract SlashDoubleSign is ISlashDoubleSign, HasContracts, HasValidatorDeprecated, PCUValidateDoubleSign {\n /// @dev The amount of RON to slash double sign.\n uint256 internal _slashDoubleSignAmount;\n /// @dev The block number that the punished validator will be jailed until, due to double signing.\n uint256 internal _doubleSigningJailUntilBlock;\n /** @dev The offset from the submitted block to the current block, from which double signing will be invalidated.\n * This parameter is exposed for system transaction.\n **/\n uint256 internal _doubleSigningOffsetLimitBlock;\n /// @dev Recording of submitted proof to prevent relay attack.\n mapping(bytes32 => bool) _submittedEvidence;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[48] private ______gap;\n\n /**\n * @inheritdoc ISlashDoubleSign\n */\n function slashDoubleSign(\n address _consensusAddr,\n bytes calldata _header1,\n bytes calldata _header2\n ) external override onlyAdmin {\n bytes32 _header1Checksum = keccak256(_header1);\n bytes32 _header2Checksum = keccak256(_header2);\n\n if (_submittedEvidence[_header1Checksum] || _submittedEvidence[_header2Checksum]) {\n revert ErrEvidenceAlreadySubmitted();\n }\n\n if (_pcValidateEvidence(_consensusAddr, _header1, _header2)) {\n IRoninValidatorSet _validatorContract = IRoninValidatorSet(getContract(ContractType.VALIDATOR));\n uint256 _period = _validatorContract.currentPeriod();\n _submittedEvidence[_header1Checksum] = true;\n _submittedEvidence[_header2Checksum] = true;\n emit Slashed(_consensusAddr, SlashType.DOUBLE_SIGNING, _period);\n _validatorContract.execSlash(_consensusAddr, _doubleSigningJailUntilBlock, _slashDoubleSignAmount, true);\n }\n }\n\n /**\n * @inheritdoc ISlashDoubleSign\n */\n function getDoubleSignSlashingConfigs()\n external\n view\n override\n returns (\n uint256 slashDoubleSignAmount_,\n uint256 doubleSigningJailUntilBlock_,\n uint256 doubleSigningOffsetLimitBlock_\n )\n {\n return (_slashDoubleSignAmount, _doubleSigningJailUntilBlock, _doubleSigningOffsetLimitBlock);\n }\n\n /**\n * @inheritdoc ISlashDoubleSign\n */\n function setDoubleSignSlashingConfigs(\n uint256 _slashAmount,\n uint256 _jailUntilBlock,\n uint256 _offsetLimitBlock\n ) external override onlyAdmin {\n _setDoubleSignSlashingConfigs(_slashAmount, _jailUntilBlock, _offsetLimitBlock);\n }\n\n /**\n * @dev See `ISlashDoubleSign-setDoubleSignSlashingConfigs`.\n */\n function _setDoubleSignSlashingConfigs(\n uint256 _slashAmount,\n uint256 _jailUntilBlock,\n uint256 _offsetLimitBlock\n ) internal {\n _slashDoubleSignAmount = _slashAmount;\n _doubleSigningJailUntilBlock = _jailUntilBlock;\n _doubleSigningOffsetLimitBlock = _offsetLimitBlock;\n emit DoubleSignSlashingConfigsUpdated(_slashAmount, _jailUntilBlock, _doubleSigningOffsetLimitBlock);\n }\n\n /**\n * @dev Returns whether the account `_addr` should be slashed or not.\n */\n function _shouldSlash(address _addr) internal view virtual returns (bool);\n}\n" + }, + "contracts/ronin/slash-indicator/SlashIndicator.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport \"../../interfaces/slash-indicator/ISlashIndicator.sol\";\nimport \"../../interfaces/validator/IRoninValidatorSet.sol\";\nimport \"../../interfaces/IMaintenance.sol\";\nimport \"./SlashDoubleSign.sol\";\nimport \"./SlashBridgeVoting.sol\";\nimport \"./SlashBridgeOperator.sol\";\nimport \"./SlashUnavailability.sol\";\nimport \"./CreditScore.sol\";\n\ncontract SlashIndicator is\n ISlashIndicator,\n SlashDoubleSign,\n SlashBridgeVoting,\n SlashBridgeOperator,\n SlashUnavailability,\n CreditScore,\n Initializable\n{\n constructor() {\n _disableInitializers();\n }\n\n /**\n * @dev Initializes the contract storage.\n */\n function initialize(\n address __validatorContract,\n address __maintenanceContract,\n address __roninTrustedOrganizationContract,\n address __roninGovernanceAdminContract,\n // _bridgeOperatorSlashingConfigs[0]: _missingVotesRatioTier1\n // _bridgeOperatorSlashingConfigs[1]: _missingVotesRatioTier2\n // _bridgeOperatorSlashingConfigs[2]: _jailDurationForMissingVotesRatioTier2\n // _bridgeOperatorSlashingConfigs[3]: _skipBridgeOperatorSlashingThreshold\n uint256[4] calldata _bridgeOperatorSlashingConfigs,\n // _bridgeVotingSlashingConfigs[0]: _bridgeVotingThreshold\n // _bridgeVotingSlashingConfigs[1]: _bridgeVotingSlashAmount\n uint256[2] calldata _bridgeVotingSlashingConfigs,\n // _doubleSignSlashingConfigs[0]: _slashDoubleSignAmount\n // _doubleSignSlashingConfigs[1]: _doubleSigningJailUntilBlock\n // _doubleSignSlashingConfigs[2]: _doubleSigningOffsetLimitBlock\n uint256[3] calldata _doubleSignSlashingConfigs,\n // _unavailabilitySlashingConfigs[0]: _unavailabilityTier1Threshold\n // _unavailabilitySlashingConfigs[1]: _unavailabilityTier2Threshold\n // _unavailabilitySlashingConfigs[2]: _slashAmountForUnavailabilityTier2Threshold\n // _unavailabilitySlashingConfigs[3]: _jailDurationForUnavailabilityTier2Threshold\n uint256[4] calldata _unavailabilitySlashingConfigs,\n // _creditScoreConfigs[0]: _gainCreditScore\n // _creditScoreConfigs[1]: _maxCreditScore\n // _creditScoreConfigs[2]: _bailOutCostMultiplier\n // _creditScoreConfigs[3]: _cutOffPercentageAfterBailout\n uint256[4] calldata _creditScoreConfigs\n ) external initializer {\n _setContract(ContractType.VALIDATOR, __validatorContract);\n _setContract(ContractType.MAINTENANCE, __maintenanceContract);\n _setContract(ContractType.GOVERNANCE_ADMIN, __roninGovernanceAdminContract);\n _setContract(ContractType.RONIN_TRUSTED_ORGANIZATION, __roninTrustedOrganizationContract);\n\n _setBridgeOperatorSlashingConfigs(\n _bridgeOperatorSlashingConfigs[0],\n _bridgeOperatorSlashingConfigs[1],\n _bridgeOperatorSlashingConfigs[2],\n _bridgeOperatorSlashingConfigs[3]\n );\n _setBridgeVotingSlashingConfigs(_bridgeVotingSlashingConfigs[0], _bridgeVotingSlashingConfigs[1]);\n _setDoubleSignSlashingConfigs(\n _doubleSignSlashingConfigs[0],\n _doubleSignSlashingConfigs[1],\n _doubleSignSlashingConfigs[2]\n );\n _setUnavailabilitySlashingConfigs(\n _unavailabilitySlashingConfigs[0],\n _unavailabilitySlashingConfigs[1],\n _unavailabilitySlashingConfigs[2],\n _unavailabilitySlashingConfigs[3]\n );\n _setCreditScoreConfigs(\n _creditScoreConfigs[0],\n _creditScoreConfigs[1],\n _creditScoreConfigs[2],\n _creditScoreConfigs[3]\n );\n }\n\n function initializeV2(address roninGovernanceAdminContract) external reinitializer(2) {\n _setContract(ContractType.VALIDATOR, ______deprecatedValidator);\n _setContract(ContractType.MAINTENANCE, ______deprecatedMaintenance);\n _setContract(ContractType.GOVERNANCE_ADMIN, roninGovernanceAdminContract);\n _setContract(ContractType.RONIN_TRUSTED_ORGANIZATION, ______deprecatedTrustedOrg);\n\n delete ______deprecatedValidator;\n delete ______deprecatedMaintenance;\n delete ______deprecatedTrustedOrg;\n delete ______deprecatedGovernanceAdmin;\n }\n\n /**\n * @dev Helper for CreditScore contract to reset the indicator of the validator after bailing out.\n */\n function _setUnavailabilityIndicator(\n address _validator,\n uint256 _period,\n uint256 _indicator\n ) internal override(CreditScore, SlashUnavailability) {\n SlashUnavailability._setUnavailabilityIndicator(_validator, _period, _indicator);\n }\n\n /**\n * @dev Helper for CreditScore contract to query indicator of the validator.\n */\n function getUnavailabilityIndicator(\n address _validator,\n uint256 _period\n ) public view override(CreditScore, ISlashUnavailability, SlashUnavailability) returns (uint256) {\n return SlashUnavailability.getUnavailabilityIndicator(_validator, _period);\n }\n\n /**\n * @inheritdoc ICreditScore\n */\n function checkBailedOutAtPeriod(\n address _validator,\n uint256 _period\n ) public view override(CreditScore, ICreditScore, SlashUnavailability) returns (bool) {\n return CreditScore.checkBailedOutAtPeriod(_validator, _period);\n }\n\n /**\n * @dev Sanity check the address to be slashed\n */\n function _shouldSlash(address _addr) internal view override(SlashDoubleSign, SlashUnavailability) returns (bool) {\n return\n (msg.sender != _addr) &&\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).isBlockProducer(_addr) &&\n !IMaintenance(getContract(ContractType.MAINTENANCE)).checkMaintained(_addr, block.number);\n }\n}\n" + }, + "contracts/ronin/slash-indicator/SlashUnavailability.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./CreditScore.sol\";\nimport \"../../interfaces/validator/IRoninValidatorSet.sol\";\nimport \"../../interfaces/slash-indicator/ISlashUnavailability.sol\";\nimport \"../../extensions/collections/HasContracts.sol\";\nimport { HasValidatorDeprecated } from \"../../utils/DeprecatedSlots.sol\";\nimport { ErrInvalidThreshold } from \"../../utils/CommonErrors.sol\";\n\nabstract contract SlashUnavailability is ISlashUnavailability, HasContracts, HasValidatorDeprecated {\n /// @dev The last block that a validator is slashed for unavailability.\n uint256 public lastUnavailabilitySlashedBlock;\n /// @dev Mapping from validator address => period index => unavailability indicator.\n mapping(address => mapping(uint256 => uint256)) internal _unavailabilityIndicator;\n\n /**\n * @dev The mining reward will be deprecated, if (s)he missed more than this threshold.\n * This threshold is applied for tier-1 and tier-3 of unavailability slash.\n */\n uint256 internal _unavailabilityTier1Threshold;\n /**\n * @dev The mining reward will be deprecated, (s)he will be put in jailed, and will be deducted\n * self-staking if (s)he misses more than this threshold. This threshold is applied for tier-2 slash.\n */\n uint256 internal _unavailabilityTier2Threshold;\n /**\n * @dev The amount of RON to deduct from self-staking of a block producer when (s)he is slashed with\n * tier-2 or tier-3.\n **/\n uint256 internal _slashAmountForUnavailabilityTier2Threshold;\n /// @dev The number of blocks to jail a block producer when (s)he is slashed with tier-2 or tier-3.\n uint256 internal _jailDurationForUnavailabilityTier2Threshold;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[50] private ______gap;\n\n modifier oncePerBlock() {\n if (block.number <= lastUnavailabilitySlashedBlock) {\n revert ErrCannotSlashAValidatorTwiceOrSlashMoreThanOneValidatorInOneBlock();\n }\n\n lastUnavailabilitySlashedBlock = block.number;\n _;\n }\n\n /**\n * @inheritdoc ISlashUnavailability\n */\n function slashUnavailability(address _validatorAddr) external override oncePerBlock {\n if (msg.sender != block.coinbase) revert ErrUnauthorized(msg.sig, RoleAccess.COINBASE);\n\n if (!_shouldSlash(_validatorAddr)) {\n // Should return instead of throwing error since this is a part of system transaction.\n return;\n }\n\n IRoninValidatorSet _validatorContract = IRoninValidatorSet(getContract(ContractType.VALIDATOR));\n uint256 _period = _validatorContract.currentPeriod();\n uint256 _count;\n unchecked {\n _count = ++_unavailabilityIndicator[_validatorAddr][_period];\n }\n uint256 _newJailedUntilBlock = Math.addIfNonZero(block.number, _jailDurationForUnavailabilityTier2Threshold);\n\n if (_count == _unavailabilityTier2Threshold) {\n emit Slashed(_validatorAddr, SlashType.UNAVAILABILITY_TIER_2, _period);\n _validatorContract.execSlash(\n _validatorAddr,\n _newJailedUntilBlock,\n _slashAmountForUnavailabilityTier2Threshold,\n false\n );\n } else if (_count == _unavailabilityTier1Threshold) {\n bool _tier1SecondTime = checkBailedOutAtPeriod(_validatorAddr, _period);\n if (!_tier1SecondTime) {\n emit Slashed(_validatorAddr, SlashType.UNAVAILABILITY_TIER_1, _period);\n _validatorContract.execSlash(_validatorAddr, 0, 0, false);\n } else {\n /// Handles tier-3\n emit Slashed(_validatorAddr, SlashType.UNAVAILABILITY_TIER_3, _period);\n _validatorContract.execSlash(\n _validatorAddr,\n _newJailedUntilBlock,\n _slashAmountForUnavailabilityTier2Threshold,\n true\n );\n }\n }\n }\n\n /**\n * @inheritdoc ISlashUnavailability\n */\n function setUnavailabilitySlashingConfigs(\n uint256 _tier1Threshold,\n uint256 _tier2Threshold,\n uint256 _slashAmountForTier2Threshold,\n uint256 _jailDurationForTier2Threshold\n ) external override onlyAdmin {\n _setUnavailabilitySlashingConfigs(\n _tier1Threshold,\n _tier2Threshold,\n _slashAmountForTier2Threshold,\n _jailDurationForTier2Threshold\n );\n }\n\n /**\n * @inheritdoc ISlashUnavailability\n */\n function getUnavailabilitySlashingConfigs()\n external\n view\n override\n returns (\n uint256 unavailabilityTier1Threshold_,\n uint256 unavailabilityTier2Threshold_,\n uint256 slashAmountForUnavailabilityTier2Threshold_,\n uint256 jailDurationForUnavailabilityTier2Threshold_\n )\n {\n return (\n _unavailabilityTier1Threshold,\n _unavailabilityTier2Threshold,\n _slashAmountForUnavailabilityTier2Threshold,\n _jailDurationForUnavailabilityTier2Threshold\n );\n }\n\n /**\n * @inheritdoc ISlashUnavailability\n */\n function currentUnavailabilityIndicator(address _validator) external view override returns (uint256) {\n return\n getUnavailabilityIndicator(_validator, IRoninValidatorSet(getContract(ContractType.VALIDATOR)).currentPeriod());\n }\n\n /**\n * @inheritdoc ISlashUnavailability\n */\n function getUnavailabilityIndicator(\n address _validator,\n uint256 _period\n ) public view virtual override returns (uint256) {\n return _unavailabilityIndicator[_validator][_period];\n }\n\n /**\n * @dev Sets the unavailability indicator of the `_validator` at `_period`.\n */\n function _setUnavailabilityIndicator(address _validator, uint256 _period, uint256 _indicator) internal virtual {\n _unavailabilityIndicator[_validator][_period] = _indicator;\n }\n\n /**\n * @dev See `ISlashUnavailability-setUnavailabilitySlashingConfigs`.\n */\n function _setUnavailabilitySlashingConfigs(\n uint256 _tier1Threshold,\n uint256 _tier2Threshold,\n uint256 _slashAmountForTier2Threshold,\n uint256 _jailDurationForTier2Threshold\n ) internal {\n if (_unavailabilityTier1Threshold > _unavailabilityTier2Threshold) revert ErrInvalidThreshold(msg.sig);\n\n _unavailabilityTier1Threshold = _tier1Threshold;\n _unavailabilityTier2Threshold = _tier2Threshold;\n _slashAmountForUnavailabilityTier2Threshold = _slashAmountForTier2Threshold;\n _jailDurationForUnavailabilityTier2Threshold = _jailDurationForTier2Threshold;\n emit UnavailabilitySlashingConfigsUpdated(\n _tier1Threshold,\n _tier2Threshold,\n _slashAmountForTier2Threshold,\n _jailDurationForTier2Threshold\n );\n }\n\n /**\n * @dev Returns whether the account `_addr` should be slashed or not.\n */\n function _shouldSlash(address _addr) internal view virtual returns (bool);\n\n /**\n * @dev See `ICreditScore-checkBailedOutAtPeriod`\n */\n function checkBailedOutAtPeriod(address _validator, uint256 _period) public view virtual returns (bool);\n}\n" + }, + "contracts/ronin/staking/BaseStaking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"../../extensions/RONTransferHelper.sol\";\nimport \"../../extensions/collections/HasContracts.sol\";\nimport \"../../interfaces/staking/IBaseStaking.sol\";\nimport \"../../interfaces/validator/IRoninValidatorSet.sol\";\nimport \"../../libraries/Math.sol\";\nimport { HasValidatorDeprecated } from \"../../utils/DeprecatedSlots.sol\";\nimport \"./RewardCalculation.sol\";\n\nabstract contract BaseStaking is\n RONTransferHelper,\n ReentrancyGuard,\n RewardCalculation,\n HasContracts,\n IBaseStaking,\n HasValidatorDeprecated\n{\n /// @dev Mapping from pool address => staking pool detail\n mapping(address => PoolDetail) internal _stakingPool;\n\n /// @dev The cooldown time in seconds to undelegate from the last timestamp (s)he delegated.\n uint256 internal _cooldownSecsToUndelegate;\n /// @dev The number of seconds that a candidate must wait to be revoked and take the self-staking amount back.\n uint256 internal _waitingSecsToRevoke;\n\n /// @dev Mapping from admin address of an active pool => consensus address.\n mapping(address => address) internal _adminOfActivePoolMapping;\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[49] private ______gap;\n\n modifier noEmptyValue() {\n _requireValue();\n _;\n }\n\n modifier anyExceptPoolAdmin(PoolDetail storage _pool, address _delegator) {\n _anyExceptPoolAdmin(_pool, _delegator);\n _;\n }\n\n modifier onlyPoolAdmin(PoolDetail storage _pool, address _requester) {\n _requirePoolAdmin(_pool, _requester);\n _;\n }\n\n modifier poolIsActive(address _poolAddr) {\n _poolIsActive(_poolAddr);\n _;\n }\n\n function _requireValue() private view {\n if (msg.value == 0) revert ErrZeroValue();\n }\n\n function _requirePoolAdmin(PoolDetail storage _pool, address _requester) private view {\n if (_pool.admin != _requester) revert ErrOnlyPoolAdminAllowed();\n }\n\n function _anyExceptPoolAdmin(PoolDetail storage _pool, address _delegator) private view {\n if (_pool.admin == _delegator) revert ErrPoolAdminForbidden();\n }\n\n function _poolIsActive(address _poolAddr) private view {\n if (!IRoninValidatorSet(getContract(ContractType.VALIDATOR)).isValidatorCandidate(_poolAddr))\n revert ErrInactivePool(_poolAddr);\n }\n\n /**\n * @inheritdoc IBaseStaking\n */\n function isAdminOfActivePool(address _poolAdminAddr) public view override returns (bool) {\n return _adminOfActivePoolMapping[_poolAdminAddr] != address(0);\n }\n\n /**\n * @inheritdoc IBaseStaking\n */\n function getPoolAddressOf(address _poolAdminAddr) external view override returns (address) {\n return _adminOfActivePoolMapping[_poolAdminAddr];\n }\n\n /**\n * @inheritdoc IBaseStaking\n */\n function getPoolDetail(\n address _poolAddr\n ) external view returns (address _admin, uint256 _stakingAmount, uint256 _stakingTotal) {\n PoolDetail storage _pool = _stakingPool[_poolAddr];\n return (_pool.admin, _pool.stakingAmount, _pool.stakingTotal);\n }\n\n /**\n * @inheritdoc IBaseStaking\n */\n function getManySelfStakings(address[] calldata _pools) external view returns (uint256[] memory _selfStakings) {\n _selfStakings = new uint256[](_pools.length);\n for (uint _i = 0; _i < _pools.length; ) {\n _selfStakings[_i] = _stakingPool[_pools[_i]].stakingAmount;\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IRewardPool\n */\n function getStakingTotal(address _poolAddr) public view override returns (uint256) {\n return _stakingPool[_poolAddr].stakingTotal;\n }\n\n /**\n * @inheritdoc IRewardPool\n */\n function getManyStakingTotals(\n address[] calldata _poolList\n ) public view override returns (uint256[] memory _stakingAmounts) {\n _stakingAmounts = new uint256[](_poolList.length);\n for (uint _i = 0; _i < _poolList.length; ) {\n _stakingAmounts[_i] = getStakingTotal(_poolList[_i]);\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IRewardPool\n */\n function getStakingAmount(address _poolAddr, address _user) public view override returns (uint256) {\n return _stakingPool[_poolAddr].delegatingAmount[_user];\n }\n\n /**\n * @inheritdoc IRewardPool\n */\n function getManyStakingAmounts(\n address[] calldata _poolAddrs,\n address[] calldata _userList\n ) external view override returns (uint256[] memory _stakingAmounts) {\n if (_poolAddrs.length != _userList.length) revert ErrInvalidArrays();\n _stakingAmounts = new uint256[](_poolAddrs.length);\n for (uint _i = 0; _i < _stakingAmounts.length; ) {\n _stakingAmounts[_i] = _stakingPool[_poolAddrs[_i]].delegatingAmount[_userList[_i]];\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IBaseStaking\n */\n function cooldownSecsToUndelegate() external view returns (uint256) {\n return _cooldownSecsToUndelegate;\n }\n\n /**\n * @inheritdoc IBaseStaking\n */\n function waitingSecsToRevoke() external view returns (uint256) {\n return _waitingSecsToRevoke;\n }\n\n /**\n * @inheritdoc IBaseStaking\n */\n function setCooldownSecsToUndelegate(uint256 _cooldownSecs) external override onlyAdmin {\n _setCooldownSecsToUndelegate(_cooldownSecs);\n }\n\n /**\n * @inheritdoc IBaseStaking\n */\n function setWaitingSecsToRevoke(uint256 _secs) external override onlyAdmin {\n _setWaitingSecsToRevoke(_secs);\n }\n\n /**\n * @dev Sets the minium number of seconds to undelegate.\n *\n * Emits the event `CooldownSecsToUndelegateUpdated`.\n *\n */\n function _setCooldownSecsToUndelegate(uint256 _cooldownSecs) internal {\n _cooldownSecsToUndelegate = _cooldownSecs;\n emit CooldownSecsToUndelegateUpdated(_cooldownSecs);\n }\n\n /**\n * @dev Sets the number of seconds that a candidate must wait to be revoked.\n *\n * Emits the event `WaitingSecsToRevokeUpdated`.\n *\n */\n function _setWaitingSecsToRevoke(uint256 _secs) internal {\n _waitingSecsToRevoke = _secs;\n emit WaitingSecsToRevokeUpdated(_secs);\n }\n\n /**\n * @dev Changes the delegate amount.\n */\n function _changeDelegatingAmount(\n PoolDetail storage _pool,\n address _delegator,\n uint256 _newDelegatingAmount,\n uint256 _newStakingTotal\n ) internal {\n _syncUserReward(_pool.addr, _delegator, _newDelegatingAmount);\n _pool.stakingTotal = _newStakingTotal;\n _pool.delegatingAmount[_delegator] = _newDelegatingAmount;\n }\n}\n" + }, + "contracts/ronin/staking/CandidateStaking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../extensions/consumers/GlobalConfigConsumer.sol\";\nimport \"../../extensions/consumers/PercentageConsumer.sol\";\nimport \"../../libraries/AddressArrayUtils.sol\";\nimport \"../../interfaces/staking/ICandidateStaking.sol\";\nimport \"./BaseStaking.sol\";\n\nabstract contract CandidateStaking is BaseStaking, ICandidateStaking, GlobalConfigConsumer, PercentageConsumer {\n /// @dev The minimum threshold for being a validator candidate.\n uint256 internal _minValidatorStakingAmount;\n\n /// @dev The max commission rate that the validator can set (in range of [0;100_00] means [0-100%])\n uint256 internal _maxCommissionRate;\n /// @dev The min commission rate that the validator can set (in range of [0;100_00] means [0-100%])\n uint256 internal _minCommissionRate;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[48] ______gap;\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function minValidatorStakingAmount() public view override returns (uint256) {\n return _minValidatorStakingAmount;\n }\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function getCommissionRateRange() external view override returns (uint256, uint256) {\n return (_minCommissionRate, _maxCommissionRate);\n }\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function setMinValidatorStakingAmount(uint256 _threshold) external override onlyAdmin {\n _setMinValidatorStakingAmount(_threshold);\n }\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function setCommissionRateRange(uint256 _minRate, uint256 _maxRate) external override onlyAdmin {\n _setCommissionRateRange(_minRate, _maxRate);\n }\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function applyValidatorCandidate(\n address _candidateAdmin,\n address _consensusAddr,\n address payable _treasuryAddr,\n uint256 _commissionRate\n ) external payable override nonReentrant {\n if (isAdminOfActivePool(msg.sender)) revert ErrAdminOfAnyActivePoolForbidden(msg.sender);\n if (_commissionRate > _maxCommissionRate || _commissionRate < _minCommissionRate) revert ErrInvalidCommissionRate();\n\n uint256 _amount = msg.value;\n address payable _poolAdmin = payable(msg.sender);\n _applyValidatorCandidate({\n _poolAdmin: _poolAdmin,\n _candidateAdmin: _candidateAdmin,\n _consensusAddr: _consensusAddr,\n _treasuryAddr: _treasuryAddr,\n _commissionRate: _commissionRate,\n _amount: _amount\n });\n\n PoolDetail storage _pool = _stakingPool[_consensusAddr];\n _pool.admin = _poolAdmin;\n _pool.addr = _consensusAddr;\n _adminOfActivePoolMapping[_poolAdmin] = _consensusAddr;\n\n _stake(_stakingPool[_consensusAddr], _poolAdmin, _amount);\n emit PoolApproved(_consensusAddr, _poolAdmin);\n }\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function requestUpdateCommissionRate(\n address _consensusAddr,\n uint256 _effectiveDaysOnwards,\n uint256 _commissionRate\n ) external override poolIsActive(_consensusAddr) onlyPoolAdmin(_stakingPool[_consensusAddr], msg.sender) {\n if (_commissionRate > _maxCommissionRate || _commissionRate < _minCommissionRate) revert ErrInvalidCommissionRate();\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execRequestUpdateCommissionRate(\n _consensusAddr,\n _effectiveDaysOnwards,\n _commissionRate\n );\n }\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function execDeprecatePools(\n address[] calldata _pools,\n uint256 _newPeriod\n ) external override onlyContract(ContractType.VALIDATOR) {\n if (_pools.length == 0) {\n return;\n }\n\n for (uint _i = 0; _i < _pools.length; ) {\n PoolDetail storage _pool = _stakingPool[_pools[_i]];\n // Deactivate the pool admin in the active mapping.\n delete _adminOfActivePoolMapping[_pool.admin];\n\n // Deduct and transfer the self staking amount to the pool admin.\n uint256 _deductingAmount = _pool.stakingAmount;\n if (_deductingAmount > 0) {\n _deductStakingAmount(_pool, _deductingAmount);\n if (!_unsafeSendRONLimitGas(payable(_pool.admin), _deductingAmount, DEFAULT_ADDITION_GAS)) {\n emit StakingAmountTransferFailed(_pool.addr, _pool.admin, _deductingAmount, address(this).balance);\n }\n }\n\n // Settle the unclaimed reward and transfer to the pool admin.\n uint256 _lastRewardAmount = _claimReward(_pools[_i], _pool.admin, _newPeriod);\n if (_lastRewardAmount > 0) {\n _unsafeSendRONLimitGas(payable(_pool.admin), _lastRewardAmount, DEFAULT_ADDITION_GAS);\n }\n\n unchecked {\n ++_i;\n }\n }\n\n emit PoolsDeprecated(_pools);\n }\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function stake(address _consensusAddr) external payable override noEmptyValue poolIsActive(_consensusAddr) {\n _stake(_stakingPool[_consensusAddr], msg.sender, msg.value);\n }\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function unstake(\n address _consensusAddr,\n uint256 _amount\n ) external override nonReentrant poolIsActive(_consensusAddr) {\n if (_amount == 0) revert ErrUnstakeZeroAmount();\n address _requester = msg.sender;\n PoolDetail storage _pool = _stakingPool[_consensusAddr];\n uint256 _remainAmount = _pool.stakingAmount - _amount;\n if (_remainAmount < _minValidatorStakingAmount) revert ErrStakingAmountLeft();\n\n _unstake(_pool, _requester, _amount);\n if (!_unsafeSendRONLimitGas(payable(_requester), _amount, DEFAULT_ADDITION_GAS)) revert ErrCannotTransferRON();\n }\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function requestRenounce(\n address _consensusAddr\n ) external override poolIsActive(_consensusAddr) onlyPoolAdmin(_stakingPool[_consensusAddr], msg.sender) {\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execRequestRenounceCandidate(\n _consensusAddr,\n _waitingSecsToRevoke\n );\n }\n\n /**\n * @inheritdoc ICandidateStaking\n */\n function requestEmergencyExit(\n address _consensusAddr\n ) external override poolIsActive(_consensusAddr) onlyPoolAdmin(_stakingPool[_consensusAddr], msg.sender) {\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execEmergencyExit(_consensusAddr, _waitingSecsToRevoke);\n }\n\n /**\n * @dev See `ICandidateStaking-applyValidatorCandidate`\n */\n function _applyValidatorCandidate(\n address payable _poolAdmin,\n address _candidateAdmin,\n address _consensusAddr,\n address payable _treasuryAddr,\n uint256 _commissionRate,\n uint256 _amount\n ) internal {\n if (!_unsafeSendRONLimitGas(_poolAdmin, 0, DEFAULT_ADDITION_GAS))\n revert ErrCannotInitTransferRON(_poolAdmin, \"pool admin\");\n if (!_unsafeSendRONLimitGas(_treasuryAddr, 0, DEFAULT_ADDITION_GAS))\n revert ErrCannotInitTransferRON(_treasuryAddr, \"treasury\");\n if (_amount < _minValidatorStakingAmount) revert ErrInsufficientStakingAmount();\n if (_poolAdmin != _candidateAdmin || _candidateAdmin != _treasuryAddr) revert ErrThreeInteractionAddrsNotEqual();\n\n {\n address[] memory _diffAddrs = new address[](2);\n _diffAddrs[0] = _poolAdmin;\n _diffAddrs[1] = _consensusAddr;\n if (AddressArrayUtils.hasDuplicate(_diffAddrs)) revert AddressArrayUtils.ErrDuplicated(msg.sig);\n }\n\n IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execApplyValidatorCandidate(\n _candidateAdmin,\n _consensusAddr,\n _treasuryAddr,\n _commissionRate\n );\n }\n\n /**\n * @dev See `ICandidateStaking-stake`\n */\n function _stake(\n PoolDetail storage _pool,\n address _requester,\n uint256 _amount\n ) internal onlyPoolAdmin(_pool, _requester) {\n _pool.stakingAmount += _amount;\n _changeDelegatingAmount(_pool, _requester, _pool.stakingAmount, _pool.stakingTotal + _amount);\n _pool.lastDelegatingTimestamp[_requester] = block.timestamp;\n emit Staked(_pool.addr, _amount);\n }\n\n /**\n * @dev See `ICandidateStaking-unstake`\n */\n function _unstake(\n PoolDetail storage _pool,\n address _requester,\n uint256 _amount\n ) internal onlyPoolAdmin(_pool, _requester) {\n if (_amount > _pool.stakingAmount) revert ErrInsufficientStakingAmount();\n if (_pool.lastDelegatingTimestamp[_requester] + _cooldownSecsToUndelegate > block.timestamp) {\n revert ErrUnstakeTooEarly();\n }\n\n _pool.stakingAmount -= _amount;\n _changeDelegatingAmount(_pool, _requester, _pool.stakingAmount, _pool.stakingTotal - _amount);\n emit Unstaked(_pool.addr, _amount);\n }\n\n /**\n * @dev Deducts from staking amount of the validator `_consensusAddr` for `_amount`.\n *\n * Emits the event `Unstaked`.\n *\n * @return The actual deducted amount\n */\n function _deductStakingAmount(PoolDetail storage _pool, uint256 _amount) internal virtual returns (uint256);\n\n /**\n * @dev Sets the minimum threshold for being a validator candidate.\n *\n * Emits the `MinValidatorStakingAmountUpdated` event.\n *\n */\n function _setMinValidatorStakingAmount(uint256 _threshold) internal {\n _minValidatorStakingAmount = _threshold;\n emit MinValidatorStakingAmountUpdated(_threshold);\n }\n\n /**\n * @dev Sets the max commission rate that a candidate can set.\n *\n * Emits the `MaxCommissionRateUpdated` event.\n *\n */\n function _setCommissionRateRange(uint256 _minRate, uint256 _maxRate) internal {\n if (_maxRate > _MAX_PERCENTAGE || _minRate > _maxRate) revert ErrInvalidCommissionRate();\n _maxCommissionRate = _maxRate;\n _minCommissionRate = _minRate;\n emit CommissionRateRangeUpdated(_minRate, _maxRate);\n }\n}\n" + }, + "contracts/ronin/staking/DelegatorStaking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../interfaces/staking/IDelegatorStaking.sol\";\nimport \"./BaseStaking.sol\";\n\nabstract contract DelegatorStaking is BaseStaking, IDelegatorStaking {\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[50] private ______gap;\n\n /**\n * @inheritdoc IDelegatorStaking\n */\n function delegate(address _consensusAddr) external payable noEmptyValue poolIsActive(_consensusAddr) {\n if (isAdminOfActivePool(msg.sender)) revert ErrAdminOfAnyActivePoolForbidden(msg.sender);\n _delegate(_stakingPool[_consensusAddr], msg.sender, msg.value);\n }\n\n /**\n * @inheritdoc IDelegatorStaking\n */\n function undelegate(address _consensusAddr, uint256 _amount) external nonReentrant {\n address payable _delegator = payable(msg.sender);\n _undelegate(_stakingPool[_consensusAddr], _delegator, _amount);\n if (!_sendRON(_delegator, _amount)) revert ErrCannotTransferRON();\n }\n\n /**\n * @inheritdoc IDelegatorStaking\n */\n function bulkUndelegate(address[] calldata _consensusAddrs, uint256[] calldata _amounts) external nonReentrant {\n if (_consensusAddrs.length == 0 || _consensusAddrs.length != _amounts.length) revert ErrInvalidArrays();\n\n address payable _delegator = payable(msg.sender);\n uint256 _total;\n\n for (uint _i = 0; _i < _consensusAddrs.length; ) {\n _total += _amounts[_i];\n _undelegate(_stakingPool[_consensusAddrs[_i]], _delegator, _amounts[_i]);\n\n unchecked {\n ++_i;\n }\n }\n\n if (!_sendRON(_delegator, _total)) revert ErrCannotTransferRON();\n }\n\n /**\n * @inheritdoc IDelegatorStaking\n */\n function redelegate(\n address _consensusAddrSrc,\n address _consensusAddrDst,\n uint256 _amount\n ) external nonReentrant poolIsActive(_consensusAddrDst) {\n address _delegator = msg.sender;\n _undelegate(_stakingPool[_consensusAddrSrc], _delegator, _amount);\n _delegate(_stakingPool[_consensusAddrDst], _delegator, _amount);\n }\n\n /**\n * @inheritdoc IDelegatorStaking\n */\n function claimRewards(\n address[] calldata _consensusAddrList\n ) external override nonReentrant returns (uint256 _amount) {\n _amount = _claimRewards(msg.sender, _consensusAddrList);\n _transferRON(payable(msg.sender), _amount);\n }\n\n /**\n * @inheritdoc IDelegatorStaking\n */\n function delegateRewards(\n address[] calldata _consensusAddrList,\n address _consensusAddrDst\n ) external override nonReentrant poolIsActive(_consensusAddrDst) returns (uint256 _amount) {\n if (isAdminOfActivePool(msg.sender)) revert ErrAdminOfAnyActivePoolForbidden(msg.sender);\n return _delegateRewards(msg.sender, _consensusAddrList, _consensusAddrDst);\n }\n\n /**\n * @inheritdoc IDelegatorStaking\n */\n function getRewards(\n address _user,\n address[] calldata _poolAddrList\n ) external view returns (uint256[] memory _rewards) {\n address _consensusAddr;\n uint256 _period = IRoninValidatorSet(getContract(ContractType.VALIDATOR)).currentPeriod();\n _rewards = new uint256[](_poolAddrList.length);\n\n for (uint256 _i = 0; _i < _poolAddrList.length; ) {\n _consensusAddr = _poolAddrList[_i];\n _rewards[_i] = _getReward(_consensusAddr, _user, _period, getStakingAmount(_consensusAddr, _user));\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @dev Delegates from a validator address.\n *\n * Requirements:\n * - The delegator is not the pool admin.\n *\n * Emits the `Delegated` event.\n *\n * Note: This function does not verify the `msg.value` with the amount.\n *\n */\n function _delegate(\n PoolDetail storage _pool,\n address _delegator,\n uint256 _amount\n ) internal anyExceptPoolAdmin(_pool, _delegator) {\n _changeDelegatingAmount(\n _pool,\n _delegator,\n _pool.delegatingAmount[_delegator] + _amount,\n _pool.stakingTotal + _amount\n );\n _pool.lastDelegatingTimestamp[_delegator] = block.timestamp;\n emit Delegated(_delegator, _pool.addr, _amount);\n }\n\n /**\n * @dev Undelegates from a validator address.\n *\n * Requirements:\n * - The delegator is not the pool admin.\n * - The amount is larger than 0.\n * - The delegating amount is larger than or equal to the undelegating amount.\n *\n * Emits the `Undelegated` event.\n *\n * Note: Consider transferring back the amount of RON after calling this function.\n *\n */\n function _undelegate(\n PoolDetail storage _pool,\n address _delegator,\n uint256 _amount\n ) private anyExceptPoolAdmin(_pool, _delegator) {\n if (_amount == 0) revert ErrUndelegateZeroAmount();\n if (_pool.delegatingAmount[_delegator] < _amount) revert ErrInsufficientDelegatingAmount();\n\n IRoninValidatorSet _validatorContract = IRoninValidatorSet(getContract(ContractType.VALIDATOR));\n if (\n _validatorContract.isValidatorCandidate(_pool.addr) &&\n _validatorContract.getCandidateInfo(_pool.addr).revokingTimestamp == 0 && // if candidate is not on renunciation\n _pool.lastDelegatingTimestamp[_delegator] + _cooldownSecsToUndelegate >= block.timestamp // delegator is still in cooldown\n ) revert ErrUndelegateTooEarly();\n\n _changeDelegatingAmount(\n _pool,\n _delegator,\n _pool.delegatingAmount[_delegator] - _amount,\n _pool.stakingTotal - _amount\n );\n emit Undelegated(_delegator, _pool.addr, _amount);\n }\n\n /**\n * @dev Claims rewards from the pools `_poolAddrList`.\n * Note: This function does not transfer reward to user.\n */\n function _claimRewards(address _user, address[] memory _poolAddrList) internal returns (uint256 _amount) {\n uint256 _period = _currentPeriod();\n for (uint256 _i = 0; _i < _poolAddrList.length; ) {\n _amount += _claimReward(_poolAddrList[_i], _user, _period);\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @dev Claims the rewards and delegates them to the consensus address.\n */\n function _delegateRewards(\n address _user,\n address[] calldata _poolAddrList,\n address _poolAddrDst\n ) internal returns (uint256 _amount) {\n _amount = _claimRewards(_user, _poolAddrList);\n _delegate(_stakingPool[_poolAddrDst], _user, _amount);\n }\n}\n" + }, + "contracts/ronin/staking/RewardCalculation.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../interfaces/staking/IRewardPool.sol\";\nimport \"../../libraries/Math.sol\";\n\n/**\n * @title RewardCalculation contract\n * @dev This contract mainly contains the methods to calculate reward for staking contract.\n */\nabstract contract RewardCalculation is IRewardPool {\n /// @dev Mapping from pool address => period number => accumulated rewards per share (one unit staking)\n mapping(address => mapping(uint256 => PeriodWrapper)) private _accumulatedRps;\n /// @dev Mapping from the pool address => user address => the reward info of the user\n mapping(address => mapping(address => UserRewardFields)) private _userReward;\n /// @dev Mapping from the pool address => reward pool fields\n mapping(address => PoolFields) private _stakingPool;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[50] private ______gap;\n\n /**\n * @inheritdoc IRewardPool\n */\n function getReward(address _poolAddr, address _user) external view returns (uint256) {\n return _getReward(_poolAddr, _user, _currentPeriod(), getStakingAmount(_poolAddr, _user));\n }\n\n /**\n * @inheritdoc IRewardPool\n */\n function getStakingAmount(address _poolAddr, address _user) public view virtual returns (uint256);\n\n /**\n * @inheritdoc IRewardPool\n */\n function getStakingTotal(address _poolAddr) public view virtual returns (uint256);\n\n /**\n * @dev Returns the reward amount that user claimable.\n */\n function _getReward(\n address _poolAddr,\n address _user,\n uint256 _latestPeriod,\n uint256 _latestStakingAmount\n ) internal view returns (uint256) {\n UserRewardFields storage _reward = _userReward[_poolAddr][_user];\n\n if (_reward.lastPeriod == _latestPeriod) {\n return _reward.debited;\n }\n\n uint256 _aRps;\n uint256 _lastPeriodReward;\n PoolFields storage _pool = _stakingPool[_poolAddr];\n PeriodWrapper storage _wrappedArps = _accumulatedRps[_poolAddr][_reward.lastPeriod];\n\n if (_wrappedArps.lastPeriod > 0) {\n // Calculates the last period reward if the aRps at the period is set\n _aRps = _wrappedArps.inner;\n _lastPeriodReward = _reward.lowestAmount * (_aRps - _reward.aRps);\n } else {\n // Fallbacks to the previous aRps in case the aRps is not set\n _aRps = _reward.aRps;\n }\n\n uint256 _newPeriodsReward = _latestStakingAmount * (_pool.aRps - _aRps);\n return _reward.debited + (_lastPeriodReward + _newPeriodsReward) / 1e18;\n }\n\n /**\n * @dev Syncs the user reward.\n *\n * Emits the event `UserRewardUpdated` once the debit amount is updated.\n * Emits the event `PoolSharesUpdated` once the pool share is updated.\n *\n * Note: The method should be called whenever the user's staking amount changes.\n *\n */\n function _syncUserReward(address _poolAddr, address _user, uint256 _newStakingAmount) internal {\n uint256 _period = _currentPeriod();\n PoolFields storage _pool = _stakingPool[_poolAddr];\n uint256 _lastShares = _pool.shares.inner;\n\n // Updates the pool shares if it is outdated\n if (_pool.shares.lastPeriod < _period) {\n _pool.shares = PeriodWrapper(getStakingTotal(_poolAddr), _period);\n }\n\n UserRewardFields storage _reward = _userReward[_poolAddr][_user];\n uint256 _currentStakingAmount = getStakingAmount(_poolAddr, _user);\n uint256 _debited = _getReward(_poolAddr, _user, _period, _currentStakingAmount);\n\n if (_reward.debited != _debited) {\n _reward.debited = _debited;\n emit UserRewardUpdated(_poolAddr, _user, _debited);\n }\n\n _syncMinStakingAmount(_pool, _reward, _period, _newStakingAmount, _currentStakingAmount);\n _reward.aRps = _pool.aRps;\n _reward.lastPeriod = _period;\n\n if (_pool.shares.inner != _lastShares) {\n emit PoolSharesUpdated(_period, _poolAddr, _pool.shares.inner);\n }\n }\n\n /**\n * @dev Syncs the minimum staking amount of an user in the current period.\n */\n function _syncMinStakingAmount(\n PoolFields storage _pool,\n UserRewardFields storage _reward,\n uint256 _latestPeriod,\n uint256 _newStakingAmount,\n uint256 _currentStakingAmount\n ) internal {\n if (_reward.lastPeriod < _latestPeriod) {\n _reward.lowestAmount = _currentStakingAmount;\n }\n\n uint256 _lowestAmount = Math.min(_reward.lowestAmount, _newStakingAmount);\n uint256 _diffAmount = _reward.lowestAmount - _lowestAmount;\n if (_diffAmount > 0) {\n _reward.lowestAmount = _lowestAmount;\n if (_pool.shares.inner < _diffAmount) revert ErrInvalidPoolShare();\n _pool.shares.inner -= _diffAmount;\n }\n }\n\n /**\n * @dev Claims the settled reward for a specific user.\n *\n * @param _lastPeriod Must be in two possible value: `_currentPeriod` in normal calculation, or\n * `_currentPeriod + 1` in case of calculating the reward for revoked validators.\n *\n * Emits the `RewardClaimed` event and the `UserRewardUpdated` event.\n *\n * Note: This method should be called before transferring rewards for the user.\n *\n */\n function _claimReward(address _poolAddr, address _user, uint256 _lastPeriod) internal returns (uint256 _amount) {\n uint256 _currentStakingAmount = getStakingAmount(_poolAddr, _user);\n _amount = _getReward(_poolAddr, _user, _lastPeriod, _currentStakingAmount);\n emit RewardClaimed(_poolAddr, _user, _amount);\n\n UserRewardFields storage _reward = _userReward[_poolAddr][_user];\n _reward.debited = 0;\n _syncMinStakingAmount(_stakingPool[_poolAddr], _reward, _lastPeriod, _currentStakingAmount, _currentStakingAmount);\n _reward.lastPeriod = _lastPeriod;\n _reward.aRps = _stakingPool[_poolAddr].aRps;\n emit UserRewardUpdated(_poolAddr, _user, 0);\n }\n\n /**\n * @dev Records the amount of rewards `_rewards` for the pools `_poolAddrs`.\n *\n * Emits the event `PoolsUpdated` once the contract recorded the rewards successfully.\n * Emits the event `PoolsUpdateFailed` once the input array lengths are not equal.\n * Emits the event `PoolUpdateConflicted` when the pool is already updated in the period.\n *\n * Note: This method should be called once at the period ending.\n *\n */\n function _recordRewards(address[] memory _poolAddrs, uint256[] calldata _rewards, uint256 _period) internal {\n if (_poolAddrs.length != _rewards.length) {\n emit PoolsUpdateFailed(_period, _poolAddrs, _rewards);\n return;\n }\n\n uint256 _rps;\n uint256 _count;\n address _poolAddr;\n uint256 _stakingTotal;\n uint256[] memory _aRps = new uint256[](_poolAddrs.length);\n uint256[] memory _shares = new uint256[](_poolAddrs.length);\n address[] memory _conflicted = new address[](_poolAddrs.length);\n\n for (uint _i = 0; _i < _poolAddrs.length; _i++) {\n _poolAddr = _poolAddrs[_i];\n PoolFields storage _pool = _stakingPool[_poolAddr];\n _stakingTotal = getStakingTotal(_poolAddr);\n\n if (_accumulatedRps[_poolAddr][_period].lastPeriod == _period) {\n unchecked {\n _conflicted[_count++] = _poolAddr;\n }\n continue;\n }\n\n // Updates the pool shares if it is outdated\n if (_pool.shares.lastPeriod < _period) {\n _pool.shares = PeriodWrapper(_stakingTotal, _period);\n }\n\n // The rps is 0 if no one stakes for the pool\n _rps = _pool.shares.inner == 0 ? 0 : (_rewards[_i] * 1e18) / _pool.shares.inner;\n _aRps[_i - _count] = _pool.aRps += _rps;\n _accumulatedRps[_poolAddr][_period] = PeriodWrapper(_pool.aRps, _period);\n _pool.shares.inner = _stakingTotal;\n _shares[_i - _count] = _pool.shares.inner;\n _poolAddrs[_i - _count] = _poolAddr;\n }\n\n if (_count > 0) {\n assembly {\n mstore(_conflicted, _count)\n mstore(_poolAddrs, sub(mload(_poolAddrs), _count))\n }\n emit PoolsUpdateConflicted(_period, _conflicted);\n }\n\n if (_poolAddrs.length > 0) {\n emit PoolsUpdated(_period, _poolAddrs, _aRps, _shares);\n }\n }\n\n /**\n * @dev Returns the current period.\n */\n function _currentPeriod() internal view virtual returns (uint256);\n}\n" + }, + "contracts/ronin/staking/Staking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport \"../../libraries/Math.sol\";\nimport \"../../interfaces/staking/IStaking.sol\";\nimport \"../../interfaces/validator/IRoninValidatorSet.sol\";\nimport \"./CandidateStaking.sol\";\nimport \"./DelegatorStaking.sol\";\n\ncontract Staking is IStaking, CandidateStaking, DelegatorStaking, Initializable {\n constructor() {\n _disableInitializers();\n }\n\n receive() external payable onlyContract(ContractType.VALIDATOR) {}\n\n fallback() external payable onlyContract(ContractType.VALIDATOR) {}\n\n /**\n * @dev Initializes the contract storage.\n */\n function initialize(\n address __validatorContract,\n uint256 __minValidatorStakingAmount,\n uint256 __maxCommissionRate,\n uint256 __cooldownSecsToUndelegate,\n uint256 __waitingSecsToRevoke\n ) external initializer {\n _setContract(ContractType.VALIDATOR, __validatorContract);\n _setMinValidatorStakingAmount(__minValidatorStakingAmount);\n _setCommissionRateRange(0, __maxCommissionRate);\n _setCooldownSecsToUndelegate(__cooldownSecsToUndelegate);\n _setWaitingSecsToRevoke(__waitingSecsToRevoke);\n }\n\n function initializeV2() external reinitializer(2) {\n _setContract(ContractType.VALIDATOR, ______deprecatedValidator);\n delete ______deprecatedValidator;\n }\n\n /**\n * @inheritdoc IStaking\n */\n function execRecordRewards(\n address[] calldata _consensusAddrs,\n uint256[] calldata _rewards,\n uint256 _period\n ) external payable override onlyContract(ContractType.VALIDATOR) {\n _recordRewards(_consensusAddrs, _rewards, _period);\n }\n\n /**\n * @inheritdoc IStaking\n */\n function execDeductStakingAmount(\n address _consensusAddr,\n uint256 _amount\n ) external override onlyContract(ContractType.VALIDATOR) returns (uint256 _actualDeductingAmount) {\n _actualDeductingAmount = _deductStakingAmount(_stakingPool[_consensusAddr], _amount);\n address payable _validatorContractAddr = payable(msg.sender);\n if (!_unsafeSendRON(_validatorContractAddr, _actualDeductingAmount)) {\n emit StakingAmountDeductFailed(\n _consensusAddr,\n _validatorContractAddr,\n _actualDeductingAmount,\n address(this).balance\n );\n }\n }\n\n /**\n * @inheritdoc RewardCalculation\n */\n function _currentPeriod() internal view virtual override returns (uint256) {\n return IRoninValidatorSet(getContract(ContractType.VALIDATOR)).currentPeriod();\n }\n\n /**\n * @inheritdoc CandidateStaking\n */\n function _deductStakingAmount(\n PoolDetail storage _pool,\n uint256 _amount\n ) internal override returns (uint256 _actualDeductingAmount) {\n _actualDeductingAmount = Math.min(_pool.stakingAmount, _amount);\n\n _pool.stakingAmount -= _actualDeductingAmount;\n _changeDelegatingAmount(\n _pool,\n _pool.admin,\n _pool.stakingAmount,\n Math.subNonNegative(_pool.stakingTotal, _actualDeductingAmount)\n );\n emit Unstaked(_pool.addr, _actualDeductingAmount);\n }\n}\n" + }, + "contracts/ronin/StakingVesting.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport \"../interfaces/IStakingVesting.sol\";\nimport \"../extensions/collections/HasContracts.sol\";\nimport { RONTransferHelper } from \"../extensions/RONTransferHelper.sol\";\nimport { HasValidatorDeprecated } from \"../utils/DeprecatedSlots.sol\";\n\ncontract StakingVesting is IStakingVesting, HasValidatorDeprecated, HasContracts, Initializable, RONTransferHelper {\n /// @dev The block bonus for the block producer whenever a new block is mined.\n uint256 internal _blockProducerBonusPerBlock;\n /// @dev The block bonus for the bridge operator whenever a new block is mined.\n uint256 internal _bridgeOperatorBonusPerBlock;\n /// @dev The last block number that the staking vesting sent.\n uint256 public lastBlockSendingBonus;\n\n constructor() {\n _disableInitializers();\n }\n\n /**\n * @dev Initializes the contract storage.\n */\n function initialize(\n address __validatorContract,\n uint256 __blockProducerBonusPerBlock,\n uint256 __bridgeOperatorBonusPerBlock\n ) external payable initializer {\n _setContract(ContractType.VALIDATOR, __validatorContract);\n _setBlockProducerBonusPerBlock(__blockProducerBonusPerBlock);\n _setBridgeOperatorBonusPerBlock(__bridgeOperatorBonusPerBlock);\n }\n\n function initializeV2() external reinitializer(2) {\n _setContract(ContractType.VALIDATOR, ______deprecatedValidator);\n delete ______deprecatedValidator;\n }\n\n /**\n * @inheritdoc IStakingVesting\n */\n function receiveRON() external payable {}\n\n /**\n * @inheritdoc IStakingVesting\n */\n function blockProducerBlockBonus(uint256 /* _block */) public view override returns (uint256) {\n return _blockProducerBonusPerBlock;\n }\n\n /**\n * @inheritdoc IStakingVesting\n */\n function bridgeOperatorBlockBonus(uint256 /* _block */) public view override returns (uint256) {\n return _bridgeOperatorBonusPerBlock;\n }\n\n /**\n * @inheritdoc IStakingVesting\n */\n function requestBonus(\n bool _forBlockProducer,\n bool _forBridgeOperator\n )\n external\n override\n onlyContract(ContractType.VALIDATOR)\n returns (bool _success, uint256 _blockProducerBonus, uint256 _bridgeOperatorBonus)\n {\n if (block.number <= lastBlockSendingBonus) revert ErrBonusAlreadySent();\n\n lastBlockSendingBonus = block.number;\n\n _blockProducerBonus = _forBlockProducer ? blockProducerBlockBonus(block.number) : 0;\n _bridgeOperatorBonus = _forBridgeOperator ? bridgeOperatorBlockBonus(block.number) : 0;\n\n uint256 _totalAmount = _blockProducerBonus + _bridgeOperatorBonus;\n\n if (_totalAmount > 0) {\n address payable _validatorContractAddr = payable(msg.sender);\n\n _success = _unsafeSendRON(_validatorContractAddr, _totalAmount);\n\n if (!_success) {\n emit BonusTransferFailed(\n block.number,\n _validatorContractAddr,\n _blockProducerBonus,\n _bridgeOperatorBonus,\n address(this).balance\n );\n return (_success, 0, 0);\n }\n\n emit BonusTransferred(block.number, _validatorContractAddr, _blockProducerBonus, _bridgeOperatorBonus);\n }\n }\n\n /**\n * @inheritdoc IStakingVesting\n */\n function setBlockProducerBonusPerBlock(uint256 _amount) external override onlyAdmin {\n _setBlockProducerBonusPerBlock(_amount);\n }\n\n /**\n * @inheritdoc IStakingVesting\n */\n function setBridgeOperatorBonusPerBlock(uint256 _amount) external override onlyAdmin {\n _setBridgeOperatorBonusPerBlock(_amount);\n }\n\n /**\n * @dev Sets the bonus amount per block for block producer.\n *\n * Emits the event `BlockProducerBonusPerBlockUpdated`.\n *\n */\n function _setBlockProducerBonusPerBlock(uint256 _amount) internal {\n _blockProducerBonusPerBlock = _amount;\n emit BlockProducerBonusPerBlockUpdated(_amount);\n }\n\n /**\n * @dev Sets the bonus amount per block for bridge operator.\n *\n * Emits the event `BridgeOperatorBonusPerBlockUpdated`.\n *\n */\n function _setBridgeOperatorBonusPerBlock(uint256 _amount) internal {\n _bridgeOperatorBonusPerBlock = _amount;\n emit BridgeOperatorBonusPerBlockUpdated(_amount);\n }\n}\n" + }, + "contracts/ronin/validator/CandidateManager.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../extensions/collections/HasContracts.sol\";\nimport \"../../extensions/consumers/GlobalConfigConsumer.sol\";\nimport \"../../extensions/consumers/PercentageConsumer.sol\";\nimport \"../../interfaces/validator/ICandidateManager.sol\";\nimport \"../../interfaces/staking/IStaking.sol\";\nimport { HasStakingDeprecated } from \"../../utils/DeprecatedSlots.sol\";\n\nabstract contract CandidateManager is\n ICandidateManager,\n PercentageConsumer,\n GlobalConfigConsumer,\n HasContracts,\n HasStakingDeprecated\n{\n /// @dev Maximum number of validator candidate\n uint256 private _maxValidatorCandidate;\n\n /// @dev The validator candidate array\n address[] internal _candidates;\n /// @dev Mapping from candidate consensus address => bitwise negation of validator index in `_candidates`\n mapping(address => uint256) internal _candidateIndex;\n /// @dev Mapping from candidate consensus address => their info\n mapping(address => ValidatorCandidate) internal _candidateInfo;\n\n /**\n * @dev The minimum offset in day from current date to the effective date of a new commission schedule.\n * Value of 1 means the change gets affected at the beginning of the following day.\n **/\n uint256 internal _minEffectiveDaysOnwards;\n /// @dev Mapping from candidate consensus address => schedule commission change.\n mapping(address => CommissionSchedule) internal _candidateCommissionChangeSchedule;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[48] private ______gap;\n\n /**\n * @inheritdoc ICandidateManager\n */\n function maxValidatorCandidate() public view override returns (uint256) {\n return _maxValidatorCandidate;\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function minEffectiveDaysOnwards() external view override returns (uint256) {\n return _minEffectiveDaysOnwards;\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function setMaxValidatorCandidate(uint256 _number) external override onlyAdmin {\n _setMaxValidatorCandidate(_number);\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function setMinEffectiveDaysOnwards(uint256 _numOfDays) external override onlyAdmin {\n _setMinEffectiveDaysOnwards(_numOfDays);\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function execApplyValidatorCandidate(\n address _candidateAdmin,\n address _consensusAddr,\n address payable _treasuryAddr,\n uint256 _commissionRate\n ) external override onlyContract(ContractType.STAKING) {\n uint256 _length = _candidates.length;\n if (_length >= maxValidatorCandidate()) revert ErrExceedsMaxNumberOfCandidate();\n if (isValidatorCandidate(_consensusAddr)) revert ErrExistentCandidate();\n if (_commissionRate > _MAX_PERCENTAGE) revert ErrInvalidCommissionRate();\n\n for (uint _i; _i < _candidates.length; ) {\n ValidatorCandidate storage existentInfo = _candidateInfo[_candidates[_i]];\n if (_candidateAdmin == existentInfo.admin) revert ErrExistentCandidateAdmin(_candidateAdmin);\n if (_treasuryAddr == existentInfo.treasuryAddr) revert ErrExistentTreasury(_treasuryAddr);\n\n unchecked {\n ++_i;\n }\n }\n\n _candidateIndex[_consensusAddr] = ~_length;\n _candidates.push(_consensusAddr);\n\n ValidatorCandidate storage _info = _candidateInfo[_consensusAddr];\n _info.admin = _candidateAdmin;\n _info.consensusAddr = _consensusAddr;\n _info.treasuryAddr = _treasuryAddr;\n _info.commissionRate = _commissionRate;\n emit CandidateGranted(_consensusAddr, _treasuryAddr, _candidateAdmin);\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function execRequestRenounceCandidate(\n address _consensusAddr,\n uint256 _secsLeft\n ) external override onlyContract(ContractType.STAKING) {\n if (_isTrustedOrg(_consensusAddr)) revert ErrTrustedOrgCannotRenounce();\n\n ValidatorCandidate storage _info = _candidateInfo[_consensusAddr];\n if (_info.revokingTimestamp != 0) revert ErrAlreadyRequestedRevokingCandidate();\n _setRevokingTimestamp(_info, block.timestamp + _secsLeft);\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function execRequestUpdateCommissionRate(\n address _consensusAddr,\n uint256 _effectiveDaysOnwards,\n uint256 _commissionRate\n ) external override onlyContract(ContractType.STAKING) {\n if (_candidateCommissionChangeSchedule[_consensusAddr].effectiveTimestamp != 0) {\n revert ErrAlreadyRequestedUpdatingCommissionRate();\n }\n if (_commissionRate > _MAX_PERCENTAGE) revert ErrInvalidCommissionRate();\n if (_effectiveDaysOnwards < _minEffectiveDaysOnwards) revert ErrInvalidEffectiveDaysOnwards();\n\n CommissionSchedule storage _schedule = _candidateCommissionChangeSchedule[_consensusAddr];\n uint256 _effectiveTimestamp = ((block.timestamp / PERIOD_DURATION) + _effectiveDaysOnwards) * PERIOD_DURATION;\n _schedule.effectiveTimestamp = _effectiveTimestamp;\n _schedule.commissionRate = _commissionRate;\n\n emit CommissionRateUpdateScheduled(_consensusAddr, _effectiveTimestamp, _commissionRate);\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function isValidatorCandidate(address _addr) public view override returns (bool) {\n return _candidateIndex[_addr] != 0;\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function getCandidateInfos() external view override returns (ValidatorCandidate[] memory _list) {\n _list = new ValidatorCandidate[](_candidates.length);\n for (uint _i; _i < _list.length; ) {\n _list[_i] = _candidateInfo[_candidates[_i]];\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function getCandidateInfo(address _candidate) external view override returns (ValidatorCandidate memory) {\n if (!isValidatorCandidate(_candidate)) revert ErrNonExistentCandidate();\n return _candidateInfo[_candidate];\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function getValidatorCandidates() public view override returns (address[] memory) {\n return _candidates;\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function getCommissionChangeSchedule(address _candidate) external view override returns (CommissionSchedule memory) {\n return _candidateCommissionChangeSchedule[_candidate];\n }\n\n /**\n * @dev Removes unsastisfied candidates, the ones who have insufficient minimum candidate staking amount,\n * or the ones who requested to renounce their candidate role.\n *\n * Emits the event `CandidatesRevoked` when a candidate is revoked.\n *\n */\n function _syncCandidateSet(uint256 _nextPeriod) internal returns (address[] memory _unsatisfiedCandidates) {\n IStaking _staking = IStaking(getContract(ContractType.STAKING));\n uint256 _waitingSecsToRevoke = _staking.waitingSecsToRevoke();\n uint256 _minStakingAmount = _staking.minValidatorStakingAmount();\n uint256[] memory _selfStakings = _staking.getManySelfStakings(_candidates);\n\n uint256 _length = _candidates.length;\n uint256 _unsatisfiedCount;\n _unsatisfiedCandidates = new address[](_length);\n\n {\n uint256 _i;\n address _addr;\n ValidatorCandidate storage _info;\n while (_i < _length) {\n _addr = _candidates[_i];\n _info = _candidateInfo[_addr];\n\n // Checks for under-balance status of candidates\n bool _hasTopupDeadline = _info.topupDeadline != 0;\n if (_selfStakings[_i] < _minStakingAmount) {\n // Updates deadline on the first time unsatisfied the staking amount condition\n if (!_hasTopupDeadline) {\n uint256 _topupDeadline = block.timestamp + _waitingSecsToRevoke;\n _info.topupDeadline = _topupDeadline;\n emit CandidateTopupDeadlineUpdated(_addr, _topupDeadline);\n }\n } else if (_hasTopupDeadline) {\n // Removes the deadline if the staking amount condition is satisfied\n delete _info.topupDeadline;\n emit CandidateTopupDeadlineUpdated(_addr, 0);\n }\n\n // Removes unsastisfied candidates\n bool _revokingActivated = (_info.revokingTimestamp != 0 && _info.revokingTimestamp <= block.timestamp) ||\n _emergencyExitLockedFundReleased(_addr);\n bool _topupDeadlineMissed = _info.topupDeadline != 0 && _info.topupDeadline <= block.timestamp;\n if (_revokingActivated || _topupDeadlineMissed) {\n _selfStakings[_i] = _selfStakings[--_length];\n unchecked {\n _unsatisfiedCandidates[_unsatisfiedCount++] = _addr;\n }\n _removeCandidate(_addr);\n continue;\n }\n\n // Checks for schedule of commission change and updates commission rate\n uint256 _scheduleTimestamp = _candidateCommissionChangeSchedule[_addr].effectiveTimestamp;\n if (_scheduleTimestamp != 0 && _scheduleTimestamp <= block.timestamp) {\n uint256 _commisionRate = _candidateCommissionChangeSchedule[_addr].commissionRate;\n delete _candidateCommissionChangeSchedule[_addr];\n _info.commissionRate = _commisionRate;\n emit CommissionRateUpdated(_addr, _commisionRate);\n }\n\n unchecked {\n _i++;\n }\n }\n }\n\n assembly {\n mstore(_unsatisfiedCandidates, _unsatisfiedCount)\n }\n\n if (_unsatisfiedCount > 0) {\n emit CandidatesRevoked(_unsatisfiedCandidates);\n _staking.execDeprecatePools(_unsatisfiedCandidates, _nextPeriod);\n }\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function isCandidateAdmin(address _candidate, address _admin) external view override returns (bool) {\n return _candidateInfo[_candidate].admin == _admin;\n }\n\n /**\n * @dev Sets the maximum number of validator candidate.\n *\n * Emits the `MaxValidatorCandidateUpdated` event.\n *\n */\n function _setMaxValidatorCandidate(uint256 _threshold) internal {\n _maxValidatorCandidate = _threshold;\n emit MaxValidatorCandidateUpdated(_threshold);\n }\n\n /**\n * @dev Sets the minimum number of days onwards to the effective date of commission rate change.\n *\n * Emits the `MinEffectiveDaysOnwardsUpdated` event.\n *\n */\n function _setMinEffectiveDaysOnwards(uint256 _numOfDays) internal {\n if (_numOfDays < 1) revert ErrInvalidMinEffectiveDaysOnwards();\n _minEffectiveDaysOnwards = _numOfDays;\n emit MinEffectiveDaysOnwardsUpdated(_numOfDays);\n }\n\n /**\n * @dev Removes the candidate.\n */\n function _removeCandidate(address _addr) internal virtual {\n uint256 _idx = _candidateIndex[_addr];\n if (_idx == 0) {\n return;\n }\n\n delete _candidateInfo[_addr];\n delete _candidateIndex[_addr];\n delete _candidateCommissionChangeSchedule[_addr];\n\n address _lastCandidate = _candidates[_candidates.length - 1];\n if (_lastCandidate != _addr) {\n _candidateIndex[_lastCandidate] = _idx;\n _candidates[~_idx] = _lastCandidate;\n }\n\n _candidates.pop();\n }\n\n /**\n * @dev Sets timestamp to revoke a candidate.\n */\n function _setRevokingTimestamp(ValidatorCandidate storage _candidate, uint256 _timestamp) internal {\n if (!isValidatorCandidate(_candidate.consensusAddr)) revert ErrNonExistentCandidate();\n _candidate.revokingTimestamp = _timestamp;\n emit CandidateRevokingTimestampUpdated(_candidate.consensusAddr, _timestamp);\n }\n\n /**\n * @dev Returns a flag indicating whether the fund is unlocked.\n */\n function _emergencyExitLockedFundReleased(address _consensusAddr) internal virtual returns (bool);\n\n /**\n * @dev Returns whether the consensus address is a trusted org or not.\n */\n function _isTrustedOrg(address _consensusAddr) internal virtual returns (bool);\n}\n" + }, + "contracts/ronin/validator/CoinbaseExecution.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../extensions/collections/HasContracts.sol\";\nimport \"../../extensions/RONTransferHelper.sol\";\nimport \"../../interfaces/IStakingVesting.sol\";\nimport \"../../interfaces/IMaintenance.sol\";\nimport \"../../interfaces/IRoninTrustedOrganization.sol\";\nimport \"../../interfaces/slash-indicator/ISlashIndicator.sol\";\nimport \"../../interfaces/validator/ICoinbaseExecution.sol\";\nimport \"../../libraries/EnumFlags.sol\";\nimport \"../../libraries/Math.sol\";\nimport { HasStakingVestingDeprecated, HasBridgeTrackingDeprecated, HasMaintenanceDeprecated, HasSlashIndicatorDeprecated } from \"../../utils/DeprecatedSlots.sol\";\nimport \"../../precompile-usages/PCUSortValidators.sol\";\nimport \"../../precompile-usages/PCUPickValidatorSet.sol\";\nimport \"./storage-fragments/CommonStorage.sol\";\nimport \"./CandidateManager.sol\";\nimport { EmergencyExit } from \"./EmergencyExit.sol\";\n\nabstract contract CoinbaseExecution is\n ICoinbaseExecution,\n RONTransferHelper,\n PCUSortValidators,\n PCUPickValidatorSet,\n HasContracts,\n HasStakingVestingDeprecated,\n HasBridgeTrackingDeprecated,\n HasMaintenanceDeprecated,\n HasSlashIndicatorDeprecated,\n EmergencyExit\n{\n using EnumFlags for EnumFlags.ValidatorFlag;\n\n modifier onlyCoinbase() {\n _requireCoinbase();\n _;\n }\n\n modifier whenEpochEnding() {\n if (!epochEndingAt(block.number)) revert ErrAtEndOfEpochOnly();\n _;\n }\n\n modifier oncePerEpoch() {\n if (epochOf(_lastUpdatedBlock) >= epochOf(block.number)) revert ErrAlreadyWrappedEpoch();\n _lastUpdatedBlock = block.number;\n _;\n }\n\n function _requireCoinbase() private view {\n if (msg.sender != block.coinbase) revert ErrCallerMustBeCoinbase();\n }\n\n /**\n * @inheritdoc ICoinbaseExecution\n */\n function submitBlockReward() external payable override onlyCoinbase {\n bool _requestForBlockProducer = isBlockProducer(msg.sender) &&\n !_jailed(msg.sender) &&\n !_miningRewardDeprecated(msg.sender, currentPeriod());\n\n (, uint256 _blockProducerBonus, ) = IStakingVesting(getContract(ContractType.STAKING_VESTING)).requestBonus({\n _forBlockProducer: _requestForBlockProducer,\n _forBridgeOperator: false\n });\n\n // Deprecates reward for non-validator or slashed validator\n if (!_requestForBlockProducer) {\n _totalDeprecatedReward += msg.value;\n emit BlockRewardDeprecated(msg.sender, msg.value, BlockRewardDeprecatedType.UNAVAILABILITY);\n return;\n }\n\n emit BlockRewardSubmitted(msg.sender, msg.value, _blockProducerBonus);\n\n uint256 _period = currentPeriod();\n uint256 _reward = msg.value + _blockProducerBonus;\n uint256 _cutOffReward;\n if (_miningRewardBailoutCutOffAtPeriod[msg.sender][_period]) {\n (, , , uint256 _cutOffPercentage) = ISlashIndicator(getContract(ContractType.SLASH_INDICATOR))\n .getCreditScoreConfigs();\n _cutOffReward = (_reward * _cutOffPercentage) / _MAX_PERCENTAGE;\n _totalDeprecatedReward += _cutOffReward;\n emit BlockRewardDeprecated(msg.sender, _cutOffReward, BlockRewardDeprecatedType.AFTER_BAILOUT);\n }\n\n _reward -= _cutOffReward;\n (uint256 _minRate, uint256 _maxRate) = IStaking(getContract(ContractType.STAKING)).getCommissionRateRange();\n uint256 _rate = Math.max(Math.min(_candidateInfo[msg.sender].commissionRate, _maxRate), _minRate);\n uint256 _miningAmount = (_rate * _reward) / _MAX_PERCENTAGE;\n _miningReward[msg.sender] += _miningAmount;\n\n uint256 _delegatingAmount = _reward - _miningAmount;\n _delegatingReward[msg.sender] += _delegatingAmount;\n }\n\n /**\n * @inheritdoc ICoinbaseExecution\n */\n function wrapUpEpoch() external payable virtual override onlyCoinbase whenEpochEnding oncePerEpoch {\n uint256 _newPeriod = _computePeriod(block.timestamp);\n bool _periodEnding = _isPeriodEnding(_newPeriod);\n\n address[] memory _currentValidators = getValidators();\n address[] memory _revokedCandidates;\n uint256 _epoch = epochOf(block.number);\n uint256 _nextEpoch = _epoch + 1;\n uint256 _lastPeriod = currentPeriod();\n\n if (_periodEnding) {\n (\n uint256 _totalDelegatingReward,\n uint256[] memory _delegatingRewards\n ) = _distributeRewardToTreasuriesAndCalculateTotalDelegatingReward(_lastPeriod, _currentValidators);\n _settleAndTransferDelegatingRewards(_lastPeriod, _currentValidators, _totalDelegatingReward, _delegatingRewards);\n _tryRecycleLockedFundsFromEmergencyExits();\n _recycleDeprecatedRewards();\n ISlashIndicator _slashIndicatorContract = ISlashIndicator(getContract(ContractType.SLASH_INDICATOR));\n _slashIndicatorContract.updateCreditScores(_currentValidators, _lastPeriod);\n (_currentValidators, _revokedCandidates) = _syncValidatorSet(_newPeriod);\n if (_revokedCandidates.length > 0) {\n _slashIndicatorContract.execResetCreditScores(_revokedCandidates);\n }\n _currentPeriodStartAtBlock = block.number + 1;\n }\n _revampRoles(_newPeriod, _nextEpoch, _currentValidators);\n emit WrappedUpEpoch(_lastPeriod, _epoch, _periodEnding);\n _periodOf[_nextEpoch] = _newPeriod;\n _lastUpdatedPeriod = _newPeriod;\n }\n\n /**\n * @dev This loops over all current validators to:\n * - Update delegating reward for and calculate total delegating rewards to be sent to the staking contract,\n * - Distribute the reward of block producers and bridge operators to their treasury addresses,\n * - Update the total deprecated reward if the two previous conditions do not sastify.\n *\n * Note: This method should be called once in the end of each period.\n *\n */\n function _distributeRewardToTreasuriesAndCalculateTotalDelegatingReward(\n uint256 _lastPeriod,\n address[] memory _currentValidators\n ) private returns (uint256 _totalDelegatingReward, uint256[] memory _delegatingRewards) {\n address _consensusAddr;\n address payable _treasury;\n _delegatingRewards = new uint256[](_currentValidators.length);\n for (uint _i; _i < _currentValidators.length; ) {\n _consensusAddr = _currentValidators[_i];\n _treasury = _candidateInfo[_consensusAddr].treasuryAddr;\n\n if (!_jailed(_consensusAddr) && !_miningRewardDeprecated(_consensusAddr, _lastPeriod)) {\n _totalDelegatingReward += _delegatingReward[_consensusAddr];\n _delegatingRewards[_i] = _delegatingReward[_consensusAddr];\n _distributeMiningReward(_consensusAddr, _treasury);\n } else {\n _totalDeprecatedReward += _miningReward[_consensusAddr] + _delegatingReward[_consensusAddr];\n }\n\n delete _delegatingReward[_consensusAddr];\n delete _miningReward[_consensusAddr];\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @dev Distributes bonus of staking vesting and mining fee for the block producer.\n *\n * Emits the `MiningRewardDistributed` once the reward is distributed successfully.\n * Emits the `MiningRewardDistributionFailed` once the contract fails to distribute reward.\n *\n * Note: This method should be called once in the end of each period.\n *\n */\n function _distributeMiningReward(address _consensusAddr, address payable _treasury) private {\n uint256 _amount = _miningReward[_consensusAddr];\n if (_amount > 0) {\n if (_unsafeSendRONLimitGas(_treasury, _amount, DEFAULT_ADDITION_GAS)) {\n emit MiningRewardDistributed(_consensusAddr, _treasury, _amount);\n return;\n }\n\n emit MiningRewardDistributionFailed(_consensusAddr, _treasury, _amount, address(this).balance);\n }\n }\n\n /**\n * @dev Helper function to settle rewards for delegators of `_currentValidators` at the end of each period,\n * then transfer the rewards from this contract to the staking contract, in order to finalize a period.\n *\n * Emits the `StakingRewardDistributed` once the reward is distributed successfully.\n * Emits the `StakingRewardDistributionFailed` once the contract fails to distribute reward.\n *\n * Note: This method should be called once in the end of each period.\n *\n */\n function _settleAndTransferDelegatingRewards(\n uint256 _period,\n address[] memory _currentValidators,\n uint256 _totalDelegatingReward,\n uint256[] memory _delegatingRewards\n ) private {\n IStaking _staking = IStaking(getContract(ContractType.STAKING));\n if (_totalDelegatingReward > 0) {\n if (_unsafeSendRON(payable(address(_staking)), _totalDelegatingReward)) {\n _staking.execRecordRewards(_currentValidators, _delegatingRewards, _period);\n emit StakingRewardDistributed(_totalDelegatingReward, _currentValidators, _delegatingRewards);\n return;\n }\n\n emit StakingRewardDistributionFailed(\n _totalDelegatingReward,\n _currentValidators,\n _delegatingRewards,\n address(this).balance\n );\n }\n }\n\n /**\n * @dev Transfer the deprecated rewards e.g. the rewards that get deprecated when validator is slashed/maintained,\n * to the staking vesting contract\n *\n * Note: This method should be called once in the end of each period.\n */\n function _recycleDeprecatedRewards() private {\n uint256 _withdrawAmount = _totalDeprecatedReward;\n\n if (_withdrawAmount != 0) {\n address _withdrawTarget = getContract(ContractType.STAKING_VESTING);\n\n delete _totalDeprecatedReward;\n\n (bool _success, ) = _withdrawTarget.call{ value: _withdrawAmount }(\n abi.encodeWithSelector(IStakingVesting.receiveRON.selector)\n );\n\n if (_success) {\n emit DeprecatedRewardRecycled(_withdrawTarget, _withdrawAmount);\n } else {\n emit DeprecatedRewardRecycleFailed(_withdrawTarget, _withdrawAmount, address(this).balance);\n }\n }\n }\n\n /**\n * @dev Updates the validator set based on the validator candidates from the Staking contract.\n *\n * Emits the `ValidatorSetUpdated` event.\n *\n * Note: This method should be called once in the end of each period.\n *\n */\n function _syncValidatorSet(\n uint256 _newPeriod\n ) private returns (address[] memory _newValidators, address[] memory _unsastifiedCandidates) {\n _unsastifiedCandidates = _syncCandidateSet(_newPeriod);\n uint256[] memory _weights = IStaking(getContract(ContractType.STAKING)).getManyStakingTotals(_candidates);\n uint256[] memory _trustedWeights = IRoninTrustedOrganization(getContract(ContractType.RONIN_TRUSTED_ORGANIZATION))\n .getConsensusWeights(_candidates);\n uint256 _newValidatorCount;\n (_newValidators, _newValidatorCount) = _pcPickValidatorSet(\n _candidates,\n _weights,\n _trustedWeights,\n _maxValidatorNumber,\n _maxPrioritizedValidatorNumber\n );\n _setNewValidatorSet(_newValidators, _newValidatorCount, _newPeriod);\n }\n\n /**\n * @dev Private helper function helps writing the new validator set into the contract storage.\n *\n * Emits the `ValidatorSetUpdated` event.\n *\n * Note: This method should be called once in the end of each period.\n *\n */\n function _setNewValidatorSet(\n address[] memory _newValidators,\n uint256 _newValidatorCount,\n uint256 _newPeriod\n ) private {\n // Remove exceeding validators in the current set\n for (uint256 _i = _newValidatorCount; _i < validatorCount; ) {\n delete _validatorMap[_validators[_i]];\n delete _validators[_i];\n\n unchecked {\n ++_i;\n }\n }\n\n // Remove flag for all validator in the current set\n for (uint _i; _i < _newValidatorCount; ) {\n delete _validatorMap[_validators[_i]];\n\n unchecked {\n ++_i;\n }\n }\n\n // Update new validator set and set flag correspondingly.\n for (uint256 _i; _i < _newValidatorCount; ) {\n address _newValidator = _newValidators[_i];\n _validatorMap[_newValidator] = EnumFlags.ValidatorFlag.Both;\n _validators[_i] = _newValidator;\n\n unchecked {\n ++_i;\n }\n }\n\n validatorCount = _newValidatorCount;\n emit ValidatorSetUpdated(_newPeriod, _newValidators);\n }\n\n /**\n * @dev Activate/Deactivate the validators from producing blocks, based on their in jail status and maintenance status.\n *\n * Requirements:\n * - This method is called at the end of each epoch\n *\n * Emits the `BlockProducerSetUpdated` event.\n * Emits the `BridgeOperatorSetUpdated` event.\n *\n */\n function _revampRoles(uint256 _newPeriod, uint256 _nextEpoch, address[] memory _currentValidators) private {\n bool[] memory _maintainedList = IMaintenance(getContract(ContractType.MAINTENANCE)).checkManyMaintained(\n _currentValidators,\n block.number + 1\n );\n\n for (uint _i; _i < _currentValidators.length; ) {\n address _validator = _currentValidators[_i];\n bool _emergencyExitRequested = block.timestamp <= _emergencyExitJailedTimestamp[_validator];\n bool _isProducerBefore = isBlockProducer(_validator);\n bool _isProducerAfter = !(_jailedAtBlock(_validator, block.number + 1) ||\n _maintainedList[_i] ||\n _emergencyExitRequested);\n\n if (!_isProducerBefore && _isProducerAfter) {\n _validatorMap[_validator] = _validatorMap[_validator].addFlag(EnumFlags.ValidatorFlag.BlockProducer);\n } else if (_isProducerBefore && !_isProducerAfter) {\n _validatorMap[_validator] = _validatorMap[_validator].removeFlag(EnumFlags.ValidatorFlag.BlockProducer);\n }\n\n unchecked {\n ++_i;\n }\n }\n emit BlockProducerSetUpdated(_newPeriod, _nextEpoch, getBlockProducers());\n }\n\n /**\n * @dev Override `CandidateManager-_isTrustedOrg`.\n */\n function _isTrustedOrg(address _consensusAddr) internal view override returns (bool) {\n return\n IRoninTrustedOrganization(getContract(ContractType.RONIN_TRUSTED_ORGANIZATION)).getConsensusWeight(\n _consensusAddr\n ) > 0;\n }\n}\n" + }, + "contracts/ronin/validator/EmergencyExit.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../extensions/RONTransferHelper.sol\";\nimport \"../../interfaces/IRoninGovernanceAdmin.sol\";\nimport \"../../interfaces/validator/IEmergencyExit.sol\";\nimport \"./storage-fragments/CommonStorage.sol\";\nimport \"./CandidateManager.sol\";\n\nabstract contract EmergencyExit is IEmergencyExit, RONTransferHelper, CandidateManager, CommonStorage {\n /**\n * @inheritdoc IEmergencyExit\n */\n function emergencyExitLockedAmount() external view returns (uint256) {\n return _emergencyExitLockedAmount;\n }\n\n /**\n * @inheritdoc IEmergencyExit\n */\n function emergencyExpiryDuration() external view returns (uint256) {\n return _emergencyExpiryDuration;\n }\n\n /**\n * @inheritdoc IEmergencyExit\n */\n function execEmergencyExit(\n address _consensusAddr,\n uint256 _secLeftToRevoke\n ) external onlyContract(ContractType.STAKING) {\n EmergencyExitInfo storage _info = _exitInfo[_consensusAddr];\n if (_info.recyclingAt != 0) revert ErrAlreadyRequestedEmergencyExit();\n\n uint256 _revokingTimestamp = block.timestamp + _secLeftToRevoke;\n _setRevokingTimestamp(_candidateInfo[_consensusAddr], _revokingTimestamp);\n _emergencyExitJailedTimestamp[_consensusAddr] = _revokingTimestamp;\n\n uint256 _deductedAmount = IStaking(msg.sender).execDeductStakingAmount(_consensusAddr, _emergencyExitLockedAmount);\n if (_deductedAmount > 0) {\n uint256 _recyclingAt = block.timestamp + _emergencyExpiryDuration;\n _lockedConsensusList.push(_consensusAddr);\n _info.lockedAmount = _deductedAmount;\n _info.recyclingAt = _recyclingAt;\n IRoninGovernanceAdmin(_getAdmin()).createEmergencyExitPoll(\n _consensusAddr,\n _candidateInfo[_consensusAddr].treasuryAddr,\n block.timestamp,\n _recyclingAt\n );\n }\n emit EmergencyExitRequested(_consensusAddr, _deductedAmount);\n }\n\n /**\n * @inheritdoc IEmergencyExit\n */\n function setEmergencyExitLockedAmount(uint256 _emergencyExitLockedAmount) external onlyAdmin {\n _setEmergencyExitLockedAmount(_emergencyExitLockedAmount);\n }\n\n /**\n * @inheritdoc IEmergencyExit\n */\n function setEmergencyExpiryDuration(uint256 _emergencyExpiryDuration) external onlyAdmin {\n _setEmergencyExpiryDuration(_emergencyExpiryDuration);\n }\n\n /**\n * @inheritdoc IEmergencyExit\n */\n function execReleaseLockedFundForEmergencyExitRequest(\n address _consensusAddr,\n address payable _recipient\n ) external onlyAdmin {\n if (_exitInfo[_consensusAddr].recyclingAt == 0) {\n return;\n }\n\n uint256 _length = _lockedConsensusList.length;\n uint256 _index = _length;\n\n for (uint _i; _i < _length; ) {\n if (_lockedConsensusList[_i] == _consensusAddr) {\n _index = _i;\n break;\n }\n\n unchecked {\n ++_i;\n }\n }\n\n // The locked amount might be recycled\n if (_index == _length) {\n return;\n }\n\n uint256 _amount = _exitInfo[_consensusAddr].lockedAmount;\n if (_amount > 0) {\n delete _exitInfo[_consensusAddr];\n if (_length > 1) {\n _lockedConsensusList[_index] = _lockedConsensusList[_length - 1];\n }\n _lockedConsensusList.pop();\n\n _lockedFundReleased[_consensusAddr] = true;\n if (_unsafeSendRONLimitGas(_recipient, _amount, DEFAULT_ADDITION_GAS)) {\n emit EmergencyExitLockedFundReleased(_consensusAddr, _recipient, _amount);\n return;\n }\n\n emit EmergencyExitLockedFundReleasingFailed(_consensusAddr, _recipient, _amount, address(this).balance);\n }\n }\n\n /**\n * @dev Tries to recycle the locked funds from emergency exit requests.\n */\n function _tryRecycleLockedFundsFromEmergencyExits() internal {\n uint256 _length = _lockedConsensusList.length;\n\n uint256 _i;\n address _addr;\n EmergencyExitInfo storage _info;\n\n while (_i < _length) {\n _addr = _lockedConsensusList[_i];\n _info = _exitInfo[_addr];\n\n if (_info.recyclingAt <= block.timestamp) {\n _totalDeprecatedReward += _info.lockedAmount;\n\n delete _exitInfo[_addr];\n if (--_length > 0) {\n _lockedConsensusList[_i] = _lockedConsensusList[_length];\n }\n _lockedConsensusList.pop();\n continue;\n }\n\n unchecked {\n _i++;\n }\n }\n }\n\n /**\n * @dev Override `CandidateManager-_emergencyExitLockedFundReleased`.\n */\n function _emergencyExitLockedFundReleased(address _consensusAddr) internal virtual override returns (bool) {\n return _lockedFundReleased[_consensusAddr];\n }\n\n /**\n * @dev Override `CandidateManager-_removeCandidate`.\n */\n function _removeCandidate(address _consensusAddr) internal override {\n delete _lockedFundReleased[_consensusAddr];\n super._removeCandidate(_consensusAddr);\n }\n\n /**\n * @dev See `setEmergencyExitLockedAmount.\n */\n function _setEmergencyExitLockedAmount(uint256 _amount) internal {\n _emergencyExitLockedAmount = _amount;\n emit EmergencyExitLockedAmountUpdated(_amount);\n }\n\n /**\n * @dev See `setEmergencyExpiryDuration`.\n */\n function _setEmergencyExpiryDuration(uint256 _duration) internal {\n _emergencyExpiryDuration = _duration;\n emit EmergencyExpiryDurationUpdated(_duration);\n }\n}\n" + }, + "contracts/ronin/validator/migrations/RoninValidatorSetTimedMigrator.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { ConditionalImplementControl } from \"../../../extensions/version-control/ConditionalImplementControl.sol\";\nimport { ITimingInfo } from \"../../../interfaces/validator/info-fragments/ITimingInfo.sol\";\nimport { ICoinbaseExecution } from \"../../../interfaces/validator/ICoinbaseExecution.sol\";\n\n/**\n * @title RoninValidatorSetTimedMigrator\n * @dev A contract that facilitates timed migration of the Ronin validator set using conditional version control.\n */\ncontract RoninValidatorSetTimedMigrator is ConditionalImplementControl {\n /**\n * @dev Modifier that executes the function when conditions are met.\n * If the function is {wrapUpEpoch} from {ICoinbaseExecution},\n * it checks the current period before and after execution.\n * If they differ, it triggers the {selfUpgrade} function.\n */\n modifier whenConditionsAreMet() override {\n if (msg.sig == ICoinbaseExecution.wrapUpEpoch.selector) {\n uint256 currentPeriod = _getCurrentPeriod();\n _;\n if (currentPeriod != _getCurrentPeriod()) {\n this.selfUpgrade();\n }\n } else {\n _;\n }\n }\n\n /**\n * @dev Constructs the {RoninValidatorSetTimedMigrator} contract.\n * @param proxyStorage The address of the proxy storage contract.\n * @param prevImpl The address of the current contract implementation.\n * @param newImpl The address of the new contract implementation.\n */\n constructor(\n address proxyStorage,\n address prevImpl,\n address newImpl\n ) ConditionalImplementControl(proxyStorage, prevImpl, newImpl) {}\n\n /**\n * @dev Internal function to choose the current version of the contract implementation.\n * @return The address of the current version implementation.\n */\n function _getConditionedImplementation() internal view override returns (address) {\n return PREV_IMPL;\n }\n\n /**\n * @dev Internal function to get the current period from ITimingInfo.\n * @return The current period.\n */\n function _getCurrentPeriod() private view returns (uint256) {\n return ITimingInfo(address(this)).currentPeriod();\n }\n}\n" + }, + "contracts/ronin/validator/RoninValidatorSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport \"../../interfaces/validator/IRoninValidatorSet.sol\";\nimport \"./CoinbaseExecution.sol\";\nimport \"./SlashingExecution.sol\";\n\ncontract RoninValidatorSet is Initializable, CoinbaseExecution, SlashingExecution {\n constructor() {\n _disableInitializers();\n }\n\n fallback() external payable {\n _fallback();\n }\n\n receive() external payable {\n _fallback();\n }\n\n /**\n * @dev Initializes the contract storage.\n */\n function initialize(\n address __slashIndicatorContract,\n address __stakingContract,\n address __stakingVestingContract,\n address __maintenanceContract,\n address __roninTrustedOrganizationContract,\n address /* __bridgeTrackingContract */,\n uint256 __maxValidatorNumber,\n uint256 __maxValidatorCandidate,\n uint256 __maxPrioritizedValidatorNumber,\n uint256 __minEffectiveDaysOnwards,\n uint256 __numberOfBlocksInEpoch,\n // __emergencyExitConfigs[0]: emergencyExitLockedAmount\n // __emergencyExitConfigs[1]: emergencyExpiryDuration\n uint256[2] calldata __emergencyExitConfigs\n ) external initializer {\n _setContract(ContractType.SLASH_INDICATOR, __slashIndicatorContract);\n _setContract(ContractType.STAKING, __stakingContract);\n _setContract(ContractType.STAKING_VESTING, __stakingVestingContract);\n _setContract(ContractType.MAINTENANCE, __maintenanceContract);\n _setContract(ContractType.RONIN_TRUSTED_ORGANIZATION, __roninTrustedOrganizationContract);\n\n _setMaxValidatorNumber(__maxValidatorNumber);\n _setMaxValidatorCandidate(__maxValidatorCandidate);\n _setMaxPrioritizedValidatorNumber(__maxPrioritizedValidatorNumber);\n _setMinEffectiveDaysOnwards(__minEffectiveDaysOnwards);\n _setEmergencyExitLockedAmount(__emergencyExitConfigs[0]);\n _setEmergencyExpiryDuration(__emergencyExitConfigs[1]);\n _numberOfBlocksInEpoch = __numberOfBlocksInEpoch;\n }\n\n function initializeV2() external reinitializer(2) {\n _setContract(ContractType.STAKING, ______deprecatedStakingContract);\n _setContract(ContractType.MAINTENANCE, ______deprecatedMaintenance);\n _setContract(ContractType.SLASH_INDICATOR, ______deprecatedSlashIndicator);\n _setContract(ContractType.STAKING_VESTING, ______deprecatedStakingVesting);\n _setContract(ContractType.RONIN_TRUSTED_ORGANIZATION, ______deprecatedTrustedOrg);\n\n delete ______deprecatedStakingContract;\n delete ______deprecatedMaintenance;\n delete ______deprecatedSlashIndicator;\n delete ______deprecatedStakingVesting;\n delete ______deprecatedBridgeTracking;\n delete ______deprecatedTrustedOrg;\n }\n\n /**\n * @dev Only receives RON from staking vesting contract (for topping up bonus), and from staking contract (for transferring\n * deducting amount on slashing).\n */\n function _fallback() internal view {\n if (msg.sender != getContract(ContractType.STAKING_VESTING) && msg.sender != getContract(ContractType.STAKING)) {\n revert ErrUnauthorizedReceiveRON();\n }\n }\n}\n" + }, + "contracts/ronin/validator/SlashingExecution.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../extensions/collections/HasContracts.sol\";\nimport \"../../interfaces/validator/ISlashingExecution.sol\";\nimport \"../../interfaces/staking/IStaking.sol\";\nimport \"../../libraries/Math.sol\";\nimport { HasSlashIndicatorDeprecated, HasStakingDeprecated } from \"../../utils/DeprecatedSlots.sol\";\nimport \"./storage-fragments/CommonStorage.sol\";\n\nabstract contract SlashingExecution is\n ISlashingExecution,\n HasContracts,\n HasSlashIndicatorDeprecated,\n HasStakingDeprecated,\n CommonStorage\n{\n /**\n * @inheritdoc ISlashingExecution\n */\n function execSlash(\n address _validatorAddr,\n uint256 _newJailedUntil,\n uint256 _slashAmount,\n bool _cannotBailout\n ) external override onlyContract(ContractType.SLASH_INDICATOR) {\n uint256 _period = currentPeriod();\n _miningRewardDeprecatedAtPeriod[_validatorAddr][_period] = true;\n\n _totalDeprecatedReward += _miningReward[_validatorAddr] + _delegatingReward[_validatorAddr];\n\n delete _miningReward[_validatorAddr];\n delete _delegatingReward[_validatorAddr];\n\n _blockProducerJailedBlock[_validatorAddr] = Math.max(_newJailedUntil, _blockProducerJailedBlock[_validatorAddr]);\n\n if (_slashAmount > 0) {\n uint256 _actualAmount = IStaking(getContract(ContractType.STAKING)).execDeductStakingAmount(\n _validatorAddr,\n _slashAmount\n );\n _totalDeprecatedReward += _actualAmount;\n }\n\n if (_cannotBailout) {\n _cannotBailoutUntilBlock[_validatorAddr] = Math.max(_newJailedUntil, _cannotBailoutUntilBlock[_validatorAddr]);\n }\n\n emit ValidatorPunished(\n _validatorAddr,\n _period,\n _blockProducerJailedBlock[_validatorAddr],\n _slashAmount,\n true,\n false\n );\n }\n\n /**\n * @inheritdoc ISlashingExecution\n */\n function execBailOut(\n address _validatorAddr,\n uint256 _period\n ) external override onlyContract(ContractType.SLASH_INDICATOR) {\n if (block.number <= _cannotBailoutUntilBlock[_validatorAddr]) revert ErrCannotBailout(_validatorAddr);\n\n // Note: Removing rewards of validator in `bailOut` function is not needed, since the rewards have been\n // removed previously in the `slash` function.\n _miningRewardBailoutCutOffAtPeriod[_validatorAddr][_period] = true;\n _miningRewardDeprecatedAtPeriod[_validatorAddr][_period] = false;\n _blockProducerJailedBlock[_validatorAddr] = block.number - 1;\n\n emit ValidatorUnjailed(_validatorAddr, _period);\n }\n}\n" + }, + "contracts/ronin/validator/storage-fragments/CommonStorage.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../../interfaces/validator/info-fragments/ICommonInfo.sol\";\nimport \"./JailingStorage.sol\";\nimport \"./TimingStorage.sol\";\nimport \"./ValidatorInfoStorageV2.sol\";\n\nabstract contract CommonStorage is ICommonInfo, TimingStorage, JailingStorage, ValidatorInfoStorageV2 {\n /// @dev Mapping from consensus address => pending reward from producing block\n mapping(address => uint256) internal _miningReward;\n /// @dev Mapping from consensus address => pending reward from delegating\n mapping(address => uint256) internal _delegatingReward;\n\n /// @dev The total reward for bridge operators\n uint256 internal ______deprecatedTotalBridgeReward;\n /// @dev Mapping from consensus address => pending reward for being bridge operator\n mapping(address => uint256) internal ______deprecatedBridgeOperatingReward;\n\n /// @dev The deprecated reward that has not been withdrawn by admin\n uint256 internal _totalDeprecatedReward;\n\n /// @dev The amount of RON to lock from a consensus address.\n uint256 internal _emergencyExitLockedAmount;\n /// @dev The duration that an emergency request is expired and the fund will be recycled.\n uint256 internal _emergencyExpiryDuration;\n /// @dev The address list of consensus addresses that being locked fund.\n address[] internal _lockedConsensusList;\n /// @dev Mapping from consensus => request exist info\n mapping(address => EmergencyExitInfo) internal _exitInfo;\n /// @dev Mapping from consensus => flag indicating whether the locked fund is released\n mapping(address => bool) internal _lockedFundReleased;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[44] private ______gap;\n\n /**\n * @inheritdoc ICommonInfo\n */\n function getEmergencyExitInfo(\n address _consensusAddr\n ) external view override returns (EmergencyExitInfo memory _info) {\n _info = _exitInfo[_consensusAddr];\n if (_info.recyclingAt == 0) revert NonExistentRecyclingInfo();\n }\n\n /**\n * @inheritdoc ICommonInfo\n */\n function totalDeprecatedReward() external view override returns (uint256) {\n return _totalDeprecatedReward;\n }\n\n /**\n * @inheritdoc ITimingInfo\n */\n function epochOf(\n uint256 _block\n ) public view virtual override(ITimingInfo, JailingStorage, TimingStorage) returns (uint256) {\n return TimingStorage.epochOf(_block);\n }\n\n /**\n * @inheritdoc ITimingInfo\n */\n function currentPeriod() public view virtual override(ITimingInfo, JailingStorage, TimingStorage) returns (uint256) {\n return TimingStorage.currentPeriod();\n }\n}\n" + }, + "contracts/ronin/validator/storage-fragments/JailingStorage.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../../interfaces/validator/info-fragments/IJailingInfo.sol\";\nimport \"./TimingStorage.sol\";\n\nabstract contract JailingStorage is IJailingInfo {\n /// @dev Mapping from consensus address => period number => block producer has no pending reward.\n mapping(address => mapping(uint256 => bool)) internal _miningRewardDeprecatedAtPeriod;\n /// @dev Mapping from consensus address => period number => whether the block producer get cut off reward, due to bailout.\n mapping(address => mapping(uint256 => bool)) internal _miningRewardBailoutCutOffAtPeriod;\n /// @dev Mapping from consensus address => period number => block operator has no pending reward.\n mapping(address => mapping(uint256 => bool)) internal ______deprecatedBridgeRewardDeprecatedAtPeriod;\n\n /// @dev Mapping from consensus address => the last block that the block producer is jailed.\n mapping(address => uint256) internal _blockProducerJailedBlock;\n /// @dev Mapping from consensus address => the last timestamp that the bridge operator is jailed.\n mapping(address => uint256) internal _emergencyExitJailedTimestamp;\n /// @dev Mapping from consensus address => the last block that the block producer cannot bailout.\n mapping(address => uint256) internal _cannotBailoutUntilBlock;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[48] private ______gap;\n\n /**\n * @inheritdoc IJailingInfo\n */\n function checkJailed(address _addr) external view override returns (bool) {\n return checkJailedAtBlock(_addr, block.number);\n }\n\n /**\n * @inheritdoc IJailingInfo\n */\n function getJailedTimeLeft(\n address _addr\n ) external view override returns (bool isJailed_, uint256 blockLeft_, uint256 epochLeft_) {\n return getJailedTimeLeftAtBlock(_addr, block.number);\n }\n\n /**\n * @inheritdoc IJailingInfo\n */\n function checkJailedAtBlock(address _addr, uint256 _blockNum) public view override returns (bool) {\n return _jailedAtBlock(_addr, _blockNum);\n }\n\n /**\n * @inheritdoc IJailingInfo\n */\n function getJailedTimeLeftAtBlock(\n address _addr,\n uint256 _blockNum\n ) public view override returns (bool isJailed_, uint256 blockLeft_, uint256 epochLeft_) {\n uint256 _jailedBlock = _blockProducerJailedBlock[_addr];\n if (_jailedBlock < _blockNum) {\n return (false, 0, 0);\n }\n\n isJailed_ = true;\n blockLeft_ = _jailedBlock - _blockNum + 1;\n epochLeft_ = epochOf(_jailedBlock) - epochOf(_blockNum) + 1;\n }\n\n /**\n * @inheritdoc IJailingInfo\n */\n function checkManyJailed(address[] calldata _addrList) external view override returns (bool[] memory _result) {\n _result = new bool[](_addrList.length);\n for (uint256 _i; _i < _addrList.length; ) {\n _result[_i] = _jailed(_addrList[_i]);\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IJailingInfo\n */\n function checkMiningRewardDeprecated(address _blockProducer) external view override returns (bool _result) {\n uint256 _period = currentPeriod();\n return _miningRewardDeprecated(_blockProducer, _period);\n }\n\n /**\n * @inheritdoc IJailingInfo\n */\n function checkMiningRewardDeprecatedAtPeriod(\n address _blockProducer,\n uint256 _period\n ) external view override returns (bool _result) {\n return _miningRewardDeprecated(_blockProducer, _period);\n }\n\n /**\n * @dev See `ITimingInfo-epochOf`\n */\n function epochOf(uint256 _block) public view virtual returns (uint256);\n\n /**\n * @dev See `ITimingInfo-currentPeriod`\n */\n function currentPeriod() public view virtual returns (uint256);\n\n /**\n * @dev Returns whether the reward of the validator is put in jail (cannot join the set of validators) during the current period.\n */\n function _jailed(address _validatorAddr) internal view returns (bool) {\n return _jailedAtBlock(_validatorAddr, block.number);\n }\n\n /**\n * @dev Returns whether the reward of the validator is put in jail (cannot join the set of validators) at a specific block.\n */\n function _jailedAtBlock(address _validatorAddr, uint256 _blockNum) internal view returns (bool) {\n return _blockNum <= _blockProducerJailedBlock[_validatorAddr];\n }\n\n /**\n * @dev Returns whether the block producer has no pending reward in that period.\n */\n function _miningRewardDeprecated(address _validatorAddr, uint256 _period) internal view returns (bool) {\n return _miningRewardDeprecatedAtPeriod[_validatorAddr][_period];\n }\n}\n" + }, + "contracts/ronin/validator/storage-fragments/TimingStorage.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../../extensions/consumers/GlobalConfigConsumer.sol\";\nimport \"../../../interfaces/validator/info-fragments/ITimingInfo.sol\";\n\nabstract contract TimingStorage is ITimingInfo, GlobalConfigConsumer {\n /// @dev The number of blocks in a epoch\n uint256 internal _numberOfBlocksInEpoch;\n /// @dev The last updated block\n uint256 internal _lastUpdatedBlock;\n /// @dev The last updated period\n uint256 internal _lastUpdatedPeriod;\n /// @dev The starting block of the last updated period\n uint256 internal _currentPeriodStartAtBlock;\n\n /// @dev Mapping from epoch index => period index\n mapping(uint256 => uint256) internal _periodOf;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[49] private ______gap;\n\n /**\n * @inheritdoc ITimingInfo\n */\n function getLastUpdatedBlock() external view override returns (uint256) {\n return _lastUpdatedBlock;\n }\n\n /**\n * @inheritdoc ITimingInfo\n */\n function epochOf(uint256 _block) public view virtual override returns (uint256) {\n return _block / _numberOfBlocksInEpoch + 1;\n }\n\n /**\n * @inheritdoc ITimingInfo\n */\n function tryGetPeriodOfEpoch(uint256 _epoch) external view returns (bool _filled, uint256 _periodNumber) {\n return (_epoch <= epochOf(block.number) || _periodOf[_epoch] > 0, _periodOf[_epoch]);\n }\n\n /**\n * @inheritdoc ITimingInfo\n */\n function isPeriodEnding() external view override returns (bool) {\n return _isPeriodEnding(_computePeriod(block.timestamp));\n }\n\n /**\n * @inheritdoc ITimingInfo\n */\n function epochEndingAt(uint256 _block) public view virtual override returns (bool) {\n return _block % _numberOfBlocksInEpoch == _numberOfBlocksInEpoch - 1;\n }\n\n /**\n * @inheritdoc ITimingInfo\n */\n function currentPeriod() public view virtual override returns (uint256) {\n return _lastUpdatedPeriod;\n }\n\n /**\n * @inheritdoc ITimingInfo\n */\n function currentPeriodStartAtBlock() public view override returns (uint256) {\n return _currentPeriodStartAtBlock;\n }\n\n /**\n * @inheritdoc ITimingInfo\n */\n function numberOfBlocksInEpoch() public view virtual override returns (uint256 _numberOfBlocks) {\n return _numberOfBlocksInEpoch;\n }\n\n /**\n * @dev See `ITimingInfo-isPeriodEnding`\n */\n function _isPeriodEnding(uint256 _newPeriod) internal view virtual returns (bool) {\n return _newPeriod > _lastUpdatedPeriod;\n }\n\n /**\n * @dev Returns the calculated period.\n */\n function _computePeriod(uint256 _timestamp) internal pure returns (uint256) {\n return _timestamp / PERIOD_DURATION;\n }\n}\n" + }, + "contracts/ronin/validator/storage-fragments/ValidatorInfoStorage.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../../libraries/EnumFlags.sol\";\nimport { HasTrustedOrgDeprecated } from \"../../../utils/DeprecatedSlots.sol\";\nimport \"../../../extensions/collections/HasContracts.sol\";\nimport \"../../../interfaces/validator/info-fragments/IValidatorInfo.sol\";\n\nabstract contract ValidatorInfoStorage is IValidatorInfo, HasContracts, HasTrustedOrgDeprecated {\n using EnumFlags for EnumFlags.ValidatorFlag;\n\n /// @dev The maximum number of validator.\n uint256 internal _maxValidatorNumber;\n\n /// @dev The total of validators\n uint256 public validatorCount;\n /// @dev Mapping from validator index => validator address\n mapping(uint256 => address) internal _validators;\n /// @dev Mapping from address => flag indicating the validator ability: producing block, operating bridge\n mapping(address => EnumFlags.ValidatorFlag) internal _validatorMap;\n /// @dev The number of slot that is reserved for prioritized validators\n uint256 internal _maxPrioritizedValidatorNumber;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[50] private ______gap;\n\n /**\n * @inheritdoc IValidatorInfo\n */\n function getValidators()\n public\n view\n override\n returns (\n address[] memory _validatorList,\n address[] memory _bridgeOperators,\n EnumFlags.ValidatorFlag[] memory _flags\n )\n {\n _validatorList = new address[](validatorCount);\n _bridgeOperators = new address[](validatorCount);\n _flags = new EnumFlags.ValidatorFlag[](validatorCount);\n for (uint _i; _i < _validatorList.length; ) {\n address _validator = _validators[_i];\n _validatorList[_i] = _validator;\n _bridgeOperators[_i] = _bridgeOperatorOf(_validator);\n _flags[_i] = _validatorMap[_validator];\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IValidatorInfo\n */\n function isValidator(address _addr) public view override returns (bool) {\n return !_validatorMap[_addr].isNone();\n }\n\n /**\n * @inheritdoc IValidatorInfo\n */\n function getBlockProducers() public view override returns (address[] memory _result) {\n _result = new address[](validatorCount);\n uint256 _count = 0;\n for (uint _i; _i < _result.length; ) {\n if (isBlockProducer(_validators[_i])) {\n _result[_count++] = _validators[_i];\n }\n\n unchecked {\n ++_i;\n }\n }\n\n assembly {\n mstore(_result, _count)\n }\n }\n\n /**\n * @inheritdoc IValidatorInfo\n */\n function isBlockProducer(address _addr) public view override returns (bool) {\n return _validatorMap[_addr].hasFlag(EnumFlags.ValidatorFlag.BlockProducer);\n }\n\n /**\n * @inheritdoc IValidatorInfo\n */\n function totalBlockProducers() external view returns (uint256 _total) {\n unchecked {\n for (uint _i; _i < validatorCount; _i++) {\n if (isBlockProducer(_validators[_i])) {\n _total++;\n }\n }\n }\n }\n\n /**\n * @inheritdoc IValidatorInfo\n */\n function getBridgeOperators()\n public\n view\n override\n returns (address[] memory _bridgeOperatorList, address[] memory _validatorList)\n {\n uint256 _length = validatorCount;\n _bridgeOperatorList = new address[](_length);\n _validatorList = new address[](_length);\n uint256 _count = 0;\n unchecked {\n for (uint _i; _i < _length; ++_i) {\n if (isOperatingBridge(_validators[_i])) {\n address __validator = _validators[_i];\n _bridgeOperatorList[_count] = _bridgeOperatorOf(__validator);\n _validatorList[_count++] = __validator;\n }\n }\n }\n\n assembly {\n mstore(_bridgeOperatorList, _count)\n mstore(_validatorList, _count)\n }\n }\n\n /**\n * @inheritdoc IValidatorInfo\n */\n function getBridgeOperatorsOf(\n address[] memory _validatorAddrs\n ) public view override returns (address[] memory _bridgeOperatorList) {\n _bridgeOperatorList = new address[](_validatorAddrs.length);\n for (uint _i; _i < _bridgeOperatorList.length; ) {\n _bridgeOperatorList[_i] = _bridgeOperatorOf(_validatorAddrs[_i]);\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IValidatorInfo\n */\n function isBridgeOperator(address _bridgeOperatorAddr) external view override returns (bool _isOperator) {\n for (uint _i; _i < validatorCount; ) {\n if (_bridgeOperatorOf(_validators[_i]) == _bridgeOperatorAddr && isOperatingBridge(_validators[_i])) {\n _isOperator = true;\n break;\n }\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IValidatorInfo\n */\n function isOperatingBridge(address _consensusAddr) public view override returns (bool) {\n return _validatorMap[_consensusAddr].hasFlag(EnumFlags.ValidatorFlag.DeprecatedBridgeOperator);\n }\n\n /**\n * @inheritdoc IValidatorInfo\n */\n function maxValidatorNumber() external view override returns (uint256 _maximumValidatorNumber) {\n return _maxValidatorNumber;\n }\n\n /**\n * @inheritdoc IValidatorInfo\n */\n function maxPrioritizedValidatorNumber() external view override returns (uint256 _maximumPrioritizedValidatorNumber) {\n return _maxPrioritizedValidatorNumber;\n }\n\n /**\n * @inheritdoc IValidatorInfo\n */\n function totalBridgeOperators() public view returns (uint256 _total) {\n unchecked {\n for (uint _i; _i < validatorCount; _i++) {\n if (isOperatingBridge(_validators[_i])) {\n _total++;\n }\n }\n }\n }\n\n /**\n * @inheritdoc IValidatorInfo\n */\n function setMaxValidatorNumber(uint256 _max) external override onlyAdmin {\n _setMaxValidatorNumber(_max);\n }\n\n /**\n * @inheritdoc IValidatorInfo\n */\n function setMaxPrioritizedValidatorNumber(uint256 _number) external override onlyAdmin {\n _setMaxPrioritizedValidatorNumber(_number);\n }\n\n /**\n * @dev Returns the bridge operator of a consensus address.\n */\n function _bridgeOperatorOf(address _consensusAddr) internal view virtual returns (address);\n\n /**\n * @dev See `IValidatorInfo-setMaxValidatorNumber`\n */\n function _setMaxValidatorNumber(uint256 _number) internal {\n _maxValidatorNumber = _number;\n emit MaxValidatorNumberUpdated(_number);\n }\n\n /**\n * @dev See `IValidatorInfo-setMaxPrioritizedValidatorNumber`\n */\n function _setMaxPrioritizedValidatorNumber(uint256 _number) internal {\n if (_number > _maxValidatorNumber) revert ErrInvalidMaxPrioritizedValidatorNumber();\n _maxPrioritizedValidatorNumber = _number;\n emit MaxPrioritizedValidatorNumberUpdated(_number);\n }\n}\n" + }, + "contracts/ronin/validator/storage-fragments/ValidatorInfoStorageV2.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../../libraries/EnumFlags.sol\";\nimport { HasTrustedOrgDeprecated } from \"../../../utils/DeprecatedSlots.sol\";\nimport \"../../../extensions/collections/HasContracts.sol\";\nimport \"../../../interfaces/validator/info-fragments/IValidatorInfoV2.sol\";\n\nabstract contract ValidatorInfoStorageV2 is IValidatorInfoV2, HasContracts, HasTrustedOrgDeprecated {\n using EnumFlags for EnumFlags.ValidatorFlag;\n\n /// @dev The maximum number of validator.\n uint256 internal _maxValidatorNumber;\n\n /// @dev The total of validators\n uint256 public validatorCount;\n /// @dev Mapping from validator index => validator address\n mapping(uint256 => address) internal _validators;\n /// @dev Mapping from address => flag indicating the validator ability: producing block, operating bridge\n mapping(address => EnumFlags.ValidatorFlag) internal _validatorMap;\n /// @dev The number of slot that is reserved for prioritized validators\n uint256 internal _maxPrioritizedValidatorNumber;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[50] private ______gap;\n\n /**\n * @inheritdoc IValidatorInfoV2\n */\n function getValidators() public view override returns (address[] memory _validatorList) {\n _validatorList = new address[](validatorCount);\n for (uint _i; _i < _validatorList.length; ) {\n address _validator = _validators[_i];\n _validatorList[_i] = _validator;\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IValidatorInfoV2\n */\n function getBlockProducers() public view override returns (address[] memory _result) {\n _result = new address[](validatorCount);\n uint256 _count = 0;\n for (uint _i; _i < _result.length; ) {\n if (isBlockProducer(_validators[_i])) {\n _result[_count++] = _validators[_i];\n }\n\n unchecked {\n ++_i;\n }\n }\n\n assembly {\n mstore(_result, _count)\n }\n }\n\n /**\n * @inheritdoc IValidatorInfoV2\n */\n function isBlockProducer(address _addr) public view override returns (bool) {\n return _validatorMap[_addr].hasFlag(EnumFlags.ValidatorFlag.BlockProducer);\n }\n\n /**\n * @inheritdoc IValidatorInfoV2\n */\n function totalBlockProducers() external view returns (uint256 _total) {\n unchecked {\n for (uint _i; _i < validatorCount; _i++) {\n if (isBlockProducer(_validators[_i])) {\n _total++;\n }\n }\n }\n }\n\n /**\n * @inheritdoc IValidatorInfoV2\n */\n function maxValidatorNumber() external view override returns (uint256 _maximumValidatorNumber) {\n return _maxValidatorNumber;\n }\n\n /**\n * @inheritdoc IValidatorInfoV2\n */\n function maxPrioritizedValidatorNumber() external view override returns (uint256 _maximumPrioritizedValidatorNumber) {\n return _maxPrioritizedValidatorNumber;\n }\n\n /**\n * @inheritdoc IValidatorInfoV2\n */\n function setMaxValidatorNumber(uint256 _max) external override onlyAdmin {\n _setMaxValidatorNumber(_max);\n }\n\n /**\n * @inheritdoc IValidatorInfoV2\n */\n function setMaxPrioritizedValidatorNumber(uint256 _number) external override onlyAdmin {\n _setMaxPrioritizedValidatorNumber(_number);\n }\n\n /**\n * @dev See `IValidatorInfoV2-setMaxValidatorNumber`\n */\n function _setMaxValidatorNumber(uint256 _number) internal {\n _maxValidatorNumber = _number;\n emit MaxValidatorNumberUpdated(_number);\n }\n\n /**\n * @dev See `IValidatorInfoV2-setMaxPrioritizedValidatorNumber`\n */\n function _setMaxPrioritizedValidatorNumber(uint256 _number) internal {\n if (_number > _maxValidatorNumber) revert ErrInvalidMaxPrioritizedValidatorNumber();\n _maxPrioritizedValidatorNumber = _number;\n emit MaxPrioritizedValidatorNumberUpdated(_number);\n }\n}\n" + }, + "contracts/ronin/VaultForwarder.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../extensions/forwarder/Forwarder.sol\";\nimport \"../extensions/RONTransferHelper.sol\";\n\n/**\n * @title A vault contract that keeps RON, and behaves as an EOA account to interact with a target contract.\n * @dev There are three roles of interaction:\n * - Admin: top-up and withdraw RON to the vault, cannot forward call to the target.\n * - Moderator: forward all calls to the target, can top-up RON, cannot withdraw RON.\n * - Others: can top-up RON, cannot execute any other actions.\n */\ncontract VaultForwarder is Forwarder, RONTransferHelper {\n /// @dev Emitted when the admin withdraws all RON from the forwarder contract.\n event ForwarderRONWithdrawn(address indexed _recipient, uint256 _value);\n\n constructor(address[] memory _targets, address _admin, address _mod) Forwarder(_targets, _admin, _mod) {}\n\n /**\n * @dev Withdraws all balance from the transfer to the admin.\n *\n * Requirements:\n * - Only the admin can call this method.\n */\n function withdrawAll() external onlyRole(DEFAULT_ADMIN_ROLE) {\n uint256 _value = address(this).balance;\n emit ForwarderRONWithdrawn(msg.sender, _value);\n _transferRON(payable(msg.sender), _value);\n }\n}\n" + }, + "contracts/types/operations/LibTUint256Slot.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.17;\n\nimport { TUint256Slot } from \"../Types.sol\";\n\n/**\n * @title LibTUint256Slot\n * @dev Library for handling unsigned 256-bit integers.\n */\nlibrary LibTUint256Slot {\n /// @dev value is equal to bytes4(keccak256(\"Panic(uint256)\"))\n /// @dev see: https://github.com/foundry-rs/forge-std/blob/master/src/StdError.sol\n uint256 private constant PANIC_ERROR_SIGNATURE = 0x4e487b71;\n /// @dev error code for {Arithmetic over/underflow} error\n uint256 private constant ARITHMETIC_ERROR_CODE = 0x11;\n /// @dev error code for {Division or modulo by 0} error\n uint256 private constant DIVISION_ERROR_CODE = 0x12;\n\n /**\n * @dev Loads the value of the TUint256Slot variable.\n * @param self The TUint256Slot variable.\n * @return val The loaded value.\n */\n function load(TUint256Slot self) internal view returns (uint256 val) {\n assembly {\n val := sload(self)\n }\n }\n\n /**\n * @dev Stores a value into the TUint256Slot variable.\n * @param self The TUint256Slot variable.\n * @param other The value to be stored.\n */\n function store(TUint256Slot self, uint256 other) internal {\n assembly {\n sstore(self, other)\n }\n }\n\n /**\n * @dev Multiplies the TUint256Slot variable by a given value.\n * @param self The TUint256Slot variable.\n * @param other The value to multiply by.\n * @return res The resulting value after multiplication.\n */\n function mul(TUint256Slot self, uint256 other) internal view returns (uint256 res) {\n assembly {\n let storedVal := sload(self)\n if iszero(iszero(storedVal)) {\n res := mul(storedVal, other)\n\n // Overflow check\n if iszero(eq(other, div(res, storedVal))) {\n // Store 4 bytes the function selector of Panic(uint256)\n // Equivalent to revert Panic(uint256)\n mstore(0x00, PANIC_ERROR_SIGNATURE)\n // Store 4 bytes of division error code in the next slot\n mstore(0x20, ARITHMETIC_ERROR_CODE)\n // Revert 36 bytes of error starting from 0x1c\n revert(0x1c, 0x24)\n }\n }\n }\n }\n\n /**\n * @dev Divides the TUint256Slot variable by a given value.\n * @param self The TUint256Slot variable.\n * @param other The value to divide by.\n * @return res The resulting value after division.\n */\n function div(TUint256Slot self, uint256 other) internal view returns (uint256 res) {\n assembly {\n let storedVal := sload(self)\n // revert if divide by zero\n if iszero(other) {\n // Store 4 bytes the function selector of Panic(uint256)\n // Equivalent to revert Panic(uint256)\n mstore(0x00, PANIC_ERROR_SIGNATURE)\n // Store 4 bytes of division error code in the next slot\n mstore(0x20, DIVISION_ERROR_CODE)\n // Revert 36 bytes of error starting from 0x1c\n revert(0x1c, 0x24)\n }\n res := div(storedVal, other)\n }\n }\n\n /**\n * @dev Subtracts a given value from the TUint256Slot variable.\n * @param self The TUint256Slot variable.\n * @param other The value to subtract.\n * @return res The resulting value after subtraction.\n */\n function sub(TUint256Slot self, uint256 other) internal view returns (uint256 res) {\n assembly {\n let storedVal := sload(self)\n\n // Underflow check\n if lt(storedVal, other) {\n // Store 4 bytes the function selector of Panic(uint256)\n // Equivalent to revert Panic(uint256)\n mstore(0x00, PANIC_ERROR_SIGNATURE)\n // Store 4 bytes of division error code in the next slot\n mstore(0x20, ARITHMETIC_ERROR_CODE)\n // Revert 36 bytes of error starting from 0x1c\n revert(0x1c, 0x24)\n }\n\n res := sub(storedVal, other)\n }\n }\n\n /**\n * @dev Adds a given value to the TUint256Slot variable.\n * @param self The TUint256Slot variable.\n * @param other The value to add.\n * @return res The resulting value after addition.\n */\n function add(TUint256Slot self, uint256 other) internal view returns (uint256 res) {\n assembly {\n let storedVal := sload(self)\n res := add(storedVal, other)\n\n // Overflow check\n if lt(res, other) {\n // Store 4 bytes the function selector of Panic(uint256)\n // Equivalent to revert Panic(uint256)\n mstore(0x00, PANIC_ERROR_SIGNATURE)\n // Store 4 bytes of division error code in the next slot\n mstore(0x20, ARITHMETIC_ERROR_CODE)\n // Revert 36 bytes of error starting from 0x1c\n revert(0x1c, 0x24)\n }\n }\n }\n\n /**\n * @dev Increments the TUint256Slot variable by 1 and returns the new value.\n * @param self The TUint256Slot variable.\n * @return res The resulting value after incrementing.\n */\n function preIncrement(TUint256Slot self) internal returns (uint256 res) {\n res = addAssign(self, 1);\n }\n\n /**\n * @dev Increments the TUint256Slot variable by 1 and returns the original value.\n * @param self The TUint256Slot variable.\n * @return res The original value before incrementing.\n */\n function postIncrement(TUint256Slot self) internal returns (uint256 res) {\n res = load(self);\n store(self, res + 1);\n }\n\n /**\n * @dev Decrements the TUint256Slot variable by 1 and returns the new value.\n * @param self The TUint256Slot variable.\n * @return res The resulting value after decrementing.\n */\n function preDecrement(TUint256Slot self) internal returns (uint256 res) {\n res = subAssign(self, 1);\n }\n\n /**\n * @dev Decrements the TUint256Slot variable by 1 and returns the new value.\n * @param self The TUint256Slot variable.\n * @return res The resulting value before decrementing.\n */\n function postDecrement(TUint256Slot self) internal returns (uint256 res) {\n res = load(self);\n store(self, res - 1);\n }\n\n /**\n * @dev Adds a given value to the TUint256Slot variable and stores the result.\n * @param self The TUint256Slot variable.\n * @param other The value to add.\n * @return res The resulting value after addition and storage.\n */\n function addAssign(TUint256Slot self, uint256 other) internal returns (uint256 res) {\n store(self, res = add(self, other));\n }\n\n /**\n * @dev Subtracts a given value from the TUint256Slot variable and stores the result.\n * @param self The TUint256Slot variable.\n * @param other The value to subtract.\n * @return res The resulting value after subtraction and storage.\n */\n function subAssign(TUint256Slot self, uint256 other) internal returns (uint256 res) {\n store(self, res = sub(self, other));\n }\n}\n" + }, + "contracts/types/Types.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.17;\n\nimport { LibTUint256Slot } from \"./operations/LibTUint256Slot.sol\";\n\ntype TUint256Slot is bytes32;\n\nusing {\n LibTUint256Slot.add,\n LibTUint256Slot.sub,\n LibTUint256Slot.mul,\n LibTUint256Slot.div,\n LibTUint256Slot.load,\n LibTUint256Slot.store,\n LibTUint256Slot.addAssign,\n LibTUint256Slot.subAssign,\n LibTUint256Slot.preDecrement,\n LibTUint256Slot.postDecrement,\n LibTUint256Slot.preIncrement,\n LibTUint256Slot.postIncrement\n} for TUint256Slot global;\n" + }, + "contracts/utils/CommonErrors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { ContractType } from \"./ContractType.sol\";\nimport { RoleAccess } from \"./RoleAccess.sol\";\n\nerror ErrSyncTooFarPeriod(uint256 period, uint256 latestRewardedPeriod);\n/**\n * @dev Error thrown when an address is expected to be an already created externally owned account (EOA).\n * This error indicates that the provided address is invalid for certain contract operations that require already created EOA.\n */\nerror ErrAddressIsNotCreatedEOA(address addr, bytes32 codehash);\n/**\n * @dev Error raised when a bridge operator update operation fails.\n * @param bridgeOperator The address of the bridge operator that failed to update.\n */\nerror ErrBridgeOperatorUpdateFailed(address bridgeOperator);\n/**\n * @dev Error thrown when attempting to add a bridge operator that already exists in the contract.\n * This error indicates that the provided bridge operator address is already registered as a bridge operator in the contract.\n */\nerror ErrBridgeOperatorAlreadyExisted(address bridgeOperator);\n/**\n * @dev The error indicating an unsupported interface.\n * @param interfaceId The bytes4 interface identifier that is not supported.\n * @param addr The address where the unsupported interface was encountered.\n */\nerror ErrUnsupportedInterface(bytes4 interfaceId, address addr);\n/**\n * @dev Error thrown when the return data from a callback function is invalid.\n * @param callbackFnSig The signature of the callback function that returned invalid data.\n * @param register The address of the register where the callback function was invoked.\n * @param returnData The invalid return data received from the callback function.\n */\nerror ErrInvalidReturnData(bytes4 callbackFnSig, address register, bytes returnData);\n/**\n * @dev Error of set to non-contract.\n */\nerror ErrZeroCodeContract(address addr);\n/**\n * @dev Error indicating that arguments are invalid.\n */\nerror ErrInvalidArguments(bytes4 msgSig);\n/**\n * @dev Error indicating that given address is null when it should not.\n */\nerror ErrZeroAddress(bytes4 msgSig);\n/**\n * @dev Error indicating that the provided threshold is invalid for a specific function signature.\n * @param msgSig The function signature (bytes4) that the invalid threshold applies to.\n */\nerror ErrInvalidThreshold(bytes4 msgSig);\n\n/**\n * @dev Error indicating that a function can only be called by the contract itself.\n * @param msgSig The function signature (bytes4) that can only be called by the contract itself.\n */\nerror ErrOnlySelfCall(bytes4 msgSig);\n\n/**\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\n * @param msgSig The function signature (bytes4) that the caller is unauthorized to perform.\n * @param expectedRole The role required to perform the function.\n */\nerror ErrUnauthorized(bytes4 msgSig, RoleAccess expectedRole);\n\n/**\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\n * @param msgSig The function signature (bytes4) that the caller is unauthorized to perform.\n */\nerror ErrUnauthorizedCall(bytes4 msgSig);\n\n/**\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\n * @param msgSig The function signature (bytes4).\n * @param expectedContractType The contract type required to perform the function.\n * @param actual The actual address that called to the function.\n */\nerror ErrUnexpectedInternalCall(bytes4 msgSig, ContractType expectedContractType, address actual);\n\n/**\n * @dev Error indicating that an array is empty when it should contain elements.\n */\nerror ErrEmptyArray();\n\n/**\n * @dev Error indicating a mismatch in the length of input parameters or arrays for a specific function.\n * @param msgSig The function signature (bytes4) that has a length mismatch.\n */\nerror ErrLengthMismatch(bytes4 msgSig);\n\n/**\n * @dev Error indicating that a proxy call to an external contract has failed.\n * @param msgSig The function signature (bytes4) of the proxy call that failed.\n * @param extCallSig The function signature (bytes4) of the external contract call that failed.\n */\nerror ErrProxyCallFailed(bytes4 msgSig, bytes4 extCallSig);\n\n/**\n * @dev Error indicating that a function tried to call a precompiled contract that is not allowed.\n * @param msgSig The function signature (bytes4) that attempted to call a precompiled contract.\n */\nerror ErrCallPrecompiled(bytes4 msgSig);\n\n/**\n * @dev Error indicating that a native token transfer has failed.\n * @param msgSig The function signature (bytes4) of the token transfer that failed.\n */\nerror ErrNativeTransferFailed(bytes4 msgSig);\n\n/**\n * @dev Error indicating that an order is invalid.\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid order.\n */\nerror ErrInvalidOrder(bytes4 msgSig);\n\n/**\n * @dev Error indicating that the chain ID is invalid.\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid chain ID.\n * @param actual Current chain ID that executing function.\n * @param expected Expected chain ID required for the tx to success.\n */\nerror ErrInvalidChainId(bytes4 msgSig, uint256 actual, uint256 expected);\n\n/**\n * @dev Error indicating that a vote type is not supported.\n * @param msgSig The function signature (bytes4) of the operation that encountered an unsupported vote type.\n */\nerror ErrUnsupportedVoteType(bytes4 msgSig);\n\n/**\n * @dev Error indicating that the proposal nonce is invalid.\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid proposal nonce.\n */\nerror ErrInvalidProposalNonce(bytes4 msgSig);\n\n/**\n * @dev Error indicating that a voter has already voted.\n * @param voter The address of the voter who has already voted.\n */\nerror ErrAlreadyVoted(address voter);\n\n/**\n * @dev Error indicating that a signature is invalid for a specific function signature.\n * @param msgSig The function signature (bytes4) that encountered an invalid signature.\n */\nerror ErrInvalidSignatures(bytes4 msgSig);\n\n/**\n * @dev Error indicating that a relay call has failed.\n * @param msgSig The function signature (bytes4) of the relay call that failed.\n */\nerror ErrRelayFailed(bytes4 msgSig);\n/**\n * @dev Error indicating that a vote weight is invalid for a specific function signature.\n * @param msgSig The function signature (bytes4) that encountered an invalid vote weight.\n */\nerror ErrInvalidVoteWeight(bytes4 msgSig);\n\n/**\n * @dev Error indicating that a query was made for an outdated bridge operator set.\n */\nerror ErrQueryForOutdatedBridgeOperatorSet();\n\n/**\n * @dev Error indicating that a request is invalid.\n */\nerror ErrInvalidRequest();\n\n/**\n * @dev Error indicating that a token standard is invalid.\n */\nerror ErrInvalidTokenStandard();\n\n/**\n * @dev Error indicating that a token is not supported.\n */\nerror ErrUnsupportedToken();\n\n/**\n * @dev Error indicating that a receipt kind is invalid.\n */\nerror ErrInvalidReceiptKind();\n\n/**\n * @dev Error indicating that a receipt is invalid.\n */\nerror ErrInvalidReceipt();\n\n/**\n * @dev Error indicating that an address is not payable.\n */\nerror ErrNonpayableAddress(address);\n\n/**\n * @dev Error indicating that the period is already processed, i.e. scattered reward.\n */\nerror ErrPeriodAlreadyProcessed(uint256 requestingPeriod, uint256 latestPeriod);\n\n/**\n * @dev Error thrown when an invalid vote hash is provided.\n */\nerror ErrInvalidVoteHash();\n\n/**\n * @dev Error thrown when querying for an empty vote.\n */\nerror ErrQueryForEmptyVote();\n\n/**\n * @dev Error thrown when querying for an expired vote.\n */\nerror ErrQueryForExpiredVote();\n\n/**\n * @dev Error thrown when querying for a non-existent vote.\n */\nerror ErrQueryForNonExistentVote();\n" + }, + "contracts/utils/ContractType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nenum ContractType {\n /* 0 */ UNKNOWN,\n /* 1 */ PAUSE_ENFORCER,\n /* 2 */ BRIDGE,\n /* 3 */ BRIDGE_TRACKING,\n /* 4 */ GOVERNANCE_ADMIN,\n /* 5 */ MAINTENANCE,\n /* 6 */ SLASH_INDICATOR,\n /* 7 */ STAKING_VESTING,\n /* 8 */ VALIDATOR,\n /* 9 */ STAKING,\n /* 10 */ RONIN_TRUSTED_ORGANIZATION,\n /* 11 */ BRIDGE_MANAGER,\n /* 12 */ BRIDGE_SLASH,\n /* 13 */ BRIDGE_REWARD\n}\n" + }, + "contracts/utils/DeprecatedSlots.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n * @title Deprecated Contracts\n * @dev These abstract contracts are deprecated and should not be used in new implementations.\n * They provide functionality related to various aspects of a smart contract but have been marked\n * as deprecated to indicate that they are no longer actively maintained or recommended for use.\n * The purpose of these contracts is to preserve the slots for already deployed contracts.\n */\ncontract HasSlashIndicatorDeprecated {\n /// @custom:deprecated Previously `_slashIndicatorContract` (non-zero value)\n address internal ______deprecatedSlashIndicator;\n}\n\ncontract HasStakingVestingDeprecated {\n /// @custom:deprecated Previously `_stakingVestingContract` (non-zero value)\n address internal ______deprecatedStakingVesting;\n}\n\ncontract HasBridgeDeprecated {\n /// @custom:deprecated Previously `_bridgeContract` (non-zero value)\n address internal ______deprecatedBridge;\n}\n\ncontract HasValidatorDeprecated {\n /// @custom:deprecated Previously `_validatorContract` (non-zero value)\n address internal ______deprecatedValidator;\n}\n\ncontract HasStakingDeprecated {\n /// @custom:deprecated Previously `_stakingContract` (non-zero value)\n address internal ______deprecatedStakingContract;\n}\n\ncontract HasMaintenanceDeprecated {\n /// @custom:deprecated Previously `_maintenanceContract` (non-zero value)\n address internal ______deprecatedMaintenance;\n}\n\ncontract HasTrustedOrgDeprecated {\n /// @custom:deprecated Previously `_trustedOrgContract` (non-zero value)\n address internal ______deprecatedTrustedOrg;\n}\n\ncontract HasGovernanceAdminDeprecated {\n /// @custom:deprecated Previously `_governanceAdminContract` (non-zero value)\n address internal ______deprecatedGovernanceAdmin;\n}\n\ncontract HasBridgeTrackingDeprecated {\n /// @custom:deprecated Previously `_bridgeTrackingContract` (non-zero value)\n address internal ______deprecatedBridgeTracking;\n}\n" + }, + "contracts/utils/IdentityGuard.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { AddressArrayUtils } from \"../libraries/AddressArrayUtils.sol\";\nimport { IERC165 } from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport { TransparentUpgradeableProxyV2 } from \"../extensions/TransparentUpgradeableProxyV2.sol\";\nimport { ErrAddressIsNotCreatedEOA, ErrZeroAddress, ErrOnlySelfCall, ErrZeroCodeContract, ErrUnsupportedInterface } from \"./CommonErrors.sol\";\n\nabstract contract IdentityGuard {\n using AddressArrayUtils for address[];\n\n /// @dev value is equal to keccak256(abi.encode())\n /// @dev see: https://eips.ethereum.org/EIPS/eip-1052\n bytes32 internal constant CREATED_ACCOUNT_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\n\n /**\n * @dev Modifier to restrict functions to only be called by this contract.\n * @dev Reverts if the caller is not this contract.\n */\n modifier onlySelfCall() virtual {\n _requireSelfCall();\n _;\n }\n\n /**\n * @dev Modifier to ensure that the elements in the `arr` array are non-duplicates.\n * It calls the internal `_checkDuplicate` function to perform the duplicate check.\n *\n * Requirements:\n * - The elements in the `arr` array must not contain any duplicates.\n */\n modifier nonDuplicate(address[] memory arr) virtual {\n _requireNonDuplicate(arr);\n _;\n }\n\n /**\n * @dev Internal method to check the method caller.\n * @dev Reverts if the method caller is not this contract.\n */\n function _requireSelfCall() internal view virtual {\n if (msg.sender != address(this)) revert ErrOnlySelfCall(msg.sig);\n }\n\n /**\n * @dev Internal function to check if a contract address has code.\n * @param addr The address of the contract to check.\n * @dev Throws an error if the contract address has no code.\n */\n function _requireHasCode(address addr) internal view {\n if (addr.code.length == 0) revert ErrZeroCodeContract(addr);\n }\n\n /**\n * @dev Checks if an address is zero and reverts if it is.\n * @param addr The address to check.\n */\n function _requireNonZeroAddress(address addr) internal pure {\n if (addr == address(0)) revert ErrZeroAddress(msg.sig);\n }\n\n /**\n * @dev Check if arr is empty and revert if it is.\n * Checks if an array contains any duplicate addresses and reverts if duplicates are found.\n * @param arr The array of addresses to check.\n */\n function _requireNonDuplicate(address[] memory arr) internal pure {\n if (arr.hasDuplicate()) revert AddressArrayUtils.ErrDuplicated(msg.sig);\n }\n\n /**\n * @dev Internal function to require that the provided address is a created externally owned account (EOA).\n * This internal function is used to ensure that the provided address is a valid externally owned account (EOA).\n * It checks the codehash of the address against a predefined constant to confirm that the address is a created EOA.\n * @notice This method only works with non-state EOA accounts\n */\n function _requireCreatedEOA(address addr) internal view {\n _requireNonZeroAddress(addr);\n bytes32 codehash = addr.codehash;\n if (codehash != CREATED_ACCOUNT_HASH) revert ErrAddressIsNotCreatedEOA(addr, codehash);\n }\n\n /**\n * @dev Internal function to require that the specified contract supports the given interface. This method handle in\n * both case that the callee is either or not the proxy admin of the caller. If the contract does not support the\n * interface `interfaceId` or EIP165, a revert with the corresponding error message is triggered.\n *\n * @param contractAddr The address of the contract to check for interface support.\n * @param interfaceId The interface ID to check for support.\n */\n function _requireSupportsInterface(address contractAddr, bytes4 interfaceId) internal view {\n bytes memory supportsInterfaceParams = abi.encodeCall(IERC165.supportsInterface, (interfaceId));\n (bool success, bytes memory returnOrRevertData) = contractAddr.staticcall(supportsInterfaceParams);\n if (!success) {\n (success, returnOrRevertData) = contractAddr.staticcall(\n abi.encodeCall(TransparentUpgradeableProxyV2.functionDelegateCall, (supportsInterfaceParams))\n );\n if (!success) revert ErrUnsupportedInterface(interfaceId, contractAddr);\n }\n if (!abi.decode(returnOrRevertData, (bool))) revert ErrUnsupportedInterface(interfaceId, contractAddr);\n }\n}\n" + }, + "contracts/utils/RoleAccess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nenum RoleAccess {\n /* 0 */ UNKNOWN,\n /* 1 */ ADMIN,\n /* 2 */ COINBASE,\n /* 3 */ GOVERNOR,\n /* 4 */ CANDIDATE_ADMIN,\n /* 5 */ WITHDRAWAL_MIGRATOR,\n /* 6 */ __DEPRECATED_BRIDGE_OPERATOR,\n /* 7 */ BLOCK_PRODUCER,\n /* 8 */ VALIDATOR_CANDIDATE\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "metadata": { + "bytecodeHash": "none", + "useLiteralContent": true + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates", + "storageLayout" + ], + "": [ + "ast" + ] + } + } + } +} \ No newline at end of file diff --git a/deployments/ronin-testnet/solcInputs/d85d6f97c6f4b4f4d9c883d9b13849c8.json b/deployments/ronin-testnet/solcInputs/d85d6f97c6f4b4f4d9c883d9b13849c8.json new file mode 100644 index 000000000..a2fade04e --- /dev/null +++ b/deployments/ronin-testnet/solcInputs/d85d6f97c6f4b4f4d9c883d9b13849c8.json @@ -0,0 +1,217 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts/interfaces/draft-IERC1822.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n *\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\n */\n constructor(address _logic, bytes memory _data) payable {\n _upgradeToAndCall(_logic, _data, false);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function _implementation() internal view virtual override returns (address impl) {\n return ERC1967Upgrade._getImplementation();\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967Upgrade {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _changeAdmin(address newAdmin) internal {\n emit AdminChanged(_getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Emitted when the beacon is upgraded.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Returns the current beacon.\n */\n function _getBeacon() internal view returns (address) {\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n Address.isContract(IBeacon(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(\n address newBeacon,\n bytes memory data,\n bool forceCall\n ) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overridden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC1967/ERC1967Proxy.sol\";\n\n/**\n * @dev This contract implements a proxy that is upgradeable by an admin.\n *\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n *\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches one of the admin functions exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\n * \"admin cannot fallback to proxy target\".\n *\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\n * to sudden errors when trying to call a function from the proxy implementation.\n *\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\n */\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\n /**\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\n */\n constructor(\n address _logic,\n address admin_,\n bytes memory _data\n ) payable ERC1967Proxy(_logic, _data) {\n _changeAdmin(admin_);\n }\n\n /**\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\n */\n modifier ifAdmin() {\n if (msg.sender == _getAdmin()) {\n _;\n } else {\n _fallback();\n }\n }\n\n /**\n * @dev Returns the current admin.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function admin() external ifAdmin returns (address admin_) {\n admin_ = _getAdmin();\n }\n\n /**\n * @dev Returns the current implementation.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n */\n function implementation() external ifAdmin returns (address implementation_) {\n implementation_ = _implementation();\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\n */\n function changeAdmin(address newAdmin) external virtual ifAdmin {\n _changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\n */\n function upgradeTo(address newImplementation) external ifAdmin {\n _upgradeToAndCall(newImplementation, bytes(\"\"), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\n * proxied contract.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\n */\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\n _upgradeToAndCall(newImplementation, data, true);\n }\n\n /**\n * @dev Returns the current admin.\n */\n function _admin() internal view virtual returns (address) {\n return _getAdmin();\n }\n\n /**\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\n */\n function _beforeFallback() internal virtual override {\n require(msg.sender != _getAdmin(), \"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n super._beforeFallback();\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n * initialization step. This is essential to configure modules that are added through upgrades and that require\n * initialization.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" + }, + "@openzeppelin/contracts/utils/StorageSlot.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n" + }, + "contracts/extensions/collections/HasContracts.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { HasProxyAdmin } from \"./HasProxyAdmin.sol\";\nimport \"../../interfaces/collections/IHasContracts.sol\";\nimport { IdentityGuard } from \"../../utils/IdentityGuard.sol\";\nimport { ErrUnexpectedInternalCall } from \"../../utils/CommonErrors.sol\";\n\n/**\n * @title HasContracts\n * @dev A contract that provides functionality to manage multiple contracts with different roles.\n */\nabstract contract HasContracts is HasProxyAdmin, IHasContracts, IdentityGuard {\n /// @dev value is equal to keccak256(\"@ronin.dpos.collections.HasContracts.slot\") - 1\n bytes32 private constant _STORAGE_SLOT = 0xdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb;\n\n /**\n * @dev Modifier to restrict access to functions only to contracts with a specific role.\n * @param contractType The contract type that allowed to call\n */\n modifier onlyContract(ContractType contractType) virtual {\n _requireContract(contractType);\n _;\n }\n\n /**\n * @inheritdoc IHasContracts\n */\n function setContract(ContractType contractType, address addr) external virtual onlyAdmin {\n _requireHasCode(addr);\n _setContract(contractType, addr);\n }\n\n /**\n * @inheritdoc IHasContracts\n */\n function getContract(ContractType contractType) public view returns (address contract_) {\n contract_ = _getContractMap()[uint8(contractType)];\n if (contract_ == address(0)) revert ErrContractTypeNotFound(contractType);\n }\n\n /**\n * @dev Internal function to set the address of a contract with a specific role.\n * @param contractType The contract type of the contract to set.\n * @param addr The address of the contract to set.\n */\n function _setContract(ContractType contractType, address addr) internal virtual {\n _getContractMap()[uint8(contractType)] = addr;\n emit ContractUpdated(contractType, addr);\n }\n\n /**\n * @dev Internal function to access the mapping of contract addresses with roles.\n * @return contracts_ The mapping of contract addresses with roles.\n */\n function _getContractMap() private pure returns (mapping(uint8 => address) storage contracts_) {\n assembly {\n contracts_.slot := _STORAGE_SLOT\n }\n }\n\n /**\n * @dev Internal function to check if the calling contract has a specific role.\n * @param contractType The contract type that the calling contract must have.\n * @dev Throws an error if the calling contract does not have the specified role.\n */\n function _requireContract(ContractType contractType) private view {\n if (msg.sender != getContract(contractType)) {\n revert ErrUnexpectedInternalCall(msg.sig, contractType, msg.sender);\n }\n }\n}\n" + }, + "contracts/extensions/collections/HasProxyAdmin.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/StorageSlot.sol\";\nimport \"../../utils/CommonErrors.sol\";\n\nabstract contract HasProxyAdmin {\n // bytes32(uint256(keccak256(\"eip1967.proxy.admin\")) - 1));\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n modifier onlyAdmin() {\n _requireAdmin();\n _;\n }\n\n /**\n * @dev Returns proxy admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n function _requireAdmin() internal view {\n if (msg.sender != _getAdmin()) revert ErrUnauthorized(msg.sig, RoleAccess.ADMIN);\n }\n}\n" + }, + "contracts/extensions/consumers/GlobalConfigConsumer.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nabstract contract GlobalConfigConsumer {\n /// @dev The addition amount of gas sending along in external calls. Total gas stipend is added with default 2300 gas.\n uint256 public constant DEFAULT_ADDITION_GAS = 1200;\n /// @dev The length of a period in second.\n uint256 public constant PERIOD_DURATION = 1 days;\n}\n" + }, + "contracts/extensions/consumers/PercentageConsumer.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract PercentageConsumer {\n uint256 internal constant _MAX_PERCENTAGE = 100_00;\n}\n" + }, + "contracts/extensions/RONTransferHelper.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nabstract contract RONTransferHelper {\n /// @dev Error of sender has insufficient balance.\n error ErrInsufficientBalance(bytes4 msgSig, uint256 currentBalance, uint256 sendAmount);\n /// @dev Error of recipient not accepting RON when transfer RON.\n error ErrRecipientRevert(bytes4 msgSig);\n\n /**\n * @dev See `_sendRON`.\n * Reverts if the recipient does not receive RON.\n */\n function _transferRON(address payable recipient, uint256 amount) internal {\n if (!_sendRON(recipient, amount)) revert ErrRecipientRevert(msg.sig);\n }\n\n /**\n * @dev Send `amount` RON to the address `recipient`.\n * Returns whether the recipient receives RON or not.\n * Reverts once the contract balance is insufficient.\n *\n * Note: consider using `ReentrancyGuard` before calling this function.\n *\n */\n function _sendRON(address payable recipient, uint256 amount) internal returns (bool success) {\n if (address(this).balance < amount) revert ErrInsufficientBalance(msg.sig, address(this).balance, amount);\n return _unsafeSendRON(recipient, amount);\n }\n\n /**\n * @dev Unsafe send `amount` RON to the address `recipient`. If the sender's balance is insufficient,\n * the call does not revert.\n *\n * Note:\n * - Does not assert whether the balance of sender is sufficient.\n * - Does not assert whether the recipient accepts RON.\n * - Consider using `ReentrancyGuard` before calling this function.\n *\n */\n function _unsafeSendRON(address payable recipient, uint256 amount) internal returns (bool success) {\n (success, ) = recipient.call{ value: amount }(\"\");\n }\n\n /**\n * @dev Same purpose with {_unsafeSendRONLimitGas(address,uin256)} but containing gas limit stipend forwarded in the call.\n */\n function _unsafeSendRONLimitGas(\n address payable recipient,\n uint256 amount,\n uint256 gas\n ) internal returns (bool success) {\n (success, ) = recipient.call{ value: amount, gas: gas }(\"\");\n }\n}\n" + }, + "contracts/extensions/TransparentUpgradeableProxyV2.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\ncontract TransparentUpgradeableProxyV2 is TransparentUpgradeableProxy {\n constructor(\n address _logic,\n address admin_,\n bytes memory _data\n ) payable TransparentUpgradeableProxy(_logic, admin_, _data) {}\n\n /**\n * @dev Calls a function from the current implementation as specified by `_data`, which should be an encoded function call.\n *\n * Requirements:\n * - Only the admin can call this function.\n *\n * Note: The proxy admin is not allowed to interact with the proxy logic through the fallback function to avoid\n * triggering some unexpected logic. This is to allow the administrator to explicitly call the proxy, please consider\n * reviewing the encoded data `_data` and the method which is called before using this.\n *\n */\n function functionDelegateCall(bytes memory _data) public payable ifAdmin {\n address _addr = _implementation();\n assembly {\n let _result := delegatecall(gas(), _addr, add(_data, 32), mload(_data), 0, 0)\n returndatacopy(0, 0, returndatasize())\n switch _result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n}\n" + }, + "contracts/interfaces/collections/IHasContracts.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport { ContractType } from \"../../utils/ContractType.sol\";\n\ninterface IHasContracts {\n /// @dev Error of invalid role.\n error ErrContractTypeNotFound(ContractType contractType);\n\n /// @dev Emitted when a contract is updated.\n event ContractUpdated(ContractType indexed contractType, address indexed addr);\n\n /**\n * @dev Returns the address of a contract with a specific role.\n * Throws an error if no contract is set for the specified role.\n *\n * @param contractType The role of the contract to retrieve.\n * @return contract_ The address of the contract with the specified role.\n */\n function getContract(ContractType contractType) external view returns (address contract_);\n\n /**\n * @dev Sets the address of a contract with a specific role.\n * Emits the event {ContractUpdated}.\n * @param contractType The role of the contract to set.\n * @param addr The address of the contract to set.\n */\n function setContract(ContractType contractType, address addr) external;\n}\n" + }, + "contracts/interfaces/consumers/PeriodWrapperConsumer.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface PeriodWrapperConsumer {\n struct PeriodWrapper {\n // Inner value.\n uint256 inner;\n // Last period number that the info updated.\n uint256 lastPeriod;\n }\n}\n" + }, + "contracts/interfaces/IMaintenance.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface IMaintenance {\n /**\n * @dev Error thrown when attempting to schedule an already scheduled event.\n */\n error ErrAlreadyScheduled();\n\n /**\n * @dev Error thrown when referring to a non-existent schedule.\n */\n error ErrUnexistedSchedule();\n\n /**\n * @dev Error thrown when the end block of a schedule is out of range.\n */\n error ErrEndBlockOutOfRange();\n\n /**\n * @dev Error thrown when the start block of a schedule is out of range.\n */\n error ErrStartBlockOutOfRange();\n\n /**\n * @dev Error thrown when attempting to initiate maintenance while already in maintenance mode.\n */\n error ErrAlreadyOnMaintenance();\n\n /**\n * @dev Error thrown when attempting an action before the cooldown period has ended.\n */\n error ErrCooldownTimeNotYetEnded();\n\n /**\n * @dev Error thrown when the total number of schedules exceeds the limit.\n */\n error ErrTotalOfSchedulesExceeded();\n\n /**\n * @dev Error thrown when an invalid maintenance duration is specified.\n */\n error ErrInvalidMaintenanceDuration();\n\n /**\n * @dev Error thrown when an invalid maintenance duration configuration is provided.\n */\n error ErrInvalidMaintenanceDurationConfig();\n\n /**\n * @dev Error thrown when an invalid offset is specified to start the schedule configurations.\n */\n error ErrInvalidOffsetToStartScheduleConfigs();\n\n struct Schedule {\n uint256 from;\n uint256 to;\n uint256 lastUpdatedBlock;\n uint256 requestTimestamp;\n }\n\n /// @dev Emitted when a maintenance is scheduled.\n event MaintenanceScheduled(address indexed consensusAddr, Schedule);\n /// @dev Emitted when a schedule of maintenance is cancelled.\n event MaintenanceScheduleCancelled(address indexed consensusAddr);\n /// @dev Emitted when the maintenance config is updated.\n event MaintenanceConfigUpdated(\n uint256 minMaintenanceDurationInBlock,\n uint256 maxMaintenanceDurationInBlock,\n uint256 minOffsetToStartSchedule,\n uint256 maxOffsetToStartSchedule,\n uint256 maxSchedules,\n uint256 cooldownSecsToMaintain\n );\n\n /**\n * @dev Returns whether the validator `_consensusAddr` maintained at the block number `_block`.\n */\n function checkMaintained(address _consensusAddr, uint256 _block) external view returns (bool);\n\n /**\n * @dev Returns whether the validator `_consensusAddr` maintained in the inclusive range [`_fromBlock`, `_toBlock`] of blocks.\n */\n function checkMaintainedInBlockRange(\n address _consensusAddr,\n uint256 _fromBlock,\n uint256 _toBlock\n ) external view returns (bool);\n\n /**\n * @dev Returns the bool array indicating the validators maintained at block number `_block` or not.\n */\n function checkManyMaintained(address[] calldata _addrList, uint256 _block) external view returns (bool[] memory);\n\n /**\n * @dev Returns a bool array indicating the validators maintained in the inclusive range [`_fromBlock`, `_toBlock`] of blocks or not.\n */\n function checkManyMaintainedInBlockRange(\n address[] calldata _addrList,\n uint256 _fromBlock,\n uint256 _toBlock\n ) external view returns (bool[] memory);\n\n /**\n * @dev Returns whether the validator `_consensusAddr` has scheduled.\n */\n function checkScheduled(address _consensusAddr) external view returns (bool);\n\n /**\n * @dev Returns whether the validator `_consensusAddr`\n */\n function checkCooldownEnds(address _consensusAddr) external view returns (bool);\n\n /**\n * @dev Returns the detailed schedule of the validator `_consensusAddr`.\n */\n function getSchedule(address _consensusAddr) external view returns (Schedule memory);\n\n /**\n * @dev Returns the total of current schedules.\n */\n function totalSchedules() external view returns (uint256 _count);\n\n /**\n * @dev Sets the duration restriction, start time restriction, and max allowed for maintenance.\n *\n * Requirements:\n * - The method caller is admin.\n * - The max duration is larger than the min duration.\n * - The max offset is larger than the min offset.\n *\n * Emits the event `MaintenanceConfigUpdated`.\n *\n */\n function setMaintenanceConfig(\n uint256 _minMaintenanceDurationInBlock,\n uint256 _maxMaintenanceDurationInBlock,\n uint256 _minOffsetToStartSchedule,\n uint256 _maxOffsetToStartSchedule,\n uint256 _maxSchedules,\n uint256 _cooldownSecsToMaintain\n ) external;\n\n /**\n * @dev Returns the min duration for maintenance in block.\n */\n function minMaintenanceDurationInBlock() external view returns (uint256);\n\n /**\n * @dev Returns the max duration for maintenance in block.\n */\n function maxMaintenanceDurationInBlock() external view returns (uint256);\n\n /**\n * @dev The offset to the min block number that the schedule can start\n */\n function minOffsetToStartSchedule() external view returns (uint256);\n\n /**\n * @dev The offset to the max block number that the schedule can start\n */\n function maxOffsetToStartSchedule() external view returns (uint256);\n\n /**\n * @dev Returns the max number of scheduled maintenances.\n */\n function maxSchedules() external view returns (uint256);\n\n /**\n * @dev Schedules for maintenance from `_startedAtBlock` to `_startedAtBlock`.\n *\n * Requirements:\n * - The candidate `_consensusAddr` is the block producer.\n * - The method caller is candidate admin of the candidate `_consensusAddr`.\n * - The candidate `_consensusAddr` has no schedule yet or the previous is done.\n * - The total number of schedules is not larger than `maxSchedules()`.\n * - The start block must be at least `minOffsetToStartSchedule()` and at most `maxOffsetToStartSchedule()` blocks from the current block.\n * - The end block is larger than the start block.\n * - The scheduled duration is larger than the `minMaintenanceDurationInBlock()` and less than the `maxMaintenanceDurationInBlock()`.\n * - The start block is at the start of an epoch.\n * - The end block is at the end of an epoch.\n *\n * Emits the event `MaintenanceScheduled`.\n *\n */\n function schedule(address _consensusAddr, uint256 _startedAtBlock, uint256 _endedAtBlock) external;\n\n /**\n * @dev Cancel the schedule of maintenance for the `_consensusAddr`.\n *\n * Requirements:\n * - The candidate `_consensusAddr` is the block producer.\n * - The method caller is candidate admin of the candidate `_consensusAddr`.\n * - A schedule for the `_consensusAddr` must be existent and not executed yet.\n *\n * Emits the event `MaintenanceScheduleCancelled`.\n */\n function cancelSchedule(address _consensusAddr) external;\n}\n" + }, + "contracts/interfaces/IQuorum.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IQuorum {\n /// @dev Emitted when the threshold is updated\n event ThresholdUpdated(\n uint256 indexed nonce,\n uint256 indexed numerator,\n uint256 indexed denominator,\n uint256 previousNumerator,\n uint256 previousDenominator\n );\n\n /**\n * @dev Returns the threshold.\n */\n function getThreshold() external view returns (uint256 _num, uint256 _denom);\n\n /**\n * @dev Checks whether the `_voteWeight` passes the threshold.\n */\n function checkThreshold(uint256 _voteWeight) external view returns (bool);\n\n /**\n * @dev Returns the minimum vote weight to pass the threshold.\n */\n function minimumVoteWeight() external view returns (uint256);\n\n /**\n * @dev Sets the threshold.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `ThresholdUpdated` event.\n *\n */\n function setThreshold(\n uint256 _numerator,\n uint256 _denominator\n ) external returns (uint256 _previousNum, uint256 _previousDenom);\n}\n" + }, + "contracts/interfaces/IRoninGovernanceAdmin.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../utils/CommonErrors.sol\";\n\ninterface IRoninGovernanceAdmin {\n /// @dev Emitted when an emergency exit poll is created.\n event EmergencyExitPollCreated(\n bytes32 _voteHash,\n address _consensusAddr,\n address _recipientAfterUnlockedFund,\n uint256 _requestedAt,\n uint256 _expiredAt\n );\n /// @dev Emitted when an emergency exit poll is approved.\n event EmergencyExitPollApproved(bytes32 _voteHash);\n /// @dev Emitted when an emergency exit poll is expired.\n event EmergencyExitPollExpired(bytes32 _voteHash);\n /// @dev Emitted when an emergency exit poll is voted.\n event EmergencyExitPollVoted(bytes32 indexed _voteHash, address indexed _voter);\n\n /**\n * @dev Create a vote to agree that an emergency exit is valid and should return the locked funds back.a\n *\n * Requirements:\n * - The method caller is validator contract.\n *\n */\n function createEmergencyExitPoll(\n address _consensusAddr,\n address _recipientAfterUnlockedFund,\n uint256 _requestedAt,\n uint256 _expiredAt\n ) external;\n}\n" + }, + "contracts/interfaces/IRoninTrustedOrganization.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IQuorum.sol\";\n\ninterface IRoninTrustedOrganization is IQuorum {\n /**\n * @dev Error indicating that a query for a duplicate entry was made.\n */\n error ErrQueryForDupplicated();\n\n /**\n * @dev Error indicating that a query was made for a non-existent consensus address.\n */\n error ErrQueryForNonExistentConsensusAddress();\n\n /**\n * @dev Error indicating that a bridge voter has already been added.\n * @param voter The address of the bridge voter that is already added.\n */\n error ErrBridgeVoterIsAlreadyAdded(address voter);\n\n /**\n * @dev Error indicating that a governor address has already been added.\n * @param addr The address of the governor that is already added.\n */\n error ErrGovernorAddressIsAlreadyAdded(address addr);\n\n /**\n * @dev Error indicating that a consensus address is not added.\n * @param addr The address of the consensus contract that is not added.\n */\n error ErrConsensusAddressIsNotAdded(address addr);\n\n /**\n * @dev Error indicating that a consensus address is already added.\n * @param addr The address of the consensus contract that is already added.\n */\n error ErrConsensusAddressIsAlreadyAdded(address addr);\n\n struct TrustedOrganization {\n // Address of the validator that produces block, e.g. block.coinbase. This is so-called validator address.\n address consensusAddr;\n // Address to voting proposal\n address governor;\n // Address to voting bridge operators\n address bridgeVoter;\n // Its Weight\n uint256 weight;\n // The block that the organization was added\n uint256 addedBlock;\n }\n\n /// @dev Emitted when the trusted organization is added.\n event TrustedOrganizationsAdded(TrustedOrganization[] orgs);\n /// @dev Emitted when the trusted organization is updated.\n event TrustedOrganizationsUpdated(TrustedOrganization[] orgs);\n /// @dev Emitted when the trusted organization is removed.\n event TrustedOrganizationsRemoved(address[] orgs);\n\n /**\n * @dev Adds a list of addresses into the trusted organization.\n *\n * Requirements:\n * - The weights should larger than 0.\n * - The method caller is admin.\n * - The field `addedBlock` should be blank.\n *\n * Emits the event `TrustedOrganizationAdded` once an organization is added.\n *\n */\n function addTrustedOrganizations(TrustedOrganization[] calldata) external;\n\n /**\n * @dev Updates weights for a list of existent trusted organization.\n *\n * Requirements:\n * - The weights should larger than 0.\n * - The method caller is admin.\n *\n * Emits the `TrustedOrganizationUpdated` event.\n *\n */\n function updateTrustedOrganizations(TrustedOrganization[] calldata _list) external;\n\n /**\n * @dev Removes a list of addresses from the trusted organization.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `TrustedOrganizationRemoved` once an organization is removed.\n *\n * @param _consensusAddrs The list of consensus addresses linked to corresponding trusted organization that to be removed.\n */\n function removeTrustedOrganizations(address[] calldata _consensusAddrs) external;\n\n /**\n * @dev Returns total weights.\n */\n function totalWeights() external view returns (uint256);\n\n /**\n * @dev Returns the weight of a consensus.\n */\n function getConsensusWeight(address _consensusAddr) external view returns (uint256);\n\n /**\n * @dev Returns the weight of a governor.\n */\n function getGovernorWeight(address _governor) external view returns (uint256);\n\n /**\n * @dev Returns the weight of a bridge voter.\n */\n function getBridgeVoterWeight(address _addr) external view returns (uint256);\n\n /**\n * @dev Returns the weights of a list of consensus addresses.\n */\n function getConsensusWeights(address[] calldata _list) external view returns (uint256[] memory);\n\n /**\n * @dev Returns the weights of a list of governor addresses.\n */\n function getGovernorWeights(address[] calldata _list) external view returns (uint256[] memory);\n\n /**\n * @dev Returns the weights of a list of bridge voter addresses.\n */\n function getBridgeVoterWeights(address[] calldata _list) external view returns (uint256[] memory);\n\n /**\n * @dev Returns total weights of the consensus list.\n */\n function sumConsensusWeights(address[] calldata _list) external view returns (uint256 _res);\n\n /**\n * @dev Returns total weights of the governor list.\n */\n function sumGovernorWeights(address[] calldata _list) external view returns (uint256 _res);\n\n /**\n * @dev Returns total weights of the bridge voter list.\n */\n function sumBridgeVoterWeights(address[] calldata _list) external view returns (uint256 _res);\n\n /**\n * @dev Returns the trusted organization at `_index`.\n */\n function getTrustedOrganizationAt(uint256 _index) external view returns (TrustedOrganization memory);\n\n /**\n * @dev Returns the number of trusted organizations.\n */\n function countTrustedOrganizations() external view returns (uint256);\n\n /**\n * @dev Returns all of the trusted organizations.\n */\n function getAllTrustedOrganizations() external view returns (TrustedOrganization[] memory);\n\n /**\n * @dev Returns the trusted organization by consensus address.\n *\n * Reverts once the consensus address is non-existent.\n */\n function getTrustedOrganization(address _consensusAddr) external view returns (TrustedOrganization memory);\n}\n" + }, + "contracts/interfaces/IStakingVesting.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface IStakingVesting {\n /**\n * @dev Error thrown when attempting to send a bonus that has already been sent.\n */\n error ErrBonusAlreadySent();\n\n /// @dev Emitted when the block bonus for block producer is transferred.\n event BonusTransferred(\n uint256 indexed blockNumber,\n address indexed recipient,\n uint256 blockProducerAmount,\n uint256 bridgeOperatorAmount\n );\n /// @dev Emitted when the transfer of block bonus for block producer is failed.\n event BonusTransferFailed(\n uint256 indexed blockNumber,\n address indexed recipient,\n uint256 blockProducerAmount,\n uint256 bridgeOperatorAmount,\n uint256 contractBalance\n );\n /// @dev Emitted when the block bonus for block producer is updated\n event BlockProducerBonusPerBlockUpdated(uint256);\n /// @dev Emitted when the block bonus for bridge operator is updated\n event BridgeOperatorBonusPerBlockUpdated(uint256);\n\n /**\n * @dev Returns the bonus amount for the block producer at `_block`.\n */\n function blockProducerBlockBonus(uint256 _block) external view returns (uint256);\n\n /**\n * @dev Returns the bonus amount for the bridge validator at `_block`.\n */\n function bridgeOperatorBlockBonus(uint256 _block) external view returns (uint256);\n\n /**\n * @dev Receives RON from any address.\n */\n function receiveRON() external payable;\n\n /**\n * @dev Returns the last block number that the staking vesting is sent.\n */\n function lastBlockSendingBonus() external view returns (uint256);\n\n /**\n * @dev Transfers the staking vesting for the block producer and the bridge operator whenever a new block is mined.\n *\n * Requirements:\n * - The method caller must be validator contract.\n * - The method must be called only once per block.\n *\n * Emits the event `BonusTransferred` or `BonusTransferFailed`.\n *\n * Notes:\n * - The method does not revert when the contract balance is insufficient to send bonus. This assure the submit reward method\n * will not be reverted, and the underlying nodes does not hang.\n *\n * @param _forBlockProducer Indicates whether requesting the bonus for the block procucer, in case of being in jail or relevance.\n * @param _forBridgeOperator Indicates whether requesting the bonus for the bridge operator.\n *\n * @return _success Whether the transfer is successfully. This returns false mostly because this contract is out of balance.\n * @return _blockProducerBonus The amount of bonus actually sent for the block producer, returns 0 when the transfer is failed.\n * @return _bridgeOperatorBonus The amount of bonus actually sent for the bridge operator, returns 0 when the transfer is failed.\n *\n */\n function requestBonus(\n bool _forBlockProducer,\n bool _forBridgeOperator\n ) external returns (bool _success, uint256 _blockProducerBonus, uint256 _bridgeOperatorBonus);\n\n /**\n * @dev Sets the bonus amount per block for block producer.\n *\n * Emits the event `BlockProducerBonusPerBlockUpdated`.\n *\n * Requirements:\n * - The method caller is admin.\n *\n */\n function setBlockProducerBonusPerBlock(uint256 _amount) external;\n\n /**\n * @dev Sets the bonus amount per block for bridge operator.\n *\n * Emits the event `BridgeOperatorBonusPerBlockUpdated`.\n *\n * Requirements:\n * - The method caller is admin.\n *\n */\n function setBridgeOperatorBonusPerBlock(uint256 _amount) external;\n}\n" + }, + "contracts/interfaces/slash-indicator/IBaseSlash.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface IBaseSlash {\n enum SlashType {\n UNKNOWN,\n UNAVAILABILITY_TIER_1,\n UNAVAILABILITY_TIER_2,\n DOUBLE_SIGNING,\n BRIDGE_VOTING,\n BRIDGE_OPERATOR_MISSING_VOTE_TIER_1,\n BRIDGE_OPERATOR_MISSING_VOTE_TIER_2,\n UNAVAILABILITY_TIER_3\n }\n\n /// @dev Emitted when the validator is slashed.\n event Slashed(address indexed validator, SlashType slashType, uint256 period);\n}\n" + }, + "contracts/interfaces/slash-indicator/ICreditScore.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface ICreditScore {\n /**\n * @dev Error thrown when an invalid credit score configuration is provided.\n */\n error ErrInvalidCreditScoreConfig();\n\n /**\n * @dev Error thrown when an invalid cut-off percentage configuration is provided.\n */\n error ErrInvalidCutOffPercentageConfig();\n\n /**\n * @dev Error thrown when the caller's credit score is insufficient to bail out a situation.\n */\n error ErrInsufficientCreditScoreToBailOut();\n\n /**\n * @dev Error thrown when a validator has previously bailed out.\n */\n error ErrValidatorHasBailedOutPreviously();\n\n /**\n * @dev Error thrown when the caller must be jailed in the current period.\n */\n error ErrCallerMustBeJailedInTheCurrentPeriod();\n\n /// @dev Emitted when the configs to credit score is updated. See the method `setCreditScoreConfigs` for param details.\n event CreditScoreConfigsUpdated(\n uint256 gainCreditScore,\n uint256 maxCreditScore,\n uint256 bailOutCostMultiplier,\n uint256 cutOffPercentageAfterBailout\n );\n /// @dev Emitted the credit score of validators is updated.\n event CreditScoresUpdated(address[] validators, uint256[] creditScores);\n /// @dev Emitted when a validator bailed out of jail.\n event BailedOut(address indexed validator, uint256 period, uint256 usedCreditScore);\n\n /**\n * @dev Updates the credit score for the validators.\n *\n * Requirements:\n * - Only validator contract can call this method.\n * - This method is only called at the end of each period.\n *\n * Emits the event `CreditScoresUpdated`.\n *\n */\n function updateCreditScores(address[] calldata _validators, uint256 _period) external;\n\n /**\n * @dev Resets the credit score for the revoked validators.\n *\n * Requirements:\n * - Only validator contract can call this method.\n * - This method is only called at the end of each period.\n *\n * Emits the event `CreditScoresUpdated`.\n *\n */\n function execResetCreditScores(address[] calldata _validators) external;\n\n /**\n * @dev A slashed validator use this method to get out of jail.\n *\n * Requirements:\n * - The `_consensusAddr` must be a validator.\n * - Only validator's admin can call this method.\n *\n * Emits the event `BailedOut`.\n *\n */\n function bailOut(address _consensusAddr) external;\n\n /**\n * @dev Sets the configs to credit score.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `CreditScoreConfigsUpdated`.\n *\n * @param _gainScore The score to gain per period.\n * @param _maxScore The max number of credit score that a validator can hold.\n * @param _bailOutMultiplier The number that will be multiplied with the remaining jailed time to get the cost of bailing out.\n * @param _cutOffPercentage The percentage of reward that the block producer will be cut off from until the end of the period after bailing out.\n *\n */\n function setCreditScoreConfigs(\n uint256 _gainScore,\n uint256 _maxScore,\n uint256 _bailOutMultiplier,\n uint256 _cutOffPercentage\n ) external;\n\n /**\n * @dev Returns the configs related to credit score.\n *\n * @return _gainCreditScore The score to gain per period.\n * @return _maxCreditScore The max number of credit score that a validator can hold.\n * @return _bailOutCostMultiplier The number that will be multiplied with the remaining jailed time to get the cost of bailing out.\n * @return _cutOffPercentageAfterBailout The percentage of reward that the block producer will be cut off from until the end of the period after bailing out.\n *\n */\n function getCreditScoreConfigs()\n external\n view\n returns (\n uint256 _gainCreditScore,\n uint256 _maxCreditScore,\n uint256 _bailOutCostMultiplier,\n uint256 _cutOffPercentageAfterBailout\n );\n\n /**\n * @dev Returns the current credit score of the validator.\n */\n function getCreditScore(address _validator) external view returns (uint256);\n\n /**\n * @dev Returns the current credit score of a list of validators.\n */\n function getManyCreditScores(address[] calldata _validators) external view returns (uint256[] memory _resultList);\n\n /**\n * @dev Returns the whether the `_validator` has been bailed out at the `_period`.\n */\n function checkBailedOutAtPeriod(address _validator, uint256 _period) external view returns (bool);\n}\n" + }, + "contracts/interfaces/slash-indicator/ISlashBridgeOperator.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IBaseSlash.sol\";\n\ninterface ISlashBridgeOperator is IBaseSlash {\n /**\n * @dev Error thrown when invalid ratios are provided.\n */\n error ErrInvalidRatios();\n\n /**\n * @dev Emitted when the configs to slash bridge operator is updated. See the method\n * `getBridgeOperatorSlashingConfigs` for param details.\n */\n event BridgeOperatorSlashingConfigsUpdated(\n uint256 missingVotesRatioTier1,\n uint256 missingVotesRatioTier2,\n uint256 jailDurationForMissingVotesRatioTier2,\n uint256 skipBridgeOperatorSlashingThreshold\n );\n\n /**\n * @dev Acknowledges bridge operator slash and emit `Slashed` event correspondingly.\n * @param _tier The tier of the slash, in value of {1, 2}, corresponding to `SlashType.BRIDGE_OPERATOR_MISSING_VOTE_TIER_1`\n * and `SlashType.BRIDGE_OPERATOR_MISSING_VOTE_TIER_2`\n *\n * Requirements:\n * - Only validator contract can invoke this method.\n * - Should be called only at the end of period.\n * - Should be called only when there is slash of bridge operator.\n *\n * Emits the event `Slashed`.\n */\n function execSlashBridgeOperator(address _consensusAddr, uint256 _tier, uint256 _period) external;\n\n /**\n * @dev Returns the configs related to bridge operator slashing.\n *\n * @return _missingVotesRatioTier1 The bridge reward will be deprecated if (s)he missed more than this ratio.\n * @return _missingVotesRatioTier2 The bridge reward and mining reward will be deprecated and the corresponding\n * block producer will be put in jail if (s)he misses more than this ratio.\n * @return _jailDurationForMissingVotesRatioTier2 The number of blocks to jail the corresponding block producer when\n * its bridge operator is slashed tier-2.\n * @return _skipBridgeOperatorSlashingThreshold The threshold to skip slashing the bridge operator in case the total\n * number of votes in the bridge is too small.\n *\n */\n function getBridgeOperatorSlashingConfigs()\n external\n view\n returns (\n uint256 _missingVotesRatioTier1,\n uint256 _missingVotesRatioTier2,\n uint256 _jailDurationForMissingVotesRatioTier2,\n uint256 _skipBridgeOperatorSlashingThreshold\n );\n\n /**\n * @dev Sets the configs to slash bridge operators.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `BridgeOperatorSlashingConfigsUpdated`.\n *\n * @param _ratioTier1 The bridge reward will be deprecated if (s)he missed more than this ratio. Values 0-10,000 map\n * to 0%-100%.\n * @param _ratioTier2 The bridge reward and mining reward will be deprecated and the corresponding block producer will\n * be put in jail if (s)he misses more than this ratio. Values 0-10,000 map to 0%-100%.\n * @param _jailDurationTier2 The number of blocks to jail the corresponding block producer when its bridge operator is\n * slashed tier-2.\n * @param _skipSlashingThreshold The threshold to skip slashing the bridge operator in case the total number of votes\n * in the bridge is too small.\n *\n */\n function setBridgeOperatorSlashingConfigs(\n uint256 _ratioTier1,\n uint256 _ratioTier2,\n uint256 _jailDurationTier2,\n uint256 _skipSlashingThreshold\n ) external;\n}\n" + }, + "contracts/interfaces/slash-indicator/ISlashBridgeVoting.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IBaseSlash.sol\";\n\ninterface ISlashBridgeVoting is IBaseSlash {\n /**\n * @dev Error thrown when an invalid slash is encountered.\n */\n error ErrInvalidSlash();\n\n /**\n * @dev Emitted when the configs to slash bridge voting is updated. See the method `getBridgeVotingSlashingConfigs` for param\n * details.\n */\n event BridgeVotingSlashingConfigsUpdated(uint256 bridgeVotingThreshold, uint256 bridgeVotingSlashAmount);\n\n /**\n * @dev Slashes for bridge voter governance.\n *\n * Emits the event `Slashed`.\n */\n function slashBridgeVoting(address _consensusAddr) external;\n\n /**\n * @dev Returns the configs related to bridge voting slashing.\n *\n * @return _bridgeVotingThreshold The threshold to slash when a trusted organization does not vote for bridge\n * operators.\n * @return _bridgeVotingSlashAmount The amount of RON to slash bridge voting.\n *\n */\n function getBridgeVotingSlashingConfigs()\n external\n view\n returns (uint256 _bridgeVotingThreshold, uint256 _bridgeVotingSlashAmount);\n\n /**\n * @dev Sets the configs to slash bridge voting.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `BridgeVotingSlashingConfigsUpdated`.\n *\n * @param _threshold The threshold to slash when a trusted organization does not vote for bridge operators.\n * @param _slashAmount The amount of RON to slash bridge voting.\n *\n */\n function setBridgeVotingSlashingConfigs(uint256 _threshold, uint256 _slashAmount) external;\n}\n" + }, + "contracts/interfaces/slash-indicator/ISlashDoubleSign.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IBaseSlash.sol\";\n\ninterface ISlashDoubleSign is IBaseSlash {\n /**\n * @dev Error thrown when evidence has already been submitted.\n */\n error ErrEvidenceAlreadySubmitted();\n\n /**\n * @dev Emitted when the configs to slash double sign is updated. See the method `getDoubleSignSlashingConfigs`\n * for param details.\n */\n event DoubleSignSlashingConfigsUpdated(\n uint256 slashDoubleSignAmount,\n uint256 doubleSigningJailUntilBlock,\n uint256 doubleSigningOffsetLimitBlock\n );\n\n /**\n * @dev Slashes for double signing.\n *\n * Requirements:\n * - The method caller is coinbase.\n *\n * Emits the event `Slashed` if the double signing evidence of the two headers valid.\n */\n function slashDoubleSign(address _validatorAddr, bytes calldata _header1, bytes calldata _header2) external;\n\n /**\n * @dev Returns the configs related to block producer slashing.\n *\n * @return _slashDoubleSignAmount The amount of RON to slash double sign.\n * @return _doubleSigningJailUntilBlock The block number that the punished validator will be jailed until, due to\n * double signing.\n * @param _doubleSigningOffsetLimitBlock The number of block that the current block is at most far from the double\n * signing block.\n *\n */\n function getDoubleSignSlashingConfigs()\n external\n view\n returns (\n uint256 _slashDoubleSignAmount,\n uint256 _doubleSigningJailUntilBlock,\n uint256 _doubleSigningOffsetLimitBlock\n );\n\n /**\n * @dev Sets the configs to slash block producers.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `DoubleSignSlashingConfigsUpdated`.\n *\n * @param _slashAmount The amount of RON to slash double sign.\n * @param _jailUntilBlock The block number that the punished validator will be jailed until, due to double signing.\n * @param _doubleSigningOffsetLimitBlock The number of block that the current block is at most far from the double\n * signing block.\n *\n */\n function setDoubleSignSlashingConfigs(\n uint256 _slashAmount,\n uint256 _jailUntilBlock,\n uint256 _doubleSigningOffsetLimitBlock\n ) external;\n}\n" + }, + "contracts/interfaces/slash-indicator/ISlashIndicator.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./ISlashDoubleSign.sol\";\nimport \"./ISlashBridgeVoting.sol\";\nimport \"./ISlashBridgeOperator.sol\";\nimport \"./ISlashUnavailability.sol\";\nimport \"./ICreditScore.sol\";\n\ninterface ISlashIndicator is\n ISlashDoubleSign,\n ISlashBridgeVoting,\n ISlashBridgeOperator,\n ISlashUnavailability,\n ICreditScore\n{}\n" + }, + "contracts/interfaces/slash-indicator/ISlashUnavailability.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IBaseSlash.sol\";\n\ninterface ISlashUnavailability is IBaseSlash {\n /**\n * @dev Error thrown when attempting to slash a validator twice or slash more than one validator in one block.\n */\n error ErrCannotSlashAValidatorTwiceOrSlashMoreThanOneValidatorInOneBlock();\n\n /**\n * @dev Emitted when the configs to slash bridge operator is updated. See the method `getUnavailabilitySlashingConfigs`\n * for param details.\n */\n event UnavailabilitySlashingConfigsUpdated(\n uint256 unavailabilityTier1Threshold,\n uint256 unavailabilityTier2Threshold,\n uint256 slashAmountForUnavailabilityTier2Threshold,\n uint256 jailDurationForUnavailabilityTier2Threshold\n );\n\n /**\n * @dev Returns the last block that a block producer is slashed for unavailability.\n */\n function lastUnavailabilitySlashedBlock() external view returns (uint256);\n\n /**\n * @dev Slashes for unavailability by increasing the counter of block producer `_consensusAddr`.\n *\n * Requirements:\n * - The method caller is coinbase.\n *\n * Emits the event `Slashed` when the threshold is reached.\n *\n */\n function slashUnavailability(address _consensusAddr) external;\n\n /**\n * @dev Returns the current unavailability indicator of a block producer.\n */\n function currentUnavailabilityIndicator(address _validator) external view returns (uint256);\n\n /**\n * @dev Returns the unavailability indicator in the period `_period` of a block producer.\n */\n function getUnavailabilityIndicator(address _validator, uint256 _period) external view returns (uint256);\n\n /**\n * @dev Returns the configs related to block producer slashing.\n *\n * @return _unavailabilityTier1Threshold The mining reward will be deprecated, if (s)he missed more than this\n * threshold. This threshold is applied for tier-1 and tier-3 slash.\n * @return _unavailabilityTier2Threshold The mining reward will be deprecated, (s)he will be put in jailed, and will\n * be deducted self-staking if (s)he misses more than this threshold. This threshold is applied for tier-2 slash.\n * @return _slashAmountForUnavailabilityTier2Threshold The amount of RON to deduct from self-staking of a block\n * producer when (s)he is slashed with tier-2 or tier-3.\n * @return _jailDurationForUnavailabilityTier2Threshold The number of blocks to jail a block producer when (s)he is\n * slashed with tier-2 or tier-3.\n *\n */\n function getUnavailabilitySlashingConfigs()\n external\n view\n returns (\n uint256 _unavailabilityTier1Threshold,\n uint256 _unavailabilityTier2Threshold,\n uint256 _slashAmountForUnavailabilityTier2Threshold,\n uint256 _jailDurationForUnavailabilityTier2Threshold\n );\n\n /**\n * @dev Sets the configs to slash block producers.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `BridgeOperatorSlashingConfigsUpdated`.\n *\n * @param _tier1Threshold The mining reward will be deprecated, if (s)he missed more than this threshold.\n * @param _tier2Threshold The mining reward will be deprecated, (s)he will be put in jailed, and will be deducted\n * self-staking if (s)he misses more than this threshold.\n * @param _slashAmountForTier2Threshold The amount of RON to deduct from self-staking of a block producer when (s)he\n * is slashed tier-2.\n * @param _jailDurationForTier2Threshold The number of blocks to jail a block producer when (s)he is slashed tier-2.\n *\n */\n function setUnavailabilitySlashingConfigs(\n uint256 _tier1Threshold,\n uint256 _tier2Threshold,\n uint256 _slashAmountForTier2Threshold,\n uint256 _jailDurationForTier2Threshold\n ) external;\n}\n" + }, + "contracts/interfaces/staking/IBaseStaking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface IBaseStaking {\n struct PoolDetail {\n // Address of the pool i.e. consensus address of the validator\n address addr;\n // Pool admin address\n address admin;\n // Self-staking amount\n uint256 stakingAmount;\n // Total number of RON staking for the pool\n uint256 stakingTotal;\n // Mapping from delegator => delegating amount\n mapping(address => uint256) delegatingAmount;\n // Mapping from delegator => the last timestamp that delegator staked\n mapping(address => uint256) lastDelegatingTimestamp;\n }\n\n /// @dev Emitted when the minium number of seconds to undelegate is updated.\n event CooldownSecsToUndelegateUpdated(uint256 minSecs);\n /// @dev Emitted when the number of seconds that a candidate must wait to be revoked.\n event WaitingSecsToRevokeUpdated(uint256 secs);\n\n /// @dev Error of cannot transfer RON.\n error ErrCannotTransferRON();\n /// @dev Error of receiving zero message value.\n error ErrZeroValue();\n /// @dev Error of pool admin is not allowed to call.\n error ErrPoolAdminForbidden();\n /// @dev Error of no one is allowed to call but the pool's admin.\n error ErrOnlyPoolAdminAllowed();\n /// @dev Error of admin of any active pool cannot delegate.\n error ErrAdminOfAnyActivePoolForbidden(address admin);\n /// @dev Error of querying inactive pool.\n error ErrInactivePool(address poolAddr);\n /// @dev Error of length of input arrays are not of the same.\n error ErrInvalidArrays();\n\n /**\n * @dev Returns whether the `_poolAdminAddr` is currently active.\n */\n function isAdminOfActivePool(address _poolAdminAddr) external view returns (bool);\n\n /**\n * @dev Returns the consensus address corresponding to the pool admin.\n */\n function getPoolAddressOf(address _poolAdminAddr) external view returns (address);\n\n /**\n * @dev Returns the staking pool detail.\n */\n function getPoolDetail(address) external view returns (address _admin, uint256 _stakingAmount, uint256 _stakingTotal);\n\n /**\n * @dev Returns the self-staking amounts of the pools.\n */\n function getManySelfStakings(address[] calldata) external view returns (uint256[] memory);\n\n /**\n * @dev Returns The cooldown time in seconds to undelegate from the last timestamp (s)he delegated.\n */\n function cooldownSecsToUndelegate() external view returns (uint256);\n\n /**\n * @dev Returns the number of seconds that a candidate must wait for the renounce request gets affected.\n */\n function waitingSecsToRevoke() external view returns (uint256);\n\n /**\n * @dev Sets the cooldown time in seconds to undelegate from the last timestamp (s)he delegated.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `CooldownSecsToUndelegateUpdated`.\n *\n */\n function setCooldownSecsToUndelegate(uint256 _cooldownSecs) external;\n\n /**\n * @dev Sets the number of seconds that a candidate must wait to be revoked.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `WaitingSecsToRevokeUpdated`.\n *\n */\n function setWaitingSecsToRevoke(uint256 _secs) external;\n}\n" + }, + "contracts/interfaces/staking/ICandidateStaking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IRewardPool.sol\";\n\ninterface ICandidateStaking is IRewardPool {\n /// @dev Emitted when the minimum staking amount for being a validator is updated.\n event MinValidatorStakingAmountUpdated(uint256 threshold);\n /// @dev Emitted when the commission rate range is updated.\n event CommissionRateRangeUpdated(uint256 minRate, uint256 maxRate);\n\n /// @dev Emitted when the pool admin staked for themself.\n event Staked(address indexed consensuAddr, uint256 amount);\n /// @dev Emitted when the pool admin unstaked the amount of RON from themself.\n event Unstaked(address indexed consensuAddr, uint256 amount);\n\n /// @dev Emitted when the validator pool is approved.\n event PoolApproved(address indexed validator, address indexed admin);\n /// @dev Emitted when the validator pool is deprecated.\n event PoolsDeprecated(address[] validator);\n /// @dev Emitted when the staking amount transfer failed.\n event StakingAmountTransferFailed(\n address indexed validator,\n address indexed admin,\n uint256 amount,\n uint256 contractBalance\n );\n /// @dev Emitted when the staking amount deducted failed, e.g. when the validator gets slashed.\n event StakingAmountDeductFailed(\n address indexed validator,\n address indexed recipient,\n uint256 amount,\n uint256 contractBalance\n );\n\n /// @dev Error of cannot transfer RON to specified target.\n error ErrCannotInitTransferRON(address addr, string extraInfo);\n /// @dev Error of three interaction addresses must be of the same in applying for validator candidate.\n error ErrThreeInteractionAddrsNotEqual();\n /// @dev Error of unstaking zero amount.\n error ErrUnstakeZeroAmount();\n /// @dev Error of invalid staking amount left after deducted.\n error ErrStakingAmountLeft();\n /// @dev Error of insufficient staking amount for unstaking.\n error ErrInsufficientStakingAmount();\n /// @dev Error of unstaking too early.\n error ErrUnstakeTooEarly();\n /// @dev Error of setting commission rate exceeds max allowed.\n error ErrInvalidCommissionRate();\n\n /**\n * @dev Returns the minimum threshold for being a validator candidate.\n */\n function minValidatorStakingAmount() external view returns (uint256);\n\n /**\n * @dev Returns the commission rate range that the candidate can set.\n */\n function getCommissionRateRange() external view returns (uint256 _minRange, uint256 _maxRange);\n\n /**\n * @dev Sets the minimum threshold for being a validator candidate.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `MinValidatorStakingAmountUpdated` event.\n *\n */\n function setMinValidatorStakingAmount(uint256) external;\n\n /**\n * @dev Sets the commission rate range that a candidate can set.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `CommissionRateRangeUpdated` event.\n *\n */\n function setCommissionRateRange(uint256 _minRate, uint256 _maxRate) external;\n\n /**\n * @dev Proposes a candidate to become a validator.\n *\n * Requirements:\n * - The method caller is able to receive RON.\n * - The treasury is able to receive RON.\n * - The amount is larger than or equal to the minimum validator staking amount `minValidatorStakingAmount()`.\n *\n * Emits the event `PoolApproved`.\n *\n * @param _candidateAdmin the candidate admin will be stored in the validator contract, used for calling function that affects\n * to its candidate, e.g. scheduling maintenance.\n *\n */\n function applyValidatorCandidate(\n address _candidateAdmin,\n address _consensusAddr,\n address payable _treasuryAddr,\n uint256 _commissionRate\n ) external payable;\n\n /**\n * @dev Deprecates the pool.\n * - Deduct self-staking amount of the pool admin to zero.\n * - Transfer the deducted amount to the pool admin.\n * - Deactivate the pool admin address in the mapping of active pool admins\n *\n * Requirements:\n * - The method caller is validator contract.\n *\n * Emits the event `PoolsDeprecated` and `Unstaked` events.\n * Emits the event `StakingAmountTransferFailed` if the contract cannot transfer RON back to the pool admin.\n *\n */\n function execDeprecatePools(address[] calldata _pools, uint256 _period) external;\n\n /**\n * @dev Self-delegates to the validator candidate `_consensusAddr`.\n *\n * Requirements:\n * - The consensus address is a validator candidate.\n * - The method caller is the pool admin.\n * - The `msg.value` is larger than 0.\n *\n * Emits the event `Staked`.\n *\n */\n function stake(address _consensusAddr) external payable;\n\n /**\n * @dev Unstakes from the validator candidate `_consensusAddr` for `_amount`.\n *\n * Requirements:\n * - The consensus address is a validator candidate.\n * - The method caller is the pool admin.\n *\n * Emits the event `Unstaked`.\n *\n */\n function unstake(address _consensusAddr, uint256 _amount) external;\n\n /**\n * @dev Pool admin requests update validator commission rate. The request will be forwarded to the candidate manager\n * contract, and the value is getting updated in {ICandidateManager-execRequestUpdateCommissionRate}.\n *\n * Requirements:\n * - The consensus address is a validator candidate.\n * - The method caller is the pool admin.\n * - The `_effectiveDaysOnwards` must be equal to or larger than the {CandidateManager-_minEffectiveDaysOnwards}.\n * - The `_rate` must be in range of [0_00; 100_00].\n *\n * Emits the event `CommissionRateUpdated`.\n *\n */\n function requestUpdateCommissionRate(\n address _consensusAddr,\n uint256 _effectiveDaysOnwards,\n uint256 _commissionRate\n ) external;\n\n /**\n * @dev Renounces being a validator candidate and takes back the delegating/staking amount.\n *\n * Requirements:\n * - The consensus address is a validator candidate.\n * - The method caller is the pool admin.\n *\n */\n function requestRenounce(address _consensusAddr) external;\n\n /**\n * @dev Renounces being a validator candidate and takes back the delegating/staking amount.\n *\n * Requirements:\n * - The consensus address is a validator candidate.\n * - The method caller is the pool admin.\n *\n */\n function requestEmergencyExit(address _consensusAddr) external;\n}\n" + }, + "contracts/interfaces/staking/IDelegatorStaking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IRewardPool.sol\";\n\ninterface IDelegatorStaking is IRewardPool {\n /// @dev Emitted when the delegator staked for a validator candidate.\n event Delegated(address indexed delegator, address indexed consensuAddr, uint256 amount);\n /// @dev Emitted when the delegator unstaked from a validator candidate.\n event Undelegated(address indexed delegator, address indexed consensuAddr, uint256 amount);\n\n /// @dev Error of undelegating zero amount.\n error ErrUndelegateZeroAmount();\n /// @dev Error of undelegating insufficient amount.\n error ErrInsufficientDelegatingAmount();\n /// @dev Error of undelegating too early.\n error ErrUndelegateTooEarly();\n\n /**\n * @dev Stakes for a validator candidate `_consensusAddr`.\n *\n * Requirements:\n * - The consensus address is a validator candidate.\n * - The method caller is not the pool admin.\n *\n * Emits the `Delegated` event.\n *\n */\n function delegate(address _consensusAddr) external payable;\n\n /**\n * @dev Unstakes from a validator candidate `_consensusAddr` for `_amount`.\n *\n * Requirements:\n * - The method caller is not the pool admin.\n *\n * Emits the `Undelegated` event.\n *\n */\n function undelegate(address _consensusAddr, uint256 _amount) external;\n\n /**\n * @dev Bulk unstakes from a list of candidates.\n *\n * Requirements:\n * - The method caller is not the pool admin.\n *\n * Emits the events `Undelegated`.\n *\n */\n function bulkUndelegate(address[] calldata _consensusAddrs, uint256[] calldata _amounts) external;\n\n /**\n * @dev Unstakes an amount of RON from the `_consensusAddrSrc` and stake for `_consensusAddrDst`.\n *\n * Requirements:\n * - The method caller is not the pool admin.\n * - The consensus address `_consensusAddrDst` is a validator candidate.\n *\n * Emits the `Undelegated` event and the `Delegated` event.\n *\n */\n function redelegate(address _consensusAddrSrc, address _consensusAddrDst, uint256 _amount) external;\n\n /**\n * @dev Returns the claimable reward of the user `_user`.\n */\n function getRewards(\n address _user,\n address[] calldata _poolAddrList\n ) external view returns (uint256[] memory _rewards);\n\n /**\n * @dev Claims the reward of method caller.\n *\n * Emits the `RewardClaimed` event.\n *\n */\n function claimRewards(address[] calldata _consensusAddrList) external returns (uint256 _amount);\n\n /**\n * @dev Claims the rewards and delegates them to the consensus address.\n *\n * Requirements:\n * - The method caller is not the pool admin.\n * - The consensus address `_consensusAddrDst` is a validator candidate.\n *\n * Emits the `RewardClaimed` event and the `Delegated` event.\n *\n */\n function delegateRewards(\n address[] calldata _consensusAddrList,\n address _consensusAddrDst\n ) external returns (uint256 _amount);\n}\n" + }, + "contracts/interfaces/staking/IRewardPool.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../interfaces/consumers/PeriodWrapperConsumer.sol\";\n\ninterface IRewardPool is PeriodWrapperConsumer {\n struct UserRewardFields {\n // Recorded reward amount.\n uint256 debited;\n // The last accumulated of the amount rewards per share (one unit staking) that the info updated.\n uint256 aRps;\n // Lowest staking amount in the period.\n uint256 lowestAmount;\n // Last period number that the info updated.\n uint256 lastPeriod;\n }\n\n struct PoolFields {\n // Accumulated of the amount rewards per share (one unit staking).\n uint256 aRps;\n // The staking total to share reward of the current period.\n PeriodWrapper shares;\n }\n\n /// @dev Emitted when the fields to calculate pending reward for the user is updated.\n event UserRewardUpdated(address indexed poolAddr, address indexed user, uint256 debited);\n /// @dev Emitted when the user claimed their reward\n event RewardClaimed(address indexed poolAddr, address indexed user, uint256 amount);\n\n /// @dev Emitted when the pool shares are updated\n event PoolSharesUpdated(uint256 indexed period, address indexed poolAddr, uint256 shares);\n /// @dev Emitted when the pools are updated\n event PoolsUpdated(uint256 indexed period, address[] poolAddrs, uint256[] aRps, uint256[] shares);\n /// @dev Emitted when the contract fails when updating the pools\n event PoolsUpdateFailed(uint256 indexed period, address[] poolAddrs, uint256[] rewards);\n /// @dev Emitted when the contract fails when updating the pools that already set\n event PoolsUpdateConflicted(uint256 indexed period, address[] poolAddrs);\n\n /// @dev Error of invalid pool share.\n error ErrInvalidPoolShare();\n\n /**\n * @dev Returns the reward amount that user claimable.\n */\n function getReward(address _poolAddr, address _user) external view returns (uint256);\n\n /**\n * @dev Returns the staking amount of an user.\n */\n function getStakingAmount(address _poolAddr, address _user) external view returns (uint256);\n\n /**\n * @dev Returns the staking amounts of the users.\n */\n function getManyStakingAmounts(\n address[] calldata _poolAddrs,\n address[] calldata _userList\n ) external view returns (uint256[] memory);\n\n /**\n * @dev Returns the total staking amount of all users for a pool.\n */\n function getStakingTotal(address _poolAddr) external view returns (uint256);\n\n /**\n * @dev Returns the total staking amounts of all users for the pools `_poolAddrs`.\n */\n function getManyStakingTotals(address[] calldata _poolAddrs) external view returns (uint256[] memory);\n}\n" + }, + "contracts/interfaces/staking/IStaking.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IBaseStaking.sol\";\nimport \"./ICandidateStaking.sol\";\nimport \"./IDelegatorStaking.sol\";\n\ninterface IStaking is IRewardPool, IBaseStaking, ICandidateStaking, IDelegatorStaking {\n /**\n * @dev Records the amount of rewards `_rewards` for the pools `_consensusAddrs`.\n *\n * Requirements:\n * - The method caller must be validator contract.\n *\n * Emits the event `PoolsUpdated` once the contract recorded the rewards successfully.\n * Emits the event `PoolsUpdateFailed` once the input array lengths are not equal.\n * Emits the event `PoolsUpdateConflicted` when there are some pools which already updated in the period.\n *\n * Note: This method should be called once at the period ending.\n *\n */\n function execRecordRewards(\n address[] calldata _consensusAddrs,\n uint256[] calldata _rewards,\n uint256 _period\n ) external payable;\n\n /**\n * @dev Deducts from staking amount of the validator `_consensusAddr` for `_amount`.\n *\n * Requirements:\n * - The method caller must be validator contract.\n *\n * Emits the event `Unstaked`.\n *\n */\n function execDeductStakingAmount(\n address _consensusAddr,\n uint256 _amount\n ) external returns (uint256 _actualDeductingAmount);\n}\n" + }, + "contracts/interfaces/validator/ICandidateManager.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface ICandidateManager {\n struct ValidatorCandidate {\n // Admin of the candidate\n address admin;\n // Address of the validator that produces block, e.g. block.coinbase. This is so-called validator address.\n address consensusAddr;\n // Address that receives mining reward of the validator\n address payable treasuryAddr;\n // Address of the bridge operator corresponding to the candidate\n address ______deprecatedbridgeOperatorAddr;\n // The percentage of reward that validators can be received, the rest goes to the delegators.\n // Values in range [0; 100_00] stands for 0-100%\n uint256 commissionRate;\n // The timestamp that scheduled to revoke the candidate (no schedule=0)\n uint256 revokingTimestamp;\n // The deadline that the candidate must top up staking amount to keep it larger than or equal to the threshold (no deadline=0)\n uint256 topupDeadline;\n }\n\n struct CommissionSchedule {\n // The timestamp that the commission schedule gets affected (no schedule=0).\n uint256 effectiveTimestamp;\n // The new commission rate. Value is in range [0; 100_00], stands for 0-100%\n uint256 commissionRate;\n }\n\n /// @dev Emitted when the maximum number of validator candidates is updated.\n event MaxValidatorCandidateUpdated(uint256 threshold);\n /// @dev Emitted when the min offset to the effective date of commission rate change is updated.\n event MinEffectiveDaysOnwardsUpdated(uint256 numOfDays);\n /// @dev Emitted when the validator candidate is granted.\n event CandidateGranted(address indexed consensusAddr, address indexed treasuryAddr, address indexed admin);\n /// @dev Emitted when the revoking timestamp of a candidate is updated.\n event CandidateRevokingTimestampUpdated(address indexed consensusAddr, uint256 revokingTimestamp);\n /// @dev Emitted when the topup deadline of a candidate is updated.\n event CandidateTopupDeadlineUpdated(address indexed consensusAddr, uint256 topupDeadline);\n /// @dev Emitted when the validator candidate is revoked.\n event CandidatesRevoked(address[] consensusAddrs);\n\n /// @dev Emitted when a schedule for updating commission rate is set.\n event CommissionRateUpdateScheduled(address indexed consensusAddr, uint256 effectiveTimestamp, uint256 rate);\n /// @dev Emitted when the commission rate of a validator is updated.\n event CommissionRateUpdated(address indexed consensusAddr, uint256 rate);\n\n /// @dev Error of exceeding maximum number of candidates.\n error ErrExceedsMaxNumberOfCandidate();\n /// @dev Error of querying for already existent candidate.\n error ErrExistentCandidate();\n /// @dev Error of querying for non-existent candidate.\n error ErrNonExistentCandidate();\n /// @dev Error of candidate admin already exists.\n error ErrExistentCandidateAdmin(address _candidateAdminAddr);\n /// @dev Error of treasury already exists.\n error ErrExistentTreasury(address _treasuryAddr);\n /// @dev Error of invalid commission rate.\n error ErrInvalidCommissionRate();\n /// @dev Error of invalid effective days onwards.\n error ErrInvalidEffectiveDaysOnwards();\n /// @dev Error of invalid min effective days onwards.\n error ErrInvalidMinEffectiveDaysOnwards();\n /// @dev Error of already requested revoking candidate before.\n error ErrAlreadyRequestedRevokingCandidate();\n /// @dev Error of commission change schedule exists.\n error ErrAlreadyRequestedUpdatingCommissionRate();\n /// @dev Error of trusted org cannot renounce.\n error ErrTrustedOrgCannotRenounce();\n\n /**\n * @dev Returns the maximum number of validator candidate.\n */\n function maxValidatorCandidate() external view returns (uint256);\n\n /**\n * @dev Returns the minimum number of days to the effective date of commission rate change.\n */\n function minEffectiveDaysOnwards() external view returns (uint256);\n\n /**\n * @dev Sets the maximum number of validator candidate.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `MaxValidatorCandidateUpdated` event.\n *\n */\n function setMaxValidatorCandidate(uint256) external;\n\n /**\n * @dev Sets the minimum number of days to the effective date of commision rate change.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `MinEffectiveDaysOnwardsUpdated` event.\n *\n */\n function setMinEffectiveDaysOnwards(uint256 _numOfDays) external;\n\n /**\n * @dev Grants a validator candidate.\n *\n * Requirements:\n * - The method caller is staking contract.\n *\n * Emits the event `CandidateGranted`.\n *\n */\n function execApplyValidatorCandidate(\n address _admin,\n address _consensusAddr,\n address payable _treasuryAddr,\n uint256 _commissionRate\n ) external;\n\n /**\n * @dev Requests to revoke a validator candidate in next `_secsLeft` seconds.\n *\n * Requirements:\n * - The method caller is staking contract.\n *\n * Emits the event `CandidateRevokingTimestampUpdated`.\n *\n */\n function execRequestRenounceCandidate(address, uint256 _secsLeft) external;\n\n /**\n * @dev Fallback function of `CandidateStaking-requestUpdateCommissionRate`.\n *\n * Requirements:\n * - The method caller is the staking contract.\n * - The `_effectiveTimestamp` must be the beginning of a UTC day, and at least from 7 days onwards\n * - The `_rate` must be in range of [0_00; 100_00].\n *\n * Emits the event `CommissionRateUpdateScheduled`.\n *\n */\n function execRequestUpdateCommissionRate(address _consensusAddr, uint256 _effectiveTimestamp, uint256 _rate) external;\n\n /**\n * @dev Returns whether the address is a validator (candidate).\n */\n function isValidatorCandidate(address _addr) external view returns (bool);\n\n /**\n * @dev Returns the validator candidate.\n */\n function getValidatorCandidates() external view returns (address[] memory);\n\n /**\n * @dev Returns all candidate info.\n */\n function getCandidateInfos() external view returns (ValidatorCandidate[] memory);\n\n /**\n * @dev Returns the info of a candidate.\n */\n function getCandidateInfo(address _candidate) external view returns (ValidatorCandidate memory);\n\n /**\n * @dev Returns whether the address is the candidate admin.\n */\n function isCandidateAdmin(address _candidate, address _admin) external view returns (bool);\n\n /**\n * @dev Returns the schedule of changing commission rate of a candidate address.\n */\n function getCommissionChangeSchedule(address _candidate) external view returns (CommissionSchedule memory);\n}\n" + }, + "contracts/interfaces/validator/ICoinbaseExecution.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./ISlashingExecution.sol\";\n\ninterface ICoinbaseExecution is ISlashingExecution {\n enum BlockRewardDeprecatedType {\n UNKNOWN,\n UNAVAILABILITY,\n AFTER_BAILOUT\n }\n\n /// @dev Emitted when the validator set is updated\n event ValidatorSetUpdated(uint256 indexed period, address[] consensusAddrs);\n /// @dev Emitted when the bridge operator set is updated, to mirror the in-jail and maintaining status of the validator.\n event BlockProducerSetUpdated(uint256 indexed period, uint256 indexed epoch, address[] consensusAddrs);\n /// @dev Emitted when the bridge operator set is updated.\n event BridgeOperatorSetUpdated(uint256 indexed period, uint256 indexed epoch, address[] bridgeOperators);\n\n /// @dev Emitted when the reward of the block producer is deprecated.\n event BlockRewardDeprecated(\n address indexed coinbaseAddr,\n uint256 rewardAmount,\n BlockRewardDeprecatedType deprecatedType\n );\n /// @dev Emitted when the block reward is submitted.\n event BlockRewardSubmitted(address indexed coinbaseAddr, uint256 submittedAmount, uint256 bonusAmount);\n\n /// @dev Emitted when the block producer reward is distributed.\n event MiningRewardDistributed(address indexed consensusAddr, address indexed recipient, uint256 amount);\n /// @dev Emitted when the contract fails when distributing the block producer reward.\n event MiningRewardDistributionFailed(\n address indexed consensusAddr,\n address indexed recipient,\n uint256 amount,\n uint256 contractBalance\n );\n\n /// @dev Emitted when the bridge operator reward is distributed.\n event BridgeOperatorRewardDistributed(\n address indexed consensusAddr,\n address indexed bridgeOperator,\n address indexed recipientAddr,\n uint256 amount\n );\n /// @dev Emitted when the contract fails when distributing the bridge operator reward.\n event BridgeOperatorRewardDistributionFailed(\n address indexed consensusAddr,\n address indexed bridgeOperator,\n address indexed recipient,\n uint256 amount,\n uint256 contractBalance\n );\n\n /// @dev Emitted when the amount of RON reward is distributed to staking contract.\n event StakingRewardDistributed(uint256 totalAmount, address[] consensusAddrs, uint256[] amounts);\n /// @dev Emitted when the contracts fails when distributing the amount of RON to the staking contract.\n event StakingRewardDistributionFailed(\n uint256 totalAmount,\n address[] consensusAddrs,\n uint256[] amounts,\n uint256 contractBalance\n );\n\n /// @dev Emitted when the epoch is wrapped up.\n event WrappedUpEpoch(uint256 indexed periodNumber, uint256 indexed epochNumber, bool periodEnding);\n\n /// @dev Error of method caller must be coinbase\n error ErrCallerMustBeCoinbase();\n /// @dev Error of only allowed at the end of epoch\n error ErrAtEndOfEpochOnly();\n /// @dev Error of query for already wrapped up epoch\n error ErrAlreadyWrappedEpoch();\n\n /**\n * @dev Submits reward of the current block.\n *\n * Requirements:\n * - The method caller is coinbase.\n *\n * Emits the event `MiningRewardDeprecated` if the coinbase is slashed or no longer be a block producer.\n * Emits the event `BlockRewardSubmitted` for the valid call.\n *\n */\n function submitBlockReward() external payable;\n\n /**\n * @dev Wraps up the current epoch.\n *\n * Requirements:\n * - The method must be called when the current epoch is ending.\n * - The epoch is not wrapped yet.\n * - The method caller is coinbase.\n *\n * Emits the event `MiningRewardDistributed` when some validator has reward distributed.\n * Emits the event `StakingRewardDistributed` when some staking pool has reward distributed.\n * Emits the event `BlockProducerSetUpdated` when the epoch is wrapped up.\n * Emits the event `BridgeOperatorSetUpdated` when the epoch is wrapped up at period ending.\n * Emits the event `ValidatorSetUpdated` when the epoch is wrapped up at period ending, and the validator set gets updated.\n * Emits the event `WrappedUpEpoch`.\n *\n */\n function wrapUpEpoch() external payable;\n}\n" + }, + "contracts/interfaces/validator/IEmergencyExit.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface IEmergencyExit {\n /// @dev Emitted when the fund is locked from an emergency exit request\n event EmergencyExitRequested(address indexed consensusAddr, uint256 lockedAmount);\n /// @dev Emitted when the fund that locked from an emergency exit request is transferred to the recipient.\n event EmergencyExitLockedFundReleased(\n address indexed consensusAddr,\n address indexed recipient,\n uint256 unlockedAmount\n );\n /// @dev Emitted when the fund that locked from an emergency exit request is failed to transferred back.\n event EmergencyExitLockedFundReleasingFailed(\n address indexed consensusAddr,\n address indexed recipient,\n uint256 unlockedAmount,\n uint256 contractBalance\n );\n\n /// @dev Emitted when the emergency exit locked amount is updated.\n event EmergencyExitLockedAmountUpdated(uint256 amount);\n /// @dev Emitted when the emergency expiry duration is updated.\n event EmergencyExpiryDurationUpdated(uint256 amount);\n\n /// @dev Error of already requested emergency exit before.\n error ErrAlreadyRequestedEmergencyExit();\n\n /**\n * @dev Returns the amount of RON to lock from a consensus address.\n */\n function emergencyExitLockedAmount() external returns (uint256);\n\n /**\n * @dev Returns the duration that an emergency request is expired and the fund will be recycled.\n */\n function emergencyExpiryDuration() external returns (uint256);\n\n /**\n * @dev Sets the amount of RON to lock from a consensus address.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `EmergencyExitLockedAmountUpdated`.\n *\n */\n function setEmergencyExitLockedAmount(uint256 _emergencyExitLockedAmount) external;\n\n /**\n * @dev Sets the duration that an emergency request is expired and the fund will be recycled.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `EmergencyExpiryDurationUpdated`.\n *\n */\n function setEmergencyExpiryDuration(uint256 _emergencyExpiryDuration) external;\n\n /**\n * @dev Unlocks fund for emergency exit request.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the event `EmergencyExitLockedFundReleased` if the fund is successfully unlocked.\n * Emits the event `EmergencyExitLockedFundReleasingFailed` if the fund is failed to unlock.\n *\n */\n function execReleaseLockedFundForEmergencyExitRequest(address _consensusAddr, address payable _recipient) external;\n\n /**\n * @dev Fallback function of `IStaking-requestEmergencyExit`.\n *\n * Requirements:\n * - The method caller is staking contract.\n *\n */\n function execEmergencyExit(address _consensusAddr, uint256 _secLeftToRevoke) external;\n}\n" + }, + "contracts/interfaces/validator/info-fragments/ICommonInfo.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./IJailingInfo.sol\";\nimport \"./ITimingInfo.sol\";\nimport \"./IValidatorInfoV2.sol\";\n\ninterface ICommonInfo is ITimingInfo, IJailingInfo, IValidatorInfoV2 {\n struct EmergencyExitInfo {\n uint256 lockedAmount;\n // The timestamp that this locked amount will be recycled to staking vesting contract\n uint256 recyclingAt;\n }\n\n /// @dev Emitted when the deprecated reward is withdrawn.\n event DeprecatedRewardRecycled(address indexed recipientAddr, uint256 amount);\n /// @dev Emitted when the deprecated reward withdrawal is failed\n event DeprecatedRewardRecycleFailed(address indexed recipientAddr, uint256 amount, uint256 balance);\n\n /// @dev Error thrown when receives RON from neither staking vesting contract nor staking contract\n error ErrUnauthorizedReceiveRON();\n /// @dev Error thrown when queries for a non existent info.\n error NonExistentRecyclingInfo();\n\n /**\n * @dev Returns the total deprecated reward, which includes reward that is not sent for slashed validators and unsastified bridge operators\n */\n function totalDeprecatedReward() external view returns (uint256);\n\n /**\n * @dev Returns the emergency exit request.\n */\n function getEmergencyExitInfo(address _consensusAddr) external view returns (EmergencyExitInfo memory);\n}\n" + }, + "contracts/interfaces/validator/info-fragments/IJailingInfo.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface IJailingInfo {\n /**\n * @dev Returns whether the validator are put in jail (cannot join the set of validators) during the current period.\n */\n function checkJailed(address) external view returns (bool);\n\n /**\n * @dev Returns whether the validator are put in jail and the number of block and epoch that he still is in the jail.\n */\n function getJailedTimeLeft(\n address _addr\n ) external view returns (bool isJailed_, uint256 blockLeft_, uint256 epochLeft_);\n\n /**\n * @dev Returns whether the validator are put in jail (cannot join the set of validators) at a specific block.\n */\n function checkJailedAtBlock(address _addr, uint256 _blockNum) external view returns (bool);\n\n /**\n * @dev Returns whether the validator are put in jail at a specific block and the number of block and epoch that he still is in the jail.\n */\n function getJailedTimeLeftAtBlock(\n address _addr,\n uint256 _blockNum\n ) external view returns (bool isJailed_, uint256 blockLeft_, uint256 epochLeft_);\n\n /**\n * @dev Returns whether the validators are put in jail (cannot join the set of validators) during the current period.\n */\n function checkManyJailed(address[] calldata) external view returns (bool[] memory);\n\n /**\n * @dev Returns whether the incoming reward of the block producer is deprecated during the current period.\n */\n function checkMiningRewardDeprecated(address _blockProducer) external view returns (bool);\n\n /**\n * @dev Returns whether the incoming reward of the block producer is deprecated during a specific period.\n */\n function checkMiningRewardDeprecatedAtPeriod(address _blockProducer, uint256 _period) external view returns (bool);\n}\n" + }, + "contracts/interfaces/validator/info-fragments/ITimingInfo.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface ITimingInfo {\n /**\n * @dev Returns the block that validator set was updated.\n */\n function getLastUpdatedBlock() external view returns (uint256);\n\n /**\n * @dev Returns the number of blocks in a epoch.\n */\n function numberOfBlocksInEpoch() external view returns (uint256 _numberOfBlocks);\n\n /**\n * @dev Returns the epoch index from the block number.\n */\n function epochOf(uint256 _block) external view returns (uint256);\n\n /**\n * @dev Returns whether the epoch ending is at the block number `_block`.\n */\n function epochEndingAt(uint256 _block) external view returns (bool);\n\n /**\n * @dev Tries to get the period index from the epoch number.\n */\n function tryGetPeriodOfEpoch(uint256 _epoch) external view returns (bool _filled, uint256 _periodNumber);\n\n /**\n * @dev Returns whether the period ending at the current block number.\n */\n function isPeriodEnding() external view returns (bool);\n\n /**\n * @dev Returns the period index from the current block.\n */\n function currentPeriod() external view returns (uint256);\n\n /**\n * @dev Returns the block number that the current period starts at.\n */\n function currentPeriodStartAtBlock() external view returns (uint256);\n}\n" + }, + "contracts/interfaces/validator/info-fragments/IValidatorInfoV2.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../../libraries/EnumFlags.sol\";\n\ninterface IValidatorInfoV2 {\n /**\n * @dev Error thrown when an invalid maximum prioritized validator number is provided.\n */\n error ErrInvalidMaxPrioritizedValidatorNumber();\n\n /// @dev Emitted when the number of max validator is updated.\n event MaxValidatorNumberUpdated(uint256);\n /// @dev Emitted when the number of reserved slots for prioritized validators is updated.\n event MaxPrioritizedValidatorNumberUpdated(uint256);\n\n /**\n * @dev Returns the maximum number of validators in the epoch.\n */\n function maxValidatorNumber() external view returns (uint256 _maximumValidatorNumber);\n\n /**\n * @dev Returns the number of reserved slots for prioritized validators.\n */\n function maxPrioritizedValidatorNumber() external view returns (uint256 _maximumPrioritizedValidatorNumber);\n\n /**\n * @dev Returns the current validator list.\n */\n function getValidators() external view returns (address[] memory _validatorList);\n\n /**\n * @dev Returns the current block producer list.\n */\n function getBlockProducers() external view returns (address[] memory);\n\n /**\n * @dev Returns whether the address is block producer or not.\n */\n function isBlockProducer(address _addr) external view returns (bool);\n\n /**\n * @dev Returns total numbers of the block producers.\n */\n function totalBlockProducers() external view returns (uint256);\n\n /**\n * @dev Updates the max validator number\n *\n * Requirements:\n * - The method caller is admin\n *\n * Emits the event `MaxValidatorNumberUpdated`\n *\n */\n function setMaxValidatorNumber(uint256 _maxValidatorNumber) external;\n\n /**\n * @dev Updates the number of reserved slots for prioritized validators\n *\n * Requirements:\n * - The method caller is admin\n *\n * Emits the event `MaxPrioritizedValidatorNumberUpdated`\n *\n */\n function setMaxPrioritizedValidatorNumber(uint256 _maxPrioritizedValidatorNumber) external;\n}\n" + }, + "contracts/interfaces/validator/IRoninValidatorSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./ICandidateManager.sol\";\nimport \"./info-fragments/ICommonInfo.sol\";\nimport \"./ICoinbaseExecution.sol\";\nimport \"./ISlashingExecution.sol\";\nimport \"./IEmergencyExit.sol\";\n\ninterface IRoninValidatorSet is\n ICandidateManager,\n ICommonInfo,\n ISlashingExecution,\n ICoinbaseExecution,\n IEmergencyExit\n{}\n" + }, + "contracts/interfaces/validator/ISlashingExecution.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface ISlashingExecution {\n /// @dev Emitted when the validator is punished.\n event ValidatorPunished(\n address indexed consensusAddr,\n uint256 indexed period,\n uint256 jailedUntil,\n uint256 deductedStakingAmount,\n bool blockProducerRewardDeprecated,\n bool bridgeOperatorRewardDeprecated\n );\n /// @dev Emitted when the validator get out of jail by bailout.\n event ValidatorUnjailed(address indexed validator, uint256 period);\n\n /// @dev Error of cannot bailout due to high tier slash.\n error ErrCannotBailout(address validator);\n\n /**\n * @dev Finalize the slash request from slash indicator contract.\n *\n * Requirements:\n * - The method caller is slash indicator contract.\n *\n * Emits the event `ValidatorPunished`.\n *\n */\n function execSlash(\n address _validatorAddr,\n uint256 _newJailedUntil,\n uint256 _slashAmount,\n bool _cannotBailout\n ) external;\n\n /**\n * @dev Finalize the bailout request from slash indicator contract.\n *\n * Requirements:\n * - The method caller is slash indicator contract.\n *\n * Emits the event `ValidatorUnjailed`.\n *\n */\n function execBailOut(address _validatorAddr, uint256 _period) external;\n}\n" + }, + "contracts/libraries/AddressArrayUtils.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\nlibrary AddressArrayUtils {\n /**\n * @dev Error thrown when a duplicated element is detected in an array.\n * @param msgSig The function signature that invoke the error.\n */\n error ErrDuplicated(bytes4 msgSig);\n\n /**\n * @dev Returns whether or not there's a duplicate. Runs in O(n^2).\n * @param A Array to search\n * @return Returns true if duplicate, false otherwise\n */\n function hasDuplicate(address[] memory A) internal pure returns (bool) {\n if (A.length == 0) {\n return false;\n }\n unchecked {\n for (uint256 i = 0; i < A.length - 1; i++) {\n for (uint256 j = i + 1; j < A.length; j++) {\n if (A[i] == A[j]) {\n return true;\n }\n }\n }\n }\n return false;\n }\n\n /**\n * @dev Returns whether two arrays of addresses are equal or not.\n */\n function isEqual(address[] memory _this, address[] memory _other) internal pure returns (bool yes_) {\n // Hashing two arrays and compare their hash\n assembly {\n let _thisHash := keccak256(add(_this, 32), mul(mload(_this), 32))\n let _otherHash := keccak256(add(_other, 32), mul(mload(_other), 32))\n yes_ := eq(_thisHash, _otherHash)\n }\n }\n\n /**\n * @dev Return the concatenated array from a and b.\n */\n function extend(address[] memory a, address[] memory b) internal pure returns (address[] memory c) {\n uint256 lengthA = a.length;\n uint256 lengthB = b.length;\n unchecked {\n c = new address[](lengthA + lengthB);\n }\n uint256 i;\n for (; i < lengthA; ) {\n c[i] = a[i];\n unchecked {\n ++i;\n }\n }\n for (uint256 j; j < lengthB; ) {\n c[i] = b[j];\n unchecked {\n ++i;\n ++j;\n }\n }\n }\n}\n" + }, + "contracts/libraries/EnumFlags.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This library implements checking flag of an enumerated value.\n * The originated idea is inherited from [Enum.HashFlag(Enum)](https://learn.microsoft.com/en-us/dotnet/api/system.enum.hasflag?view=net-6.0) method of C#.\n */\nlibrary EnumFlags {\n enum ValidatorFlag {\n None, // bit(00)\n BlockProducer, // bit(01)\n DeprecatedBridgeOperator, // bit(10)\n Both // bit(11)\n }\n\n function isNone(ValidatorFlag _value) internal pure returns (bool) {\n return uint8(_value) == 0;\n }\n\n /**\n * @dev Checks if `_value` has `_flag`.\n */\n function hasFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (bool) {\n return (uint8(_value) & uint8(_flag)) != 0;\n }\n\n /**\n * @dev Calculate new value of `_value` after adding `_flag`.\n */\n function addFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (ValidatorFlag) {\n return ValidatorFlag(uint8(_value) | uint8(_flag));\n }\n\n /**\n * @dev Calculate new value of `_value` after remove `_flag`.\n */\n function removeFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (ValidatorFlag) {\n return ValidatorFlag(uint8(_value) & ~uint8(_flag));\n }\n}\n" + }, + "contracts/libraries/Math.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\nlibrary Math {\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a >= b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns whether the number `c` is in range of [a; b].\n */\n function inRange(uint256 c, uint256 a, uint256 b) internal pure returns (bool) {\n return a <= c && c <= b;\n }\n\n /**\n * @dev Returns whether two inclusive ranges [x1;x2] and [y1;y2] overlap.\n */\n function twoRangeOverlap(uint256 x1, uint256 x2, uint256 y1, uint256 y2) internal pure returns (bool) {\n return x1 <= y2 && y1 <= x2;\n }\n\n /**\n * @dev Returns value of a + b; in case result is larger than upperbound, upperbound is returned.\n */\n function addWithUpperbound(uint256 a, uint256 b, uint256 upperbound) internal pure returns (uint256) {\n return min(a + b, upperbound);\n }\n\n /**\n * @dev Returns value of a - b; in case of negative result, 0 is returned.\n */\n function subNonNegative(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a - b : 0;\n }\n\n /**\n * @dev Returns value of `a + zeroable` if zerobale is not 0; otherwise, return 0.\n */\n function addIfNonZero(uint256 a, uint256 zeroable) internal pure returns (uint256) {\n return zeroable != 0 ? a + zeroable : 0;\n }\n}\n" + }, + "contracts/precompile-usages/PCUPickValidatorSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./PrecompiledUsage.sol\";\n\nabstract contract PCUPickValidatorSet is PrecompiledUsage {\n /// @dev Gets the address of the precompile of picking validator set\n function precompilePickValidatorSetAddress() public view virtual returns (address) {\n return address(0x68);\n }\n\n /**\n * @dev Sorts and arranges to return a new validator set.\n *\n * Note: The recover process is done by pre-compiled contract. This function is marked as\n * virtual for implementing mocking contract for testing purpose.\n */\n function _pcPickValidatorSet(\n address[] memory _candidates,\n uint256[] memory _weights,\n uint256[] memory _trustedWeights,\n uint256 _maxValidatorNumber,\n uint256 _maxPrioritizedValidatorNumber\n ) internal view virtual returns (address[] memory _result, uint256 _newValidatorCount) {\n address _smc = precompilePickValidatorSetAddress();\n bytes memory _payload = abi.encodeWithSignature(\n \"pickValidatorSet(address[],uint256[],uint256[],uint256,uint256)\",\n _candidates,\n _weights,\n _trustedWeights,\n _maxValidatorNumber,\n _maxPrioritizedValidatorNumber\n );\n bool _success = true;\n\n uint256 _payloadLength = _payload.length;\n uint256 _resultLength = 0x20 * _candidates.length + 0x40;\n\n assembly {\n let _payloadStart := add(_payload, 0x20)\n\n if iszero(staticcall(gas(), _smc, _payloadStart, _payloadLength, _result, _resultLength)) {\n _success := 0\n }\n\n if iszero(returndatasize()) {\n _success := 0\n }\n\n _result := add(_result, 0x20)\n }\n\n if (!_success) revert ErrCallPrecompiled();\n\n _newValidatorCount = _result.length;\n }\n}\n" + }, + "contracts/precompile-usages/PCUSortValidators.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./PrecompiledUsage.sol\";\n\nabstract contract PCUSortValidators is PrecompiledUsage {\n /// @dev Gets the address of the precompile of sorting validators\n function precompileSortValidatorsAddress() public view virtual returns (address) {\n return address(0x66);\n }\n\n /**\n * @dev Sorts candidates descending by their weights by calling precompile contract.\n *\n * Note: This function is marked as virtual for being wrapping in mock contract for testing purpose.\n */\n function _pcSortCandidates(\n address[] memory _candidates,\n uint256[] memory _weights\n ) internal view virtual returns (address[] memory _result) {\n address _smc = precompileSortValidatorsAddress();\n bool _success = true;\n\n bytes memory _payload = abi.encodeWithSignature(\"sortValidators(address[],uint256[])\", _candidates, _weights);\n uint256 _payloadLength = _payload.length;\n uint256 _resultLength = 0x20 * _candidates.length + 0x40;\n\n assembly {\n let _payloadStart := add(_payload, 0x20)\n\n if iszero(staticcall(gas(), _smc, _payloadStart, _payloadLength, _result, _resultLength)) {\n _success := 0\n }\n\n if iszero(returndatasize()) {\n _success := 0\n }\n\n _result := add(_result, 0x20)\n }\n\n if (!_success) revert ErrCallPrecompiled();\n }\n}\n" + }, + "contracts/precompile-usages/PrecompiledUsage.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"./PrecompiledUsage.sol\";\n\nabstract contract PrecompiledUsage {\n /// @dev Error of call to precompile fails.\n error ErrCallPrecompiled();\n}\n" + }, + "contracts/ronin/validator/CandidateManager.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../extensions/collections/HasContracts.sol\";\nimport \"../../extensions/consumers/GlobalConfigConsumer.sol\";\nimport \"../../extensions/consumers/PercentageConsumer.sol\";\nimport \"../../interfaces/validator/ICandidateManager.sol\";\nimport \"../../interfaces/staking/IStaking.sol\";\nimport { HasStakingDeprecated } from \"../../utils/DeprecatedSlots.sol\";\n\nabstract contract CandidateManager is\n ICandidateManager,\n PercentageConsumer,\n GlobalConfigConsumer,\n HasContracts,\n HasStakingDeprecated\n{\n /// @dev Maximum number of validator candidate\n uint256 private _maxValidatorCandidate;\n\n /// @dev The validator candidate array\n address[] internal _candidates;\n /// @dev Mapping from candidate consensus address => bitwise negation of validator index in `_candidates`\n mapping(address => uint256) internal _candidateIndex;\n /// @dev Mapping from candidate consensus address => their info\n mapping(address => ValidatorCandidate) internal _candidateInfo;\n\n /**\n * @dev The minimum offset in day from current date to the effective date of a new commission schedule.\n * Value of 1 means the change gets affected at the beginning of the following day.\n **/\n uint256 internal _minEffectiveDaysOnwards;\n /// @dev Mapping from candidate consensus address => schedule commission change.\n mapping(address => CommissionSchedule) internal _candidateCommissionChangeSchedule;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[48] private ______gap;\n\n /**\n * @inheritdoc ICandidateManager\n */\n function maxValidatorCandidate() public view override returns (uint256) {\n return _maxValidatorCandidate;\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function minEffectiveDaysOnwards() external view override returns (uint256) {\n return _minEffectiveDaysOnwards;\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function setMaxValidatorCandidate(uint256 _number) external override onlyAdmin {\n _setMaxValidatorCandidate(_number);\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function setMinEffectiveDaysOnwards(uint256 _numOfDays) external override onlyAdmin {\n _setMinEffectiveDaysOnwards(_numOfDays);\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function execApplyValidatorCandidate(\n address _candidateAdmin,\n address _consensusAddr,\n address payable _treasuryAddr,\n uint256 _commissionRate\n ) external override onlyContract(ContractType.STAKING) {\n uint256 _length = _candidates.length;\n if (_length >= maxValidatorCandidate()) revert ErrExceedsMaxNumberOfCandidate();\n if (isValidatorCandidate(_consensusAddr)) revert ErrExistentCandidate();\n if (_commissionRate > _MAX_PERCENTAGE) revert ErrInvalidCommissionRate();\n\n for (uint _i; _i < _candidates.length; ) {\n ValidatorCandidate storage existentInfo = _candidateInfo[_candidates[_i]];\n if (_candidateAdmin == existentInfo.admin) revert ErrExistentCandidateAdmin(_candidateAdmin);\n if (_treasuryAddr == existentInfo.treasuryAddr) revert ErrExistentTreasury(_treasuryAddr);\n\n unchecked {\n ++_i;\n }\n }\n\n _candidateIndex[_consensusAddr] = ~_length;\n _candidates.push(_consensusAddr);\n\n ValidatorCandidate storage _info = _candidateInfo[_consensusAddr];\n _info.admin = _candidateAdmin;\n _info.consensusAddr = _consensusAddr;\n _info.treasuryAddr = _treasuryAddr;\n _info.commissionRate = _commissionRate;\n emit CandidateGranted(_consensusAddr, _treasuryAddr, _candidateAdmin);\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function execRequestRenounceCandidate(\n address _consensusAddr,\n uint256 _secsLeft\n ) external override onlyContract(ContractType.STAKING) {\n if (_isTrustedOrg(_consensusAddr)) revert ErrTrustedOrgCannotRenounce();\n\n ValidatorCandidate storage _info = _candidateInfo[_consensusAddr];\n if (_info.revokingTimestamp != 0) revert ErrAlreadyRequestedRevokingCandidate();\n _setRevokingTimestamp(_info, block.timestamp + _secsLeft);\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function execRequestUpdateCommissionRate(\n address _consensusAddr,\n uint256 _effectiveDaysOnwards,\n uint256 _commissionRate\n ) external override onlyContract(ContractType.STAKING) {\n if (_candidateCommissionChangeSchedule[_consensusAddr].effectiveTimestamp != 0) {\n revert ErrAlreadyRequestedUpdatingCommissionRate();\n }\n if (_commissionRate > _MAX_PERCENTAGE) revert ErrInvalidCommissionRate();\n if (_effectiveDaysOnwards < _minEffectiveDaysOnwards) revert ErrInvalidEffectiveDaysOnwards();\n\n CommissionSchedule storage _schedule = _candidateCommissionChangeSchedule[_consensusAddr];\n uint256 _effectiveTimestamp = ((block.timestamp / PERIOD_DURATION) + _effectiveDaysOnwards) * PERIOD_DURATION;\n _schedule.effectiveTimestamp = _effectiveTimestamp;\n _schedule.commissionRate = _commissionRate;\n\n emit CommissionRateUpdateScheduled(_consensusAddr, _effectiveTimestamp, _commissionRate);\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function isValidatorCandidate(address _addr) public view override returns (bool) {\n return _candidateIndex[_addr] != 0;\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function getCandidateInfos() external view override returns (ValidatorCandidate[] memory _list) {\n _list = new ValidatorCandidate[](_candidates.length);\n for (uint _i; _i < _list.length; ) {\n _list[_i] = _candidateInfo[_candidates[_i]];\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function getCandidateInfo(address _candidate) external view override returns (ValidatorCandidate memory) {\n if (!isValidatorCandidate(_candidate)) revert ErrNonExistentCandidate();\n return _candidateInfo[_candidate];\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function getValidatorCandidates() public view override returns (address[] memory) {\n return _candidates;\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function getCommissionChangeSchedule(address _candidate) external view override returns (CommissionSchedule memory) {\n return _candidateCommissionChangeSchedule[_candidate];\n }\n\n /**\n * @dev Removes unsastisfied candidates, the ones who have insufficient minimum candidate staking amount,\n * or the ones who requested to renounce their candidate role.\n *\n * Emits the event `CandidatesRevoked` when a candidate is revoked.\n *\n */\n function _syncCandidateSet(uint256 _nextPeriod) internal returns (address[] memory _unsatisfiedCandidates) {\n IStaking _staking = IStaking(getContract(ContractType.STAKING));\n uint256 _waitingSecsToRevoke = _staking.waitingSecsToRevoke();\n uint256 _minStakingAmount = _staking.minValidatorStakingAmount();\n uint256[] memory _selfStakings = _staking.getManySelfStakings(_candidates);\n\n uint256 _length = _candidates.length;\n uint256 _unsatisfiedCount;\n _unsatisfiedCandidates = new address[](_length);\n\n {\n uint256 _i;\n address _addr;\n ValidatorCandidate storage _info;\n while (_i < _length) {\n _addr = _candidates[_i];\n _info = _candidateInfo[_addr];\n\n // Checks for under-balance status of candidates\n bool _hasTopupDeadline = _info.topupDeadline != 0;\n if (_selfStakings[_i] < _minStakingAmount) {\n // Updates deadline on the first time unsatisfied the staking amount condition\n if (!_hasTopupDeadline) {\n uint256 _topupDeadline = block.timestamp + _waitingSecsToRevoke;\n _info.topupDeadline = _topupDeadline;\n emit CandidateTopupDeadlineUpdated(_addr, _topupDeadline);\n }\n } else if (_hasTopupDeadline) {\n // Removes the deadline if the staking amount condition is satisfied\n delete _info.topupDeadline;\n emit CandidateTopupDeadlineUpdated(_addr, 0);\n }\n\n // Removes unsastisfied candidates\n bool _revokingActivated = (_info.revokingTimestamp != 0 && _info.revokingTimestamp <= block.timestamp) ||\n _emergencyExitLockedFundReleased(_addr);\n bool _topupDeadlineMissed = _info.topupDeadline != 0 && _info.topupDeadline <= block.timestamp;\n if (_revokingActivated || _topupDeadlineMissed) {\n _selfStakings[_i] = _selfStakings[--_length];\n unchecked {\n _unsatisfiedCandidates[_unsatisfiedCount++] = _addr;\n }\n _removeCandidate(_addr);\n continue;\n }\n\n // Checks for schedule of commission change and updates commission rate\n uint256 _scheduleTimestamp = _candidateCommissionChangeSchedule[_addr].effectiveTimestamp;\n if (_scheduleTimestamp != 0 && _scheduleTimestamp <= block.timestamp) {\n uint256 _commisionRate = _candidateCommissionChangeSchedule[_addr].commissionRate;\n delete _candidateCommissionChangeSchedule[_addr];\n _info.commissionRate = _commisionRate;\n emit CommissionRateUpdated(_addr, _commisionRate);\n }\n\n unchecked {\n _i++;\n }\n }\n }\n\n assembly {\n mstore(_unsatisfiedCandidates, _unsatisfiedCount)\n }\n\n if (_unsatisfiedCount > 0) {\n emit CandidatesRevoked(_unsatisfiedCandidates);\n _staking.execDeprecatePools(_unsatisfiedCandidates, _nextPeriod);\n }\n }\n\n /**\n * @inheritdoc ICandidateManager\n */\n function isCandidateAdmin(address _candidate, address _admin) external view override returns (bool) {\n return _candidateInfo[_candidate].admin == _admin;\n }\n\n /**\n * @dev Sets the maximum number of validator candidate.\n *\n * Emits the `MaxValidatorCandidateUpdated` event.\n *\n */\n function _setMaxValidatorCandidate(uint256 _threshold) internal {\n _maxValidatorCandidate = _threshold;\n emit MaxValidatorCandidateUpdated(_threshold);\n }\n\n /**\n * @dev Sets the minimum number of days onwards to the effective date of commission rate change.\n *\n * Emits the `MinEffectiveDaysOnwardsUpdated` event.\n *\n */\n function _setMinEffectiveDaysOnwards(uint256 _numOfDays) internal {\n if (_numOfDays < 1) revert ErrInvalidMinEffectiveDaysOnwards();\n _minEffectiveDaysOnwards = _numOfDays;\n emit MinEffectiveDaysOnwardsUpdated(_numOfDays);\n }\n\n /**\n * @dev Removes the candidate.\n */\n function _removeCandidate(address _addr) internal virtual {\n uint256 _idx = _candidateIndex[_addr];\n if (_idx == 0) {\n return;\n }\n\n delete _candidateInfo[_addr];\n delete _candidateIndex[_addr];\n delete _candidateCommissionChangeSchedule[_addr];\n\n address _lastCandidate = _candidates[_candidates.length - 1];\n if (_lastCandidate != _addr) {\n _candidateIndex[_lastCandidate] = _idx;\n _candidates[~_idx] = _lastCandidate;\n }\n\n _candidates.pop();\n }\n\n /**\n * @dev Sets timestamp to revoke a candidate.\n */\n function _setRevokingTimestamp(ValidatorCandidate storage _candidate, uint256 _timestamp) internal {\n if (!isValidatorCandidate(_candidate.consensusAddr)) revert ErrNonExistentCandidate();\n _candidate.revokingTimestamp = _timestamp;\n emit CandidateRevokingTimestampUpdated(_candidate.consensusAddr, _timestamp);\n }\n\n /**\n * @dev Returns a flag indicating whether the fund is unlocked.\n */\n function _emergencyExitLockedFundReleased(address _consensusAddr) internal virtual returns (bool);\n\n /**\n * @dev Returns whether the consensus address is a trusted org or not.\n */\n function _isTrustedOrg(address _consensusAddr) internal virtual returns (bool);\n}\n" + }, + "contracts/ronin/validator/CoinbaseExecution.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../extensions/collections/HasContracts.sol\";\nimport \"../../extensions/RONTransferHelper.sol\";\nimport \"../../interfaces/IStakingVesting.sol\";\nimport \"../../interfaces/IMaintenance.sol\";\nimport \"../../interfaces/IRoninTrustedOrganization.sol\";\nimport \"../../interfaces/slash-indicator/ISlashIndicator.sol\";\nimport \"../../interfaces/validator/ICoinbaseExecution.sol\";\nimport \"../../libraries/EnumFlags.sol\";\nimport \"../../libraries/Math.sol\";\nimport { HasStakingVestingDeprecated, HasBridgeTrackingDeprecated, HasMaintenanceDeprecated, HasSlashIndicatorDeprecated } from \"../../utils/DeprecatedSlots.sol\";\nimport \"../../precompile-usages/PCUSortValidators.sol\";\nimport \"../../precompile-usages/PCUPickValidatorSet.sol\";\nimport \"./storage-fragments/CommonStorage.sol\";\nimport \"./CandidateManager.sol\";\nimport { EmergencyExit } from \"./EmergencyExit.sol\";\n\nabstract contract CoinbaseExecution is\n ICoinbaseExecution,\n RONTransferHelper,\n PCUSortValidators,\n PCUPickValidatorSet,\n HasContracts,\n HasStakingVestingDeprecated,\n HasBridgeTrackingDeprecated,\n HasMaintenanceDeprecated,\n HasSlashIndicatorDeprecated,\n EmergencyExit\n{\n using EnumFlags for EnumFlags.ValidatorFlag;\n\n modifier onlyCoinbase() {\n _requireCoinbase();\n _;\n }\n\n modifier whenEpochEnding() {\n if (!epochEndingAt(block.number)) revert ErrAtEndOfEpochOnly();\n _;\n }\n\n modifier oncePerEpoch() {\n if (epochOf(_lastUpdatedBlock) >= epochOf(block.number)) revert ErrAlreadyWrappedEpoch();\n _lastUpdatedBlock = block.number;\n _;\n }\n\n function _requireCoinbase() private view {\n if (msg.sender != block.coinbase) revert ErrCallerMustBeCoinbase();\n }\n\n /**\n * @inheritdoc ICoinbaseExecution\n */\n function submitBlockReward() external payable override onlyCoinbase {\n bool _requestForBlockProducer = isBlockProducer(msg.sender) &&\n !_jailed(msg.sender) &&\n !_miningRewardDeprecated(msg.sender, currentPeriod());\n\n (, uint256 _blockProducerBonus, ) = IStakingVesting(getContract(ContractType.STAKING_VESTING)).requestBonus({\n _forBlockProducer: _requestForBlockProducer,\n _forBridgeOperator: false\n });\n\n // Deprecates reward for non-validator or slashed validator\n if (!_requestForBlockProducer) {\n _totalDeprecatedReward += msg.value;\n emit BlockRewardDeprecated(msg.sender, msg.value, BlockRewardDeprecatedType.UNAVAILABILITY);\n return;\n }\n\n emit BlockRewardSubmitted(msg.sender, msg.value, _blockProducerBonus);\n\n uint256 _period = currentPeriod();\n uint256 _reward = msg.value + _blockProducerBonus;\n uint256 _cutOffReward;\n if (_miningRewardBailoutCutOffAtPeriod[msg.sender][_period]) {\n (, , , uint256 _cutOffPercentage) = ISlashIndicator(getContract(ContractType.SLASH_INDICATOR))\n .getCreditScoreConfigs();\n _cutOffReward = (_reward * _cutOffPercentage) / _MAX_PERCENTAGE;\n _totalDeprecatedReward += _cutOffReward;\n emit BlockRewardDeprecated(msg.sender, _cutOffReward, BlockRewardDeprecatedType.AFTER_BAILOUT);\n }\n\n _reward -= _cutOffReward;\n (uint256 _minRate, uint256 _maxRate) = IStaking(getContract(ContractType.STAKING)).getCommissionRateRange();\n uint256 _rate = Math.max(Math.min(_candidateInfo[msg.sender].commissionRate, _maxRate), _minRate);\n uint256 _miningAmount = (_rate * _reward) / _MAX_PERCENTAGE;\n _miningReward[msg.sender] += _miningAmount;\n\n uint256 _delegatingAmount = _reward - _miningAmount;\n _delegatingReward[msg.sender] += _delegatingAmount;\n }\n\n /**\n * @inheritdoc ICoinbaseExecution\n */\n function wrapUpEpoch() external payable virtual override onlyCoinbase whenEpochEnding oncePerEpoch {\n uint256 _newPeriod = _computePeriod(block.timestamp);\n bool _periodEnding = _isPeriodEnding(_newPeriod);\n\n address[] memory _currentValidators = getValidators();\n address[] memory _revokedCandidates;\n uint256 _epoch = epochOf(block.number);\n uint256 _nextEpoch = _epoch + 1;\n uint256 _lastPeriod = currentPeriod();\n\n if (_periodEnding) {\n (\n uint256 _totalDelegatingReward,\n uint256[] memory _delegatingRewards\n ) = _distributeRewardToTreasuriesAndCalculateTotalDelegatingReward(_lastPeriod, _currentValidators);\n _settleAndTransferDelegatingRewards(_lastPeriod, _currentValidators, _totalDelegatingReward, _delegatingRewards);\n _tryRecycleLockedFundsFromEmergencyExits();\n _recycleDeprecatedRewards();\n ISlashIndicator _slashIndicatorContract = ISlashIndicator(getContract(ContractType.SLASH_INDICATOR));\n _slashIndicatorContract.updateCreditScores(_currentValidators, _lastPeriod);\n (_currentValidators, _revokedCandidates) = _syncValidatorSet(_newPeriod);\n if (_revokedCandidates.length > 0) {\n _slashIndicatorContract.execResetCreditScores(_revokedCandidates);\n }\n _currentPeriodStartAtBlock = block.number + 1;\n }\n _revampRoles(_newPeriod, _nextEpoch, _currentValidators);\n emit WrappedUpEpoch(_lastPeriod, _epoch, _periodEnding);\n _periodOf[_nextEpoch] = _newPeriod;\n _lastUpdatedPeriod = _newPeriod;\n }\n\n /**\n * @dev This loops over all current validators to:\n * - Update delegating reward for and calculate total delegating rewards to be sent to the staking contract,\n * - Distribute the reward of block producers and bridge operators to their treasury addresses,\n * - Update the total deprecated reward if the two previous conditions do not sastify.\n *\n * Note: This method should be called once in the end of each period.\n *\n */\n function _distributeRewardToTreasuriesAndCalculateTotalDelegatingReward(\n uint256 _lastPeriod,\n address[] memory _currentValidators\n ) private returns (uint256 _totalDelegatingReward, uint256[] memory _delegatingRewards) {\n address _consensusAddr;\n address payable _treasury;\n _delegatingRewards = new uint256[](_currentValidators.length);\n for (uint _i; _i < _currentValidators.length; ) {\n _consensusAddr = _currentValidators[_i];\n _treasury = _candidateInfo[_consensusAddr].treasuryAddr;\n\n if (!_jailed(_consensusAddr) && !_miningRewardDeprecated(_consensusAddr, _lastPeriod)) {\n _totalDelegatingReward += _delegatingReward[_consensusAddr];\n _delegatingRewards[_i] = _delegatingReward[_consensusAddr];\n _distributeMiningReward(_consensusAddr, _treasury);\n } else {\n _totalDeprecatedReward += _miningReward[_consensusAddr] + _delegatingReward[_consensusAddr];\n }\n\n delete _delegatingReward[_consensusAddr];\n delete _miningReward[_consensusAddr];\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @dev Distributes bonus of staking vesting and mining fee for the block producer.\n *\n * Emits the `MiningRewardDistributed` once the reward is distributed successfully.\n * Emits the `MiningRewardDistributionFailed` once the contract fails to distribute reward.\n *\n * Note: This method should be called once in the end of each period.\n *\n */\n function _distributeMiningReward(address _consensusAddr, address payable _treasury) private {\n uint256 _amount = _miningReward[_consensusAddr];\n if (_amount > 0) {\n if (_unsafeSendRONLimitGas(_treasury, _amount, DEFAULT_ADDITION_GAS)) {\n emit MiningRewardDistributed(_consensusAddr, _treasury, _amount);\n return;\n }\n\n emit MiningRewardDistributionFailed(_consensusAddr, _treasury, _amount, address(this).balance);\n }\n }\n\n /**\n * @dev Helper function to settle rewards for delegators of `_currentValidators` at the end of each period,\n * then transfer the rewards from this contract to the staking contract, in order to finalize a period.\n *\n * Emits the `StakingRewardDistributed` once the reward is distributed successfully.\n * Emits the `StakingRewardDistributionFailed` once the contract fails to distribute reward.\n *\n * Note: This method should be called once in the end of each period.\n *\n */\n function _settleAndTransferDelegatingRewards(\n uint256 _period,\n address[] memory _currentValidators,\n uint256 _totalDelegatingReward,\n uint256[] memory _delegatingRewards\n ) private {\n IStaking _staking = IStaking(getContract(ContractType.STAKING));\n if (_totalDelegatingReward > 0) {\n if (_unsafeSendRON(payable(address(_staking)), _totalDelegatingReward)) {\n _staking.execRecordRewards(_currentValidators, _delegatingRewards, _period);\n emit StakingRewardDistributed(_totalDelegatingReward, _currentValidators, _delegatingRewards);\n return;\n }\n\n emit StakingRewardDistributionFailed(\n _totalDelegatingReward,\n _currentValidators,\n _delegatingRewards,\n address(this).balance\n );\n }\n }\n\n /**\n * @dev Transfer the deprecated rewards e.g. the rewards that get deprecated when validator is slashed/maintained,\n * to the staking vesting contract\n *\n * Note: This method should be called once in the end of each period.\n */\n function _recycleDeprecatedRewards() private {\n uint256 _withdrawAmount = _totalDeprecatedReward;\n\n if (_withdrawAmount != 0) {\n address _withdrawTarget = getContract(ContractType.STAKING_VESTING);\n\n delete _totalDeprecatedReward;\n\n (bool _success, ) = _withdrawTarget.call{ value: _withdrawAmount }(\n abi.encodeWithSelector(IStakingVesting.receiveRON.selector)\n );\n\n if (_success) {\n emit DeprecatedRewardRecycled(_withdrawTarget, _withdrawAmount);\n } else {\n emit DeprecatedRewardRecycleFailed(_withdrawTarget, _withdrawAmount, address(this).balance);\n }\n }\n }\n\n /**\n * @dev Updates the validator set based on the validator candidates from the Staking contract.\n *\n * Emits the `ValidatorSetUpdated` event.\n *\n * Note: This method should be called once in the end of each period.\n *\n */\n function _syncValidatorSet(\n uint256 _newPeriod\n ) private returns (address[] memory _newValidators, address[] memory _unsastifiedCandidates) {\n _unsastifiedCandidates = _syncCandidateSet(_newPeriod);\n uint256[] memory _weights = IStaking(getContract(ContractType.STAKING)).getManyStakingTotals(_candidates);\n uint256[] memory _trustedWeights = IRoninTrustedOrganization(getContract(ContractType.RONIN_TRUSTED_ORGANIZATION))\n .getConsensusWeights(_candidates);\n uint256 _newValidatorCount;\n (_newValidators, _newValidatorCount) = _pcPickValidatorSet(\n _candidates,\n _weights,\n _trustedWeights,\n _maxValidatorNumber,\n _maxPrioritizedValidatorNumber\n );\n _setNewValidatorSet(_newValidators, _newValidatorCount, _newPeriod);\n }\n\n /**\n * @dev Private helper function helps writing the new validator set into the contract storage.\n *\n * Emits the `ValidatorSetUpdated` event.\n *\n * Note: This method should be called once in the end of each period.\n *\n */\n function _setNewValidatorSet(\n address[] memory _newValidators,\n uint256 _newValidatorCount,\n uint256 _newPeriod\n ) private {\n // Remove exceeding validators in the current set\n for (uint256 _i = _newValidatorCount; _i < validatorCount; ) {\n delete _validatorMap[_validators[_i]];\n delete _validators[_i];\n\n unchecked {\n ++_i;\n }\n }\n\n // Remove flag for all validator in the current set\n for (uint _i; _i < _newValidatorCount; ) {\n delete _validatorMap[_validators[_i]];\n\n unchecked {\n ++_i;\n }\n }\n\n // Update new validator set and set flag correspondingly.\n for (uint256 _i; _i < _newValidatorCount; ) {\n address _newValidator = _newValidators[_i];\n _validatorMap[_newValidator] = EnumFlags.ValidatorFlag.Both;\n _validators[_i] = _newValidator;\n\n unchecked {\n ++_i;\n }\n }\n\n validatorCount = _newValidatorCount;\n emit ValidatorSetUpdated(_newPeriod, _newValidators);\n }\n\n /**\n * @dev Activate/Deactivate the validators from producing blocks, based on their in jail status and maintenance status.\n *\n * Requirements:\n * - This method is called at the end of each epoch\n *\n * Emits the `BlockProducerSetUpdated` event.\n * Emits the `BridgeOperatorSetUpdated` event.\n *\n */\n function _revampRoles(uint256 _newPeriod, uint256 _nextEpoch, address[] memory _currentValidators) private {\n bool[] memory _maintainedList = IMaintenance(getContract(ContractType.MAINTENANCE)).checkManyMaintained(\n _currentValidators,\n block.number + 1\n );\n\n for (uint _i; _i < _currentValidators.length; ) {\n address _validator = _currentValidators[_i];\n bool _emergencyExitRequested = block.timestamp <= _emergencyExitJailedTimestamp[_validator];\n bool _isProducerBefore = isBlockProducer(_validator);\n bool _isProducerAfter = !(_jailedAtBlock(_validator, block.number + 1) ||\n _maintainedList[_i] ||\n _emergencyExitRequested);\n\n if (!_isProducerBefore && _isProducerAfter) {\n _validatorMap[_validator] = _validatorMap[_validator].addFlag(EnumFlags.ValidatorFlag.BlockProducer);\n } else if (_isProducerBefore && !_isProducerAfter) {\n _validatorMap[_validator] = _validatorMap[_validator].removeFlag(EnumFlags.ValidatorFlag.BlockProducer);\n }\n\n unchecked {\n ++_i;\n }\n }\n emit BlockProducerSetUpdated(_newPeriod, _nextEpoch, getBlockProducers());\n }\n\n /**\n * @dev Override `CandidateManager-_isTrustedOrg`.\n */\n function _isTrustedOrg(address _consensusAddr) internal view override returns (bool) {\n return\n IRoninTrustedOrganization(getContract(ContractType.RONIN_TRUSTED_ORGANIZATION)).getConsensusWeight(\n _consensusAddr\n ) > 0;\n }\n}\n" + }, + "contracts/ronin/validator/EmergencyExit.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../extensions/RONTransferHelper.sol\";\nimport \"../../interfaces/IRoninGovernanceAdmin.sol\";\nimport \"../../interfaces/validator/IEmergencyExit.sol\";\nimport \"./storage-fragments/CommonStorage.sol\";\nimport \"./CandidateManager.sol\";\n\nabstract contract EmergencyExit is IEmergencyExit, RONTransferHelper, CandidateManager, CommonStorage {\n /**\n * @inheritdoc IEmergencyExit\n */\n function emergencyExitLockedAmount() external view returns (uint256) {\n return _emergencyExitLockedAmount;\n }\n\n /**\n * @inheritdoc IEmergencyExit\n */\n function emergencyExpiryDuration() external view returns (uint256) {\n return _emergencyExpiryDuration;\n }\n\n /**\n * @inheritdoc IEmergencyExit\n */\n function execEmergencyExit(\n address _consensusAddr,\n uint256 _secLeftToRevoke\n ) external onlyContract(ContractType.STAKING) {\n EmergencyExitInfo storage _info = _exitInfo[_consensusAddr];\n if (_info.recyclingAt != 0) revert ErrAlreadyRequestedEmergencyExit();\n\n uint256 _revokingTimestamp = block.timestamp + _secLeftToRevoke;\n _setRevokingTimestamp(_candidateInfo[_consensusAddr], _revokingTimestamp);\n _emergencyExitJailedTimestamp[_consensusAddr] = _revokingTimestamp;\n\n uint256 _deductedAmount = IStaking(msg.sender).execDeductStakingAmount(_consensusAddr, _emergencyExitLockedAmount);\n if (_deductedAmount > 0) {\n uint256 _recyclingAt = block.timestamp + _emergencyExpiryDuration;\n _lockedConsensusList.push(_consensusAddr);\n _info.lockedAmount = _deductedAmount;\n _info.recyclingAt = _recyclingAt;\n IRoninGovernanceAdmin(_getAdmin()).createEmergencyExitPoll(\n _consensusAddr,\n _candidateInfo[_consensusAddr].treasuryAddr,\n block.timestamp,\n _recyclingAt\n );\n }\n emit EmergencyExitRequested(_consensusAddr, _deductedAmount);\n }\n\n /**\n * @inheritdoc IEmergencyExit\n */\n function setEmergencyExitLockedAmount(uint256 _emergencyExitLockedAmount) external onlyAdmin {\n _setEmergencyExitLockedAmount(_emergencyExitLockedAmount);\n }\n\n /**\n * @inheritdoc IEmergencyExit\n */\n function setEmergencyExpiryDuration(uint256 _emergencyExpiryDuration) external onlyAdmin {\n _setEmergencyExpiryDuration(_emergencyExpiryDuration);\n }\n\n /**\n * @inheritdoc IEmergencyExit\n */\n function execReleaseLockedFundForEmergencyExitRequest(\n address _consensusAddr,\n address payable _recipient\n ) external onlyAdmin {\n if (_exitInfo[_consensusAddr].recyclingAt == 0) {\n return;\n }\n\n uint256 _length = _lockedConsensusList.length;\n uint256 _index = _length;\n\n for (uint _i; _i < _length; ) {\n if (_lockedConsensusList[_i] == _consensusAddr) {\n _index = _i;\n break;\n }\n\n unchecked {\n ++_i;\n }\n }\n\n // The locked amount might be recycled\n if (_index == _length) {\n return;\n }\n\n uint256 _amount = _exitInfo[_consensusAddr].lockedAmount;\n if (_amount > 0) {\n delete _exitInfo[_consensusAddr];\n if (_length > 1) {\n _lockedConsensusList[_index] = _lockedConsensusList[_length - 1];\n }\n _lockedConsensusList.pop();\n\n _lockedFundReleased[_consensusAddr] = true;\n if (_unsafeSendRONLimitGas(_recipient, _amount, DEFAULT_ADDITION_GAS)) {\n emit EmergencyExitLockedFundReleased(_consensusAddr, _recipient, _amount);\n return;\n }\n\n emit EmergencyExitLockedFundReleasingFailed(_consensusAddr, _recipient, _amount, address(this).balance);\n }\n }\n\n /**\n * @dev Tries to recycle the locked funds from emergency exit requests.\n */\n function _tryRecycleLockedFundsFromEmergencyExits() internal {\n uint256 _length = _lockedConsensusList.length;\n\n uint256 _i;\n address _addr;\n EmergencyExitInfo storage _info;\n\n while (_i < _length) {\n _addr = _lockedConsensusList[_i];\n _info = _exitInfo[_addr];\n\n if (_info.recyclingAt <= block.timestamp) {\n _totalDeprecatedReward += _info.lockedAmount;\n\n delete _exitInfo[_addr];\n if (--_length > 0) {\n _lockedConsensusList[_i] = _lockedConsensusList[_length];\n }\n _lockedConsensusList.pop();\n continue;\n }\n\n unchecked {\n _i++;\n }\n }\n }\n\n /**\n * @dev Override `CandidateManager-_emergencyExitLockedFundReleased`.\n */\n function _emergencyExitLockedFundReleased(address _consensusAddr) internal virtual override returns (bool) {\n return _lockedFundReleased[_consensusAddr];\n }\n\n /**\n * @dev Override `CandidateManager-_removeCandidate`.\n */\n function _removeCandidate(address _consensusAddr) internal override {\n delete _lockedFundReleased[_consensusAddr];\n super._removeCandidate(_consensusAddr);\n }\n\n /**\n * @dev See `setEmergencyExitLockedAmount.\n */\n function _setEmergencyExitLockedAmount(uint256 _amount) internal {\n _emergencyExitLockedAmount = _amount;\n emit EmergencyExitLockedAmountUpdated(_amount);\n }\n\n /**\n * @dev See `setEmergencyExpiryDuration`.\n */\n function _setEmergencyExpiryDuration(uint256 _duration) internal {\n _emergencyExpiryDuration = _duration;\n emit EmergencyExpiryDurationUpdated(_duration);\n }\n}\n" + }, + "contracts/ronin/validator/RoninValidatorSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport \"../../interfaces/validator/IRoninValidatorSet.sol\";\nimport \"./CoinbaseExecution.sol\";\nimport \"./SlashingExecution.sol\";\n\ncontract RoninValidatorSet is Initializable, CoinbaseExecution, SlashingExecution {\n constructor() {\n _disableInitializers();\n }\n\n fallback() external payable {\n _fallback();\n }\n\n receive() external payable {\n _fallback();\n }\n\n /**\n * @dev Initializes the contract storage.\n */\n function initialize(\n address __slashIndicatorContract,\n address __stakingContract,\n address __stakingVestingContract,\n address __maintenanceContract,\n address __roninTrustedOrganizationContract,\n address /* __bridgeTrackingContract */,\n uint256 __maxValidatorNumber,\n uint256 __maxValidatorCandidate,\n uint256 __maxPrioritizedValidatorNumber,\n uint256 __minEffectiveDaysOnwards,\n uint256 __numberOfBlocksInEpoch,\n // __emergencyExitConfigs[0]: emergencyExitLockedAmount\n // __emergencyExitConfigs[1]: emergencyExpiryDuration\n uint256[2] calldata __emergencyExitConfigs\n ) external initializer {\n _setContract(ContractType.SLASH_INDICATOR, __slashIndicatorContract);\n _setContract(ContractType.STAKING, __stakingContract);\n _setContract(ContractType.STAKING_VESTING, __stakingVestingContract);\n _setContract(ContractType.MAINTENANCE, __maintenanceContract);\n _setContract(ContractType.RONIN_TRUSTED_ORGANIZATION, __roninTrustedOrganizationContract);\n\n _setMaxValidatorNumber(__maxValidatorNumber);\n _setMaxValidatorCandidate(__maxValidatorCandidate);\n _setMaxPrioritizedValidatorNumber(__maxPrioritizedValidatorNumber);\n _setMinEffectiveDaysOnwards(__minEffectiveDaysOnwards);\n _setEmergencyExitLockedAmount(__emergencyExitConfigs[0]);\n _setEmergencyExpiryDuration(__emergencyExitConfigs[1]);\n _numberOfBlocksInEpoch = __numberOfBlocksInEpoch;\n }\n\n function initializeV2() external reinitializer(2) {\n _setContract(ContractType.STAKING, ______deprecatedStakingContract);\n _setContract(ContractType.MAINTENANCE, ______deprecatedMaintenance);\n _setContract(ContractType.SLASH_INDICATOR, ______deprecatedSlashIndicator);\n _setContract(ContractType.STAKING_VESTING, ______deprecatedStakingVesting);\n _setContract(ContractType.RONIN_TRUSTED_ORGANIZATION, ______deprecatedTrustedOrg);\n\n delete ______deprecatedStakingContract;\n delete ______deprecatedMaintenance;\n delete ______deprecatedSlashIndicator;\n delete ______deprecatedStakingVesting;\n delete ______deprecatedBridgeTracking;\n delete ______deprecatedTrustedOrg;\n }\n\n /**\n * @dev Only receives RON from staking vesting contract (for topping up bonus), and from staking contract (for transferring\n * deducting amount on slashing).\n */\n function _fallback() internal view {\n if (msg.sender != getContract(ContractType.STAKING_VESTING) && msg.sender != getContract(ContractType.STAKING)) {\n revert ErrUnauthorizedReceiveRON();\n }\n }\n}\n" + }, + "contracts/ronin/validator/SlashingExecution.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../extensions/collections/HasContracts.sol\";\nimport \"../../interfaces/validator/ISlashingExecution.sol\";\nimport \"../../interfaces/staking/IStaking.sol\";\nimport \"../../libraries/Math.sol\";\nimport { HasSlashIndicatorDeprecated, HasStakingDeprecated } from \"../../utils/DeprecatedSlots.sol\";\nimport \"./storage-fragments/CommonStorage.sol\";\n\nabstract contract SlashingExecution is\n ISlashingExecution,\n HasContracts,\n HasSlashIndicatorDeprecated,\n HasStakingDeprecated,\n CommonStorage\n{\n /**\n * @inheritdoc ISlashingExecution\n */\n function execSlash(\n address _validatorAddr,\n uint256 _newJailedUntil,\n uint256 _slashAmount,\n bool _cannotBailout\n ) external override onlyContract(ContractType.SLASH_INDICATOR) {\n uint256 _period = currentPeriod();\n _miningRewardDeprecatedAtPeriod[_validatorAddr][_period] = true;\n\n _totalDeprecatedReward += _miningReward[_validatorAddr] + _delegatingReward[_validatorAddr];\n\n delete _miningReward[_validatorAddr];\n delete _delegatingReward[_validatorAddr];\n\n _blockProducerJailedBlock[_validatorAddr] = Math.max(_newJailedUntil, _blockProducerJailedBlock[_validatorAddr]);\n\n if (_slashAmount > 0) {\n uint256 _actualAmount = IStaking(getContract(ContractType.STAKING)).execDeductStakingAmount(\n _validatorAddr,\n _slashAmount\n );\n _totalDeprecatedReward += _actualAmount;\n }\n\n if (_cannotBailout) {\n _cannotBailoutUntilBlock[_validatorAddr] = Math.max(_newJailedUntil, _cannotBailoutUntilBlock[_validatorAddr]);\n }\n\n emit ValidatorPunished(\n _validatorAddr,\n _period,\n _blockProducerJailedBlock[_validatorAddr],\n _slashAmount,\n true,\n false\n );\n }\n\n /**\n * @inheritdoc ISlashingExecution\n */\n function execBailOut(\n address _validatorAddr,\n uint256 _period\n ) external override onlyContract(ContractType.SLASH_INDICATOR) {\n if (block.number <= _cannotBailoutUntilBlock[_validatorAddr]) revert ErrCannotBailout(_validatorAddr);\n\n // Note: Removing rewards of validator in `bailOut` function is not needed, since the rewards have been\n // removed previously in the `slash` function.\n _miningRewardBailoutCutOffAtPeriod[_validatorAddr][_period] = true;\n _miningRewardDeprecatedAtPeriod[_validatorAddr][_period] = false;\n _blockProducerJailedBlock[_validatorAddr] = block.number - 1;\n\n emit ValidatorUnjailed(_validatorAddr, _period);\n }\n}\n" + }, + "contracts/ronin/validator/storage-fragments/CommonStorage.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../../interfaces/validator/info-fragments/ICommonInfo.sol\";\nimport \"./JailingStorage.sol\";\nimport \"./TimingStorage.sol\";\nimport \"./ValidatorInfoStorageV2.sol\";\n\nabstract contract CommonStorage is ICommonInfo, TimingStorage, JailingStorage, ValidatorInfoStorageV2 {\n /// @dev Mapping from consensus address => pending reward from producing block\n mapping(address => uint256) internal _miningReward;\n /// @dev Mapping from consensus address => pending reward from delegating\n mapping(address => uint256) internal _delegatingReward;\n\n /// @dev The total reward for bridge operators\n uint256 internal ______deprecatedTotalBridgeReward;\n /// @dev Mapping from consensus address => pending reward for being bridge operator\n mapping(address => uint256) internal ______deprecatedBridgeOperatingReward;\n\n /// @dev The deprecated reward that has not been withdrawn by admin\n uint256 internal _totalDeprecatedReward;\n\n /// @dev The amount of RON to lock from a consensus address.\n uint256 internal _emergencyExitLockedAmount;\n /// @dev The duration that an emergency request is expired and the fund will be recycled.\n uint256 internal _emergencyExpiryDuration;\n /// @dev The address list of consensus addresses that being locked fund.\n address[] internal _lockedConsensusList;\n /// @dev Mapping from consensus => request exist info\n mapping(address => EmergencyExitInfo) internal _exitInfo;\n /// @dev Mapping from consensus => flag indicating whether the locked fund is released\n mapping(address => bool) internal _lockedFundReleased;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[44] private ______gap;\n\n /**\n * @inheritdoc ICommonInfo\n */\n function getEmergencyExitInfo(\n address _consensusAddr\n ) external view override returns (EmergencyExitInfo memory _info) {\n _info = _exitInfo[_consensusAddr];\n if (_info.recyclingAt == 0) revert NonExistentRecyclingInfo();\n }\n\n /**\n * @inheritdoc ICommonInfo\n */\n function totalDeprecatedReward() external view override returns (uint256) {\n return _totalDeprecatedReward;\n }\n\n /**\n * @inheritdoc ITimingInfo\n */\n function epochOf(\n uint256 _block\n ) public view virtual override(ITimingInfo, JailingStorage, TimingStorage) returns (uint256) {\n return TimingStorage.epochOf(_block);\n }\n\n /**\n * @inheritdoc ITimingInfo\n */\n function currentPeriod() public view virtual override(ITimingInfo, JailingStorage, TimingStorage) returns (uint256) {\n return TimingStorage.currentPeriod();\n }\n}\n" + }, + "contracts/ronin/validator/storage-fragments/JailingStorage.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../../interfaces/validator/info-fragments/IJailingInfo.sol\";\nimport \"./TimingStorage.sol\";\n\nabstract contract JailingStorage is IJailingInfo {\n /// @dev Mapping from consensus address => period number => block producer has no pending reward.\n mapping(address => mapping(uint256 => bool)) internal _miningRewardDeprecatedAtPeriod;\n /// @dev Mapping from consensus address => period number => whether the block producer get cut off reward, due to bailout.\n mapping(address => mapping(uint256 => bool)) internal _miningRewardBailoutCutOffAtPeriod;\n /// @dev Mapping from consensus address => period number => block operator has no pending reward.\n mapping(address => mapping(uint256 => bool)) internal ______deprecatedBridgeRewardDeprecatedAtPeriod;\n\n /// @dev Mapping from consensus address => the last block that the block producer is jailed.\n mapping(address => uint256) internal _blockProducerJailedBlock;\n /// @dev Mapping from consensus address => the last timestamp that the bridge operator is jailed.\n mapping(address => uint256) internal _emergencyExitJailedTimestamp;\n /// @dev Mapping from consensus address => the last block that the block producer cannot bailout.\n mapping(address => uint256) internal _cannotBailoutUntilBlock;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[48] private ______gap;\n\n /**\n * @inheritdoc IJailingInfo\n */\n function checkJailed(address _addr) external view override returns (bool) {\n return checkJailedAtBlock(_addr, block.number);\n }\n\n /**\n * @inheritdoc IJailingInfo\n */\n function getJailedTimeLeft(\n address _addr\n ) external view override returns (bool isJailed_, uint256 blockLeft_, uint256 epochLeft_) {\n return getJailedTimeLeftAtBlock(_addr, block.number);\n }\n\n /**\n * @inheritdoc IJailingInfo\n */\n function checkJailedAtBlock(address _addr, uint256 _blockNum) public view override returns (bool) {\n return _jailedAtBlock(_addr, _blockNum);\n }\n\n /**\n * @inheritdoc IJailingInfo\n */\n function getJailedTimeLeftAtBlock(\n address _addr,\n uint256 _blockNum\n ) public view override returns (bool isJailed_, uint256 blockLeft_, uint256 epochLeft_) {\n uint256 _jailedBlock = _blockProducerJailedBlock[_addr];\n if (_jailedBlock < _blockNum) {\n return (false, 0, 0);\n }\n\n isJailed_ = true;\n blockLeft_ = _jailedBlock - _blockNum + 1;\n epochLeft_ = epochOf(_jailedBlock) - epochOf(_blockNum) + 1;\n }\n\n /**\n * @inheritdoc IJailingInfo\n */\n function checkManyJailed(address[] calldata _addrList) external view override returns (bool[] memory _result) {\n _result = new bool[](_addrList.length);\n for (uint256 _i; _i < _addrList.length; ) {\n _result[_i] = _jailed(_addrList[_i]);\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IJailingInfo\n */\n function checkMiningRewardDeprecated(address _blockProducer) external view override returns (bool _result) {\n uint256 _period = currentPeriod();\n return _miningRewardDeprecated(_blockProducer, _period);\n }\n\n /**\n * @inheritdoc IJailingInfo\n */\n function checkMiningRewardDeprecatedAtPeriod(\n address _blockProducer,\n uint256 _period\n ) external view override returns (bool _result) {\n return _miningRewardDeprecated(_blockProducer, _period);\n }\n\n /**\n * @dev See `ITimingInfo-epochOf`\n */\n function epochOf(uint256 _block) public view virtual returns (uint256);\n\n /**\n * @dev See `ITimingInfo-currentPeriod`\n */\n function currentPeriod() public view virtual returns (uint256);\n\n /**\n * @dev Returns whether the reward of the validator is put in jail (cannot join the set of validators) during the current period.\n */\n function _jailed(address _validatorAddr) internal view returns (bool) {\n return _jailedAtBlock(_validatorAddr, block.number);\n }\n\n /**\n * @dev Returns whether the reward of the validator is put in jail (cannot join the set of validators) at a specific block.\n */\n function _jailedAtBlock(address _validatorAddr, uint256 _blockNum) internal view returns (bool) {\n return _blockNum <= _blockProducerJailedBlock[_validatorAddr];\n }\n\n /**\n * @dev Returns whether the block producer has no pending reward in that period.\n */\n function _miningRewardDeprecated(address _validatorAddr, uint256 _period) internal view returns (bool) {\n return _miningRewardDeprecatedAtPeriod[_validatorAddr][_period];\n }\n}\n" + }, + "contracts/ronin/validator/storage-fragments/TimingStorage.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../../extensions/consumers/GlobalConfigConsumer.sol\";\nimport \"../../../interfaces/validator/info-fragments/ITimingInfo.sol\";\n\nabstract contract TimingStorage is ITimingInfo, GlobalConfigConsumer {\n /// @dev The number of blocks in a epoch\n uint256 internal _numberOfBlocksInEpoch;\n /// @dev The last updated block\n uint256 internal _lastUpdatedBlock;\n /// @dev The last updated period\n uint256 internal _lastUpdatedPeriod;\n /// @dev The starting block of the last updated period\n uint256 internal _currentPeriodStartAtBlock;\n\n /// @dev Mapping from epoch index => period index\n mapping(uint256 => uint256) internal _periodOf;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[49] private ______gap;\n\n /**\n * @inheritdoc ITimingInfo\n */\n function getLastUpdatedBlock() external view override returns (uint256) {\n return _lastUpdatedBlock;\n }\n\n /**\n * @inheritdoc ITimingInfo\n */\n function epochOf(uint256 _block) public view virtual override returns (uint256) {\n return _block / _numberOfBlocksInEpoch + 1;\n }\n\n /**\n * @inheritdoc ITimingInfo\n */\n function tryGetPeriodOfEpoch(uint256 _epoch) external view returns (bool _filled, uint256 _periodNumber) {\n return (_epoch <= epochOf(block.number) || _periodOf[_epoch] > 0, _periodOf[_epoch]);\n }\n\n /**\n * @inheritdoc ITimingInfo\n */\n function isPeriodEnding() external view override returns (bool) {\n return _isPeriodEnding(_computePeriod(block.timestamp));\n }\n\n /**\n * @inheritdoc ITimingInfo\n */\n function epochEndingAt(uint256 _block) public view virtual override returns (bool) {\n return _block % _numberOfBlocksInEpoch == _numberOfBlocksInEpoch - 1;\n }\n\n /**\n * @inheritdoc ITimingInfo\n */\n function currentPeriod() public view virtual override returns (uint256) {\n return _lastUpdatedPeriod;\n }\n\n /**\n * @inheritdoc ITimingInfo\n */\n function currentPeriodStartAtBlock() public view override returns (uint256) {\n return _currentPeriodStartAtBlock;\n }\n\n /**\n * @inheritdoc ITimingInfo\n */\n function numberOfBlocksInEpoch() public view virtual override returns (uint256 _numberOfBlocks) {\n return _numberOfBlocksInEpoch;\n }\n\n /**\n * @dev See `ITimingInfo-isPeriodEnding`\n */\n function _isPeriodEnding(uint256 _newPeriod) internal view virtual returns (bool) {\n return _newPeriod > _lastUpdatedPeriod;\n }\n\n /**\n * @dev Returns the calculated period.\n */\n function _computePeriod(uint256 _timestamp) internal pure returns (uint256) {\n return _timestamp / PERIOD_DURATION;\n }\n}\n" + }, + "contracts/ronin/validator/storage-fragments/ValidatorInfoStorageV2.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../../../libraries/EnumFlags.sol\";\nimport { HasTrustedOrgDeprecated } from \"../../../utils/DeprecatedSlots.sol\";\nimport \"../../../extensions/collections/HasContracts.sol\";\nimport \"../../../interfaces/validator/info-fragments/IValidatorInfoV2.sol\";\n\nabstract contract ValidatorInfoStorageV2 is IValidatorInfoV2, HasContracts, HasTrustedOrgDeprecated {\n using EnumFlags for EnumFlags.ValidatorFlag;\n\n /// @dev The maximum number of validator.\n uint256 internal _maxValidatorNumber;\n\n /// @dev The total of validators\n uint256 public validatorCount;\n /// @dev Mapping from validator index => validator address\n mapping(uint256 => address) internal _validators;\n /// @dev Mapping from address => flag indicating the validator ability: producing block, operating bridge\n mapping(address => EnumFlags.ValidatorFlag) internal _validatorMap;\n /// @dev The number of slot that is reserved for prioritized validators\n uint256 internal _maxPrioritizedValidatorNumber;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[50] private ______gap;\n\n /**\n * @inheritdoc IValidatorInfoV2\n */\n function getValidators() public view override returns (address[] memory _validatorList) {\n _validatorList = new address[](validatorCount);\n for (uint _i; _i < _validatorList.length; ) {\n address _validator = _validators[_i];\n _validatorList[_i] = _validator;\n\n unchecked {\n ++_i;\n }\n }\n }\n\n /**\n * @inheritdoc IValidatorInfoV2\n */\n function getBlockProducers() public view override returns (address[] memory _result) {\n _result = new address[](validatorCount);\n uint256 _count = 0;\n for (uint _i; _i < _result.length; ) {\n if (isBlockProducer(_validators[_i])) {\n _result[_count++] = _validators[_i];\n }\n\n unchecked {\n ++_i;\n }\n }\n\n assembly {\n mstore(_result, _count)\n }\n }\n\n /**\n * @inheritdoc IValidatorInfoV2\n */\n function isBlockProducer(address _addr) public view override returns (bool) {\n return _validatorMap[_addr].hasFlag(EnumFlags.ValidatorFlag.BlockProducer);\n }\n\n /**\n * @inheritdoc IValidatorInfoV2\n */\n function totalBlockProducers() external view returns (uint256 _total) {\n unchecked {\n for (uint _i; _i < validatorCount; _i++) {\n if (isBlockProducer(_validators[_i])) {\n _total++;\n }\n }\n }\n }\n\n /**\n * @inheritdoc IValidatorInfoV2\n */\n function maxValidatorNumber() external view override returns (uint256 _maximumValidatorNumber) {\n return _maxValidatorNumber;\n }\n\n /**\n * @inheritdoc IValidatorInfoV2\n */\n function maxPrioritizedValidatorNumber() external view override returns (uint256 _maximumPrioritizedValidatorNumber) {\n return _maxPrioritizedValidatorNumber;\n }\n\n /**\n * @inheritdoc IValidatorInfoV2\n */\n function setMaxValidatorNumber(uint256 _max) external override onlyAdmin {\n _setMaxValidatorNumber(_max);\n }\n\n /**\n * @inheritdoc IValidatorInfoV2\n */\n function setMaxPrioritizedValidatorNumber(uint256 _number) external override onlyAdmin {\n _setMaxPrioritizedValidatorNumber(_number);\n }\n\n /**\n * @dev See `IValidatorInfoV2-setMaxValidatorNumber`\n */\n function _setMaxValidatorNumber(uint256 _number) internal {\n _maxValidatorNumber = _number;\n emit MaxValidatorNumberUpdated(_number);\n }\n\n /**\n * @dev See `IValidatorInfoV2-setMaxPrioritizedValidatorNumber`\n */\n function _setMaxPrioritizedValidatorNumber(uint256 _number) internal {\n if (_number > _maxValidatorNumber) revert ErrInvalidMaxPrioritizedValidatorNumber();\n _maxPrioritizedValidatorNumber = _number;\n emit MaxPrioritizedValidatorNumberUpdated(_number);\n }\n}\n" + }, + "contracts/utils/CommonErrors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { ContractType } from \"./ContractType.sol\";\nimport { RoleAccess } from \"./RoleAccess.sol\";\n\nerror ErrSyncTooFarPeriod(uint256 period, uint256 latestRewardedPeriod);\n/**\n * @dev Error thrown when an address is expected to be an already created externally owned account (EOA).\n * This error indicates that the provided address is invalid for certain contract operations that require already created EOA.\n */\nerror ErrAddressIsNotCreatedEOA(address addr, bytes32 codehash);\n/**\n * @dev Error raised when a bridge operator update operation fails.\n * @param bridgeOperator The address of the bridge operator that failed to update.\n */\nerror ErrBridgeOperatorUpdateFailed(address bridgeOperator);\n/**\n * @dev Error thrown when attempting to add a bridge operator that already exists in the contract.\n * This error indicates that the provided bridge operator address is already registered as a bridge operator in the contract.\n */\nerror ErrBridgeOperatorAlreadyExisted(address bridgeOperator);\n/**\n * @dev The error indicating an unsupported interface.\n * @param interfaceId The bytes4 interface identifier that is not supported.\n * @param addr The address where the unsupported interface was encountered.\n */\nerror ErrUnsupportedInterface(bytes4 interfaceId, address addr);\n/**\n * @dev Error thrown when the return data from a callback function is invalid.\n * @param callbackFnSig The signature of the callback function that returned invalid data.\n * @param register The address of the register where the callback function was invoked.\n * @param returnData The invalid return data received from the callback function.\n */\nerror ErrInvalidReturnData(bytes4 callbackFnSig, address register, bytes returnData);\n/**\n * @dev Error of set to non-contract.\n */\nerror ErrZeroCodeContract(address addr);\n/**\n * @dev Error indicating that arguments are invalid.\n */\nerror ErrInvalidArguments(bytes4 msgSig);\n/**\n * @dev Error indicating that given address is null when it should not.\n */\nerror ErrZeroAddress(bytes4 msgSig);\n/**\n * @dev Error indicating that the provided threshold is invalid for a specific function signature.\n * @param msgSig The function signature (bytes4) that the invalid threshold applies to.\n */\nerror ErrInvalidThreshold(bytes4 msgSig);\n\n/**\n * @dev Error indicating that a function can only be called by the contract itself.\n * @param msgSig The function signature (bytes4) that can only be called by the contract itself.\n */\nerror ErrOnlySelfCall(bytes4 msgSig);\n\n/**\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\n * @param msgSig The function signature (bytes4) that the caller is unauthorized to perform.\n * @param expectedRole The role required to perform the function.\n */\nerror ErrUnauthorized(bytes4 msgSig, RoleAccess expectedRole);\n\n/**\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\n * @param msgSig The function signature (bytes4) that the caller is unauthorized to perform.\n */\nerror ErrUnauthorizedCall(bytes4 msgSig);\n\n/**\n * @dev Error indicating that the caller is unauthorized to perform a specific function.\n * @param msgSig The function signature (bytes4).\n * @param expectedContractType The contract type required to perform the function.\n * @param actual The actual address that called to the function.\n */\nerror ErrUnexpectedInternalCall(bytes4 msgSig, ContractType expectedContractType, address actual);\n\n/**\n * @dev Error indicating that an array is empty when it should contain elements.\n */\nerror ErrEmptyArray();\n\n/**\n * @dev Error indicating a mismatch in the length of input parameters or arrays for a specific function.\n * @param msgSig The function signature (bytes4) that has a length mismatch.\n */\nerror ErrLengthMismatch(bytes4 msgSig);\n\n/**\n * @dev Error indicating that a proxy call to an external contract has failed.\n * @param msgSig The function signature (bytes4) of the proxy call that failed.\n * @param extCallSig The function signature (bytes4) of the external contract call that failed.\n */\nerror ErrProxyCallFailed(bytes4 msgSig, bytes4 extCallSig);\n\n/**\n * @dev Error indicating that a function tried to call a precompiled contract that is not allowed.\n * @param msgSig The function signature (bytes4) that attempted to call a precompiled contract.\n */\nerror ErrCallPrecompiled(bytes4 msgSig);\n\n/**\n * @dev Error indicating that a native token transfer has failed.\n * @param msgSig The function signature (bytes4) of the token transfer that failed.\n */\nerror ErrNativeTransferFailed(bytes4 msgSig);\n\n/**\n * @dev Error indicating that an order is invalid.\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid order.\n */\nerror ErrInvalidOrder(bytes4 msgSig);\n\n/**\n * @dev Error indicating that the chain ID is invalid.\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid chain ID.\n * @param actual Current chain ID that executing function.\n * @param expected Expected chain ID required for the tx to success.\n */\nerror ErrInvalidChainId(bytes4 msgSig, uint256 actual, uint256 expected);\n\n/**\n * @dev Error indicating that a vote type is not supported.\n * @param msgSig The function signature (bytes4) of the operation that encountered an unsupported vote type.\n */\nerror ErrUnsupportedVoteType(bytes4 msgSig);\n\n/**\n * @dev Error indicating that the proposal nonce is invalid.\n * @param msgSig The function signature (bytes4) of the operation that encountered an invalid proposal nonce.\n */\nerror ErrInvalidProposalNonce(bytes4 msgSig);\n\n/**\n * @dev Error indicating that a voter has already voted.\n * @param voter The address of the voter who has already voted.\n */\nerror ErrAlreadyVoted(address voter);\n\n/**\n * @dev Error indicating that a signature is invalid for a specific function signature.\n * @param msgSig The function signature (bytes4) that encountered an invalid signature.\n */\nerror ErrInvalidSignatures(bytes4 msgSig);\n\n/**\n * @dev Error indicating that a relay call has failed.\n * @param msgSig The function signature (bytes4) of the relay call that failed.\n */\nerror ErrRelayFailed(bytes4 msgSig);\n/**\n * @dev Error indicating that a vote weight is invalid for a specific function signature.\n * @param msgSig The function signature (bytes4) that encountered an invalid vote weight.\n */\nerror ErrInvalidVoteWeight(bytes4 msgSig);\n\n/**\n * @dev Error indicating that a query was made for an outdated bridge operator set.\n */\nerror ErrQueryForOutdatedBridgeOperatorSet();\n\n/**\n * @dev Error indicating that a request is invalid.\n */\nerror ErrInvalidRequest();\n\n/**\n * @dev Error indicating that a token standard is invalid.\n */\nerror ErrInvalidTokenStandard();\n\n/**\n * @dev Error indicating that a token is not supported.\n */\nerror ErrUnsupportedToken();\n\n/**\n * @dev Error indicating that a receipt kind is invalid.\n */\nerror ErrInvalidReceiptKind();\n\n/**\n * @dev Error indicating that a receipt is invalid.\n */\nerror ErrInvalidReceipt();\n\n/**\n * @dev Error indicating that an address is not payable.\n */\nerror ErrNonpayableAddress(address);\n\n/**\n * @dev Error indicating that the period is already processed, i.e. scattered reward.\n */\nerror ErrPeriodAlreadyProcessed(uint256 requestingPeriod, uint256 latestPeriod);\n\n/**\n * @dev Error thrown when an invalid vote hash is provided.\n */\nerror ErrInvalidVoteHash();\n\n/**\n * @dev Error thrown when querying for an empty vote.\n */\nerror ErrQueryForEmptyVote();\n\n/**\n * @dev Error thrown when querying for an expired vote.\n */\nerror ErrQueryForExpiredVote();\n\n/**\n * @dev Error thrown when querying for a non-existent vote.\n */\nerror ErrQueryForNonExistentVote();\n" + }, + "contracts/utils/ContractType.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nenum ContractType {\n /* 0 */ UNKNOWN,\n /* 1 */ PAUSE_ENFORCER,\n /* 2 */ BRIDGE,\n /* 3 */ BRIDGE_TRACKING,\n /* 4 */ GOVERNANCE_ADMIN,\n /* 5 */ MAINTENANCE,\n /* 6 */ SLASH_INDICATOR,\n /* 7 */ STAKING_VESTING,\n /* 8 */ VALIDATOR,\n /* 9 */ STAKING,\n /* 10 */ RONIN_TRUSTED_ORGANIZATION,\n /* 11 */ BRIDGE_MANAGER,\n /* 12 */ BRIDGE_SLASH,\n /* 13 */ BRIDGE_REWARD\n}\n" + }, + "contracts/utils/DeprecatedSlots.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n * @title Deprecated Contracts\n * @dev These abstract contracts are deprecated and should not be used in new implementations.\n * They provide functionality related to various aspects of a smart contract but have been marked\n * as deprecated to indicate that they are no longer actively maintained or recommended for use.\n * The purpose of these contracts is to preserve the slots for already deployed contracts.\n */\ncontract HasSlashIndicatorDeprecated {\n /// @custom:deprecated Previously `_slashIndicatorContract` (non-zero value)\n address internal ______deprecatedSlashIndicator;\n}\n\ncontract HasStakingVestingDeprecated {\n /// @custom:deprecated Previously `_stakingVestingContract` (non-zero value)\n address internal ______deprecatedStakingVesting;\n}\n\ncontract HasBridgeDeprecated {\n /// @custom:deprecated Previously `_bridgeContract` (non-zero value)\n address internal ______deprecatedBridge;\n}\n\ncontract HasValidatorDeprecated {\n /// @custom:deprecated Previously `_validatorContract` (non-zero value)\n address internal ______deprecatedValidator;\n}\n\ncontract HasStakingDeprecated {\n /// @custom:deprecated Previously `_stakingContract` (non-zero value)\n address internal ______deprecatedStakingContract;\n}\n\ncontract HasMaintenanceDeprecated {\n /// @custom:deprecated Previously `_maintenanceContract` (non-zero value)\n address internal ______deprecatedMaintenance;\n}\n\ncontract HasTrustedOrgDeprecated {\n /// @custom:deprecated Previously `_trustedOrgContract` (non-zero value)\n address internal ______deprecatedTrustedOrg;\n}\n\ncontract HasGovernanceAdminDeprecated {\n /// @custom:deprecated Previously `_governanceAdminContract` (non-zero value)\n address internal ______deprecatedGovernanceAdmin;\n}\n\ncontract HasBridgeTrackingDeprecated {\n /// @custom:deprecated Previously `_bridgeTrackingContract` (non-zero value)\n address internal ______deprecatedBridgeTracking;\n}\n" + }, + "contracts/utils/IdentityGuard.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { AddressArrayUtils } from \"../libraries/AddressArrayUtils.sol\";\nimport { IERC165 } from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport { TransparentUpgradeableProxyV2 } from \"../extensions/TransparentUpgradeableProxyV2.sol\";\nimport { ErrAddressIsNotCreatedEOA, ErrZeroAddress, ErrOnlySelfCall, ErrZeroCodeContract, ErrUnsupportedInterface } from \"./CommonErrors.sol\";\n\nabstract contract IdentityGuard {\n using AddressArrayUtils for address[];\n\n /// @dev value is equal to keccak256(abi.encode())\n /// @dev see: https://eips.ethereum.org/EIPS/eip-1052\n bytes32 internal constant CREATED_ACCOUNT_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\n\n /**\n * @dev Modifier to restrict functions to only be called by this contract.\n * @dev Reverts if the caller is not this contract.\n */\n modifier onlySelfCall() virtual {\n _requireSelfCall();\n _;\n }\n\n /**\n * @dev Modifier to ensure that the elements in the `arr` array are non-duplicates.\n * It calls the internal `_checkDuplicate` function to perform the duplicate check.\n *\n * Requirements:\n * - The elements in the `arr` array must not contain any duplicates.\n */\n modifier nonDuplicate(address[] memory arr) virtual {\n _requireNonDuplicate(arr);\n _;\n }\n\n /**\n * @dev Internal method to check the method caller.\n * @dev Reverts if the method caller is not this contract.\n */\n function _requireSelfCall() internal view virtual {\n if (msg.sender != address(this)) revert ErrOnlySelfCall(msg.sig);\n }\n\n /**\n * @dev Internal function to check if a contract address has code.\n * @param addr The address of the contract to check.\n * @dev Throws an error if the contract address has no code.\n */\n function _requireHasCode(address addr) internal view {\n if (addr.code.length == 0) revert ErrZeroCodeContract(addr);\n }\n\n /**\n * @dev Checks if an address is zero and reverts if it is.\n * @param addr The address to check.\n */\n function _requireNonZeroAddress(address addr) internal pure {\n if (addr == address(0)) revert ErrZeroAddress(msg.sig);\n }\n\n /**\n * @dev Check if arr is empty and revert if it is.\n * Checks if an array contains any duplicate addresses and reverts if duplicates are found.\n * @param arr The array of addresses to check.\n */\n function _requireNonDuplicate(address[] memory arr) internal pure {\n if (arr.hasDuplicate()) revert AddressArrayUtils.ErrDuplicated(msg.sig);\n }\n\n /**\n * @dev Internal function to require that the provided address is a created externally owned account (EOA).\n * This internal function is used to ensure that the provided address is a valid externally owned account (EOA).\n * It checks the codehash of the address against a predefined constant to confirm that the address is a created EOA.\n * @notice This method only works with non-state EOA accounts\n */\n function _requireCreatedEOA(address addr) internal view {\n _requireNonZeroAddress(addr);\n bytes32 codehash = addr.codehash;\n if (codehash != CREATED_ACCOUNT_HASH) revert ErrAddressIsNotCreatedEOA(addr, codehash);\n }\n\n /**\n * @dev Internal function to require that the specified contract supports the given interface. This method handle in\n * both case that the callee is either or not the proxy admin of the caller. If the contract does not support the\n * interface `interfaceId` or EIP165, a revert with the corresponding error message is triggered.\n *\n * @param contractAddr The address of the contract to check for interface support.\n * @param interfaceId The interface ID to check for support.\n */\n function _requireSupportsInterface(address contractAddr, bytes4 interfaceId) internal view {\n bytes memory supportsInterfaceParams = abi.encodeCall(IERC165.supportsInterface, (interfaceId));\n (bool success, bytes memory returnOrRevertData) = contractAddr.staticcall(supportsInterfaceParams);\n if (!success) {\n (success, returnOrRevertData) = contractAddr.staticcall(\n abi.encodeCall(TransparentUpgradeableProxyV2.functionDelegateCall, (supportsInterfaceParams))\n );\n if (!success) revert ErrUnsupportedInterface(interfaceId, contractAddr);\n }\n if (!abi.decode(returnOrRevertData, (bool))) revert ErrUnsupportedInterface(interfaceId, contractAddr);\n }\n}\n" + }, + "contracts/utils/RoleAccess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nenum RoleAccess {\n /* 0 */ UNKNOWN,\n /* 1 */ ADMIN,\n /* 2 */ COINBASE,\n /* 3 */ GOVERNOR,\n /* 4 */ CANDIDATE_ADMIN,\n /* 5 */ WITHDRAWAL_MIGRATOR,\n /* 6 */ __DEPRECATED_BRIDGE_OPERATOR,\n /* 7 */ BLOCK_PRODUCER,\n /* 8 */ VALIDATOR_CANDIDATE\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 10 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata" + ], + "": [ + "ast" + ] + } + } + } +} \ No newline at end of file From 3ce71ccc4546943dc310e27d98d3f8edf57d206f Mon Sep 17 00:00:00 2001 From: nxqbao Date: Mon, 14 Aug 2023 13:36:07 +0700 Subject: [PATCH 3/5] add s7 script --- ...de-missing-dpos-contract-v0.6.1-testnet.ts | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/upgrades/REP-002/230814-s7-upgrade-missing-dpos-contract-v0.6.1-testnet.ts diff --git a/src/upgrades/REP-002/230814-s7-upgrade-missing-dpos-contract-v0.6.1-testnet.ts b/src/upgrades/REP-002/230814-s7-upgrade-missing-dpos-contract-v0.6.1-testnet.ts new file mode 100644 index 000000000..deb5b9c78 --- /dev/null +++ b/src/upgrades/REP-002/230814-s7-upgrade-missing-dpos-contract-v0.6.1-testnet.ts @@ -0,0 +1,75 @@ +import { HardhatRuntimeEnvironment } from 'hardhat/types'; +import { explorerUrl, proxyInterface } from '../upgradeUtils'; +import { VoteType } from '../../script/proposal'; +import { RoninTrustedOrganization__factory, RoninGatewayV2__factory } from '../../types'; +import { generalRoninConf, roninchainNetworks } from '../../configs/config'; +import { network } from 'hardhat'; + +const deploy = async ({ getNamedAccounts, deployments, ethers }: HardhatRuntimeEnvironment) => { + if (!roninchainNetworks.includes(network.name!)) { + return; + } + + const { execute } = deployments; + let { governor } = await getNamedAccounts(); // NOTE: Should double check the `governor` account in the `hardhat.config.ts` file + console.log('Governor:', governor); + + // Upgrade Ronin Trusted Org Contract + const RoninTrustedOrganizationProxy = await deployments.get('RoninTrustedOrganizationProxy'); + const RoninTrustedOrganizationLogic = await deployments.get('RoninTrustedOrganizationLogic'); + const RoninTrustedOrganizationInstr = [ + proxyInterface.encodeFunctionData('upgradeTo', [RoninTrustedOrganizationLogic.address]), + ]; + console.info('RoninTrustedOrganizationInstr', RoninTrustedOrganizationInstr); + + // Upgrade Slash Indicator Contract + const SlashIndicatorProxy = await deployments.get('SlashIndicatorProxy'); + const SlashIndicatorLogic = await deployments.get('SlashIndicatorLogic'); + const SlashIndicatorInstr = [proxyInterface.encodeFunctionData('upgradeTo', [SlashIndicatorLogic.address])]; + console.info('SlashIndicatorInstr', SlashIndicatorInstr); + + // Upgrade Staking Contract + const StakingProxy = await deployments.get('StakingProxy'); + const StakingLogic = await deployments.get('StakingLogic'); + const StakingInstr = [proxyInterface.encodeFunctionData('upgradeTo', [StakingLogic.address])]; + console.info('StakingInstr', StakingInstr); + + // Upgrade Ronin Validator Set Contract + const RoninValidatorSetProxy = await deployments.get('RoninValidatorSetProxy'); + const RoninValidatorSetLogic = await deployments.get('RoninValidatorSetLogic'); + const RoninValidatorSetInstr = [proxyInterface.encodeFunctionData('upgradeTo', [RoninValidatorSetLogic.address])]; + console.info('RoninValidatorSetInstr', RoninValidatorSetInstr); + + // Propose the proposal + const blockNumBefore = await ethers.provider.getBlockNumber(); + const blockBefore = await ethers.provider.getBlock(blockNumBefore); + const timestampBefore = blockBefore.timestamp; + const proposalExpiryTimestamp = timestampBefore + 3600 * 24 * 10; // expired in 10 days + + // NOTE: Should double check the RoninGovernanceAdmin address in `deployments` folder is 0x946397deDFd2f79b75a72B322944a21C3240c9c3 + const tx = await execute( + 'RoninGovernanceAdmin', + { from: governor, log: true }, + 'proposeProposalForCurrentNetwork', + proposalExpiryTimestamp, // expiryTimestamp + [ + ...RoninTrustedOrganizationInstr.map(() => RoninTrustedOrganizationProxy.address), + ...SlashIndicatorInstr.map(() => SlashIndicatorProxy.address), + ...StakingInstr.map(() => StakingProxy.address), + ...RoninValidatorSetInstr.map(() => RoninValidatorSetProxy.address), + ], // targets + [...RoninTrustedOrganizationInstr, ...SlashIndicatorInstr, ...StakingInstr, ...RoninValidatorSetInstr].map(() => 0), // values + [...RoninTrustedOrganizationInstr, ...SlashIndicatorInstr, ...StakingInstr, ...RoninValidatorSetInstr], // datas + [...RoninTrustedOrganizationInstr, ...SlashIndicatorInstr, ...StakingInstr, ...RoninValidatorSetInstr].map( + () => 1_000_000 + ), // gasAmounts + VoteType.For // ballot type + ); + + deployments.log(`${explorerUrl[network.name!]}/tx/${tx.transactionHash}`); +}; + +// yarn hardhat deploy --tags 230804_S7_UpgradeMissingDPoSContract_V0_6_1 --network ronin-testnet +deploy.tags = ['230804_S7_UpgradeMissingDPoSContract_V0_6_1']; + +export default deploy; From 4a46a45f3c0b5a08ef0c93d7fd3756779c83f396 Mon Sep 17 00:00:00 2001 From: nxqbao Date: Tue, 15 Aug 2023 13:57:07 +0700 Subject: [PATCH 4/5] add final executed script --- ...de-missing-dpos-contract-v0.6.1-testnet.ts | 4 +- ...de-missing-dpos-contract-v0.6.1-testnet.ts | 84 +++++++++++++++++++ src/upgrades/upgradeUtils.ts | 2 +- 3 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 src/upgrades/REP-002/230814-vote-s7-upgrade-missing-dpos-contract-v0.6.1-testnet.ts diff --git a/src/upgrades/REP-002/230814-s7-upgrade-missing-dpos-contract-v0.6.1-testnet.ts b/src/upgrades/REP-002/230814-s7-upgrade-missing-dpos-contract-v0.6.1-testnet.ts index deb5b9c78..45d4eaf06 100644 --- a/src/upgrades/REP-002/230814-s7-upgrade-missing-dpos-contract-v0.6.1-testnet.ts +++ b/src/upgrades/REP-002/230814-s7-upgrade-missing-dpos-contract-v0.6.1-testnet.ts @@ -69,7 +69,7 @@ const deploy = async ({ getNamedAccounts, deployments, ethers }: HardhatRuntimeE deployments.log(`${explorerUrl[network.name!]}/tx/${tx.transactionHash}`); }; -// yarn hardhat deploy --tags 230804_S7_UpgradeMissingDPoSContract_V0_6_1 --network ronin-testnet -deploy.tags = ['230804_S7_UpgradeMissingDPoSContract_V0_6_1']; +// yarn hardhat deploy --tags 230814_S7_UpgradeMissingDPoSContract_V0_6_1 --network ronin-testnet +deploy.tags = ['230814_S7_UpgradeMissingDPoSContract_V0_6_1']; export default deploy; diff --git a/src/upgrades/REP-002/230814-vote-s7-upgrade-missing-dpos-contract-v0.6.1-testnet.ts b/src/upgrades/REP-002/230814-vote-s7-upgrade-missing-dpos-contract-v0.6.1-testnet.ts new file mode 100644 index 000000000..986fce0ca --- /dev/null +++ b/src/upgrades/REP-002/230814-vote-s7-upgrade-missing-dpos-contract-v0.6.1-testnet.ts @@ -0,0 +1,84 @@ +import { HardhatRuntimeEnvironment } from 'hardhat/types'; +import { explorerUrl, proxyInterface } from '../upgradeUtils'; +import { VoteType } from '../../script/proposal'; +import { roninchainNetworks } from '../../configs/config'; +import { network } from 'hardhat'; + +const deploy = async ({ getNamedAccounts, deployments, ethers }: HardhatRuntimeEnvironment) => { + if (!roninchainNetworks.includes(network.name!)) { + return; + } + + const { execute } = deployments; + let { governor } = await getNamedAccounts(); // NOTE: Should double check the `governor` account in the `hardhat.config.ts` file + console.log('Governor:', governor); + + // Upgrade Ronin Trusted Org Contract + const RoninTrustedOrganizationProxy = await deployments.get('RoninTrustedOrganizationProxy'); + const RoninTrustedOrganizationLogic = await deployments.get('RoninTrustedOrganizationLogic'); + const RoninTrustedOrganizationInstr = [ + proxyInterface.encodeFunctionData('upgradeTo', [RoninTrustedOrganizationLogic.address]), + ]; + console.info('RoninTrustedOrganizationInstr', RoninTrustedOrganizationInstr); + + // Upgrade Slash Indicator Contract + const SlashIndicatorProxy = await deployments.get('SlashIndicatorProxy'); + const SlashIndicatorLogic = await deployments.get('SlashIndicatorLogic'); + const SlashIndicatorInstr = [proxyInterface.encodeFunctionData('upgradeTo', [SlashIndicatorLogic.address])]; + console.info('SlashIndicatorInstr', SlashIndicatorInstr); + + // Upgrade Staking Contract + const StakingProxy = await deployments.get('StakingProxy'); + const StakingLogic = await deployments.get('StakingLogic'); + const StakingInstr = [proxyInterface.encodeFunctionData('upgradeTo', [StakingLogic.address])]; + console.info('StakingInstr', StakingInstr); + + // Upgrade Ronin Validator Set Contract + const RoninValidatorSetProxy = await deployments.get('RoninValidatorSetProxy'); + const RoninValidatorSetLogic = await deployments.get('RoninValidatorSetLogic'); + const RoninValidatorSetInstr = [proxyInterface.encodeFunctionData('upgradeTo', [RoninValidatorSetLogic.address])]; + console.info('RoninValidatorSetInstr', RoninValidatorSetInstr); + + // Propose the proposal + + const proposalExpiryTimestamp = 0x64e848e9; + + const tx = await execute( + 'RoninGovernanceAdmin', + { from: governor, log: true }, + 'castProposalVoteForCurrentNetwork', + + // uint256 nonce; + // uint256 chainId; + // uint256 expiryTimestamp; + // address[] targets; + // uint256[] values; + // bytes[] calldatas; + // uint256[] gasAmounts; + [ + 0xe, + 2021, + proposalExpiryTimestamp, // expiryTimestamp + [ + ...RoninTrustedOrganizationInstr.map(() => RoninTrustedOrganizationProxy.address), + ...SlashIndicatorInstr.map(() => SlashIndicatorProxy.address), + ...StakingInstr.map(() => StakingProxy.address), + ...RoninValidatorSetInstr.map(() => RoninValidatorSetProxy.address), + ], // targets + [...RoninTrustedOrganizationInstr, ...SlashIndicatorInstr, ...StakingInstr, ...RoninValidatorSetInstr].map( + () => 0 + ), // values + [...RoninTrustedOrganizationInstr, ...SlashIndicatorInstr, ...StakingInstr, ...RoninValidatorSetInstr], // datas + [...RoninTrustedOrganizationInstr, ...SlashIndicatorInstr, ...StakingInstr, ...RoninValidatorSetInstr].map( + () => 1_000_000 + ), // gasAmounts + ], + VoteType.For // ballot type + ); + deployments.log(`${explorerUrl[network.name!]}/tx/${tx.transactionHash}`); +}; + +// yarn hardhat deploy --tags 230814_Vote_S7_UpgradeMissingDPoSContract_V0_6_1 --network ronin-testnet +deploy.tags = ['230814_Vote_S7_UpgradeMissingDPoSContract_V0_6_1']; + +export default deploy; diff --git a/src/upgrades/upgradeUtils.ts b/src/upgrades/upgradeUtils.ts index 24bb514d4..fdcc9087e 100644 --- a/src/upgrades/upgradeUtils.ts +++ b/src/upgrades/upgradeUtils.ts @@ -12,7 +12,7 @@ interface ExplorerURLs { export const explorerUrl: ExplorerURLs = { [Network.Hardhat]: undefined, - [Network.Goerli]: 'https://goerli.etherscan.io/', + [Network.Goerli]: 'https://goerli.etherscan.io', [Network.Testnet]: 'https://saigon-app.roninchain.com', [Network.Mainnet]: 'https://app.roninchain.com', }; From e1c4df3329131ea37fa39f90d9c870d8b4eac30f Mon Sep 17 00:00:00 2001 From: Bao Date: Tue, 15 Aug 2023 14:03:18 +0700 Subject: [PATCH 5/5] Update contracts/ronin/staking/Staking.sol Co-authored-by: Duc Tho Tran --- contracts/ronin/staking/Staking.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/ronin/staking/Staking.sol b/contracts/ronin/staking/Staking.sol index 539579f5a..1fe1ddcd6 100644 --- a/contracts/ronin/staking/Staking.sol +++ b/contracts/ronin/staking/Staking.sol @@ -42,7 +42,7 @@ contract Staking is IStaking, CandidateStaking, DelegatorStaking, Initializable /** * @dev This method only work on testnet, to hotfix the applied validator candidate that is failed. - * Should remove this method before deploying it on mainnet. + * TODO: Should remove this method before deploying it on mainnet. */ function tmp_re_applyValidatorCandidate( address _candidateAdmin,