Source Code
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
MainchainGatewayV3
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 200 runs
Other Settings:
istanbul EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
import { IBridgeManager } from "../interfaces/bridge/IBridgeManager.sol";
import { IBridgeManagerCallback } from "../interfaces/bridge/IBridgeManagerCallback.sol";
import { HasContracts, ContractType } from "../extensions/collections/HasContracts.sol";
import "../extensions/WethUnwrapper.sol";
import "../extensions/WithdrawalLimitation.sol";
import "../libraries/Transfer.sol";
import "../interfaces/IMainchainGatewayV3.sol";
contract MainchainGatewayV3 is
WithdrawalLimitation,
Initializable,
AccessControlEnumerable,
ERC1155Holder,
IMainchainGatewayV3,
HasContracts,
IBridgeManagerCallback
{
using LibTokenInfo for TokenInfo;
using Transfer for Transfer.Request;
using Transfer for Transfer.Receipt;
/// @dev Withdrawal unlocker role hash
bytes32 public constant WITHDRAWAL_UNLOCKER_ROLE = keccak256("WITHDRAWAL_UNLOCKER_ROLE");
/// @dev Wrapped native token address
IWETH public wrappedNativeToken;
/// @dev Ronin network id
uint256 public roninChainId;
/// @dev Total deposit
uint256 public depositCount;
/// @dev Domain separator
bytes32 internal _domainSeparator;
/// @dev Mapping from mainchain token => token address on Ronin network
mapping(address => MappedToken) internal _roninToken;
/// @dev Mapping from withdrawal id => withdrawal hash
mapping(uint256 => bytes32) public withdrawalHash;
/// @dev Mapping from withdrawal id => locked
mapping(uint256 => bool) public withdrawalLocked;
/// @custom:deprecated Previously `_bridgeOperatorAddedBlock` (mapping(address => uint256))
uint256 private ______deprecatedBridgeOperatorAddedBlock;
/// @custom:deprecated Previously `_bridgeOperators` (uint256[])
uint256 private ______deprecatedBridgeOperators;
uint96 private _totalOperatorWeight;
mapping(address operator => uint96 weight) private _operatorWeight;
WethUnwrapper public wethUnwrapper;
constructor() {
_disableInitializers();
}
fallback() external payable {
_fallback();
}
receive() external payable {
_fallback();
}
/**
* @dev Initializes contract storage.
*/
function initialize(
address _roleSetter,
IWETH _wrappedToken,
uint256 _roninChainId,
uint256 _numerator,
uint256 _highTierVWNumerator,
uint256 _denominator,
// _addresses[0]: mainchainTokens
// _addresses[1]: roninTokens
// _addresses[2]: withdrawalUnlockers
address[][3] calldata _addresses,
// _thresholds[0]: highTierThreshold
// _thresholds[1]: lockedThreshold
// _thresholds[2]: unlockFeePercentages
// _thresholds[3]: dailyWithdrawalLimit
uint256[][4] calldata _thresholds,
TokenStandard[] calldata _standards
) external payable virtual initializer {
_setupRole(DEFAULT_ADMIN_ROLE, _roleSetter);
roninChainId = _roninChainId;
_setWrappedNativeTokenContract(_wrappedToken);
_updateDomainSeparator();
_setThreshold(_numerator, _denominator);
_setHighTierVoteWeightThreshold(_highTierVWNumerator, _denominator);
_verifyThresholds();
if (_addresses[0].length > 0) {
// Map mainchain tokens to ronin tokens
_mapTokens(_addresses[0], _addresses[1], _standards);
// Sets thresholds based on the mainchain tokens
_setHighTierThresholds(_addresses[0], _thresholds[0]);
_setLockedThresholds(_addresses[0], _thresholds[1]);
_setUnlockFeePercentages(_addresses[0], _thresholds[2]);
_setDailyWithdrawalLimits(_addresses[0], _thresholds[3]);
}
// Grant role for withdrawal unlocker
for (uint256 i; i < _addresses[2].length; i++) {
_grantRole(WITHDRAWAL_UNLOCKER_ROLE, _addresses[2][i]);
}
}
function initializeV2(address bridgeManagerContract) external reinitializer(2) {
_setContract(ContractType.BRIDGE_MANAGER, bridgeManagerContract);
}
function initializeV3() external reinitializer(3) {
IBridgeManager mainchainBridgeManager = IBridgeManager(getContract(ContractType.BRIDGE_MANAGER));
(, address[] memory operators, uint96[] memory weights) = mainchainBridgeManager.getFullBridgeOperatorInfos();
uint96 totalWeight;
for (uint i; i < operators.length; i++) {
_operatorWeight[operators[i]] = weights[i];
totalWeight += weights[i];
}
_totalOperatorWeight = totalWeight;
}
function initializeV4(address payable wethUnwrapper_) external reinitializer(4) {
wethUnwrapper = WethUnwrapper(wethUnwrapper_);
}
/**
* @dev Receives ether without doing anything. Use this function to topup native token.
*/
function receiveEther() external payable { }
/**
* @inheritdoc IMainchainGatewayV3
*/
function DOMAIN_SEPARATOR() external view virtual returns (bytes32) {
return _domainSeparator;
}
/**
* @inheritdoc IMainchainGatewayV3
*/
function setWrappedNativeTokenContract(IWETH _wrappedToken) external virtual onlyProxyAdmin {
_setWrappedNativeTokenContract(_wrappedToken);
}
/**
* @inheritdoc IMainchainGatewayV3
*/
function requestDepositFor(Transfer.Request calldata _request) external payable virtual whenNotPaused {
_requestDepositFor(_request, msg.sender);
}
/**
* @inheritdoc IMainchainGatewayV3
*/
function requestDepositForBatch(Transfer.Request[] calldata _requests) external payable virtual whenNotPaused {
uint length = _requests.length;
for (uint256 i; i < length; ++i) {
_requestDepositFor(_requests[i], msg.sender);
}
}
/**
* @inheritdoc IMainchainGatewayV3
*/
function submitWithdrawal(Transfer.Receipt calldata _receipt, Signature[] calldata _signatures) external virtual whenNotPaused returns (bool _locked) {
return _submitWithdrawal(_receipt, _signatures);
}
/**
* @inheritdoc IMainchainGatewayV3
*/
function unlockWithdrawal(Transfer.Receipt calldata receipt) external onlyRole(WITHDRAWAL_UNLOCKER_ROLE) {
bytes32 _receiptHash = receipt.hash();
if (withdrawalHash[receipt.id] != receipt.hash()) {
revert ErrInvalidReceipt();
}
if (!withdrawalLocked[receipt.id]) {
revert ErrQueryForApprovedWithdrawal();
}
delete withdrawalLocked[receipt.id];
emit WithdrawalUnlocked(_receiptHash, receipt);
address token = receipt.mainchain.tokenAddr;
if (receipt.info.erc == TokenStandard.ERC20) {
TokenInfo memory feeInfo = receipt.info;
feeInfo.quantity = _computeFeePercentage(receipt.info.quantity, unlockFeePercentages[token]);
TokenInfo memory withdrawInfo = receipt.info;
withdrawInfo.quantity = receipt.info.quantity - feeInfo.quantity;
feeInfo.handleAssetOut(payable(msg.sender), token, wrappedNativeToken);
withdrawInfo.handleAssetOut(payable(receipt.mainchain.addr), token, wrappedNativeToken);
} else {
receipt.info.handleAssetOut(payable(receipt.mainchain.addr), token, wrappedNativeToken);
}
emit Withdrew(_receiptHash, receipt);
}
/**
* @inheritdoc IMainchainGatewayV3
*/
function mapTokens(address[] calldata _mainchainTokens, address[] calldata _roninTokens, TokenStandard[] calldata _standards) external virtual onlyProxyAdmin {
if (_mainchainTokens.length == 0) revert ErrEmptyArray();
_mapTokens(_mainchainTokens, _roninTokens, _standards);
}
/**
* @inheritdoc IMainchainGatewayV3
*/
function mapTokensAndThresholds(
address[] calldata _mainchainTokens,
address[] calldata _roninTokens,
TokenStandard[] calldata _standards,
// _thresholds[0]: highTierThreshold
// _thresholds[1]: lockedThreshold
// _thresholds[2]: unlockFeePercentages
// _thresholds[3]: dailyWithdrawalLimit
uint256[][4] calldata _thresholds
) external virtual onlyProxyAdmin {
if (_mainchainTokens.length == 0) revert ErrEmptyArray();
_mapTokens(_mainchainTokens, _roninTokens, _standards);
_setHighTierThresholds(_mainchainTokens, _thresholds[0]);
_setLockedThresholds(_mainchainTokens, _thresholds[1]);
_setUnlockFeePercentages(_mainchainTokens, _thresholds[2]);
_setDailyWithdrawalLimits(_mainchainTokens, _thresholds[3]);
}
/**
* @inheritdoc IMainchainGatewayV3
*/
function getRoninToken(address mainchainToken) public view returns (MappedToken memory token) {
token = _roninToken[mainchainToken];
if (token.tokenAddr == address(0)) revert ErrUnsupportedToken();
}
/**
* @dev Maps mainchain tokens to Ronin network.
*
* Requirement:
* - The arrays have the same length.
*
* Emits the `TokenMapped` event.
*
*/
function _mapTokens(address[] calldata mainchainTokens, address[] calldata roninTokens, TokenStandard[] calldata standards) internal virtual {
if (!(mainchainTokens.length == roninTokens.length && mainchainTokens.length == standards.length)) revert ErrLengthMismatch(msg.sig);
for (uint256 i; i < mainchainTokens.length; ++i) {
_roninToken[mainchainTokens[i]].tokenAddr = roninTokens[i];
_roninToken[mainchainTokens[i]].erc = standards[i];
}
emit TokenMapped(mainchainTokens, roninTokens, standards);
}
/**
* @dev Submits withdrawal receipt.
*
* Requirements:
* - The receipt kind is withdrawal.
* - The receipt is to withdraw on this chain.
* - The receipt is not used to withdraw before.
* - The withdrawal is not reached the limit threshold.
* - The signer weight total is larger than or equal to the minimum threshold.
* - The signature signers are in order.
*
* Emits the `Withdrew` once the assets are released.
*
*/
function _submitWithdrawal(Transfer.Receipt calldata receipt, Signature[] memory signatures) internal virtual returns (bool locked) {
uint256 id = receipt.id;
uint256 quantity = receipt.info.quantity;
address tokenAddr = receipt.mainchain.tokenAddr;
receipt.info.validate();
if (receipt.kind != Transfer.Kind.Withdrawal) revert ErrInvalidReceiptKind();
if (receipt.mainchain.chainId != block.chainid) {
revert ErrInvalidChainId(msg.sig, receipt.mainchain.chainId, block.chainid);
}
MappedToken memory token = getRoninToken(receipt.mainchain.tokenAddr);
if (!(token.erc == receipt.info.erc && token.tokenAddr == receipt.ronin.tokenAddr && receipt.ronin.chainId == roninChainId)) {
revert ErrInvalidReceipt();
}
if (withdrawalHash[id] != 0) revert ErrQueryForProcessedWithdrawal();
if (!(receipt.info.erc == TokenStandard.ERC721 || !_reachedWithdrawalLimit(tokenAddr, quantity))) {
revert ErrReachedDailyWithdrawalLimit();
}
bytes32 receiptHash = receipt.hash();
bytes32 receiptDigest = Transfer.receiptDigest(_domainSeparator, receiptHash);
uint256 minimumWeight;
(minimumWeight, locked) = _computeMinVoteWeight(receipt.info.erc, tokenAddr, quantity);
{
bool passed;
address signer;
address lastSigner;
Signature memory sig;
uint256 weight;
for (uint256 i; i < signatures.length; i++) {
sig = signatures[i];
signer = ecrecover(receiptDigest, sig.v, sig.r, sig.s);
if (lastSigner >= signer) revert ErrInvalidOrder(msg.sig);
lastSigner = signer;
weight += _getWeight(signer);
if (weight >= minimumWeight) {
passed = true;
break;
}
}
if (!passed) revert ErrQueryForInsufficientVoteWeight();
withdrawalHash[id] = receiptHash;
}
if (locked) {
withdrawalLocked[id] = true;
emit WithdrawalLocked(receiptHash, receipt);
return locked;
}
_recordWithdrawal(tokenAddr, quantity);
receipt.info.handleAssetOut(payable(receipt.mainchain.addr), tokenAddr, wrappedNativeToken);
emit Withdrew(receiptHash, receipt);
}
/**
* @dev Requests deposit made by `_requester` address.
*
* Requirements:
* - The token info is valid.
* - The `msg.value` is 0 while depositing ERC20 token.
* - The `msg.value` is equal to deposit quantity while depositing native token.
*
* Emits the `DepositRequested` event.
*
*/
function _requestDepositFor(Transfer.Request memory _request, address _requester) internal virtual {
MappedToken memory _token;
address _roninWeth = address(wrappedNativeToken);
_request.info.validate();
if (_request.tokenAddr == address(0)) {
if (_request.info.quantity != msg.value) revert ErrInvalidRequest();
_token = getRoninToken(_roninWeth);
if (_token.erc != _request.info.erc) revert ErrInvalidTokenStandard();
_request.tokenAddr = _roninWeth;
} else {
if (msg.value != 0) revert ErrInvalidRequest();
_token = getRoninToken(_request.tokenAddr);
if (_token.erc != _request.info.erc) revert ErrInvalidTokenStandard();
_request.info.handleAssetIn(_requester, _request.tokenAddr);
// Withdraw if token is WETH
// The withdraw of WETH must go via `WethUnwrapper`, because `WETH.withdraw` only sends 2300 gas, which is insufficient when recipient is a proxy.
if (_roninWeth == _request.tokenAddr) {
wrappedNativeToken.approve(address(wethUnwrapper), _request.info.quantity);
wethUnwrapper.unwrap(_request.info.quantity);
}
}
uint256 _depositId = depositCount++;
Transfer.Receipt memory _receipt = _request.into_deposit_receipt(_requester, _depositId, _token.tokenAddr, roninChainId);
emit DepositRequested(_receipt.hash(), _receipt);
}
/**
* @dev Returns the minimum vote weight for the token.
*/
function _computeMinVoteWeight(TokenStandard _erc, address _token, uint256 _quantity) internal virtual returns (uint256 _weight, bool _locked) {
uint256 _totalWeight = _getTotalWeight();
_weight = _minimumVoteWeight(_totalWeight);
if (_erc == TokenStandard.ERC20) {
if (highTierThreshold[_token] <= _quantity) {
_weight = _highTierVoteWeight(_totalWeight);
}
_locked = _lockedWithdrawalRequest(_token, _quantity);
}
}
/**
* @dev Update domain seperator.
*/
function _updateDomainSeparator() internal {
/*
* _domainSeparator = keccak256(
* abi.encode(
* keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
* keccak256("MainchainGatewayV2"),
* keccak256("2"),
* block.chainid,
* address(this)
* )
* );
*/
assembly {
let ptr := mload(0x40)
// keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")
mstore(ptr, 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f)
// keccak256("MainchainGatewayV2")
mstore(add(ptr, 0x20), 0x159f52c1e3a2b6a6aad3950adf713516211484e0516dad685ea662a094b7c43b)
// keccak256("2")
mstore(add(ptr, 0x40), 0xad7c5bef027816a800da1736444fb58a807ef4c9603b7848673f7e3a68eb14a5)
mstore(add(ptr, 0x60), chainid())
mstore(add(ptr, 0x80), address())
sstore(_domainSeparator.slot, keccak256(ptr, 0xa0))
}
}
/**
* @dev Sets the WETH contract.
*
* Emits the `WrappedNativeTokenContractUpdated` event.
*
*/
function _setWrappedNativeTokenContract(IWETH _wrapedToken) internal {
wrappedNativeToken = _wrapedToken;
emit WrappedNativeTokenContractUpdated(_wrapedToken);
}
/**
* @dev Receives ETH from WETH or creates deposit request if sender is not WETH or WETHUnwrapper.
*/
function _fallback() internal virtual {
if (msg.sender == address(wrappedNativeToken) || msg.sender == address(wethUnwrapper)) {
return;
}
_createDepositOnFallback();
}
/**
* @dev Creates deposit request.
*/
function _createDepositOnFallback() internal virtual whenNotPaused {
Transfer.Request memory _request;
_request.recipientAddr = msg.sender;
_request.info.quantity = msg.value;
_requestDepositFor(_request, _request.recipientAddr);
}
/**
* @inheritdoc GatewayV3
*/
function _getTotalWeight() internal view override returns (uint256) {
return _totalOperatorWeight;
}
/**
* @dev Returns the weight of an address.
*/
function _getWeight(address addr) internal view returns (uint256) {
return _operatorWeight[addr];
}
///////////////////////////////////////////////
// CALLBACKS
///////////////////////////////////////////////
/**
* @inheritdoc IBridgeManagerCallback
*/
function onBridgeOperatorsAdded(
address[] calldata operators,
uint96[] calldata weights,
bool[] memory addeds
) external onlyContract(ContractType.BRIDGE_MANAGER) returns (bytes4) {
uint256 length = operators.length;
if (length != addeds.length || length != weights.length) revert ErrLengthMismatch(msg.sig);
if (length == 0) {
return IBridgeManagerCallback.onBridgeOperatorsAdded.selector;
}
for (uint256 i; i < length; ++i) {
unchecked {
if (addeds[i]) {
_totalOperatorWeight += weights[i];
_operatorWeight[operators[i]] = weights[i];
}
}
}
return IBridgeManagerCallback.onBridgeOperatorsAdded.selector;
}
/**
* @inheritdoc IBridgeManagerCallback
*/
function onBridgeOperatorsRemoved(address[] calldata operators, bool[] calldata removeds) external onlyContract(ContractType.BRIDGE_MANAGER) returns (bytes4) {
uint length = operators.length;
if (length != removeds.length) revert ErrLengthMismatch(msg.sig);
if (length == 0) {
return IBridgeManagerCallback.onBridgeOperatorsRemoved.selector;
}
uint96 totalRemovingWeight;
for (uint i; i < length; ++i) {
unchecked {
if (removeds[i]) {
totalRemovingWeight += _operatorWeight[operators[i]];
delete _operatorWeight[operators[i]];
}
}
}
_totalOperatorWeight -= totalRemovingWeight;
return IBridgeManagerCallback.onBridgeOperatorsRemoved.selector;
}
function supportsInterface(bytes4 interfaceId) public view override(AccessControlEnumerable, IERC165, ERC1155Receiver) returns (bool) {
return
interfaceId == type(IMainchainGatewayV3).interfaceId || interfaceId == type(IBridgeManagerCallback).interfaceId || super.supportsInterface(interfaceId);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)
pragma solidity ^0.8.0;
import "./IAccessControlEnumerable.sol";
import "./AccessControl.sol";
import "../utils/structs/EnumerableSet.sol";
/**
* @dev Extension of {AccessControl} that allows enumerating the members of each role.
*/
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
using EnumerableSet for EnumerableSet.AddressSet;
mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {
return _roleMembers[role].at(index);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {
return _roleMembers[role].length();
}
/**
* @dev Overload {_grantRole} to track enumerable memberships
*/
function _grantRole(bytes32 role, address account) internal virtual override {
super._grantRole(role, account);
_roleMembers[role].add(account);
}
/**
* @dev Overload {_revokeRole} to track enumerable memberships
*/
function _revokeRole(bytes32 role, address account) internal virtual override {
super._revokeRole(role, account);
_roleMembers[role].remove(account);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/Address.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
* initialization step. This is essential to configure modules that are added through upgrades and that require
* initialization.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized < type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/utils/ERC1155Holder.sol)
pragma solidity ^0.8.0;
import "./ERC1155Receiver.sol";
/**
* Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens.
*
* IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
* stuck.
*
* @dev _Available since v3.1._
*/
contract ERC1155Holder is ERC1155Receiver {
function onERC1155Received(
address,
address,
uint256,
uint256,
bytes memory
) public virtual override returns (bytes4) {
return this.onERC1155Received.selector;
}
function onERC1155BatchReceived(
address,
address,
uint256[] memory,
uint256[] memory,
bytes memory
) public virtual override returns (bytes4) {
return this.onERC1155BatchReceived.selector;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { IBridgeManagerEvents } from "./events/IBridgeManagerEvents.sol";
/**
* @title IBridgeManager
* @dev The interface for managing bridge operators.
*/
interface IBridgeManager is IBridgeManagerEvents {
/// @notice Error indicating that cannot find the querying operator
error ErrOperatorNotFound(address operator);
/// @notice Error indicating that cannot find the querying governor
error ErrGovernorNotFound(address governor);
/// @notice Error indicating that the msg.sender is not match the required governor
error ErrGovernorNotMatch(address required, address sender);
/// @notice Error indicating that the governors list will go below minimum number of required governor.
error ErrBelowMinRequiredGovernors();
/// @notice Common invalid input error
error ErrInvalidInput();
/**
* @dev The domain separator used for computing hash digests in the contract.
*/
function DOMAIN_SEPARATOR() external view returns (bytes32);
/**
* @dev Returns the total number of bridge operators.
* @return The total number of bridge operators.
*/
function totalBridgeOperator() external view returns (uint256);
/**
* @dev Checks if the given address is a bridge operator.
* @param addr The address to check.
* @return A boolean indicating whether the address is a bridge operator.
*/
function isBridgeOperator(address addr) external view returns (bool);
/**
* @dev Retrieves the full information of all registered bridge operators.
*
* This external function allows external callers to obtain the full information of all the registered bridge operators.
* The returned arrays include the addresses of governors, bridge operators, and their corresponding vote weights.
*
* @return governors An array of addresses representing the governors of each bridge operator.
* @return bridgeOperators An array of addresses representing the registered bridge operators.
* @return weights An array of uint256 values representing the vote weights of each bridge operator.
*
* Note: The length of each array will be the same, and the order of elements corresponds to the same bridge operator.
*
* Example Usage:
* ```
* (address[] memory governors, address[] memory bridgeOperators, uint256[] memory weights) = getFullBridgeOperatorInfos();
* for (uint256 i = 0; i < bridgeOperators.length; i++) {
* // Access individual information for each bridge operator.
* address governor = governors[i];
* address bridgeOperator = bridgeOperators[i];
* uint256 weight = weights[i];
* // ... (Process or use the information as required) ...
* }
* ```
*
*/
function getFullBridgeOperatorInfos() external view returns (address[] memory governors, address[] memory bridgeOperators, uint96[] memory weights);
/**
* @dev Returns total weights of the governor list.
*/
function sumGovernorsWeight(address[] calldata governors) external view returns (uint256 sum);
/**
* @dev Returns total weights.
*/
function getTotalWeight() external view returns (uint256);
/**
* @dev Returns an array of all bridge operators.
* @return An array containing the addresses of all bridge operators.
*/
function getBridgeOperators() external view returns (address[] memory);
/**
* @dev Returns the corresponding `operator` of a `governor`.
*/
function getOperatorOf(address governor) external view returns (address operator);
/**
* @dev Returns the corresponding `governor` of a `operator`.
*/
function getGovernorOf(address operator) external view returns (address governor);
/**
* @dev External function to retrieve the vote weight of a specific governor.
* @param governor The address of the governor to get the vote weight for.
* @return voteWeight The vote weight of the specified governor.
*/
function getGovernorWeight(address governor) external view returns (uint96);
/**
* @dev External function to retrieve the vote weight of a specific bridge operator.
* @param bridgeOperator The address of the bridge operator to get the vote weight for.
* @return weight The vote weight of the specified bridge operator.
*/
function getBridgeOperatorWeight(address bridgeOperator) external view returns (uint96 weight);
/**
* @dev Returns the weights of a list of governor addresses.
*/
function getGovernorWeights(address[] calldata governors) external view returns (uint96[] memory weights);
/**
* @dev Returns an array of all governors.
* @return An array containing the addresses of all governors.
*/
function getGovernors() external view returns (address[] memory);
/**
* @dev Adds multiple bridge operators.
* @param governors An array of addresses of hot/cold wallets for bridge operator to update their node address.
* @param bridgeOperators An array of addresses representing the bridge operators to add.
*/
function addBridgeOperators(uint96[] calldata voteWeights, address[] calldata governors, address[] calldata bridgeOperators) external;
/**
* @dev Removes multiple bridge operators.
* @param bridgeOperators An array of addresses representing the bridge operators to remove.
*/
function removeBridgeOperators(address[] calldata bridgeOperators) external;
/**
* @dev Self-call to update the minimum required governor.
* @param min The minimum number, this must not less than 3.
*/
function setMinRequiredGovernor(uint min) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @title IBridgeManagerCallback
* @dev Interface for the callback functions to be implemented by the Bridge Manager contract.
*/
interface IBridgeManagerCallback is IERC165 {
/**
* @dev Handles the event when bridge operators are added.
* @param bridgeOperators The addresses of the bridge operators.
* @param addeds The corresponding boolean values indicating whether the operators were added or not.
* @return selector The selector of the function being called.
*/
function onBridgeOperatorsAdded(address[] memory bridgeOperators, uint96[] calldata weights, bool[] memory addeds) external returns (bytes4 selector);
/**
* @dev Handles the event when bridge operators are removed.
* @param bridgeOperators The addresses of the bridge operators.
* @param removeds The corresponding boolean values indicating whether the operators were removed or not.
* @return selector The selector of the function being called.
*/
function onBridgeOperatorsRemoved(address[] memory bridgeOperators, bool[] memory removeds) external returns (bytes4 selector);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { HasProxyAdmin } from "./HasProxyAdmin.sol";
import "../../interfaces/collections/IHasContracts.sol";
import { IdentityGuard } from "../../utils/IdentityGuard.sol";
import { ErrUnexpectedInternalCall } from "../../utils/CommonErrors.sol";
/**
* @title HasContracts
* @dev A contract that provides functionality to manage multiple contracts with different roles.
*/
abstract contract HasContracts is HasProxyAdmin, IHasContracts, IdentityGuard {
/// @dev value is equal to keccak256("@ronin.dpos.collections.HasContracts.slot") - 1
bytes32 private constant _STORAGE_SLOT = 0xdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb;
/**
* @dev Modifier to restrict access to functions only to contracts with a specific role.
* @param contractType The contract type that allowed to call
*/
modifier onlyContract(ContractType contractType) virtual {
_requireContract(contractType);
_;
}
/**
* @inheritdoc IHasContracts
*/
function setContract(ContractType contractType, address addr) external virtual onlyProxyAdmin {
_requireHasCode(addr);
_setContract(contractType, addr);
}
/**
* @inheritdoc IHasContracts
*/
function getContract(ContractType contractType) public view returns (address contract_) {
contract_ = _getContractMap()[uint8(contractType)];
if (contract_ == address(0)) revert ErrContractTypeNotFound(contractType);
}
/**
* @dev Internal function to set the address of a contract with a specific role.
* @param contractType The contract type of the contract to set.
* @param addr The address of the contract to set.
*/
function _setContract(ContractType contractType, address addr) internal virtual {
_getContractMap()[uint8(contractType)] = addr;
emit ContractUpdated(contractType, addr);
}
/**
* @dev Internal function to access the mapping of contract addresses with roles.
* @return contracts_ The mapping of contract addresses with roles.
*/
function _getContractMap() private pure returns (mapping(uint8 => address) storage contracts_) {
assembly {
contracts_.slot := _STORAGE_SLOT
}
}
/**
* @dev Internal function to check if the calling contract has a specific role.
* @param contractType The contract type that the calling contract must have.
* @dev Throws an error if the calling contract does not have the specified role.
*/
function _requireContract(ContractType contractType) private view {
if (msg.sender != getContract(contractType)) {
revert ErrUnexpectedInternalCall(msg.sig, contractType, msg.sender);
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "../interfaces/IWETH.sol";
contract WethUnwrapper is ReentrancyGuard {
IWETH public immutable weth;
error ErrCannotTransferFrom();
error ErrNotWrappedContract();
error ErrExternalCallFailed(address sender, bytes4 sig);
constructor(address weth_) {
if (address(weth_).code.length == 0) revert ErrNotWrappedContract();
weth = IWETH(weth_);
}
fallback() external payable {
_fallback();
}
receive() external payable {
_fallback();
}
function unwrap(uint256 amount) external nonReentrant {
_deductWrappedAndWithdraw(amount);
_sendNativeTo(payable(msg.sender), amount);
}
function unwrapTo(uint256 amount, address payable to) external nonReentrant {
_deductWrappedAndWithdraw(amount);
_sendNativeTo(payable(to), amount);
}
function _deductWrappedAndWithdraw(uint256 amount) internal {
(bool success,) = address(weth).call(abi.encodeCall(IWETH.transferFrom, (msg.sender, address(this), amount)));
if (!success) revert ErrCannotTransferFrom();
weth.withdraw(amount);
}
function _sendNativeTo(address payable to, uint256 val) internal {
(bool success,) = to.call{ value: val }("");
if (!success) {
revert ErrExternalCallFailed(to, msg.sig);
}
}
function _fallback() internal view {
if (msg.sender != address(weth)) revert ErrNotWrappedContract();
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./GatewayV3.sol";
abstract contract WithdrawalLimitation is GatewayV3 {
/// @dev Error of invalid percentage.
error ErrInvalidPercentage();
/// @dev Emitted when the high-tier vote weight threshold is updated
event HighTierVoteWeightThresholdUpdated(
uint256 indexed nonce, uint256 indexed numerator, uint256 indexed denominator, uint256 previousNumerator, uint256 previousDenominator
);
/// @dev Emitted when the thresholds for high-tier withdrawals that requires high-tier vote weights are updated
event HighTierThresholdsUpdated(address[] tokens, uint256[] thresholds);
/// @dev Emitted when the thresholds for locked withdrawals are updated
event LockedThresholdsUpdated(address[] tokens, uint256[] thresholds);
/// @dev Emitted when the fee percentages to unlock withdraw are updated
event UnlockFeePercentagesUpdated(address[] tokens, uint256[] percentages);
/// @dev Emitted when the daily limit thresholds are updated
event DailyWithdrawalLimitsUpdated(address[] tokens, uint256[] limits);
uint256 public constant _MAX_PERCENTAGE = 1_000_000;
uint256 internal _highTierVWNum;
uint256 internal _highTierVWDenom;
/// @dev Mapping from mainchain token => the amount thresholds for high-tier withdrawals that requires high-tier vote weights
mapping(address => uint256) public highTierThreshold;
/// @dev Mapping from mainchain token => the amount thresholds to lock withdrawal
mapping(address => uint256) public lockedThreshold;
/// @dev Mapping from mainchain token => unlock fee percentages for unlocker
/// @notice Values 0-1,000,000 map to 0%-100%
mapping(address => uint256) public unlockFeePercentages;
/// @dev Mapping from mainchain token => daily limit amount for withdrawal
mapping(address => uint256) public dailyWithdrawalLimit;
/// @dev Mapping from token address => today withdrawal amount
mapping(address => uint256) public lastSyncedWithdrawal;
/// @dev Mapping from token address => last date synced to record the `lastSyncedWithdrawal`
mapping(address => uint256) public lastDateSynced;
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
*/
uint256[50] private ______gap;
/**
* @dev Override `GatewayV3-setThreshold`.
*
* Requirements:
* - The high-tier vote weight threshold must equal to or larger than the normal threshold.
*
*/
function setThreshold(uint256 num, uint256 denom) external virtual override onlyProxyAdmin {
_setThreshold(num, denom);
_verifyThresholds();
}
/**
* @dev Returns the high-tier vote weight threshold.
*/
function getHighTierVoteWeightThreshold() external view virtual returns (uint256, uint256) {
return (_highTierVWNum, _highTierVWDenom);
}
/**
* @dev Checks whether the `_voteWeight` passes the high-tier vote weight threshold.
*/
function checkHighTierVoteWeightThreshold(uint256 _voteWeight) external view virtual returns (bool) {
return _voteWeight * _highTierVWDenom >= _highTierVWNum * _getTotalWeight();
}
/**
* @dev Sets high-tier vote weight threshold and returns the old one.
*
* Requirements:
* - The method caller is admin.
* - The high-tier vote weight threshold must equal to or larger than the normal threshold.
*
* Emits the `HighTierVoteWeightThresholdUpdated` event.
*
*/
function setHighTierVoteWeightThreshold(
uint256 _numerator,
uint256 _denominator
) external virtual onlyProxyAdmin returns (uint256 _previousNum, uint256 _previousDenom) {
(_previousNum, _previousDenom) = _setHighTierVoteWeightThreshold(_numerator, _denominator);
_verifyThresholds();
}
/**
* @dev Sets the thresholds for high-tier withdrawals that requires high-tier vote weights.
*
* Requirements:
* - The method caller is admin.
* - The arrays have the same length and its length larger than 0.
*
* Emits the `HighTierThresholdsUpdated` event.
*
*/
function setHighTierThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) external virtual onlyProxyAdmin {
if (_tokens.length == 0) revert ErrEmptyArray();
_setHighTierThresholds(_tokens, _thresholds);
}
/**
* @dev Sets the amount thresholds to lock withdrawal.
*
* Requirements:
* - The method caller is admin.
* - The arrays have the same length and its length larger than 0.
*
* Emits the `LockedThresholdsUpdated` event.
*
*/
function setLockedThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) external virtual onlyProxyAdmin {
if (_tokens.length == 0) revert ErrEmptyArray();
_setLockedThresholds(_tokens, _thresholds);
}
/**
* @dev Sets fee percentages to unlock withdrawal.
*
* Requirements:
* - The method caller is admin.
* - The arrays have the same length and its length larger than 0.
*
* Emits the `UnlockFeePercentagesUpdated` event.
*
*/
function setUnlockFeePercentages(address[] calldata _tokens, uint256[] calldata _percentages) external virtual onlyProxyAdmin {
if (_tokens.length == 0) revert ErrEmptyArray();
_setUnlockFeePercentages(_tokens, _percentages);
}
/**
* @dev Sets daily limit amounts for the withdrawals.
*
* Requirements:
* - The method caller is admin.
* - The arrays have the same length and its length larger than 0.
*
* Emits the `DailyWithdrawalLimitsUpdated` event.
*
*/
function setDailyWithdrawalLimits(address[] calldata _tokens, uint256[] calldata _limits) external virtual onlyProxyAdmin {
if (_tokens.length == 0) revert ErrEmptyArray();
_setDailyWithdrawalLimits(_tokens, _limits);
}
/**
* @dev Checks whether the withdrawal reaches the limitation.
*/
function reachedWithdrawalLimit(address _token, uint256 _quantity) external view virtual returns (bool) {
return _reachedWithdrawalLimit(_token, _quantity);
}
/**
* @dev Sets high-tier vote weight threshold and returns the old one.
*
* Emits the `HighTierVoteWeightThresholdUpdated` event.
*
*/
function _setHighTierVoteWeightThreshold(uint256 _numerator, uint256 _denominator) internal returns (uint256 _previousNum, uint256 _previousDenom) {
if (_numerator > _denominator) revert ErrInvalidThreshold(msg.sig);
_previousNum = _highTierVWNum;
_previousDenom = _highTierVWDenom;
_highTierVWNum = _numerator;
_highTierVWDenom = _denominator;
unchecked {
emit HighTierVoteWeightThresholdUpdated(nonce++, _numerator, _denominator, _previousNum, _previousDenom);
}
}
/**
* @dev Sets the thresholds for high-tier withdrawals that requires high-tier vote weights.
*
* Requirements:
* - The array lengths are equal.
*
* Emits the `HighTierThresholdsUpdated` event.
*
*/
function _setHighTierThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) internal virtual {
if (_tokens.length != _thresholds.length) revert ErrLengthMismatch(msg.sig);
for (uint256 _i; _i < _tokens.length;) {
highTierThreshold[_tokens[_i]] = _thresholds[_i];
unchecked {
++_i;
}
}
emit HighTierThresholdsUpdated(_tokens, _thresholds);
}
/**
* @dev Sets the amount thresholds to lock withdrawal.
*
* Requirements:
* - The array lengths are equal.
*
* Emits the `LockedThresholdsUpdated` event.
*
*/
function _setLockedThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) internal virtual {
if (_tokens.length != _thresholds.length) revert ErrLengthMismatch(msg.sig);
for (uint256 _i; _i < _tokens.length;) {
lockedThreshold[_tokens[_i]] = _thresholds[_i];
unchecked {
++_i;
}
}
emit LockedThresholdsUpdated(_tokens, _thresholds);
}
/**
* @dev Sets fee percentages to unlock withdrawal.
*
* Requirements:
* - The array lengths are equal.
* - The percentage is equal to or less than 100_000.
*
* Emits the `UnlockFeePercentagesUpdated` event.
*
*/
function _setUnlockFeePercentages(address[] calldata _tokens, uint256[] calldata _percentages) internal virtual {
if (_tokens.length != _percentages.length) revert ErrLengthMismatch(msg.sig);
for (uint256 _i; _i < _tokens.length;) {
if (_percentages[_i] > _MAX_PERCENTAGE) revert ErrInvalidPercentage();
unlockFeePercentages[_tokens[_i]] = _percentages[_i];
unchecked {
++_i;
}
}
emit UnlockFeePercentagesUpdated(_tokens, _percentages);
}
/**
* @dev Sets daily limit amounts for the withdrawals.
*
* Requirements:
* - The array lengths are equal.
*
* Emits the `DailyWithdrawalLimitsUpdated` event.
*
*/
function _setDailyWithdrawalLimits(address[] calldata _tokens, uint256[] calldata _limits) internal virtual {
if (_tokens.length != _limits.length) revert ErrLengthMismatch(msg.sig);
for (uint256 _i; _i < _tokens.length;) {
dailyWithdrawalLimit[_tokens[_i]] = _limits[_i];
unchecked {
++_i;
}
}
emit DailyWithdrawalLimitsUpdated(_tokens, _limits);
}
/**
* @dev Checks whether the withdrawal reaches the daily limitation.
*
* Requirements:
* - The daily withdrawal threshold should not apply for locked withdrawals.
*
*/
function _reachedWithdrawalLimit(address _token, uint256 _quantity) internal view virtual returns (bool) {
if (_lockedWithdrawalRequest(_token, _quantity)) {
return false;
}
uint256 _currentDate = block.timestamp / 1 days;
if (_currentDate > lastDateSynced[_token]) {
return dailyWithdrawalLimit[_token] <= _quantity;
} else {
return dailyWithdrawalLimit[_token] <= lastSyncedWithdrawal[_token] + _quantity;
}
}
/**
* @dev Record withdrawal token.
*/
function _recordWithdrawal(address _token, uint256 _quantity) internal virtual {
uint256 _currentDate = block.timestamp / 1 days;
if (_currentDate > lastDateSynced[_token]) {
lastDateSynced[_token] = _currentDate;
lastSyncedWithdrawal[_token] = _quantity;
} else {
lastSyncedWithdrawal[_token] += _quantity;
}
}
/**
* @dev Returns whether the withdrawal request is locked or not.
*/
function _lockedWithdrawalRequest(address _token, uint256 _quantity) internal view virtual returns (bool) {
return lockedThreshold[_token] <= _quantity;
}
/**
* @dev Computes fee percentage.
*/
function _computeFeePercentage(uint256 _amount, uint256 _percentage) internal view virtual returns (uint256) {
return (_amount * _percentage) / _MAX_PERCENTAGE;
}
/**
* @dev Returns high-tier vote weight.
*/
function _highTierVoteWeight(uint256 _totalWeight) internal view virtual returns (uint256) {
return (_highTierVWNum * _totalWeight + _highTierVWDenom - 1) / _highTierVWDenom;
}
/**
* @dev Validates whether the high-tier vote weight threshold is larger than the normal threshold.
*/
function _verifyThresholds() internal view {
if (_num * _highTierVWDenom > _highTierVWNum * _denom) revert ErrInvalidThreshold(msg.sig);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./LibTokenInfo.sol";
import "./LibTokenOwner.sol";
library Transfer {
using ECDSA for bytes32;
using LibTokenOwner for TokenOwner;
using LibTokenInfo for TokenInfo;
enum Kind {
Deposit,
Withdrawal
}
struct Request {
// For deposit request: Recipient address on Ronin network
// For withdrawal request: Recipient address on mainchain network
address recipientAddr;
// Token address to deposit/withdraw
// Value 0: native token
address tokenAddr;
TokenInfo info;
}
/**
* @dev Converts the transfer request into the deposit receipt.
*/
function into_deposit_receipt(
Request memory _request,
address _requester,
uint256 _id,
address _roninTokenAddr,
uint256 _roninChainId
) internal view returns (Receipt memory _receipt) {
_receipt.id = _id;
_receipt.kind = Kind.Deposit;
_receipt.mainchain.addr = _requester;
_receipt.mainchain.tokenAddr = _request.tokenAddr;
_receipt.mainchain.chainId = block.chainid;
_receipt.ronin.addr = _request.recipientAddr;
_receipt.ronin.tokenAddr = _roninTokenAddr;
_receipt.ronin.chainId = _roninChainId;
_receipt.info = _request.info;
}
/**
* @dev Converts the transfer request into the withdrawal receipt.
*/
function into_withdrawal_receipt(
Request memory _request,
address _requester,
uint256 _id,
address _mainchainTokenAddr,
uint256 _mainchainId
) internal view returns (Receipt memory _receipt) {
_receipt.id = _id;
_receipt.kind = Kind.Withdrawal;
_receipt.ronin.addr = _requester;
_receipt.ronin.tokenAddr = _request.tokenAddr;
_receipt.ronin.chainId = block.chainid;
_receipt.mainchain.addr = _request.recipientAddr;
_receipt.mainchain.tokenAddr = _mainchainTokenAddr;
_receipt.mainchain.chainId = _mainchainId;
_receipt.info = _request.info;
}
struct Receipt {
uint256 id;
Kind kind;
TokenOwner mainchain;
TokenOwner ronin;
TokenInfo info;
}
// 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)");
bytes32 public constant TYPE_HASH = 0xb9d1fe7c9deeec5dc90a2f47ff1684239519f2545b2228d3d91fb27df3189eea;
/**
* @dev Returns token info struct hash.
*/
function hash(Receipt memory _receipt) internal pure returns (bytes32 digest) {
bytes32 hashedReceiptMainchain = _receipt.mainchain.hash();
bytes32 hashedReceiptRonin = _receipt.ronin.hash();
bytes32 hashedReceiptInfo = _receipt.info.hash();
/*
* return
* keccak256(
* abi.encode(
* TYPE_HASH,
* _receipt.id,
* _receipt.kind,
* Token.hash(_receipt.mainchain),
* Token.hash(_receipt.ronin),
* Token.hash(_receipt.info)
* )
* );
*/
assembly {
let ptr := mload(0x40)
mstore(ptr, TYPE_HASH)
mstore(add(ptr, 0x20), mload(_receipt)) // _receipt.id
mstore(add(ptr, 0x40), mload(add(_receipt, 0x20))) // _receipt.kind
mstore(add(ptr, 0x60), hashedReceiptMainchain)
mstore(add(ptr, 0x80), hashedReceiptRonin)
mstore(add(ptr, 0xa0), hashedReceiptInfo)
digest := keccak256(ptr, 0xc0)
}
}
/**
* @dev Returns the receipt digest.
*/
function receiptDigest(bytes32 _domainSeparator, bytes32 _receiptHash) internal pure returns (bytes32) {
return _domainSeparator.toTypedDataHash(_receiptHash);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IWETH.sol";
import "./consumers/SignatureConsumer.sol";
import "./consumers/MappedTokenConsumer.sol";
import "../libraries/Transfer.sol";
interface IMainchainGatewayV3 is SignatureConsumer, MappedTokenConsumer {
/**
* @dev Error indicating that a query was made for an approved withdrawal.
*/
error ErrQueryForApprovedWithdrawal();
/**
* @dev Error indicating that the daily withdrawal limit has been reached.
*/
error ErrReachedDailyWithdrawalLimit();
/**
* @dev Error indicating that a query was made for a processed withdrawal.
*/
error ErrQueryForProcessedWithdrawal();
/**
* @dev Error indicating that a query was made for insufficient vote weight.
*/
error ErrQueryForInsufficientVoteWeight();
/// @dev Emitted when the deposit is requested
event DepositRequested(bytes32 receiptHash, Transfer.Receipt receipt);
/// @dev Emitted when the assets are withdrawn
event Withdrew(bytes32 receiptHash, Transfer.Receipt receipt);
/// @dev Emitted when the tokens are mapped
event TokenMapped(address[] mainchainTokens, address[] roninTokens, TokenStandard[] standards);
/// @dev Emitted when the wrapped native token contract is updated
event WrappedNativeTokenContractUpdated(IWETH weth);
/// @dev Emitted when the withdrawal is locked
event WithdrawalLocked(bytes32 receiptHash, Transfer.Receipt receipt);
/// @dev Emitted when the withdrawal is unlocked
event WithdrawalUnlocked(bytes32 receiptHash, Transfer.Receipt receipt);
/**
* @dev Returns the domain seperator.
*/
function DOMAIN_SEPARATOR() external view returns (bytes32);
/**
* @dev Returns deposit count.
*/
function depositCount() external view returns (uint256);
/**
* @dev Sets the wrapped native token contract.
*
* Requirements:
* - The method caller is admin.
*
* Emits the `WrappedNativeTokenContractUpdated` event.
*
*/
function setWrappedNativeTokenContract(IWETH _wrappedToken) external;
/**
* @dev Returns whether the withdrawal is locked.
*/
function withdrawalLocked(uint256 withdrawalId) external view returns (bool);
/**
* @dev Returns the withdrawal hash.
*/
function withdrawalHash(uint256 withdrawalId) external view returns (bytes32);
/**
* @dev Locks the assets and request deposit.
*/
function requestDepositFor(Transfer.Request calldata _request) external payable;
/**
* @dev Locks the assets and request deposit for batch.
*/
function requestDepositForBatch(Transfer.Request[] calldata requests) external payable;
/**
* @dev Withdraws based on the receipt and the validator signatures.
* Returns whether the withdrawal is locked.
*
* Emits the `Withdrew` once the assets are released.
*
*/
function submitWithdrawal(Transfer.Receipt memory _receipt, Signature[] memory _signatures) external returns (bool _locked);
/**
* @dev Approves a specific withdrawal.
*
* Requirements:
* - The method caller is a validator.
*
* Emits the `Withdrew` once the assets are released.
*
*/
function unlockWithdrawal(Transfer.Receipt calldata _receipt) external;
/**
* @dev Maps mainchain tokens to Ronin network.
*
* Requirement:
* - The method caller is admin.
* - The arrays have the same length and its length larger than 0.
*
* Emits the `TokenMapped` event.
*
*/
function mapTokens(address[] calldata _mainchainTokens, address[] calldata _roninTokens, TokenStandard[] calldata _standards) external;
/**
* @dev Maps mainchain tokens to Ronin network and sets thresholds.
*
* Requirement:
* - The method caller is admin.
* - The arrays have the same length and its length larger than 0.
*
* Emits the `TokenMapped` event.
*
*/
function mapTokensAndThresholds(
address[] calldata _mainchainTokens,
address[] calldata _roninTokens,
TokenStandard[] calldata _standards,
uint256[][4] calldata _thresholds
) external;
/**
* @dev Returns token address on Ronin network.
* Note: Reverts for unsupported token.
*/
function getRoninToken(address _mainchainToken) external view returns (MappedToken memory _token);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
/**
* @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
*/
interface IAccessControlEnumerable is IAccessControl {
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) external view returns (address);
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* May emit a {RoleGranted} event.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* 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.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
return _values(set._inner);
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol)
pragma solidity ^0.8.0;
import "../IERC1155Receiver.sol";
import "../../../utils/introspection/ERC165.sol";
/**
* @dev _Available since v3.1._
*/
abstract contract ERC1155Receiver is ERC165, IERC1155Receiver {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IBridgeManagerEvents {
/**
* @dev Emitted when new bridge operators are added.
*/
event BridgeOperatorsAdded(bool[] statuses, uint96[] voteWeights, address[] governors, address[] bridgeOperators);
/**
* @dev Emitted when a bridge operator is failed to add.
*/
event BridgeOperatorAddingFailed(address indexed operator);
/**
* @dev Emitted when bridge operators are removed.
*/
event BridgeOperatorsRemoved(bool[] statuses, address[] bridgeOperators);
/**
* @dev Emitted when a bridge operator is failed to remove.
*/
event BridgeOperatorRemovingFailed(address indexed operator);
/**
* @dev Emitted when a bridge operator is updated.
*/
event BridgeOperatorUpdated(address indexed governor, address indexed fromBridgeOperator, address indexed toBridgeOperator);
/**
* @dev Emitted when the minimum number of required governors is updated.
*/
event MinRequiredGovernorUpdated(uint min);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/StorageSlot.sol";
import "../../utils/CommonErrors.sol";
abstract contract HasProxyAdmin {
// bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1));
bytes32 private constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
modifier onlyProxyAdmin() {
_requireProxyAdmin();
_;
}
/**
* @dev Returns proxy admin.
*/
function _getProxyAdmin() internal view virtual returns (address) {
return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
}
function _requireProxyAdmin() internal view {
if (msg.sender != _getProxyAdmin()) revert ErrUnauthorized(msg.sig, RoleAccess.ADMIN);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import { ContractType } from "../../utils/ContractType.sol";
interface IHasContracts {
/// @dev Error of invalid role.
error ErrContractTypeNotFound(ContractType contractType);
/// @dev Emitted when a contract is updated.
event ContractUpdated(ContractType indexed contractType, address indexed addr);
/**
* @dev Returns the address of a contract with a specific role.
* Throws an error if no contract is set for the specified role.
*
* @param contractType The role of the contract to retrieve.
* @return contract_ The address of the contract with the specified role.
*/
function getContract(ContractType contractType) external view returns (address contract_);
/**
* @dev Sets the address of a contract with a specific role.
* Emits the event {ContractUpdated}.
* @param contractType The role of the contract to set.
* @param addr The address of the contract to set.
*/
function setContract(ContractType contractType, address addr) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { AddressArrayUtils } from "../libraries/AddressArrayUtils.sol";
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import { TransparentUpgradeableProxyV2 } from "../extensions/TransparentUpgradeableProxyV2.sol";
import { ErrAddressIsNotCreatedEOA, ErrZeroAddress, ErrOnlySelfCall, ErrZeroCodeContract, ErrUnsupportedInterface } from "./CommonErrors.sol";
abstract contract IdentityGuard {
using AddressArrayUtils for address[];
/// @dev value is equal to keccak256(abi.encode())
/// @dev see: https://eips.ethereum.org/EIPS/eip-1052
bytes32 internal constant CREATED_ACCOUNT_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
/**
* @dev Modifier to restrict functions to only be called by this contract.
* @dev Reverts if the caller is not this contract.
*/
modifier onlySelfCall() virtual {
_requireSelfCall();
_;
}
/**
* @dev Modifier to ensure that the elements in the `arr` array are non-duplicates.
* It calls the internal `_checkDuplicate` function to perform the duplicate check.
*
* Requirements:
* - The elements in the `arr` array must not contain any duplicates.
*/
modifier nonDuplicate(address[] memory arr) virtual {
_requireNonDuplicate(arr);
_;
}
/**
* @dev Internal method to check the method caller.
* @dev Reverts if the method caller is not this contract.
*/
function _requireSelfCall() internal view virtual {
if (msg.sender != address(this)) revert ErrOnlySelfCall(msg.sig);
}
/**
* @dev Internal function to check if a contract address has code.
* @param addr The address of the contract to check.
* @dev Throws an error if the contract address has no code.
*/
function _requireHasCode(address addr) internal view {
if (addr.code.length == 0) revert ErrZeroCodeContract(addr);
}
/**
* @dev Checks if an address is zero and reverts if it is.
* @param addr The address to check.
*/
function _requireNonZeroAddress(address addr) internal pure {
if (addr == address(0)) revert ErrZeroAddress(msg.sig);
}
/**
* @dev Check if arr is empty and revert if it is.
* Checks if an array contains any duplicate addresses and reverts if duplicates are found.
* @param arr The array of addresses to check.
*/
function _requireNonDuplicate(address[] memory arr) internal pure {
if (arr.hasDuplicate()) revert AddressArrayUtils.ErrDuplicated(msg.sig);
}
/**
* @dev Internal function to require that the provided address is a created externally owned account (EOA).
* This internal function is used to ensure that the provided address is a valid externally owned account (EOA).
* It checks the codehash of the address against a predefined constant to confirm that the address is a created EOA.
* @notice This method only works with non-state EOA accounts
*/
function _requireCreatedEOA(address addr) internal view {
_requireNonZeroAddress(addr);
bytes32 codehash = addr.codehash;
if (codehash != CREATED_ACCOUNT_HASH) revert ErrAddressIsNotCreatedEOA(addr, codehash);
}
/**
* @dev Internal function to require that the specified contract supports the given interface. This method handle in
* both case that the callee is either or not the proxy admin of the caller. If the contract does not support the
* interface `interfaceId` or EIP165, a revert with the corresponding error message is triggered.
*
* @param contractAddr The address of the contract to check for interface support.
* @param interfaceId The interface ID to check for support.
*/
function _requireSupportsInterface(address contractAddr, bytes4 interfaceId) internal view {
bytes memory supportsInterfaceParams = abi.encodeCall(IERC165.supportsInterface, (interfaceId));
(bool success, bytes memory returnOrRevertData) = contractAddr.staticcall(supportsInterfaceParams);
if (!success) {
(success, returnOrRevertData) = contractAddr.staticcall(abi.encodeCall(TransparentUpgradeableProxyV2.functionDelegateCall, (supportsInterfaceParams)));
if (!success) revert ErrUnsupportedInterface(interfaceId, contractAddr);
}
if (!abi.decode(returnOrRevertData, (bool))) revert ErrUnsupportedInterface(interfaceId, contractAddr);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { ContractType } from "./ContractType.sol";
import { RoleAccess } from "./RoleAccess.sol";
error ErrSyncTooFarPeriod(uint256 period, uint256 latestRewardedPeriod);
/**
* @dev Error thrown when an address is expected to be an already created externally owned account (EOA).
* This error indicates that the provided address is invalid for certain contract operations that require already created EOA.
*/
error ErrAddressIsNotCreatedEOA(address addr, bytes32 codehash);
/**
* @dev Error raised when a bridge operator update operation fails.
* @param bridgeOperator The address of the bridge operator that failed to update.
*/
error ErrBridgeOperatorUpdateFailed(address bridgeOperator);
/**
* @dev Error thrown when attempting to add a bridge operator that already exists in the contract.
* This error indicates that the provided bridge operator address is already registered as a bridge operator in the contract.
*/
error ErrBridgeOperatorAlreadyExisted(address bridgeOperator);
/**
* @dev The error indicating an unsupported interface.
* @param interfaceId The bytes4 interface identifier that is not supported.
* @param addr The address where the unsupported interface was encountered.
*/
error ErrUnsupportedInterface(bytes4 interfaceId, address addr);
/**
* @dev Error thrown when the return data from a callback function is invalid.
* @param callbackFnSig The signature of the callback function that returned invalid data.
* @param register The address of the register where the callback function was invoked.
* @param returnData The invalid return data received from the callback function.
*/
error ErrInvalidReturnData(bytes4 callbackFnSig, address register, bytes returnData);
/**
* @dev Error of set to non-contract.
*/
error ErrZeroCodeContract(address addr);
/**
* @dev Error indicating that arguments are invalid.
*/
error ErrInvalidArguments(bytes4 msgSig);
/**
* @dev Error indicating that given address is null when it should not.
*/
error ErrZeroAddress(bytes4 msgSig);
/**
* @dev Error indicating that the provided threshold is invalid for a specific function signature.
* @param msgSig The function signature (bytes4) that the invalid threshold applies to.
*/
error ErrInvalidThreshold(bytes4 msgSig);
/**
* @dev Error indicating that a function can only be called by the contract itself.
* @param msgSig The function signature (bytes4) that can only be called by the contract itself.
*/
error ErrOnlySelfCall(bytes4 msgSig);
/**
* @dev Error indicating that the caller is unauthorized to perform a specific function.
* @param msgSig The function signature (bytes4) that the caller is unauthorized to perform.
* @param expectedRole The role required to perform the function.
*/
error ErrUnauthorized(bytes4 msgSig, RoleAccess expectedRole);
/**
* @dev Error indicating that the caller is unauthorized to perform a specific function.
* @param msgSig The function signature (bytes4) that the caller is unauthorized to perform.
*/
error ErrUnauthorizedCall(bytes4 msgSig);
/**
* @dev Error indicating that the caller is unauthorized to perform a specific function.
* @param msgSig The function signature (bytes4).
* @param expectedContractType The contract type required to perform the function.
* @param actual The actual address that called to the function.
*/
error ErrUnexpectedInternalCall(bytes4 msgSig, ContractType expectedContractType, address actual);
/**
* @dev Error indicating that an array is empty when it should contain elements.
*/
error ErrEmptyArray();
/**
* @dev Error indicating a mismatch in the length of input parameters or arrays for a specific function.
* @param msgSig The function signature (bytes4) that has a length mismatch.
*/
error ErrLengthMismatch(bytes4 msgSig);
/**
* @dev Error indicating that a proxy call to an external contract has failed.
* @param msgSig The function signature (bytes4) of the proxy call that failed.
* @param extCallSig The function signature (bytes4) of the external contract call that failed.
*/
error ErrProxyCallFailed(bytes4 msgSig, bytes4 extCallSig);
/**
* @dev Error indicating that a function tried to call a precompiled contract that is not allowed.
* @param msgSig The function signature (bytes4) that attempted to call a precompiled contract.
*/
error ErrCallPrecompiled(bytes4 msgSig);
/**
* @dev Error indicating that a native token transfer has failed.
* @param msgSig The function signature (bytes4) of the token transfer that failed.
*/
error ErrNativeTransferFailed(bytes4 msgSig);
/**
* @dev Error indicating that an order is invalid.
* @param msgSig The function signature (bytes4) of the operation that encountered an invalid order.
*/
error ErrInvalidOrder(bytes4 msgSig);
/**
* @dev Error indicating that the chain ID is invalid.
* @param msgSig The function signature (bytes4) of the operation that encountered an invalid chain ID.
* @param actual Current chain ID that executing function.
* @param expected Expected chain ID required for the tx to success.
*/
error ErrInvalidChainId(bytes4 msgSig, uint256 actual, uint256 expected);
/**
* @dev Error indicating that a vote type is not supported.
* @param msgSig The function signature (bytes4) of the operation that encountered an unsupported vote type.
*/
error ErrUnsupportedVoteType(bytes4 msgSig);
/**
* @dev Error indicating that the proposal nonce is invalid.
* @param msgSig The function signature (bytes4) of the operation that encountered an invalid proposal nonce.
*/
error ErrInvalidProposalNonce(bytes4 msgSig);
/**
* @dev Error indicating that a voter has already voted.
* @param voter The address of the voter who has already voted.
*/
error ErrAlreadyVoted(address voter);
/**
* @dev Error indicating that a signature is invalid for a specific function signature.
* @param msgSig The function signature (bytes4) that encountered an invalid signature.
*/
error ErrInvalidSignatures(bytes4 msgSig);
/**
* @dev Error indicating that a relay call has failed.
* @param msgSig The function signature (bytes4) of the relay call that failed.
*/
error ErrRelayFailed(bytes4 msgSig);
/**
* @dev Error indicating that a vote weight is invalid for a specific function signature.
* @param msgSig The function signature (bytes4) that encountered an invalid vote weight.
*/
error ErrInvalidVoteWeight(bytes4 msgSig);
/**
* @dev Error indicating that a query was made for an outdated bridge operator set.
*/
error ErrQueryForOutdatedBridgeOperatorSet();
/**
* @dev Error indicating that a request is invalid.
*/
error ErrInvalidRequest();
/**
* @dev Error indicating that a token standard is invalid.
*/
error ErrInvalidTokenStandard();
/**
* @dev Error indicating that a token is not supported.
*/
error ErrUnsupportedToken();
/**
* @dev Error indicating that a receipt kind is invalid.
*/
error ErrInvalidReceiptKind();
/**
* @dev Error indicating that a receipt is invalid.
*/
error ErrInvalidReceipt();
/**
* @dev Error indicating that an address is not payable.
*/
error ErrNonpayableAddress(address);
/**
* @dev Error indicating that the period is already processed, i.e. scattered reward.
*/
error ErrPeriodAlreadyProcessed(uint256 requestingPeriod, uint256 latestPeriod);
/**
* @dev Error thrown when an invalid vote hash is provided.
*/
error ErrInvalidVoteHash();
/**
* @dev Error thrown when querying for an empty vote.
*/
error ErrQueryForEmptyVote();
/**
* @dev Error thrown when querying for an expired vote.
*/
error ErrQueryForExpiredVote();
/**
* @dev Error thrown when querying for a non-existent vote.
*/
error ErrQueryForNonExistentVote();
/**
* @dev Error indicating that the method is only called once per block.
*/
error ErrOncePerBlock();
/**
* @dev Error of method caller must be coinbase
*/
error ErrCallerMustBeCoinbase();
/**
* @dev Error thrown when an invalid proposal is encountered.
* @param actual The actual value of the proposal.
* @param expected The expected value of the proposal.
*/
error ErrInvalidProposal(bytes32 actual, bytes32 expected);
/**
* @dev Error of proposal is not approved for executing.
*/
error ErrProposalNotApproved();
/**
* @dev Error of the caller is not the specified executor.
*/
error ErrInvalidExecutor();
/**
* @dev Error of the `caller` to relay is not the specified `executor`.
*/
error ErrNonExecutorCannotRelay(address executor, address caller);// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IWETH {
event Transfer(address indexed src, address indexed dst, uint wad);
function deposit() external payable;
function transfer(address dst, uint wad) external returns (bool);
function approve(address guy, uint wad) external returns (bool);
function transferFrom(address src, address dst, uint wad) external returns (bool);
function withdraw(uint256 _wad) external;
function balanceOf(address) external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/security/Pausable.sol";
import "../interfaces/IQuorum.sol";
import "./collections/HasProxyAdmin.sol";
abstract contract GatewayV3 is HasProxyAdmin, Pausable, IQuorum {
uint256 internal _num;
uint256 internal _denom;
address private ______deprecated;
uint256 public nonce;
address public emergencyPauser;
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
*/
uint256[49] private ______gap;
/**
* @dev Grant emergency pauser role for `_addr`.
*/
function setEmergencyPauser(address _addr) external onlyProxyAdmin {
emergencyPauser = _addr;
}
/**
* @inheritdoc IQuorum
*/
function getThreshold() external view virtual returns (uint256 num_, uint256 denom_) {
return (_num, _denom);
}
/**
* @inheritdoc IQuorum
*/
function checkThreshold(uint256 _voteWeight) external view virtual returns (bool) {
return _voteWeight * _denom >= _num * _getTotalWeight();
}
/**
* @inheritdoc IQuorum
*/
function setThreshold(uint256 _numerator, uint256 _denominator) external virtual onlyProxyAdmin {
return _setThreshold(_numerator, _denominator);
}
/**
* @dev Triggers paused state.
*/
function pause() external {
_requireAuth();
_pause();
}
/**
* @dev Triggers unpaused state.
*/
function unpause() external {
_requireAuth();
_unpause();
}
/**
* @inheritdoc IQuorum
*/
function minimumVoteWeight() public view virtual returns (uint256) {
return _minimumVoteWeight(_getTotalWeight());
}
/**
* @dev Sets threshold and returns the old one.
*
* Emits the `ThresholdUpdated` event.
*
*/
function _setThreshold(uint256 num, uint256 denom) internal virtual {
if (num > denom) revert ErrInvalidThreshold(msg.sig);
uint256 prevNum = _num;
uint256 prevDenom = _denom;
_num = num;
_denom = denom;
unchecked {
emit ThresholdUpdated(nonce++, num, denom, prevNum, prevDenom);
}
}
/**
* @dev Returns minimum vote weight.
*/
function _minimumVoteWeight(uint256 _totalWeight) internal view virtual returns (uint256) {
return (_num * _totalWeight + _denom - 1) / _denom;
}
/**
* @dev Internal method to check method caller.
*
* Requirements:
*
* - The method caller must be admin or pauser.
*
*/
function _requireAuth() private view {
if (!(msg.sender == _getProxyAdmin() || msg.sender == emergencyPauser)) {
revert ErrUnauthorized(msg.sig, RoleAccess.ADMIN);
}
}
/**
* @dev Returns the total weight.
*/
function _getTotalWeight() internal view virtual returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../Strings.sol";
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC1155/presets/ERC1155PresetMinterPauser.sol";
import "../interfaces/IWETH.sol";
enum TokenStandard {
ERC20,
ERC721,
ERC1155
}
struct TokenInfo {
TokenStandard erc;
// For ERC20: the id must be 0 and the quantity is larger than 0.
// For ERC721: the quantity must be 0.
uint256 id;
uint256 quantity;
}
/**
* @dev Error indicating that the `transfer` has failed.
* @param tokenInfo Info of the token including ERC standard, id or quantity.
* @param to Receiver of the token value.
* @param token Address of the token.
*/
error ErrTokenCouldNotTransfer(TokenInfo tokenInfo, address to, address token);
/**
* @dev Error indicating that the `handleAssetIn` has failed.
* @param tokenInfo Info of the token including ERC standard, id or quantity.
* @param from Owner of the token value.
* @param to Receiver of the token value.
* @param token Address of the token.
*/
error ErrTokenCouldNotTransferFrom(TokenInfo tokenInfo, address from, address to, address token);
/// @dev Error indicating that the provided information is invalid.
error ErrInvalidInfo();
/// @dev Error indicating that the minting of ERC20 tokens has failed.
error ErrERC20MintingFailed();
/// @dev Error indicating that the minting of ERC721 tokens has failed.
error ErrERC721MintingFailed();
/// @dev Error indicating that the transfer of ERC1155 tokens has failed.
error ErrERC1155TransferFailed();
/// @dev Error indicating that the mint of ERC1155 tokens has failed.
error ErrERC1155MintingFailed();
/// @dev Error indicating that an unsupported standard is encountered.
error ErrUnsupportedStandard();
library LibTokenInfo {
/**
*
* HASH
*
*/
// keccak256("TokenInfo(uint8 erc,uint256 id,uint256 quantity)");
bytes32 public constant INFO_TYPE_HASH_SINGLE = 0x1e2b74b2a792d5c0f0b6e59b037fa9d43d84fbb759337f0112fcc15ca414fc8d;
/**
* @dev Returns token info struct hash.
*/
function hash(TokenInfo memory self) internal pure returns (bytes32 digest) {
// keccak256(abi.encode(INFO_TYPE_HASH_SINGLE, info.erc, info.id, info.quantity))
assembly ("memory-safe") {
let ptr := mload(0x40)
mstore(ptr, INFO_TYPE_HASH_SINGLE)
mstore(add(ptr, 0x20), mload(self)) // info.erc
mstore(add(ptr, 0x40), mload(add(self, 0x20))) // info.id
mstore(add(ptr, 0x60), mload(add(self, 0x40))) // info.quantity
digest := keccak256(ptr, 0x80)
}
}
/**
*
* VALIDATE
*
*/
/**
* @dev Validates the token info.
*/
function validate(TokenInfo memory self) internal pure {
if (!(_checkERC20(self) || _checkERC721(self) || _checkERC1155(self))) {
revert ErrInvalidInfo();
}
}
function _checkERC20(TokenInfo memory self) private pure returns (bool) {
return (self.erc == TokenStandard.ERC20 && self.quantity > 0 && self.id == 0);
}
function _checkERC721(TokenInfo memory self) private pure returns (bool) {
return (self.erc == TokenStandard.ERC721 && self.quantity == 0);
}
function _checkERC1155(TokenInfo memory self) private pure returns (bool res) {
// Only validate the quantity, because id of ERC-1155 can be 0.
return (self.erc == TokenStandard.ERC1155 && self.quantity > 0);
}
/**
*
* TRANSFER IN/OUT METHOD
*
*/
/**
* @dev Transfer asset in.
*
* Requirements:
* - The `_from` address must approve for the contract using this library.
*
*/
function handleAssetIn(TokenInfo memory self, address from, address token) internal {
bool success;
bytes memory data;
if (self.erc == TokenStandard.ERC20) {
(success, data) = token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, address(this), self.quantity));
success = success && (data.length == 0 || abi.decode(data, (bool)));
} else if (self.erc == TokenStandard.ERC721) {
success = _tryTransferFromERC721(token, from, address(this), self.id);
} else if (self.erc == TokenStandard.ERC1155) {
success = _tryTransferFromERC1155(token, from, address(this), self.id, self.quantity);
} else {
revert ErrUnsupportedStandard();
}
if (!success) revert ErrTokenCouldNotTransferFrom(self, from, address(this), token);
}
/**
* @dev Tries transfer assets out, or mint the assets if cannot transfer.
*
* @notice Prioritizes transfer native token if the token is wrapped.
*
*/
function handleAssetOut(TokenInfo memory self, address payable to, address token, IWETH wrappedNativeToken) internal {
if (token == address(wrappedNativeToken)) {
// Try sending the native token before transferring the wrapped token
if (!to.send(self.quantity)) {
wrappedNativeToken.deposit{ value: self.quantity }();
_transferTokenOut(self, to, token);
}
return;
}
if (self.erc == TokenStandard.ERC20) {
uint256 balance = IERC20(token).balanceOf(address(this));
if (balance < self.quantity) {
if (!_tryMintERC20(token, address(this), self.quantity - balance)) revert ErrERC20MintingFailed();
}
_transferTokenOut(self, to, token);
return;
}
if (self.erc == TokenStandard.ERC721) {
if (!_tryTransferOutOrMintERC721(token, to, self.id)) {
revert ErrERC721MintingFailed();
}
return;
}
if (self.erc == TokenStandard.ERC1155) {
if (!_tryTransferOutOrMintERC1155(token, to, self.id, self.quantity)) {
revert ErrERC1155MintingFailed();
}
return;
}
revert ErrUnsupportedStandard();
}
/**
*
* TRANSFER HELPERS
*
*/
/**
* @dev Transfer assets from current address to `_to` address.
*/
function _transferTokenOut(TokenInfo memory self, address to, address token) private {
bool success;
if (self.erc == TokenStandard.ERC20) {
success = _tryTransferERC20(token, to, self.quantity);
} else if (self.erc == TokenStandard.ERC721) {
success = _tryTransferFromERC721(token, address(this), to, self.id);
} else {
revert ErrUnsupportedStandard();
}
if (!success) revert ErrTokenCouldNotTransfer(self, to, token);
}
/**
* TRANSFER ERC-20
*/
/**
* @dev Transfers ERC20 token and returns the result.
*/
function _tryTransferERC20(address token, address to, uint256 quantity) private returns (bool success) {
bytes memory data;
(success, data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, quantity));
success = success && (data.length == 0 || abi.decode(data, (bool)));
}
/**
* @dev Mints ERC20 token and returns the result.
*/
function _tryMintERC20(address token, address to, uint256 quantity) private returns (bool success) {
// bytes4(keccak256("mint(address,uint256)"))
(success,) = token.call(abi.encodeWithSelector(0x40c10f19, to, quantity));
}
/**
* TRANSFER ERC-721
*/
/**
* @dev Transfers the ERC721 token out. If the transfer failed, mints the ERC721.
* @return success Returns `false` if both transfer and mint are failed.
*/
function _tryTransferOutOrMintERC721(address token, address to, uint256 id) private returns (bool success) {
success = _tryTransferFromERC721(token, address(this), to, id);
if (!success) {
return _tryMintERC721(token, to, id);
}
}
/**
* @dev Transfers ERC721 token and returns the result.
*/
function _tryTransferFromERC721(address token, address from, address to, uint256 id) private returns (bool success) {
(success,) = token.call(abi.encodeWithSelector(IERC721.transferFrom.selector, from, to, id));
}
/**
* @dev Mints ERC721 token and returns the result.
*/
function _tryMintERC721(address token, address to, uint256 id) private returns (bool success) {
// bytes4(keccak256("mint(address,uint256)"))
(success,) = token.call(abi.encodeWithSelector(0x40c10f19, to, id));
}
/**
* TRANSFER ERC-1155
*/
/**
* @dev Transfers the ERC1155 token out. If the transfer failed, mints the ERC11555.
* @return success Returns `false` if both transfer and mint are failed.
*/
function _tryTransferOutOrMintERC1155(address token, address to, uint256 id, uint256 amount) private returns (bool success) {
success = _tryTransferFromERC1155(token, address(this), to, id, amount);
if (!success) {
return _tryMintERC1155(token, to, id, amount);
}
}
/**
* @dev Transfers ERC1155 token and returns the result.
*/
function _tryTransferFromERC1155(address token, address from, address to, uint256 id, uint256 amount) private returns (bool success) {
(success,) = token.call(abi.encodeCall(IERC1155.safeTransferFrom, (from, to, id, amount, new bytes(0))));
}
/**
* @dev Mints ERC1155 token and returns the result.
*/
function _tryMintERC1155(address token, address to, uint256 id, uint256 amount) private returns (bool success) {
(success,) = token.call(abi.encodeCall(ERC1155PresetMinterPauser.mint, (to, id, amount, new bytes(0))));
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
struct TokenOwner {
address addr;
address tokenAddr;
uint256 chainId;
}
library LibTokenOwner {
// keccak256("TokenOwner(address addr,address tokenAddr,uint256 chainId)");
bytes32 public constant OWNER_TYPE_HASH = 0x353bdd8d69b9e3185b3972e08b03845c0c14a21a390215302776a7a34b0e8764;
/**
* @dev Returns ownership struct hash.
*/
function hash(TokenOwner memory owner) internal pure returns (bytes32 digest) {
// keccak256(abi.encode(OWNER_TYPE_HASH, owner.addr, owner.tokenAddr, owner.chainId))
assembly ("memory-safe") {
let ptr := mload(0x40)
mstore(ptr, OWNER_TYPE_HASH)
mstore(add(ptr, 0x20), mload(owner)) // owner.addr
mstore(add(ptr, 0x40), mload(add(owner, 0x20))) // owner.tokenAddr
mstore(add(ptr, 0x60), mload(add(owner, 0x40))) // owner.chainId
digest := keccak256(ptr, 0x80)
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface SignatureConsumer {
struct Signature {
uint8 v;
bytes32 r;
bytes32 s;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../../libraries/LibTokenInfo.sol";
interface MappedTokenConsumer {
struct MappedToken {
TokenStandard erc;
address tokenAddr;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev _Available since v3.1._
*/
interface IERC1155Receiver is IERC165 {
/**
* @dev Handles the receipt of a single ERC1155 token type. This function is
* called at the end of a `safeTransferFrom` after the balance has been updated.
*
* NOTE: To accept the transfer, this must return
* `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
* (i.e. 0xf23a6e61, or its own function selector).
*
* @param operator The address which initiated the transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param id The ID of the token being transferred
* @param value The amount of tokens being transferred
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
/**
* @dev Handles the receipt of a multiple ERC1155 token types. This function
* is called at the end of a `safeBatchTransferFrom` after the balances have
* been updated.
*
* NOTE: To accept the transfer(s), this must return
* `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
* (i.e. 0xbc197c81, or its own function selector).
*
* @param operator The address which initiated the batch transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param ids An array containing ids of each token being transferred (order and length must match values array)
* @param values An array containing amounts of each token being transferred (order and length must match ids array)
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
enum ContractType {
UNKNOWN, // 0
PAUSE_ENFORCER, // 1
BRIDGE, // 2
BRIDGE_TRACKING, // 3
GOVERNANCE_ADMIN, // 4
MAINTENANCE, // 5
SLASH_INDICATOR, // 6
STAKING_VESTING, // 7
VALIDATOR, // 8
STAKING, // 9
RONIN_TRUSTED_ORGANIZATION, // 10
BRIDGE_MANAGER, // 11
BRIDGE_SLASH, // 12
BRIDGE_REWARD, // 13
FAST_FINALITY_TRACKING, // 14
PROFILE // 15
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
library AddressArrayUtils {
/**
* @dev Error thrown when a duplicated element is detected in an array.
* @param msgSig The function signature that invoke the error.
*/
error ErrDuplicated(bytes4 msgSig);
/**
* @dev Returns whether or not there's a duplicate. Runs in O(n^2).
* @param A Array to search
* @return Returns true if duplicate, false otherwise
*/
function hasDuplicate(address[] memory A) internal pure returns (bool) {
if (A.length == 0) {
return false;
}
unchecked {
for (uint256 i = 0; i < A.length - 1; i++) {
for (uint256 j = i + 1; j < A.length; j++) {
if (A[i] == A[j]) {
return true;
}
}
}
}
return false;
}
/**
* @dev Returns whether two arrays of addresses are equal or not.
*/
function isEqual(address[] memory _this, address[] memory _other) internal pure returns (bool yes_) {
// Hashing two arrays and compare their hash
assembly {
let _thisHash := keccak256(add(_this, 32), mul(mload(_this), 32))
let _otherHash := keccak256(add(_other, 32), mul(mload(_other), 32))
yes_ := eq(_thisHash, _otherHash)
}
}
/**
* @dev Return the concatenated array from a and b.
*/
function extend(address[] memory a, address[] memory b) internal pure returns (address[] memory c) {
uint256 lengthA = a.length;
uint256 lengthB = b.length;
unchecked {
c = new address[](lengthA + lengthB);
}
uint256 i;
for (; i < lengthA;) {
c[i] = a[i];
unchecked {
++i;
}
}
for (uint256 j; j < lengthB;) {
c[i] = b[j];
unchecked {
++i;
++j;
}
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
contract TransparentUpgradeableProxyV2 is TransparentUpgradeableProxy {
constructor(address _logic, address admin_, bytes memory _data) payable TransparentUpgradeableProxy(_logic, admin_, _data) { }
/**
* @dev Calls a function from the current implementation as specified by `_data`, which should be an encoded function call.
*
* Requirements:
* - Only the admin can call this function.
*
* Note: The proxy admin is not allowed to interact with the proxy logic through the fallback function to avoid
* triggering some unexpected logic. This is to allow the administrator to explicitly call the proxy, please consider
* reviewing the encoded data `_data` and the method which is called before using this.
*
*/
function functionDelegateCall(bytes memory _data) public payable ifAdmin {
address _addr = _implementation();
assembly {
let _result := delegatecall(gas(), _addr, add(_data, 32), mload(_data), 0, 0)
returndatacopy(0, 0, returndatasize())
switch _result
case 0 { revert(0, returndatasize()) }
default { return(0, returndatasize()) }
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
enum RoleAccess {
UNKNOWN, // 0
ADMIN, // 1
COINBASE, // 2
GOVERNOR, // 3
CANDIDATE_ADMIN, // 4
WITHDRAWAL_MIGRATOR, // 5
__DEPRECATED_BRIDGE_OPERATOR, // 6
BLOCK_PRODUCER, // 7
VALIDATOR_CANDIDATE, // 8
CONSENSUS, // 9
TREASURY // 10
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IQuorum {
/// @dev Emitted when the threshold is updated
event ThresholdUpdated(uint256 indexed nonce, uint256 indexed numerator, uint256 indexed denominator, uint256 previousNumerator, uint256 previousDenominator);
/**
* @dev Returns the threshold.
*/
function getThreshold() external view returns (uint256 _num, uint256 _denom);
/**
* @dev Checks whether the `_voteWeight` passes the threshold.
*/
function checkThreshold(uint256 _voteWeight) external view returns (bool);
/**
* @dev Returns the minimum vote weight to pass the threshold.
*/
function minimumVoteWeight() external view returns (uint256);
/**
* @dev Sets the threshold.
*
* Requirements:
* - The method caller is admin.
*
* Emits the `ThresholdUpdated` event.
*
*/
function setThreshold(uint256 numerator, uint256 denominator) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*
* _Available since v3.1._
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
external
view
returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/presets/ERC1155PresetMinterPauser.sol)
pragma solidity ^0.8.0;
import "../ERC1155.sol";
import "../extensions/ERC1155Burnable.sol";
import "../extensions/ERC1155Pausable.sol";
import "../../../access/AccessControlEnumerable.sol";
import "../../../utils/Context.sol";
/**
* @dev {ERC1155} token, including:
*
* - ability for holders to burn (destroy) their tokens
* - a minter role that allows for token minting (creation)
* - a pauser role that allows to stop all token transfers
*
* This contract uses {AccessControl} to lock permissioned functions using the
* different roles - head to its documentation for details.
*
* The account that deploys the contract will be granted the minter and pauser
* roles, as well as the default admin role, which will let it grant both minter
* and pauser roles to other accounts.
*
* _Deprecated in favor of https://wizard.openzeppelin.com/[Contracts Wizard]._
*/
contract ERC1155PresetMinterPauser is Context, AccessControlEnumerable, ERC1155Burnable, ERC1155Pausable {
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
/**
* @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE`, and `PAUSER_ROLE` to the account that
* deploys the contract.
*/
constructor(string memory uri) ERC1155(uri) {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_setupRole(MINTER_ROLE, _msgSender());
_setupRole(PAUSER_ROLE, _msgSender());
}
/**
* @dev Creates `amount` new tokens for `to`, of token type `id`.
*
* See {ERC1155-_mint}.
*
* Requirements:
*
* - the caller must have the `MINTER_ROLE`.
*/
function mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual {
require(hasRole(MINTER_ROLE, _msgSender()), "ERC1155PresetMinterPauser: must have minter role to mint");
_mint(to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] variant of {mint}.
*/
function mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual {
require(hasRole(MINTER_ROLE, _msgSender()), "ERC1155PresetMinterPauser: must have minter role to mint");
_mintBatch(to, ids, amounts, data);
}
/**
* @dev Pauses all token transfers.
*
* See {ERC1155Pausable} and {Pausable-_pause}.
*
* Requirements:
*
* - the caller must have the `PAUSER_ROLE`.
*/
function pause() public virtual {
require(hasRole(PAUSER_ROLE, _msgSender()), "ERC1155PresetMinterPauser: must have pauser role to pause");
_pause();
}
/**
* @dev Unpauses all token transfers.
*
* See {ERC1155Pausable} and {Pausable-_unpause}.
*
* Requirements:
*
* - the caller must have the `PAUSER_ROLE`.
*/
function unpause() public virtual {
require(hasRole(PAUSER_ROLE, _msgSender()), "ERC1155PresetMinterPauser: must have pauser role to unpause");
_unpause();
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(AccessControlEnumerable, ERC1155)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual override(ERC1155, ERC1155Pausable) {
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)
pragma solidity ^0.8.0;
import "../ERC1967/ERC1967Proxy.sol";
/**
* @dev This contract implements a proxy that is upgradeable by an admin.
*
* To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
* clashing], which can potentially be used in an attack, this contract uses the
* https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
* things that go hand in hand:
*
* 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
* that call matches one of the admin functions exposed by the proxy itself.
* 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
* implementation. If the admin tries to call a function on the implementation it will fail with an error that says
* "admin cannot fallback to proxy target".
*
* These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
* the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
* to sudden errors when trying to call a function from the proxy implementation.
*
* Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
* you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
*/
contract TransparentUpgradeableProxy is ERC1967Proxy {
/**
* @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
* optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
*/
constructor(
address _logic,
address admin_,
bytes memory _data
) payable ERC1967Proxy(_logic, _data) {
_changeAdmin(admin_);
}
/**
* @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
*/
modifier ifAdmin() {
if (msg.sender == _getAdmin()) {
_;
} else {
_fallback();
}
}
/**
* @dev Returns the current admin.
*
* NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
* https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function admin() external ifAdmin returns (address admin_) {
admin_ = _getAdmin();
}
/**
* @dev Returns the current implementation.
*
* NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
* https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
*/
function implementation() external ifAdmin returns (address implementation_) {
implementation_ = _implementation();
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*
* NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.
*/
function changeAdmin(address newAdmin) external virtual ifAdmin {
_changeAdmin(newAdmin);
}
/**
* @dev Upgrade the implementation of the proxy.
*
* NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.
*/
function upgradeTo(address newImplementation) external ifAdmin {
_upgradeToAndCall(newImplementation, bytes(""), false);
}
/**
* @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
* by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
* proxied contract.
*
* NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.
*/
function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {
_upgradeToAndCall(newImplementation, data, true);
}
/**
* @dev Returns the current admin.
*/
function _admin() internal view virtual returns (address) {
return _getAdmin();
}
/**
* @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.
*/
function _beforeFallback() internal virtual override {
require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target");
super._beforeFallback();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/ERC1155.sol)
pragma solidity ^0.8.0;
import "./IERC1155.sol";
import "./IERC1155Receiver.sol";
import "./extensions/IERC1155MetadataURI.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of the basic standard multi-token.
* See https://eips.ethereum.org/EIPS/eip-1155
* Originally based on code by Enjin: https://github.com/enjin/erc-1155
*
* _Available since v3.1._
*/
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
using Address for address;
// Mapping from token ID to account balances
mapping(uint256 => mapping(address => uint256)) private _balances;
// Mapping from account to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string private _uri;
/**
* @dev See {_setURI}.
*/
constructor(string memory uri_) {
_setURI(uri_);
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the same URI for *all* token types. It relies
* on the token type ID substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/
function uri(uint256) public view virtual override returns (string memory) {
return _uri;
}
/**
* @dev See {IERC1155-balanceOf}.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
require(account != address(0), "ERC1155: address zero is not a valid owner");
return _balances[id][account];
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
public
view
virtual
override
returns (uint256[] memory)
{
require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts[i], ids[i]);
}
return batchBalances;
}
/**
* @dev See {IERC1155-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC1155-isApprovedForAll}.
*/
function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
return _operatorApprovals[account][operator];
}
/**
* @dev See {IERC1155-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not token owner nor approved"
);
_safeTransferFrom(from, to, id, amount, data);
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not token owner nor approved"
);
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
emit TransferSingle(operator, from, to, id, amount);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
}
emit TransferBatch(operator, from, to, ids, amounts);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
}
/**
* @dev Sets a new URI for all token types, by relying on the token type ID
* substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* By this mechanism, any occurrence of the `\{id\}` substring in either the
* URI or any of the amounts in the JSON file at said URI will be replaced by
* clients with the token type ID.
*
* For example, the `https://token-cdn-domain/\{id\}.json` URI would be
* interpreted by clients as
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
* for token type ID 0x4cce0.
*
* See {uri}.
*
* Because these URIs cannot be meaningfully represented by the {URI} event,
* this function emits no events.
*/
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
_balances[id][to] += amount;
emit TransferSingle(operator, address(0), to, id, amount);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; i++) {
_balances[ids[i]][to] += amounts[i];
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
/**
* @dev Destroys `amount` tokens of token type `id` from `from`
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `amount` tokens of token type `id`.
*/
function _burn(
address from,
uint256 id,
uint256 amount
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
emit TransferSingle(operator, from, address(0), id, amount);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
*/
function _burnBatch(
address from,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC1155: setting approval status for self");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `ids` and `amounts` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
/**
* @dev Hook that is called after any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `id` and `amount` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
function _doSafeTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non ERC1155Receiver implementer");
}
}
}
function _doSafeBatchTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non ERC1155Receiver implementer");
}
}
}
function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/extensions/ERC1155Burnable.sol)
pragma solidity ^0.8.0;
import "../ERC1155.sol";
/**
* @dev Extension of {ERC1155} that allows token holders to destroy both their
* own tokens and those that they have been approved to use.
*
* _Available since v3.1._
*/
abstract contract ERC1155Burnable is ERC1155 {
function burn(
address account,
uint256 id,
uint256 value
) public virtual {
require(
account == _msgSender() || isApprovedForAll(account, _msgSender()),
"ERC1155: caller is not token owner nor approved"
);
_burn(account, id, value);
}
function burnBatch(
address account,
uint256[] memory ids,
uint256[] memory values
) public virtual {
require(
account == _msgSender() || isApprovedForAll(account, _msgSender()),
"ERC1155: caller is not token owner nor approved"
);
_burnBatch(account, ids, values);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/ERC1155Pausable.sol)
pragma solidity ^0.8.0;
import "../ERC1155.sol";
import "../../../security/Pausable.sol";
/**
* @dev ERC1155 token with pausable token transfers, minting and burning.
*
* Useful for scenarios such as preventing trades until the end of an evaluation
* period, or having an emergency switch for freezing all token transfers in the
* event of a large bug.
*
* _Available since v3.1._
*/
abstract contract ERC1155Pausable is ERC1155, Pausable {
/**
* @dev See {ERC1155-_beforeTokenTransfer}.
*
* Requirements:
*
* - the contract must not be paused.
*/
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual override {
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
require(!paused(), "ERC1155Pausable: token transfer while paused");
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)
pragma solidity ^0.8.0;
import "../Proxy.sol";
import "./ERC1967Upgrade.sol";
/**
* @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
* implementation address that can be changed. This address is stored in storage in the location specified by
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
* implementation behind the proxy.
*/
contract ERC1967Proxy is Proxy, ERC1967Upgrade {
/**
* @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
*
* If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
* function call, and allows initializing the storage of the proxy like a Solidity constructor.
*/
constructor(address _logic, bytes memory _data) payable {
_upgradeToAndCall(_logic, _data, false);
}
/**
* @dev Returns the current implementation address.
*/
function _implementation() internal view virtual override returns (address impl) {
return ERC1967Upgrade._getImplementation();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)
pragma solidity ^0.8.0;
import "../IERC1155.sol";
/**
* @dev Interface of the optional ERC1155MetadataExtension interface, as defined
* in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
*
* _Available since v3.1._
*/
interface IERC1155MetadataURI is IERC1155 {
/**
* @dev Returns the URI for token type `id`.
*
* If the `\{id\}` substring is present in the URI, it must be replaced by
* clients with the actual token type ID.
*/
function uri(uint256 id) external view returns (string memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)
pragma solidity ^0.8.0;
/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/
abstract contract Proxy {
/**
* @dev Delegates the current call to `implementation`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _delegate(address implementation) internal virtual {
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @dev This is a virtual function that should be overridden so it returns the address to which the fallback function
* and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
* function in the contract matches the call data.
*/
fallback() external payable virtual {
_fallback();
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
* is empty.
*/
receive() external payable virtual {
_fallback();
}
/**
* @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
* call, or as part of the Solidity `fallback` or `receive` functions.
*
* If overridden should call `super._beforeFallback()`.
*/
function _beforeFallback() internal virtual {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)
pragma solidity ^0.8.2;
import "../beacon/IBeacon.sol";
import "../../interfaces/draft-IERC1822.sol";
import "../../utils/Address.sol";
import "../../utils/StorageSlot.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*
* _Available since v4.1._
*
* @custom:oz-upgrades-unsafe-allow delegatecall
*/
abstract contract ERC1967Upgrade {
// This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Returns the current implementation address.
*/
function _getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Perform implementation upgrade
*
* Emits an {Upgraded} event.
*/
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
/**
* @dev Perform implementation upgrade with additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCall(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
_upgradeTo(newImplementation);
if (data.length > 0 || forceCall) {
Address.functionDelegateCall(newImplementation, data);
}
}
/**
* @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCallUUPS(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
// Upgrades from old implementations will perform a rollback test. This test requires the new
// implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
// this special case will break upgrade paths from old UUPS implementation to new ones.
if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {
_setImplementation(newImplementation);
} else {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
} catch {
revert("ERC1967Upgrade: new implementation is not UUPS");
}
_upgradeToAndCall(newImplementation, data, forceCall);
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Returns the current admin.
*/
function _getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*/
function _changeAdmin(address newAdmin) internal {
emit AdminChanged(_getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
*/
bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Emitted when the beacon is upgraded.
*/
event BeaconUpgraded(address indexed beacon);
/**
* @dev Returns the current beacon.
*/
function _getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
require(
Address.isContract(IBeacon(newBeacon).implementation()),
"ERC1967: beacon implementation is not a contract"
);
StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
}
/**
* @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
* not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
*
* Emits a {BeaconUpgraded} event.
*/
function _upgradeBeaconToAndCall(
address newBeacon,
bytes memory data,
bool forceCall
) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0 || forceCall) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.0;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {BeaconProxy} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}{
"remappings": [
"forge-std/=dependencies/@fdk-0.3.1-beta/dependencies/@forge-std-1.9.1/src/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"hardhat/=node_modules/hardhat/",
"@ronin/contracts/=src/",
"@ronin/test/=test/",
"@ronin/script/=script/",
"@prb/test/=lib/prb-test/src/",
"@prb/math/=lib/prb-math/",
"solady/=dependencies/@fdk-0.3.1-beta/dependencies/@solady-0.0.228/src/",
"@fdk/=dependencies/@fdk-0.3.1-beta/script/",
"@fdk-0.3.1-beta/=dependencies/@fdk-0.3.1-beta/",
"ds-test/=lib/prb-math/lib/forge-std/lib/ds-test/src/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"prb-math/=lib/prb-math/src/",
"prb-test/=lib/prb-test/src/",
"sample-projects/=node_modules/hardhat/sample-projects/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": true,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "istanbul",
"viaIR": false,
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"enum ContractType","name":"contractType","type":"uint8"}],"name":"ErrContractTypeNotFound","type":"error"},{"inputs":[],"name":"ErrERC1155MintingFailed","type":"error"},{"inputs":[],"name":"ErrERC20MintingFailed","type":"error"},{"inputs":[],"name":"ErrERC721MintingFailed","type":"error"},{"inputs":[],"name":"ErrEmptyArray","type":"error"},{"inputs":[{"internalType":"bytes4","name":"msgSig","type":"bytes4"},{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"expected","type":"uint256"}],"name":"ErrInvalidChainId","type":"error"},{"inputs":[],"name":"ErrInvalidInfo","type":"error"},{"inputs":[{"internalType":"bytes4","name":"msgSig","type":"bytes4"}],"name":"ErrInvalidOrder","type":"error"},{"inputs":[],"name":"ErrInvalidPercentage","type":"error"},{"inputs":[],"name":"ErrInvalidReceipt","type":"error"},{"inputs":[],"name":"ErrInvalidReceiptKind","type":"error"},{"inputs":[],"name":"ErrInvalidRequest","type":"error"},{"inputs":[{"internalType":"bytes4","name":"msgSig","type":"bytes4"}],"name":"ErrInvalidThreshold","type":"error"},{"inputs":[],"name":"ErrInvalidTokenStandard","type":"error"},{"inputs":[{"internalType":"bytes4","name":"msgSig","type":"bytes4"}],"name":"ErrLengthMismatch","type":"error"},{"inputs":[],"name":"ErrQueryForApprovedWithdrawal","type":"error"},{"inputs":[],"name":"ErrQueryForInsufficientVoteWeight","type":"error"},{"inputs":[],"name":"ErrQueryForProcessedWithdrawal","type":"error"},{"inputs":[],"name":"ErrReachedDailyWithdrawalLimit","type":"error"},{"inputs":[{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"internalType":"struct TokenInfo","name":"tokenInfo","type":"tuple"},{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"ErrTokenCouldNotTransfer","type":"error"},{"inputs":[{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"internalType":"struct TokenInfo","name":"tokenInfo","type":"tuple"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"ErrTokenCouldNotTransferFrom","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":"ErrUnsupportedStandard","type":"error"},{"inputs":[],"name":"ErrUnsupportedToken","type":"error"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"ErrZeroCodeContract","type":"error"},{"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":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"limits","type":"uint256[]"}],"name":"DailyWithdrawalLimitsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"receiptHash","type":"bytes32"},{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"enum Transfer.Kind","name":"kind","type":"uint8"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"mainchain","type":"tuple"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"ronin","type":"tuple"},{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"internalType":"struct TokenInfo","name":"info","type":"tuple"}],"indexed":false,"internalType":"struct Transfer.Receipt","name":"receipt","type":"tuple"}],"name":"DepositRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"thresholds","type":"uint256[]"}],"name":"HighTierThresholdsUpdated","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":"HighTierVoteWeightThresholdUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"thresholds","type":"uint256[]"}],"name":"LockedThresholdsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","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":[{"indexed":false,"internalType":"address[]","name":"mainchainTokens","type":"address[]"},{"indexed":false,"internalType":"address[]","name":"roninTokens","type":"address[]"},{"indexed":false,"internalType":"enum TokenStandard[]","name":"standards","type":"uint8[]"}],"name":"TokenMapped","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"percentages","type":"uint256[]"}],"name":"UnlockFeePercentagesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"receiptHash","type":"bytes32"},{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"enum Transfer.Kind","name":"kind","type":"uint8"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"mainchain","type":"tuple"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"ronin","type":"tuple"},{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"internalType":"struct TokenInfo","name":"info","type":"tuple"}],"indexed":false,"internalType":"struct Transfer.Receipt","name":"receipt","type":"tuple"}],"name":"WithdrawalLocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"receiptHash","type":"bytes32"},{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"enum Transfer.Kind","name":"kind","type":"uint8"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"mainchain","type":"tuple"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"ronin","type":"tuple"},{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"internalType":"struct TokenInfo","name":"info","type":"tuple"}],"indexed":false,"internalType":"struct Transfer.Receipt","name":"receipt","type":"tuple"}],"name":"WithdrawalUnlocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"receiptHash","type":"bytes32"},{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"enum Transfer.Kind","name":"kind","type":"uint8"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"mainchain","type":"tuple"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"ronin","type":"tuple"},{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"internalType":"struct TokenInfo","name":"info","type":"tuple"}],"indexed":false,"internalType":"struct Transfer.Receipt","name":"receipt","type":"tuple"}],"name":"Withdrew","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IWETH","name":"weth","type":"address"}],"name":"WrappedNativeTokenContractUpdated","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WITHDRAWAL_UNLOCKER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_MAX_PERCENTAGE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_voteWeight","type":"uint256"}],"name":"checkHighTierVoteWeightThreshold","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_voteWeight","type":"uint256"}],"name":"checkThreshold","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"dailyWithdrawalLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"depositCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emergencyPauser","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[],"name":"getHighTierVoteWeightThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"mainchainToken","type":"address"}],"name":"getRoninToken","outputs":[{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"address","name":"tokenAddr","type":"address"}],"internalType":"struct MappedTokenConsumer.MappedToken","name":"token","type":"tuple"}],"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":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"highTierThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_roleSetter","type":"address"},{"internalType":"contract IWETH","name":"_wrappedToken","type":"address"},{"internalType":"uint256","name":"_roninChainId","type":"uint256"},{"internalType":"uint256","name":"_numerator","type":"uint256"},{"internalType":"uint256","name":"_highTierVWNumerator","type":"uint256"},{"internalType":"uint256","name":"_denominator","type":"uint256"},{"internalType":"address[][3]","name":"_addresses","type":"address[][3]"},{"internalType":"uint256[][4]","name":"_thresholds","type":"uint256[][4]"},{"internalType":"enum TokenStandard[]","name":"_standards","type":"uint8[]"}],"name":"initialize","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"bridgeManagerContract","type":"address"}],"name":"initializeV2","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initializeV3","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"wethUnwrapper_","type":"address"}],"name":"initializeV4","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastDateSynced","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastSyncedWithdrawal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lockedThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_mainchainTokens","type":"address[]"},{"internalType":"address[]","name":"_roninTokens","type":"address[]"},{"internalType":"enum TokenStandard[]","name":"_standards","type":"uint8[]"}],"name":"mapTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_mainchainTokens","type":"address[]"},{"internalType":"address[]","name":"_roninTokens","type":"address[]"},{"internalType":"enum TokenStandard[]","name":"_standards","type":"uint8[]"},{"internalType":"uint256[][4]","name":"_thresholds","type":"uint256[][4]"}],"name":"mapTokensAndThresholds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"minimumVoteWeight","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"operators","type":"address[]"},{"internalType":"uint96[]","name":"weights","type":"uint96[]"},{"internalType":"bool[]","name":"addeds","type":"bool[]"}],"name":"onBridgeOperatorsAdded","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"operators","type":"address[]"},{"internalType":"bool[]","name":"removeds","type":"bool[]"}],"name":"onBridgeOperatorsRemoved","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_quantity","type":"uint256"}],"name":"reachedWithdrawalLimit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"receiveEther","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"recipientAddr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"internalType":"struct TokenInfo","name":"info","type":"tuple"}],"internalType":"struct Transfer.Request","name":"_request","type":"tuple"}],"name":"requestDepositFor","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"recipientAddr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"internalType":"struct TokenInfo","name":"info","type":"tuple"}],"internalType":"struct Transfer.Request[]","name":"_requests","type":"tuple[]"}],"name":"requestDepositForBatch","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"roninChainId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"address[]","name":"_tokens","type":"address[]"},{"internalType":"uint256[]","name":"_limits","type":"uint256[]"}],"name":"setDailyWithdrawalLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_addr","type":"address"}],"name":"setEmergencyPauser","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"uint256[]","name":"_thresholds","type":"uint256[]"}],"name":"setHighTierThresholds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_numerator","type":"uint256"},{"internalType":"uint256","name":"_denominator","type":"uint256"}],"name":"setHighTierVoteWeightThreshold","outputs":[{"internalType":"uint256","name":"_previousNum","type":"uint256"},{"internalType":"uint256","name":"_previousDenom","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"uint256[]","name":"_thresholds","type":"uint256[]"}],"name":"setLockedThresholds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"num","type":"uint256"},{"internalType":"uint256","name":"denom","type":"uint256"}],"name":"setThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"uint256[]","name":"_percentages","type":"uint256[]"}],"name":"setUnlockFeePercentages","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IWETH","name":"_wrappedToken","type":"address"}],"name":"setWrappedNativeTokenContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"enum Transfer.Kind","name":"kind","type":"uint8"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"mainchain","type":"tuple"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"ronin","type":"tuple"},{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"internalType":"struct TokenInfo","name":"info","type":"tuple"}],"internalType":"struct Transfer.Receipt","name":"_receipt","type":"tuple"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct SignatureConsumer.Signature[]","name":"_signatures","type":"tuple[]"}],"name":"submitWithdrawal","outputs":[{"internalType":"bool","name":"_locked","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"unlockFeePercentages","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"enum Transfer.Kind","name":"kind","type":"uint8"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"mainchain","type":"tuple"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"ronin","type":"tuple"},{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"internalType":"struct TokenInfo","name":"info","type":"tuple"}],"internalType":"struct Transfer.Receipt","name":"receipt","type":"tuple"}],"name":"unlockWithdrawal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"wethUnwrapper","outputs":[{"internalType":"contract WethUnwrapper","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"withdrawalHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"withdrawalLocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"wrappedNativeToken","outputs":[{"internalType":"contract IWETH","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
60806040523480156200001157600080fd5b506000805460ff19169055620000266200002c565b620000ee565b607154610100900460ff1615620000995760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60715460ff9081161015620000ec576071805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b61563b80620000fe6000396000f3fe6080604052600436106103a65760003560e01c80638f34e347116101e7578063b9c362091161010d578063d64af2a6116100a0578063e400327c1161006f578063e400327c14610b2f578063e6a4561814610b4f578063e75235b814610b62578063f23a6e6114610b7a576103b5565b8063d64af2a614610aaf578063dafae40814610acf578063de981f1b14610aef578063dff525e114610b0f576103b5565b8063cdb67444116100dc578063cdb6744414610a1d578063d19773d214610a35578063d547741f14610a62578063d55ed10314610a82576103b5565b8063b9c3620914610991578063bc197c81146109b1578063c48549de146109dd578063ca15c873146109fd576103b5565b8063a217fddf11610185578063affed0e011610154578063affed0e014610901578063b1a2567e14610917578063b1d08a0314610937578063b297579414610964576103b5565b8063a217fddf1461089f578063a3912ec8146103b3578063ab796566146108b4578063ac78dfe8146108e1576103b5565b80639157921c116101c15780639157921c1461080a57806391d148541461082a57806393c5678f1461084a5780639dcc4da31461086a576103b5565b80638f34e347146107895780638f851d8a146107bd5780639010d07c146107ea576103b5565b806338e454b1116102cc578063504af48c1161026a5780636c1ce670116102395780636c1ce6701461071f5780637de5dedd1461073f5780638456cb5914610754578063865e6fd314610769576103b5565b8063504af48c1461069a57806359122f6b146106ad5780635c975abb146106da5780636932be98146106f2576103b5565b80634b14557e116102a65780634b14557e146106175780634d0d66731461062a5780634d493f4e1461064a5780634f4247a11461067a576103b5565b806338e454b1146105cd5780633e70838b146105e25780633f4ba83a14610602576103b5565b80631d4a7210116103445780632f2ff15d116103135780632f2ff15d14610561578063302d12db146105815780633644e5151461059857806336568abe146105ad576103b5565b80631d4a7210146104ce578063248a9ca3146104fb57806329b6eca91461052b5780632dfdf0b51461054b576103b5565b806317ce2dd41161038057806317ce2dd41461044a57806317fcb39b1461046e5780631a8e55b01461048e5780631b6e7594146104ae576103b5565b806301ffc9a7146103bd578063065b3adf146103f2578063110a83081461042a576103b5565b366103b5576103b3610ba6565b005b6103b3610ba6565b3480156103c957600080fd5b506103dd6103d83660046141d4565b610bda565b60405190151581526020015b60405180910390f35b3480156103fe57600080fd5b50600554610412906001600160a01b031681565b6040516001600160a01b0390911681526020016103e9565b34801561043657600080fd5b506103b3610445366004614213565b610c20565b34801561045657600080fd5b5061046060755481565b6040519081526020016103e9565b34801561047a57600080fd5b50607454610412906001600160a01b031681565b34801561049a57600080fd5b506103b36104a9366004614274565b610cc5565b3480156104ba57600080fd5b506103b36104c93660046142df565b610d01565b3480156104da57600080fd5b506104606104e9366004614213565b603e6020526000908152604090205481565b34801561050757600080fd5b50610460610516366004614383565b60009081526072602052604090206001015490565b34801561053757600080fd5b506103b3610546366004614213565b610d41565b34801561055757600080fd5b5061046060765481565b34801561056d57600080fd5b506103b361057c36600461439c565b610dca565b34801561058d57600080fd5b50610460620f424081565b3480156105a457600080fd5b50607754610460565b3480156105b957600080fd5b506103b36105c836600461439c565b610df4565b3480156105d957600080fd5b506103b3610e72565b3480156105ee57600080fd5b506103b36105fd366004614213565b61104f565b34801561060e57600080fd5b506103b3611079565b6103b36106253660046143cc565b611089565b34801561063657600080fd5b506103dd6106453660046143f7565b6110ac565b34801561065657600080fd5b506103dd610665366004614383565b607a6020526000908152604090205460ff1681565b34801561068657600080fd5b50607f54610412906001600160a01b031681565b6103b36106a83660046144a1565b61111c565b3480156106b957600080fd5b506104606106c8366004614213565b603a6020526000908152604090205481565b3480156106e657600080fd5b5060005460ff166103dd565b3480156106fe57600080fd5b5061046061070d366004614383565b60796020526000908152604090205481565b34801561072b57600080fd5b506103dd61073a36600461457b565b6113e2565b34801561074b57600080fd5b506104606113ee565b34801561076057600080fd5b506103b361140f565b34801561077557600080fd5b506103b36107843660046145b6565b61141f565b34801561079557600080fd5b506104607f5e5712e902fff5e704bc4d506ad976718319e019e9d2a872528a01a85db433e481565b3480156107c957600080fd5b506107dd6107d8366004614681565b61143a565b6040516103e99190614778565b3480156107f657600080fd5b5061041261080536600461478d565b6115bc565b34801561081657600080fd5b506103b36108253660046147af565b6115d4565b34801561083657600080fd5b506103dd61084536600461439c565b611858565b34801561085657600080fd5b506103b3610865366004614274565b611883565b34801561087657600080fd5b5061088a61088536600461478d565b6118b9565b604080519283526020830191909152016103e9565b3480156108ab57600080fd5b50610460600081565b3480156108c057600080fd5b506104606108cf366004614213565b603c6020526000908152604090205481565b3480156108ed57600080fd5b506103dd6108fc366004614383565b6118e2565b34801561090d57600080fd5b5061046060045481565b34801561092357600080fd5b506103b3610932366004614274565b611918565b34801561094357600080fd5b50610460610952366004614213565b60396020526000908152604090205481565b34801561097057600080fd5b5061098461097f366004614213565b61194e565b6040516103e991906147f6565b34801561099d57600080fd5b506103b36109ac36600461478d565b6119f1565b3480156109bd57600080fd5b506107dd6109cc3660046148f9565b63bc197c8160e01b95945050505050565b3480156109e957600080fd5b506107dd6109f8366004614274565b611a0b565b348015610a0957600080fd5b50610460610a18366004614383565b611b9f565b348015610a2957600080fd5b5060375460385461088a565b348015610a4157600080fd5b50610460610a50366004614213565b603b6020526000908152604090205481565b348015610a6e57600080fd5b506103b3610a7d36600461439c565b611bb6565b348015610a8e57600080fd5b50610460610a9d366004614213565b603d6020526000908152604090205481565b348015610abb57600080fd5b506103b3610aca366004614213565b611bdb565b348015610adb57600080fd5b506103dd610aea366004614383565b611bec565b348015610afb57600080fd5b50610412610b0a3660046149a6565b611c1a565b348015610b1b57600080fd5b506103b3610b2a3660046149c1565b611c90565b348015610b3b57600080fd5b506103b3610b4a366004614274565b611d05565b6103b3610b5d366004614a7e565b611d3b565b348015610b6e57600080fd5b5060015460025461088a565b348015610b8657600080fd5b506107dd610b95366004614af2565b63f23a6e6160e01b95945050505050565b6074546001600160a01b0316331480610bc95750607f546001600160a01b031633145b15610bd057565b610bd8611d82565b565b60006001600160e01b03198216631dcdd2c760e31b1480610c0b57506001600160e01b031982166312c0151560e21b145b80610c1a5750610c1a82611dac565b92915050565b607154600490610100900460ff16158015610c42575060715460ff8083169116105b610c675760405162461bcd60e51b8152600401610c5e90614b5a565b60405180910390fd5b60718054607f80546001600160a01b0319166001600160a01b03861617905561ff001961010060ff851661ffff19909316831717169091556040519081526000805160206155e6833981519152906020015b60405180910390a15050565b610ccd611dd1565b6000839003610cef576040516316ee9d3b60e11b815260040160405180910390fd5b610cfb84848484611e2b565b50505050565b610d09611dd1565b6000859003610d2b576040516316ee9d3b60e11b815260040160405180910390fd5b610d39868686868686611f00565b505050505050565b607154600290610100900460ff16158015610d63575060715460ff8083169116105b610d7f5760405162461bcd60e51b8152600401610c5e90614b5a565b6071805461ffff191660ff831617610100179055610d9e600b836120a8565b6071805461ff001916905560405160ff821681526000805160206155e683398151915290602001610cb9565b600082815260726020526040902060010154610de58161214c565b610def8383612156565b505050565b6001600160a01b0381163314610e645760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610c5e565b610e6e8282612178565b5050565b607154600390610100900460ff16158015610e94575060715460ff8083169116105b610eb05760405162461bcd60e51b8152600401610c5e90614b5a565b6071805461ffff191660ff8316176101001790556000610ed0600b611c1a565b9050600080826001600160a01b031663c441c4a86040518163ffffffff1660e01b8152600401600060405180830381865afa158015610f13573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f3b9190810190614c25565b92509250506000805b8351811015610ff857828181518110610f5f57610f5f614d0b565b6020026020010151607e6000868481518110610f7d57610f7d614d0b565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a8154816001600160601b0302191690836001600160601b03160217905550828181518110610fdb57610fdb614d0b565b602002602001015182610fee9190614d37565b9150600101610f44565b50607d80546001600160601b0319166001600160601b039290921691909117905550506071805461ff00191690555060405160ff821681526000805160206155e6833981519152906020015b60405180910390a150565b611057611dd1565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b61108161219a565b610bd8612209565b61109161225b565b6110a96110a336839003830183614da7565b336122a1565b50565b60006110b661225b565b611112848484808060200260200160405190810160405280939291908181526020016000905b82821015611108576110f960608302860136819003810190614dfa565b815260200190600101906110dc565b505050505061257c565b90505b9392505050565b607154610100900460ff161580801561113c5750607154600160ff909116105b806111565750303b158015611156575060715460ff166001145b6111725760405162461bcd60e51b8152600401610c5e90614b5a565b6071805460ff191660011790558015611195576071805461ff0019166101001790555b6111a060008c612a10565b60758990556111ae8a612a1a565b6112396040517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81527f159f52c1e3a2b6a6aad3950adf713516211484e0516dad685ea662a094b7c43b60208201527fad7c5bef027816a800da1736444fb58a807ef4c9603b7848673f7e3a68eb14a5604082015246606082015230608082015260a0812060775550565b6112438887612a68565b61124d8787612af8565b5050611257612b8f565b60006112638680614e44565b905011156113245761128c6112788680614e44565b6112856020890189614e44565b8787611f00565b6112b26112998680614e44565b8660005b6020028101906112ad9190614e44565b612bdc565b6112d86112bf8680614e44565b8660015b6020028101906112d39190614e44565b611e2b565b6112fe6112e58680614e44565b8660025b6020028101906112f99190614e44565b612cb1565b61132461130b8680614e44565b8660035b60200281019061131f9190614e44565b612dc2565b60005b6113346040870187614e44565b90508110156113a0576113987f5e5712e902fff5e704bc4d506ad976718319e019e9d2a872528a01a85db433e461136e6040890189614e44565b8481811061137e5761137e614d0b565b90506020020160208101906113939190614213565b612156565b600101611327565b5080156113d5576071805461ff0019169055604051600181526000805160206155e68339815191529060200160405180910390a15b5050505050505050505050565b60006111158383612e97565b600061140a611405607d546001600160601b031690565b612f62565b905090565b61141761219a565b610bd8612f98565b611427611dd1565b61143081612fd5565b610e6e82826120a8565b6000600b6114478161300b565b82518690811415806114595750808514155b15611485576000356001600160e01b0319166040516306b5667560e21b8152600401610c5e9190614778565b8060000361149d57506347c28ec560e11b91506115b2565b60005b818110156115a5578481815181106114ba576114ba614d0b565b60200260200101511561159d578686828181106114d9576114d9614d0b565b90506020020160208101906114ee9190614e8d565b607d80546001600160601b031981166001600160601b03918216939093011691909117905586868281811061152557611525614d0b565b905060200201602081019061153a9190614e8d565b607e60008b8b8581811061155057611550614d0b565b90506020020160208101906115659190614213565b6001600160a01b03168152602081019190915260400160002080546001600160601b0319166001600160601b03929092169190911790555b6001016114a0565b506347c28ec560e11b9250505b5095945050505050565b60008281526073602052604081206111159083613057565b7f5e5712e902fff5e704bc4d506ad976718319e019e9d2a872528a01a85db433e46115fe8161214c565b600061161761161236859003850185614f07565b613063565b905061162b61161236859003850185614f07565b83356000908152607960205260409020541461165a5760405163f4b8742f60e01b815260040160405180910390fd5b82356000908152607a602052604090205460ff1661168b5760405163147bfe0760e01b815260040160405180910390fd5b82356000908152607a602052604090819020805460ff19169055517fd639511b37b3b002cca6cfe6bca0d833945a5af5a045578a0627fc43b79b2630906116d59083908690614fda565b60405180910390a160006116ef6080850160608601614213565b9050600061170561012086016101008701615060565b6002811115611716576117166147cc565b036117dd576000611730368690038601610100870161507b565b6001600160a01b0383166000908152603b602052604090205490915061175c906101408701359061312d565b60408201526000611776368790038701610100880161507b565b604083015190915061178d90610140880135615097565b60408201526074546117ad908390339086906001600160a01b0316613147565b6117d66117c06060880160408901614213565b60745483919086906001600160a01b0316613147565b5050611819565b6118196117f06060860160408701614213565b60745483906001600160a01b03166118113689900389016101008a0161507b565b929190613147565b7f21e88e956aa3e086f6388e899965cef814688f99ad8bb29b08d396571016372d828560405161184a929190614fda565b60405180910390a150505050565b60009182526072602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61188b611dd1565b60008390036118ad576040516316ee9d3b60e11b815260040160405180910390fd5b610cfb84848484612bdc565b6000806118c4611dd1565b6118ce8484612af8565b90925090506118db612b8f565b9250929050565b60006118f6607d546001600160601b031690565b60375461190391906150aa565b60385461191090846150aa565b101592915050565b611920611dd1565b6000839003611942576040516316ee9d3b60e11b815260040160405180910390fd5b610cfb84848484612cb1565b60408051808201909152600080825260208201526001600160a01b0382166000908152607860205260409081902081518083019092528054829060ff16600281111561199c5761199c6147cc565b60028111156119ad576119ad6147cc565b815290546001600160a01b03610100909104811660209283015290820151919250166119ec57604051631b79f53b60e21b815260040160405180910390fd5b919050565b6119f9611dd1565b611a038282612a68565b610e6e612b8f565b6000600b611a188161300b565b84838114611a47576000356001600160e01b0319166040516306b5667560e21b8152600401610c5e9190614778565b80600003611a5f5750636242a4ef60e11b9150611b96565b6000805b82811015611b4657868682818110611a7d57611a7d614d0b565b9050602002016020810190611a9291906150c1565b15611b3e57607e60008a8a84818110611aad57611aad614d0b565b9050602002016020810190611ac29190614213565b6001600160a01b0316815260208101919091526040016000908120546001600160601b03169290920191607e908a8a84818110611b0157611b01614d0b565b9050602002016020810190611b169190614213565b6001600160a01b03168152602081019190915260400160002080546001600160601b03191690555b600101611a63565b50607d8054829190600090611b659084906001600160601b03166150de565b92506101000a8154816001600160601b0302191690836001600160601b0316021790555063c48549de60e01b935050505b50949350505050565b6000818152607360205260408120610c1a90613379565b600082815260726020526040902060010154611bd18161214c565b610def8383612178565b611be3611dd1565b6110a981612a1a565b6000611c00607d546001600160601b031690565b600154611c0d91906150aa565b60025461191090846150aa565b60007fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb600083600f811115611c5157611c516147cc565b60ff1681526020810191909152604001600020546001600160a01b03169050806119ec578160405163409140df60e11b8152600401610c5e919061510e565b611c98611dd1565b6000869003611cba576040516316ee9d3b60e11b815260040160405180910390fd5b611cc8878787878787611f00565b611cd5878783600061129d565b611ce287878360016112c3565b611cef87878360026112e9565b611cfc878783600361130f565b50505050505050565b611d0d611dd1565b6000839003611d2f576040516316ee9d3b60e11b815260040160405180910390fd5b610cfb84848484612dc2565b611d4361225b565b8060005b81811015610cfb57611d7a848483818110611d6457611d64614d0b565b905060a002018036038101906110a39190614da7565b600101611d47565b611d8a61225b565b611d92614193565b3381526040808201513491015280516110a99082906122a1565b60006001600160e01b03198216630271189760e51b1480610c1a5750610c1a82613383565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b03163314610bd8576000356001600160e01b0319166001604051620f948f60ea1b8152600401610c5e92919061511c565b828114611e59576000356001600160e01b0319166040516306b5667560e21b8152600401610c5e9190614778565b60005b83811015611eca57828282818110611e7657611e76614d0b565b90506020020135603a6000878785818110611e9357611e93614d0b565b9050602002016020810190611ea89190614213565b6001600160a01b03168152602081019190915260400160002055600101611e5c565b507f64557254143204d91ba2d95acb9fda1e5fea55f77efd028685765bc1e94dd4b58484848460405161184a9493929190615193565b8483148015611f0e57508481145b611f39576000356001600160e01b0319166040516306b5667560e21b8152600401610c5e9190614778565b60005b8581101561205e57848482818110611f5657611f56614d0b565b9050602002016020810190611f6b9190614213565b60786000898985818110611f8157611f81614d0b565b9050602002016020810190611f969190614213565b6001600160a01b03908116825260208201929092526040016000208054610100600160a81b0319166101009390921692909202179055828282818110611fde57611fde614d0b565b9050602002016020810190611ff39190615060565b6078600089898581811061200957612009614d0b565b905060200201602081019061201e9190614213565b6001600160a01b031681526020810191909152604001600020805460ff19166001836002811115612051576120516147cc565b0217905550600101611f3c565b507fa4f03cc9c0e0aeb5b71b4ec800702753f65748c2cf3064695ba8e8b46be70444868686868686604051612098969594939291906151df565b60405180910390a1505050505050565b807fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb600084600f8111156120de576120de6147cc565b60ff168152602081019190915260400160002080546001600160a01b0319166001600160a01b03928316179055811682600f81111561211f5761211f6147cc565b6040517f865d1c228a8ea13709cfe61f346f7ff67f1bbd4a18ff31ad3e7147350d317c5990600090a35050565b6110a981336133a8565b612160828261340c565b6000828152607360205260409020610def9082613492565b61218282826134a7565b6000828152607360205260409020610def908261350e565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b03163314806121dc57506005546001600160a01b031633145b610bd8576000356001600160e01b0319166001604051620f948f60ea1b8152600401610c5e92919061511c565b612211613523565b6000805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60005460ff1615610bd85760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610c5e565b604080518082018252600080825260208201526074549184015190916001600160a01b0316906122d09061356c565b60208401516001600160a01b031661237157348460400151604001511461230a5760405163129c2ce160e31b815260040160405180910390fd5b6123138161194e565b604085015151909250600281111561232d5761232d6147cc565b82516002811115612340576123406147cc565b1461235d5760405162035e2b60ea1b815260040160405180910390fd5b6001600160a01b0381166020850152612509565b34156123905760405163129c2ce160e31b815260040160405180910390fd5b61239d846020015161194e565b60408501515190925060028111156123b7576123b76147cc565b825160028111156123ca576123ca6147cc565b146123e75760405162035e2b60ea1b815260040160405180910390fd5b602084015160408501516123fc9185906135b0565b83602001516001600160a01b0316816001600160a01b03160361250957607454607f54604086810151810151905163095ea7b360e01b81526001600160a01b039283166004820152602481019190915291169063095ea7b3906044016020604051808303816000875af1158015612477573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061249b9190615250565b50607f546040808601518101519051636f074d1f60e11b81526001600160a01b039092169163de0e9a3e916124d69160040190815260200190565b600060405180830381600087803b1580156124f057600080fd5b505af1158015612504573d6000803e3d6000fd5b505050505b607680546000918261251a8361526d565b9190505590506000612541858386602001516075548a61372990949392919063ffffffff16565b90507fd7b25068d9dc8d00765254cfb7f5070f98d263c8d68931d937c7362fa738048b61256d82613063565b826040516120989291906152a6565b60008235610140840135826125976080870160608801614213565b90506125b46125af368890038801610100890161507b565b61356c565b60016125c66040880160208901615342565b60018111156125d7576125d76147cc565b146125f55760405163182f3d8760e11b815260040160405180910390fd5b608086013546146126375760405163092048d160e11b81526000356001600160e01b031916600482015260808701356024820152466044820152606401610c5e565b600061264c61097f6080890160608a01614213565b905061266061012088016101008901615060565b6002811115612671576126716147cc565b81516002811115612684576126846147cc565b1480156126b5575061269c60e0880160c08901614213565b6001600160a01b031681602001516001600160a01b0316145b80156126c6575060755460e0880135145b6126e35760405163f4b8742f60e01b815260040160405180910390fd5b6000848152607960205260409020541561271057604051634f13df6160e01b815260040160405180910390fd5b600161272461012089016101008a01615060565b6002811115612735576127356147cc565b148061274857506127468284612e97565b155b6127655760405163c51297b760e01b815260040160405180910390fd5b6000612779611612368a90038a018a614f07565b90506000612789607754836137fe565b905060006127a96127a26101208c016101008d01615060565b868861383f565b60408051606081018252600080825260208201819052918101829052919a50919250819081906000805b8e518110156128e7578e81815181106127ee576127ee614d0b565b6020908102919091018101518051818301516040808401518151600081529586018083528e905260ff9093169085015260608401526080830152935060019060a0016020604051602081039080840390855afa158015612852573d6000803e3d6000fd5b505050602060405103519450846001600160a01b0316846001600160a01b03161061289e576000356001600160e01b031916604051635d3dcd3160e01b8152600401610c5e9190614778565b6001600160a01b0385166000908152607e60205260409020548594506001600160601b03166128cd908361535d565b91508682106128df57600195506128e7565b6001016127d3565b508461290657604051639e8f5f6360e01b815260040160405180910390fd5b505050600089815260796020526040902085905550508715612981576000878152607a602052604090819020805460ff19166001179055517f89e52969465b1f1866fc5d46fd62de953962e9cb33552443cd999eba05bd20dc9061296d9085908d90614fda565b60405180910390a150505050505050610c1a565b61298b85876138cf565b6129ca61299e60608c0160408d01614213565b86607460009054906101000a90046001600160a01b03168d61010001803603810190611811919061507b565b7f21e88e956aa3e086f6388e899965cef814688f99ad8bb29b08d396571016372d838b6040516129fb929190614fda565b60405180910390a15050505050505092915050565b610e6e8282612156565b607480546001600160a01b0319166001600160a01b0383169081179091556040519081527f9d2334c23be647e994f27a72c5eee42a43d5bdcfe15bb88e939103c2b114cbaf90602001611044565b80821115612a97576000356001600160e01b0319166040516387f6f09560e01b8152600401610c5e9190614778565b6001805460028054858455908490556004805493840190556040805183815260208101839052929391928592879290917f976f8a9c5bdf8248dec172376d6e2b80a8e3df2f0328e381c6db8e1cf138c0f8910160405180910390a450505050565b60008082841115612b2a576000356001600160e01b0319166040516387f6f09560e01b8152600401610c5e9190614778565b5050603780546038805492859055839055600480546001810190915560408051838152602081018590529293928592879290917f31312c97b89cc751b832d98fd459b967a2c3eef3b49757d1cf5ebaa12bb6eee1910160405180910390a49250929050565b600254603754612b9f91906150aa565b603854600154612baf91906150aa565b1115610bd8576000356001600160e01b0319166040516387f6f09560e01b8152600401610c5e9190614778565b828114612c0a576000356001600160e01b0319166040516306b5667560e21b8152600401610c5e9190614778565b60005b83811015612c7b57828282818110612c2757612c27614d0b565b9050602002013560396000878785818110612c4457612c44614d0b565b9050602002016020810190612c599190614213565b6001600160a01b03168152602081019190915260400160002055600101612c0d565b507f80bc635c452ae67f12f9b6f12ad4daa6dbbc04eeb9ebb87d354ce10c0e210dc08484848460405161184a9493929190615193565b828114612cdf576000356001600160e01b0319166040516306b5667560e21b8152600401610c5e9190614778565b60005b83811015612d8c57620f4240838383818110612d0057612d00614d0b565b905060200201351115612d265760405163572d3bd360e11b815260040160405180910390fd5b828282818110612d3857612d38614d0b565b90506020020135603b6000878785818110612d5557612d55614d0b565b9050602002016020810190612d6a9190614213565b6001600160a01b03168152602081019190915260400160002055600101612ce2565b507fb05f5de88ae0294ebb6f67c5af2fcbbd593cc6bdfe543e2869794a4c8ce3ea508484848460405161184a9493929190615193565b828114612df0576000356001600160e01b0319166040516306b5667560e21b8152600401610c5e9190614778565b60005b83811015612e6157828282818110612e0d57612e0d614d0b565b90506020020135603c6000878785818110612e2a57612e2a614d0b565b9050602002016020810190612e3f9190614213565b6001600160a01b03168152602081019190915260400160002055600101612df3565b507fb5d2963614d72181b4df1f993d45b83edf42fa19710f0204217ba1b3e183bb738484848460405161184a9493929190615193565b6001600160a01b0382166000908152603a60205260408120548210612ebe57506000610c1a565b6000612ecd6201518042615370565b6001600160a01b0385166000908152603e6020526040902054909150811115612f135750506001600160a01b0382166000908152603c6020526040902054811015610c1a565b6001600160a01b0384166000908152603d6020526040902054612f3790849061535d565b6001600160a01b0385166000908152603c602052604090205411159150610c1a9050565b5092915050565b6000600254600160025484600154612f7a91906150aa565b612f84919061535d565b612f8e9190615097565b610c1a9190615370565b612fa061225b565b6000805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861223e3390565b806001600160a01b03163b6000036110a957604051630bfc64a360e21b81526001600160a01b0382166004820152602401610c5e565b61301481611c1a565b6001600160a01b0316336001600160a01b0316146110a9576000356001600160e01b03191681336040516320e0f98d60e21b8152600401610c5e93929190615392565b6000611115838361395f565b6000806130738360400151613989565b905060006130848460600151613989565b905060006130d88560800151604080517f1e2b74b2a792d5c0f0b6e59b037fa9d43d84fbb759337f0112fcc15ca414fc8d815282516020808301919091528301518183015291015160608201526080902090565b604080517fb9d1fe7c9deeec5dc90a2f47ff1684239519f2545b2228d3d91fb27df3189eea815287516020808301919091529097015190870152606086019390935250608084015260a08301525060c0902090565b6000620f424061313d83856150aa565b6111159190615370565b806001600160a01b0316826001600160a01b0316036131f45760408085015190516001600160a01b0385169180156108fc02916000818181858888f193505050506131ef57806001600160a01b031663d0e30db085604001516040518263ffffffff1660e01b81526004016000604051808303818588803b1580156131cb57600080fd5b505af11580156131df573d6000803e3d6000fd5b50505050506131ef8484846139d1565b610cfb565b600084516002811115613209576132096147cc565b036132cf576040516370a0823160e01b81523060048201526000906001600160a01b038416906370a0823190602401602060405180830381865afa158015613255573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061327991906153c9565b905084604001518110156132be576132a1833083886040015161329c9190615097565b613a50565b6132be57604051632f739fff60e11b815260040160405180910390fd5b6132c98585856139d1565b50610cfb565b6001845160028111156132e4576132e46147cc565b03613315576132f882848660200151613af5565b6131ef5760405163c8e3a09f60e01b815260040160405180910390fd5b60028451600281111561332a5761332a6147cc565b0361336057613343828486602001518760400151613b1c565b6131ef576040516334b471a760e21b815260040160405180910390fd5b6040516361e411a760e11b815260040160405180910390fd5b6000610c1a825490565b60006001600160e01b03198216635a05180f60e01b1480610c1a5750610c1a82613b49565b6133b28282611858565b610e6e576133ca816001600160a01b03166014613b7e565b6133d5836020613b7e565b6040516020016133e6929190615406565b60408051601f198184030181529082905262461bcd60e51b8252610c5e916004016154a7565b6134168282611858565b610e6e5760008281526072602090815260408083206001600160a01b03851684529091529020805460ff1916600117905561344e3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000611115836001600160a01b038416613d19565b6134b18282611858565b15610e6e5760008281526072602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000611115836001600160a01b038416613d68565b60005460ff16610bd85760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610c5e565b61357581613e5b565b80613584575061358481613e92565b80613593575061359381613eba565b6110a95760405163034992a760e51b815260040160405180910390fd5b6000606081855160028111156135c8576135c86147cc565b036136a35760408581015181516001600160a01b03878116602483015230604483015260648083019390935283518083039093018352608490910183526020820180516001600160e01b03166323b872dd60e01b17905291519185169161362f91906154ba565b6000604051808303816000865af19150503d806000811461366c576040519150601f19603f3d011682016040523d82523d6000602084013e613671565b606091505b50909250905081801561369c57508051158061369c57508080602001905181019061369c9190615250565b91506136fc565b6001855160028111156136b8576136b86147cc565b036136cd5761369c8385308860200151613ee3565b6002855160028111156136e2576136e26147cc565b036133605761369c83853088602001518960400151613f91565b816137225784843085604051639d2e4c6760e01b8152600401610c5e94939291906154d6565b5050505050565b6137996040805160a08101825260008082526020808301829052835160608082018652838252818301849052818601849052848601919091528451808201865283815280830184905280860184905281850152845190810185528281529081018290529283015290608082015290565b83815260006020820181905250604080820180516001600160a01b039788169052602080890151825190891690820152905146908301528751606084018051918916909152805195909716940193909352935182015292909201516080820152919050565b6040805161190160f01b6020808301919091526022820185905260428083018590528351808403909101815260629092019092528051910120600090611115565b6000806000613856607d546001600160601b031690565b905061386181612f62565b92506000866002811115613877576138776147cc565b036138c6576001600160a01b03851660009081526039602052604090205484106138a7576138a481614045565b92505b6001600160a01b0385166000908152603a602052604090205484101591505b50935093915050565b60006138de6201518042615370565b6001600160a01b0384166000908152603e602052604090205490915081111561392d576001600160a01b03929092166000908152603e6020908152604080832094909455603d90529190912055565b6001600160a01b0383166000908152603d60205260408120805484929061395590849061535d565b9091555050505050565b600082600001828154811061397657613976614d0b565b9060005260206000200154905092915050565b604080517f353bdd8d69b9e3185b3972e08b03845c0c14a21a390215302776a7a34b0e8764815282516020808301919091528301518183015291015160608201526080902090565b600080845160028111156139e7576139e76147cc565b03613a02576139fb8284866040015161405d565b9050613a2c565b600184516002811115613a1757613a176147cc565b03613360576139fb8230858760200151613ee3565b80610cfb578383836040516341bd7d9160e11b8152600401610c5e9392919061550c565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b03166340c10f1960e01b1790529151600092861691613aa8916154ba565b6000604051808303816000865af19150503d8060008114613ae5576040519150601f19603f3d011682016040523d82523d6000602084013e613aea565b606091505b509095945050505050565b6000613b0384308585613ee3565b90508061111557613b15848484613a50565b9050611115565b6000613b2b8530868686613f91565b905080613b4157613b3e85858585614130565b90505b949350505050565b60006001600160e01b03198216637965db0b60e01b1480610c1a57506301ffc9a760e01b6001600160e01b0319831614610c1a565b60606000613b8d8360026150aa565b613b9890600261535d565b6001600160401b03811115613baf57613baf6145e2565b6040519080825280601f01601f191660200182016040528015613bd9576020820181803683370190505b509050600360fc1b81600081518110613bf457613bf4614d0b565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613c2357613c23614d0b565b60200101906001600160f81b031916908160001a9053506000613c478460026150aa565b613c5290600161535d565b90505b6001811115613cca576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613c8657613c86614d0b565b1a60f81b828281518110613c9c57613c9c614d0b565b60200101906001600160f81b031916908160001a90535060049490941c93613cc38161553c565b9050613c55565b5083156111155760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610c5e565b6000818152600183016020526040812054613d6057508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610c1a565b506000610c1a565b60008181526001830160205260408120548015613e51576000613d8c600183615097565b8554909150600090613da090600190615097565b9050818114613e05576000866000018281548110613dc057613dc0614d0b565b9060005260206000200154905080876000018481548110613de357613de3614d0b565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080613e1657613e16615553565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610c1a565b6000915050610c1a565b60008082516002811115613e7157613e716147cc565b148015613e82575060008260400151115b8015610c1a575050602001511590565b6000600182516002811115613ea957613ea96147cc565b148015610c1a575050604001511590565b6000600282516002811115613ed157613ed16147cc565b148015610c1a57505060400151151590565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b1790529151600092871691613f43916154ba565b6000604051808303816000865af19150503d8060008114613f80576040519150601f19603f3d011682016040523d82523d6000602084013e613f85565b606091505b50909695505050505050565b604080516000808252602082019092526001600160a01b03871690613fc190879087908790879060448101615569565b60408051601f198184030181529181526020820180516001600160e01b0316637921219560e11b17905251613ff691906154ba565b6000604051808303816000865af19150503d8060008114614033576040519150601f19603f3d011682016040523d82523d6000602084013e614038565b606091505b5090979650505050505050565b6000603854600160385484603754612f7a91906150aa565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b1790529151600092606092908716916140ba91906154ba565b6000604051808303816000865af19150503d80600081146140f7576040519150601f19603f3d011682016040523d82523d6000602084013e6140fc565b606091505b5090925090508180156141275750805115806141275750808060200190518101906141279190615250565b95945050505050565b604080516000808252602082019092526001600160a01b0386169061415e90869086908690604481016155ae565b60408051601f198184030181529181526020820180516001600160e01b031663731133e960e01b17905251613f4391906154ba565b60408051606081018252600080825260208201529081016141cf6040805160608101909152806000815260200160008152602001600081525090565b905290565b6000602082840312156141e657600080fd5b81356001600160e01b03198116811461111557600080fd5b6001600160a01b03811681146110a957600080fd5b60006020828403121561422557600080fd5b8135611115816141fe565b60008083601f84011261424257600080fd5b5081356001600160401b0381111561425957600080fd5b6020830191508360208260051b85010111156118db57600080fd5b6000806000806040858703121561428a57600080fd5b84356001600160401b03808211156142a157600080fd5b6142ad88838901614230565b909650945060208701359150808211156142c657600080fd5b506142d387828801614230565b95989497509550505050565b600080600080600080606087890312156142f857600080fd5b86356001600160401b038082111561430f57600080fd5b61431b8a838b01614230565b9098509650602089013591508082111561433457600080fd5b6143408a838b01614230565b9096509450604089013591508082111561435957600080fd5b5061436689828a01614230565b979a9699509497509295939492505050565b80356119ec816141fe565b60006020828403121561439557600080fd5b5035919050565b600080604083850312156143af57600080fd5b8235915060208301356143c1816141fe565b809150509250929050565b600060a082840312156143de57600080fd5b50919050565b600061016082840312156143de57600080fd5b6000806000610180848603121561440d57600080fd5b61441785856143e4565b92506101608401356001600160401b038082111561443457600080fd5b818601915086601f83011261444857600080fd5b81358181111561445757600080fd5b87602060608302850101111561446c57600080fd5b6020830194508093505050509250925092565b8060608101831015610c1a57600080fd5b8060808101831015610c1a57600080fd5b6000806000806000806000806000806101208b8d0312156144c157600080fd5b6144ca8b614378565b99506144d860208c01614378565b985060408b0135975060608b0135965060808b0135955060a08b0135945060c08b01356001600160401b038082111561451057600080fd5b61451c8e838f0161447f565b955060e08d013591508082111561453257600080fd5b61453e8e838f01614490565b94506101008d013591508082111561455557600080fd5b506145628d828e01614230565b915080935050809150509295989b9194979a5092959850565b6000806040838503121561458e57600080fd5b8235614599816141fe565b946020939093013593505050565b8035601081106119ec57600080fd5b600080604083850312156145c957600080fd5b6145d2836145a7565b915060208301356143c1816141fe565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b038111828210171561461a5761461a6145e2565b60405290565b604051601f8201601f191681016001600160401b0381118282101715614648576146486145e2565b604052919050565b60006001600160401b03821115614669576146696145e2565b5060051b60200190565b80151581146110a957600080fd5b60008060008060006060868803121561469957600080fd5b85356001600160401b03808211156146b057600080fd5b6146bc89838a01614230565b90975095506020915087820135818111156146d657600080fd5b6146e28a828b01614230565b9096509450506040880135818111156146fa57600080fd5b88019050601f8101891361470d57600080fd5b803561472061471b82614650565b614620565b81815260059190911b8201830190838101908b83111561473f57600080fd5b928401925b8284101561476657833561475781614673565b82529284019290840190614744565b80955050505050509295509295909350565b6001600160e01b031991909116815260200190565b600080604083850312156147a057600080fd5b50508035926020909101359150565b600061016082840312156147c257600080fd5b61111583836143e4565b634e487b7160e01b600052602160045260246000fd5b600381106147f2576147f26147cc565b9052565b60006040820190506148098284516147e2565b6020928301516001600160a01b0316919092015290565b600082601f83011261483157600080fd5b8135602061484161471b83614650565b8083825260208201915060208460051b87010193508684111561486357600080fd5b602086015b8481101561487f5780358352918301918301614868565b509695505050505050565b600082601f83011261489b57600080fd5b81356001600160401b038111156148b4576148b46145e2565b6148c7601f8201601f1916602001614620565b8181528460208386010111156148dc57600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a0868803121561491157600080fd5b853561491c816141fe565b9450602086013561492c816141fe565b935060408601356001600160401b038082111561494857600080fd5b61495489838a01614820565b9450606088013591508082111561496a57600080fd5b61497689838a01614820565b9350608088013591508082111561498c57600080fd5b506149998882890161488a565b9150509295509295909350565b6000602082840312156149b857600080fd5b611115826145a7565b60008060008060008060006080888a0312156149dc57600080fd5b87356001600160401b03808211156149f357600080fd5b6149ff8b838c01614230565b909950975060208a0135915080821115614a1857600080fd5b614a248b838c01614230565b909750955060408a0135915080821115614a3d57600080fd5b614a498b838c01614230565b909550935060608a0135915080821115614a6257600080fd5b50614a6f8a828b01614490565b91505092959891949750929550565b60008060208385031215614a9157600080fd5b82356001600160401b0380821115614aa857600080fd5b818501915085601f830112614abc57600080fd5b813581811115614acb57600080fd5b86602060a083028501011115614ae057600080fd5b60209290920196919550909350505050565b600080600080600060a08688031215614b0a57600080fd5b8535614b15816141fe565b94506020860135614b25816141fe565b9350604086013592506060860135915060808601356001600160401b03811115614b4e57600080fd5b6149998882890161488a565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b600082601f830112614bb957600080fd5b81516020614bc961471b83614650565b8083825260208201915060208460051b870101935086841115614beb57600080fd5b602086015b8481101561487f578051614c03816141fe565b8352918301918301614bf0565b6001600160601b03811681146110a957600080fd5b600080600060608486031215614c3a57600080fd5b83516001600160401b0380821115614c5157600080fd5b614c5d87838801614ba8565b9450602091508186015181811115614c7457600080fd5b614c8088828901614ba8565b945050604086015181811115614c9557600080fd5b86019050601f81018713614ca857600080fd5b8051614cb661471b82614650565b81815260059190911b82018301908381019089831115614cd557600080fd5b928401925b82841015614cfc578351614ced81614c10565b82529284019290840190614cda565b80955050505050509250925092565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6001600160601b03818116838216019080821115612f5b57612f5b614d21565b8035600381106119ec57600080fd5b600060608284031215614d7857600080fd5b614d806145f8565b9050614d8b82614d57565b8152602082013560208201526040820135604082015292915050565b600060a08284031215614db957600080fd5b614dc16145f8565b8235614dcc816141fe565b81526020830135614ddc816141fe565b6020820152614dee8460408501614d66565b60408201529392505050565b600060608284031215614e0c57600080fd5b614e146145f8565b823560ff81168114614e2557600080fd5b8152602083810135908201526040928301359281019290925250919050565b6000808335601e19843603018112614e5b57600080fd5b8301803591506001600160401b03821115614e7557600080fd5b6020019150600581901b36038213156118db57600080fd5b600060208284031215614e9f57600080fd5b813561111581614c10565b8035600281106119ec57600080fd5b600060608284031215614ecb57600080fd5b614ed36145f8565b90508135614ee0816141fe565b81526020820135614ef0816141fe565b806020830152506040820135604082015292915050565b60006101608284031215614f1a57600080fd5b60405160a081018181106001600160401b0382111715614f3c57614f3c6145e2565b60405282358152614f4f60208401614eaa565b6020820152614f618460408501614eb9565b6040820152614f738460a08501614eb9565b6060820152614f86846101008501614d66565b60808201529392505050565b600281106147f2576147f26147cc565b8035614fad816141fe565b6001600160a01b039081168352602082013590614fc9826141fe565b166020830152604090810135910152565b60006101808201905083825282356020830152614ff960208401614eaa565b6150066040840182614f92565b506150176060830160408501614fa2565b61502760c0830160a08501614fa2565b61012061504281840161503d6101008701614d57565b6147e2565b61014081850135818501528085013561016085015250509392505050565b60006020828403121561507257600080fd5b61111582614d57565b60006060828403121561508d57600080fd5b6111158383614d66565b81810381811115610c1a57610c1a614d21565b8082028115828204841417610c1a57610c1a614d21565b6000602082840312156150d357600080fd5b813561111581614673565b6001600160601b03828116828216039080821115612f5b57612f5b614d21565b601081106147f2576147f26147cc565b60208101610c1a82846150fe565b6001600160e01b03198316815260408101600b831061513d5761513d6147cc565b8260208301529392505050565b8183526000602080850194508260005b8581101561518857813561516d816141fe565b6001600160a01b03168752958201959082019060010161515a565b509495945050505050565b6040815260006151a760408301868861514a565b82810360208401528381526001600160fb1b038411156151c657600080fd5b8360051b80866020840137016020019695505050505050565b6060815260006151f360608301888a61514a565b6020838203602085015261520882888a61514a565b848103604086015285815286925060200160005b86811015615241576152318261503d86614d57565b928201929082019060010161521c565b509a9950505050505050505050565b60006020828403121561526257600080fd5b815161111581614673565b60006001820161527f5761527f614d21565b5060010190565b6152918282516147e2565b60208181015190830152604090810151910152565b6000610180820190508382528251602083015260208301516152cb6040840182614f92565b5060408381015180516001600160a01b03908116606086015260208201511660808501529081015160a084015250606083015180516001600160a01b0390811660c085015260208201511660e0840152604081015161010084015250608083015161533a610120840182615286565b509392505050565b60006020828403121561535457600080fd5b61111582614eaa565b80820180821115610c1a57610c1a614d21565b60008261538d57634e487b7160e01b600052601260045260246000fd5b500490565b6001600160e01b031984168152606081016153b060208301856150fe565b6001600160a01b03929092166040919091015292915050565b6000602082840312156153db57600080fd5b5051919050565b60005b838110156153fd5781810151838201526020016153e5565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161543e8160178501602088016153e2565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161546f8160288401602088016153e2565b01602801949350505050565b600081518084526154938160208601602086016153e2565b601f01601f19169290920160200192915050565b602081526000611115602083018461547b565b600082516154cc8184602087016153e2565b9190910192915050565b60c081016154e48287615286565b6001600160a01b0394851660608301529284166080820152921660a090920191909152919050565b60a0810161551a8286615286565b6001600160a01b03938416606083015291909216608090920191909152919050565b60008161554b5761554b614d21565b506000190190565b634e487b7160e01b600052603160045260246000fd5b6001600160a01b03868116825285166020820152604081018490526060810183905260a0608082018190526000906155a39083018461547b565b979650505050505050565b60018060a01b03851681528360208201528260408201526080606082015260006155db608083018461547b565b969550505050505056fe7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498a2646970667358221220adc544fca693cfd23fbe440435aafb94a2ad08c9840546710b0fb29a782fcc0e64736f6c63430008170033
Deployed Bytecode
0x6080604052600436106103a65760003560e01c80638f34e347116101e7578063b9c362091161010d578063d64af2a6116100a0578063e400327c1161006f578063e400327c14610b2f578063e6a4561814610b4f578063e75235b814610b62578063f23a6e6114610b7a576103b5565b8063d64af2a614610aaf578063dafae40814610acf578063de981f1b14610aef578063dff525e114610b0f576103b5565b8063cdb67444116100dc578063cdb6744414610a1d578063d19773d214610a35578063d547741f14610a62578063d55ed10314610a82576103b5565b8063b9c3620914610991578063bc197c81146109b1578063c48549de146109dd578063ca15c873146109fd576103b5565b8063a217fddf11610185578063affed0e011610154578063affed0e014610901578063b1a2567e14610917578063b1d08a0314610937578063b297579414610964576103b5565b8063a217fddf1461089f578063a3912ec8146103b3578063ab796566146108b4578063ac78dfe8146108e1576103b5565b80639157921c116101c15780639157921c1461080a57806391d148541461082a57806393c5678f1461084a5780639dcc4da31461086a576103b5565b80638f34e347146107895780638f851d8a146107bd5780639010d07c146107ea576103b5565b806338e454b1116102cc578063504af48c1161026a5780636c1ce670116102395780636c1ce6701461071f5780637de5dedd1461073f5780638456cb5914610754578063865e6fd314610769576103b5565b8063504af48c1461069a57806359122f6b146106ad5780635c975abb146106da5780636932be98146106f2576103b5565b80634b14557e116102a65780634b14557e146106175780634d0d66731461062a5780634d493f4e1461064a5780634f4247a11461067a576103b5565b806338e454b1146105cd5780633e70838b146105e25780633f4ba83a14610602576103b5565b80631d4a7210116103445780632f2ff15d116103135780632f2ff15d14610561578063302d12db146105815780633644e5151461059857806336568abe146105ad576103b5565b80631d4a7210146104ce578063248a9ca3146104fb57806329b6eca91461052b5780632dfdf0b51461054b576103b5565b806317ce2dd41161038057806317ce2dd41461044a57806317fcb39b1461046e5780631a8e55b01461048e5780631b6e7594146104ae576103b5565b806301ffc9a7146103bd578063065b3adf146103f2578063110a83081461042a576103b5565b366103b5576103b3610ba6565b005b6103b3610ba6565b3480156103c957600080fd5b506103dd6103d83660046141d4565b610bda565b60405190151581526020015b60405180910390f35b3480156103fe57600080fd5b50600554610412906001600160a01b031681565b6040516001600160a01b0390911681526020016103e9565b34801561043657600080fd5b506103b3610445366004614213565b610c20565b34801561045657600080fd5b5061046060755481565b6040519081526020016103e9565b34801561047a57600080fd5b50607454610412906001600160a01b031681565b34801561049a57600080fd5b506103b36104a9366004614274565b610cc5565b3480156104ba57600080fd5b506103b36104c93660046142df565b610d01565b3480156104da57600080fd5b506104606104e9366004614213565b603e6020526000908152604090205481565b34801561050757600080fd5b50610460610516366004614383565b60009081526072602052604090206001015490565b34801561053757600080fd5b506103b3610546366004614213565b610d41565b34801561055757600080fd5b5061046060765481565b34801561056d57600080fd5b506103b361057c36600461439c565b610dca565b34801561058d57600080fd5b50610460620f424081565b3480156105a457600080fd5b50607754610460565b3480156105b957600080fd5b506103b36105c836600461439c565b610df4565b3480156105d957600080fd5b506103b3610e72565b3480156105ee57600080fd5b506103b36105fd366004614213565b61104f565b34801561060e57600080fd5b506103b3611079565b6103b36106253660046143cc565b611089565b34801561063657600080fd5b506103dd6106453660046143f7565b6110ac565b34801561065657600080fd5b506103dd610665366004614383565b607a6020526000908152604090205460ff1681565b34801561068657600080fd5b50607f54610412906001600160a01b031681565b6103b36106a83660046144a1565b61111c565b3480156106b957600080fd5b506104606106c8366004614213565b603a6020526000908152604090205481565b3480156106e657600080fd5b5060005460ff166103dd565b3480156106fe57600080fd5b5061046061070d366004614383565b60796020526000908152604090205481565b34801561072b57600080fd5b506103dd61073a36600461457b565b6113e2565b34801561074b57600080fd5b506104606113ee565b34801561076057600080fd5b506103b361140f565b34801561077557600080fd5b506103b36107843660046145b6565b61141f565b34801561079557600080fd5b506104607f5e5712e902fff5e704bc4d506ad976718319e019e9d2a872528a01a85db433e481565b3480156107c957600080fd5b506107dd6107d8366004614681565b61143a565b6040516103e99190614778565b3480156107f657600080fd5b5061041261080536600461478d565b6115bc565b34801561081657600080fd5b506103b36108253660046147af565b6115d4565b34801561083657600080fd5b506103dd61084536600461439c565b611858565b34801561085657600080fd5b506103b3610865366004614274565b611883565b34801561087657600080fd5b5061088a61088536600461478d565b6118b9565b604080519283526020830191909152016103e9565b3480156108ab57600080fd5b50610460600081565b3480156108c057600080fd5b506104606108cf366004614213565b603c6020526000908152604090205481565b3480156108ed57600080fd5b506103dd6108fc366004614383565b6118e2565b34801561090d57600080fd5b5061046060045481565b34801561092357600080fd5b506103b3610932366004614274565b611918565b34801561094357600080fd5b50610460610952366004614213565b60396020526000908152604090205481565b34801561097057600080fd5b5061098461097f366004614213565b61194e565b6040516103e991906147f6565b34801561099d57600080fd5b506103b36109ac36600461478d565b6119f1565b3480156109bd57600080fd5b506107dd6109cc3660046148f9565b63bc197c8160e01b95945050505050565b3480156109e957600080fd5b506107dd6109f8366004614274565b611a0b565b348015610a0957600080fd5b50610460610a18366004614383565b611b9f565b348015610a2957600080fd5b5060375460385461088a565b348015610a4157600080fd5b50610460610a50366004614213565b603b6020526000908152604090205481565b348015610a6e57600080fd5b506103b3610a7d36600461439c565b611bb6565b348015610a8e57600080fd5b50610460610a9d366004614213565b603d6020526000908152604090205481565b348015610abb57600080fd5b506103b3610aca366004614213565b611bdb565b348015610adb57600080fd5b506103dd610aea366004614383565b611bec565b348015610afb57600080fd5b50610412610b0a3660046149a6565b611c1a565b348015610b1b57600080fd5b506103b3610b2a3660046149c1565b611c90565b348015610b3b57600080fd5b506103b3610b4a366004614274565b611d05565b6103b3610b5d366004614a7e565b611d3b565b348015610b6e57600080fd5b5060015460025461088a565b348015610b8657600080fd5b506107dd610b95366004614af2565b63f23a6e6160e01b95945050505050565b6074546001600160a01b0316331480610bc95750607f546001600160a01b031633145b15610bd057565b610bd8611d82565b565b60006001600160e01b03198216631dcdd2c760e31b1480610c0b57506001600160e01b031982166312c0151560e21b145b80610c1a5750610c1a82611dac565b92915050565b607154600490610100900460ff16158015610c42575060715460ff8083169116105b610c675760405162461bcd60e51b8152600401610c5e90614b5a565b60405180910390fd5b60718054607f80546001600160a01b0319166001600160a01b03861617905561ff001961010060ff851661ffff19909316831717169091556040519081526000805160206155e6833981519152906020015b60405180910390a15050565b610ccd611dd1565b6000839003610cef576040516316ee9d3b60e11b815260040160405180910390fd5b610cfb84848484611e2b565b50505050565b610d09611dd1565b6000859003610d2b576040516316ee9d3b60e11b815260040160405180910390fd5b610d39868686868686611f00565b505050505050565b607154600290610100900460ff16158015610d63575060715460ff8083169116105b610d7f5760405162461bcd60e51b8152600401610c5e90614b5a565b6071805461ffff191660ff831617610100179055610d9e600b836120a8565b6071805461ff001916905560405160ff821681526000805160206155e683398151915290602001610cb9565b600082815260726020526040902060010154610de58161214c565b610def8383612156565b505050565b6001600160a01b0381163314610e645760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610c5e565b610e6e8282612178565b5050565b607154600390610100900460ff16158015610e94575060715460ff8083169116105b610eb05760405162461bcd60e51b8152600401610c5e90614b5a565b6071805461ffff191660ff8316176101001790556000610ed0600b611c1a565b9050600080826001600160a01b031663c441c4a86040518163ffffffff1660e01b8152600401600060405180830381865afa158015610f13573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f3b9190810190614c25565b92509250506000805b8351811015610ff857828181518110610f5f57610f5f614d0b565b6020026020010151607e6000868481518110610f7d57610f7d614d0b565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a8154816001600160601b0302191690836001600160601b03160217905550828181518110610fdb57610fdb614d0b565b602002602001015182610fee9190614d37565b9150600101610f44565b50607d80546001600160601b0319166001600160601b039290921691909117905550506071805461ff00191690555060405160ff821681526000805160206155e6833981519152906020015b60405180910390a150565b611057611dd1565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b61108161219a565b610bd8612209565b61109161225b565b6110a96110a336839003830183614da7565b336122a1565b50565b60006110b661225b565b611112848484808060200260200160405190810160405280939291908181526020016000905b82821015611108576110f960608302860136819003810190614dfa565b815260200190600101906110dc565b505050505061257c565b90505b9392505050565b607154610100900460ff161580801561113c5750607154600160ff909116105b806111565750303b158015611156575060715460ff166001145b6111725760405162461bcd60e51b8152600401610c5e90614b5a565b6071805460ff191660011790558015611195576071805461ff0019166101001790555b6111a060008c612a10565b60758990556111ae8a612a1a565b6112396040517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81527f159f52c1e3a2b6a6aad3950adf713516211484e0516dad685ea662a094b7c43b60208201527fad7c5bef027816a800da1736444fb58a807ef4c9603b7848673f7e3a68eb14a5604082015246606082015230608082015260a0812060775550565b6112438887612a68565b61124d8787612af8565b5050611257612b8f565b60006112638680614e44565b905011156113245761128c6112788680614e44565b6112856020890189614e44565b8787611f00565b6112b26112998680614e44565b8660005b6020028101906112ad9190614e44565b612bdc565b6112d86112bf8680614e44565b8660015b6020028101906112d39190614e44565b611e2b565b6112fe6112e58680614e44565b8660025b6020028101906112f99190614e44565b612cb1565b61132461130b8680614e44565b8660035b60200281019061131f9190614e44565b612dc2565b60005b6113346040870187614e44565b90508110156113a0576113987f5e5712e902fff5e704bc4d506ad976718319e019e9d2a872528a01a85db433e461136e6040890189614e44565b8481811061137e5761137e614d0b565b90506020020160208101906113939190614213565b612156565b600101611327565b5080156113d5576071805461ff0019169055604051600181526000805160206155e68339815191529060200160405180910390a15b5050505050505050505050565b60006111158383612e97565b600061140a611405607d546001600160601b031690565b612f62565b905090565b61141761219a565b610bd8612f98565b611427611dd1565b61143081612fd5565b610e6e82826120a8565b6000600b6114478161300b565b82518690811415806114595750808514155b15611485576000356001600160e01b0319166040516306b5667560e21b8152600401610c5e9190614778565b8060000361149d57506347c28ec560e11b91506115b2565b60005b818110156115a5578481815181106114ba576114ba614d0b565b60200260200101511561159d578686828181106114d9576114d9614d0b565b90506020020160208101906114ee9190614e8d565b607d80546001600160601b031981166001600160601b03918216939093011691909117905586868281811061152557611525614d0b565b905060200201602081019061153a9190614e8d565b607e60008b8b8581811061155057611550614d0b565b90506020020160208101906115659190614213565b6001600160a01b03168152602081019190915260400160002080546001600160601b0319166001600160601b03929092169190911790555b6001016114a0565b506347c28ec560e11b9250505b5095945050505050565b60008281526073602052604081206111159083613057565b7f5e5712e902fff5e704bc4d506ad976718319e019e9d2a872528a01a85db433e46115fe8161214c565b600061161761161236859003850185614f07565b613063565b905061162b61161236859003850185614f07565b83356000908152607960205260409020541461165a5760405163f4b8742f60e01b815260040160405180910390fd5b82356000908152607a602052604090205460ff1661168b5760405163147bfe0760e01b815260040160405180910390fd5b82356000908152607a602052604090819020805460ff19169055517fd639511b37b3b002cca6cfe6bca0d833945a5af5a045578a0627fc43b79b2630906116d59083908690614fda565b60405180910390a160006116ef6080850160608601614213565b9050600061170561012086016101008701615060565b6002811115611716576117166147cc565b036117dd576000611730368690038601610100870161507b565b6001600160a01b0383166000908152603b602052604090205490915061175c906101408701359061312d565b60408201526000611776368790038701610100880161507b565b604083015190915061178d90610140880135615097565b60408201526074546117ad908390339086906001600160a01b0316613147565b6117d66117c06060880160408901614213565b60745483919086906001600160a01b0316613147565b5050611819565b6118196117f06060860160408701614213565b60745483906001600160a01b03166118113689900389016101008a0161507b565b929190613147565b7f21e88e956aa3e086f6388e899965cef814688f99ad8bb29b08d396571016372d828560405161184a929190614fda565b60405180910390a150505050565b60009182526072602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61188b611dd1565b60008390036118ad576040516316ee9d3b60e11b815260040160405180910390fd5b610cfb84848484612bdc565b6000806118c4611dd1565b6118ce8484612af8565b90925090506118db612b8f565b9250929050565b60006118f6607d546001600160601b031690565b60375461190391906150aa565b60385461191090846150aa565b101592915050565b611920611dd1565b6000839003611942576040516316ee9d3b60e11b815260040160405180910390fd5b610cfb84848484612cb1565b60408051808201909152600080825260208201526001600160a01b0382166000908152607860205260409081902081518083019092528054829060ff16600281111561199c5761199c6147cc565b60028111156119ad576119ad6147cc565b815290546001600160a01b03610100909104811660209283015290820151919250166119ec57604051631b79f53b60e21b815260040160405180910390fd5b919050565b6119f9611dd1565b611a038282612a68565b610e6e612b8f565b6000600b611a188161300b565b84838114611a47576000356001600160e01b0319166040516306b5667560e21b8152600401610c5e9190614778565b80600003611a5f5750636242a4ef60e11b9150611b96565b6000805b82811015611b4657868682818110611a7d57611a7d614d0b565b9050602002016020810190611a9291906150c1565b15611b3e57607e60008a8a84818110611aad57611aad614d0b565b9050602002016020810190611ac29190614213565b6001600160a01b0316815260208101919091526040016000908120546001600160601b03169290920191607e908a8a84818110611b0157611b01614d0b565b9050602002016020810190611b169190614213565b6001600160a01b03168152602081019190915260400160002080546001600160601b03191690555b600101611a63565b50607d8054829190600090611b659084906001600160601b03166150de565b92506101000a8154816001600160601b0302191690836001600160601b0316021790555063c48549de60e01b935050505b50949350505050565b6000818152607360205260408120610c1a90613379565b600082815260726020526040902060010154611bd18161214c565b610def8383612178565b611be3611dd1565b6110a981612a1a565b6000611c00607d546001600160601b031690565b600154611c0d91906150aa565b60025461191090846150aa565b60007fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb600083600f811115611c5157611c516147cc565b60ff1681526020810191909152604001600020546001600160a01b03169050806119ec578160405163409140df60e11b8152600401610c5e919061510e565b611c98611dd1565b6000869003611cba576040516316ee9d3b60e11b815260040160405180910390fd5b611cc8878787878787611f00565b611cd5878783600061129d565b611ce287878360016112c3565b611cef87878360026112e9565b611cfc878783600361130f565b50505050505050565b611d0d611dd1565b6000839003611d2f576040516316ee9d3b60e11b815260040160405180910390fd5b610cfb84848484612dc2565b611d4361225b565b8060005b81811015610cfb57611d7a848483818110611d6457611d64614d0b565b905060a002018036038101906110a39190614da7565b600101611d47565b611d8a61225b565b611d92614193565b3381526040808201513491015280516110a99082906122a1565b60006001600160e01b03198216630271189760e51b1480610c1a5750610c1a82613383565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b03163314610bd8576000356001600160e01b0319166001604051620f948f60ea1b8152600401610c5e92919061511c565b828114611e59576000356001600160e01b0319166040516306b5667560e21b8152600401610c5e9190614778565b60005b83811015611eca57828282818110611e7657611e76614d0b565b90506020020135603a6000878785818110611e9357611e93614d0b565b9050602002016020810190611ea89190614213565b6001600160a01b03168152602081019190915260400160002055600101611e5c565b507f64557254143204d91ba2d95acb9fda1e5fea55f77efd028685765bc1e94dd4b58484848460405161184a9493929190615193565b8483148015611f0e57508481145b611f39576000356001600160e01b0319166040516306b5667560e21b8152600401610c5e9190614778565b60005b8581101561205e57848482818110611f5657611f56614d0b565b9050602002016020810190611f6b9190614213565b60786000898985818110611f8157611f81614d0b565b9050602002016020810190611f969190614213565b6001600160a01b03908116825260208201929092526040016000208054610100600160a81b0319166101009390921692909202179055828282818110611fde57611fde614d0b565b9050602002016020810190611ff39190615060565b6078600089898581811061200957612009614d0b565b905060200201602081019061201e9190614213565b6001600160a01b031681526020810191909152604001600020805460ff19166001836002811115612051576120516147cc565b0217905550600101611f3c565b507fa4f03cc9c0e0aeb5b71b4ec800702753f65748c2cf3064695ba8e8b46be70444868686868686604051612098969594939291906151df565b60405180910390a1505050505050565b807fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb600084600f8111156120de576120de6147cc565b60ff168152602081019190915260400160002080546001600160a01b0319166001600160a01b03928316179055811682600f81111561211f5761211f6147cc565b6040517f865d1c228a8ea13709cfe61f346f7ff67f1bbd4a18ff31ad3e7147350d317c5990600090a35050565b6110a981336133a8565b612160828261340c565b6000828152607360205260409020610def9082613492565b61218282826134a7565b6000828152607360205260409020610def908261350e565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b03163314806121dc57506005546001600160a01b031633145b610bd8576000356001600160e01b0319166001604051620f948f60ea1b8152600401610c5e92919061511c565b612211613523565b6000805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60005460ff1615610bd85760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610c5e565b604080518082018252600080825260208201526074549184015190916001600160a01b0316906122d09061356c565b60208401516001600160a01b031661237157348460400151604001511461230a5760405163129c2ce160e31b815260040160405180910390fd5b6123138161194e565b604085015151909250600281111561232d5761232d6147cc565b82516002811115612340576123406147cc565b1461235d5760405162035e2b60ea1b815260040160405180910390fd5b6001600160a01b0381166020850152612509565b34156123905760405163129c2ce160e31b815260040160405180910390fd5b61239d846020015161194e565b60408501515190925060028111156123b7576123b76147cc565b825160028111156123ca576123ca6147cc565b146123e75760405162035e2b60ea1b815260040160405180910390fd5b602084015160408501516123fc9185906135b0565b83602001516001600160a01b0316816001600160a01b03160361250957607454607f54604086810151810151905163095ea7b360e01b81526001600160a01b039283166004820152602481019190915291169063095ea7b3906044016020604051808303816000875af1158015612477573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061249b9190615250565b50607f546040808601518101519051636f074d1f60e11b81526001600160a01b039092169163de0e9a3e916124d69160040190815260200190565b600060405180830381600087803b1580156124f057600080fd5b505af1158015612504573d6000803e3d6000fd5b505050505b607680546000918261251a8361526d565b9190505590506000612541858386602001516075548a61372990949392919063ffffffff16565b90507fd7b25068d9dc8d00765254cfb7f5070f98d263c8d68931d937c7362fa738048b61256d82613063565b826040516120989291906152a6565b60008235610140840135826125976080870160608801614213565b90506125b46125af368890038801610100890161507b565b61356c565b60016125c66040880160208901615342565b60018111156125d7576125d76147cc565b146125f55760405163182f3d8760e11b815260040160405180910390fd5b608086013546146126375760405163092048d160e11b81526000356001600160e01b031916600482015260808701356024820152466044820152606401610c5e565b600061264c61097f6080890160608a01614213565b905061266061012088016101008901615060565b6002811115612671576126716147cc565b81516002811115612684576126846147cc565b1480156126b5575061269c60e0880160c08901614213565b6001600160a01b031681602001516001600160a01b0316145b80156126c6575060755460e0880135145b6126e35760405163f4b8742f60e01b815260040160405180910390fd5b6000848152607960205260409020541561271057604051634f13df6160e01b815260040160405180910390fd5b600161272461012089016101008a01615060565b6002811115612735576127356147cc565b148061274857506127468284612e97565b155b6127655760405163c51297b760e01b815260040160405180910390fd5b6000612779611612368a90038a018a614f07565b90506000612789607754836137fe565b905060006127a96127a26101208c016101008d01615060565b868861383f565b60408051606081018252600080825260208201819052918101829052919a50919250819081906000805b8e518110156128e7578e81815181106127ee576127ee614d0b565b6020908102919091018101518051818301516040808401518151600081529586018083528e905260ff9093169085015260608401526080830152935060019060a0016020604051602081039080840390855afa158015612852573d6000803e3d6000fd5b505050602060405103519450846001600160a01b0316846001600160a01b03161061289e576000356001600160e01b031916604051635d3dcd3160e01b8152600401610c5e9190614778565b6001600160a01b0385166000908152607e60205260409020548594506001600160601b03166128cd908361535d565b91508682106128df57600195506128e7565b6001016127d3565b508461290657604051639e8f5f6360e01b815260040160405180910390fd5b505050600089815260796020526040902085905550508715612981576000878152607a602052604090819020805460ff19166001179055517f89e52969465b1f1866fc5d46fd62de953962e9cb33552443cd999eba05bd20dc9061296d9085908d90614fda565b60405180910390a150505050505050610c1a565b61298b85876138cf565b6129ca61299e60608c0160408d01614213565b86607460009054906101000a90046001600160a01b03168d61010001803603810190611811919061507b565b7f21e88e956aa3e086f6388e899965cef814688f99ad8bb29b08d396571016372d838b6040516129fb929190614fda565b60405180910390a15050505050505092915050565b610e6e8282612156565b607480546001600160a01b0319166001600160a01b0383169081179091556040519081527f9d2334c23be647e994f27a72c5eee42a43d5bdcfe15bb88e939103c2b114cbaf90602001611044565b80821115612a97576000356001600160e01b0319166040516387f6f09560e01b8152600401610c5e9190614778565b6001805460028054858455908490556004805493840190556040805183815260208101839052929391928592879290917f976f8a9c5bdf8248dec172376d6e2b80a8e3df2f0328e381c6db8e1cf138c0f8910160405180910390a450505050565b60008082841115612b2a576000356001600160e01b0319166040516387f6f09560e01b8152600401610c5e9190614778565b5050603780546038805492859055839055600480546001810190915560408051838152602081018590529293928592879290917f31312c97b89cc751b832d98fd459b967a2c3eef3b49757d1cf5ebaa12bb6eee1910160405180910390a49250929050565b600254603754612b9f91906150aa565b603854600154612baf91906150aa565b1115610bd8576000356001600160e01b0319166040516387f6f09560e01b8152600401610c5e9190614778565b828114612c0a576000356001600160e01b0319166040516306b5667560e21b8152600401610c5e9190614778565b60005b83811015612c7b57828282818110612c2757612c27614d0b565b9050602002013560396000878785818110612c4457612c44614d0b565b9050602002016020810190612c599190614213565b6001600160a01b03168152602081019190915260400160002055600101612c0d565b507f80bc635c452ae67f12f9b6f12ad4daa6dbbc04eeb9ebb87d354ce10c0e210dc08484848460405161184a9493929190615193565b828114612cdf576000356001600160e01b0319166040516306b5667560e21b8152600401610c5e9190614778565b60005b83811015612d8c57620f4240838383818110612d0057612d00614d0b565b905060200201351115612d265760405163572d3bd360e11b815260040160405180910390fd5b828282818110612d3857612d38614d0b565b90506020020135603b6000878785818110612d5557612d55614d0b565b9050602002016020810190612d6a9190614213565b6001600160a01b03168152602081019190915260400160002055600101612ce2565b507fb05f5de88ae0294ebb6f67c5af2fcbbd593cc6bdfe543e2869794a4c8ce3ea508484848460405161184a9493929190615193565b828114612df0576000356001600160e01b0319166040516306b5667560e21b8152600401610c5e9190614778565b60005b83811015612e6157828282818110612e0d57612e0d614d0b565b90506020020135603c6000878785818110612e2a57612e2a614d0b565b9050602002016020810190612e3f9190614213565b6001600160a01b03168152602081019190915260400160002055600101612df3565b507fb5d2963614d72181b4df1f993d45b83edf42fa19710f0204217ba1b3e183bb738484848460405161184a9493929190615193565b6001600160a01b0382166000908152603a60205260408120548210612ebe57506000610c1a565b6000612ecd6201518042615370565b6001600160a01b0385166000908152603e6020526040902054909150811115612f135750506001600160a01b0382166000908152603c6020526040902054811015610c1a565b6001600160a01b0384166000908152603d6020526040902054612f3790849061535d565b6001600160a01b0385166000908152603c602052604090205411159150610c1a9050565b5092915050565b6000600254600160025484600154612f7a91906150aa565b612f84919061535d565b612f8e9190615097565b610c1a9190615370565b612fa061225b565b6000805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861223e3390565b806001600160a01b03163b6000036110a957604051630bfc64a360e21b81526001600160a01b0382166004820152602401610c5e565b61301481611c1a565b6001600160a01b0316336001600160a01b0316146110a9576000356001600160e01b03191681336040516320e0f98d60e21b8152600401610c5e93929190615392565b6000611115838361395f565b6000806130738360400151613989565b905060006130848460600151613989565b905060006130d88560800151604080517f1e2b74b2a792d5c0f0b6e59b037fa9d43d84fbb759337f0112fcc15ca414fc8d815282516020808301919091528301518183015291015160608201526080902090565b604080517fb9d1fe7c9deeec5dc90a2f47ff1684239519f2545b2228d3d91fb27df3189eea815287516020808301919091529097015190870152606086019390935250608084015260a08301525060c0902090565b6000620f424061313d83856150aa565b6111159190615370565b806001600160a01b0316826001600160a01b0316036131f45760408085015190516001600160a01b0385169180156108fc02916000818181858888f193505050506131ef57806001600160a01b031663d0e30db085604001516040518263ffffffff1660e01b81526004016000604051808303818588803b1580156131cb57600080fd5b505af11580156131df573d6000803e3d6000fd5b50505050506131ef8484846139d1565b610cfb565b600084516002811115613209576132096147cc565b036132cf576040516370a0823160e01b81523060048201526000906001600160a01b038416906370a0823190602401602060405180830381865afa158015613255573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061327991906153c9565b905084604001518110156132be576132a1833083886040015161329c9190615097565b613a50565b6132be57604051632f739fff60e11b815260040160405180910390fd5b6132c98585856139d1565b50610cfb565b6001845160028111156132e4576132e46147cc565b03613315576132f882848660200151613af5565b6131ef5760405163c8e3a09f60e01b815260040160405180910390fd5b60028451600281111561332a5761332a6147cc565b0361336057613343828486602001518760400151613b1c565b6131ef576040516334b471a760e21b815260040160405180910390fd5b6040516361e411a760e11b815260040160405180910390fd5b6000610c1a825490565b60006001600160e01b03198216635a05180f60e01b1480610c1a5750610c1a82613b49565b6133b28282611858565b610e6e576133ca816001600160a01b03166014613b7e565b6133d5836020613b7e565b6040516020016133e6929190615406565b60408051601f198184030181529082905262461bcd60e51b8252610c5e916004016154a7565b6134168282611858565b610e6e5760008281526072602090815260408083206001600160a01b03851684529091529020805460ff1916600117905561344e3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000611115836001600160a01b038416613d19565b6134b18282611858565b15610e6e5760008281526072602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000611115836001600160a01b038416613d68565b60005460ff16610bd85760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610c5e565b61357581613e5b565b80613584575061358481613e92565b80613593575061359381613eba565b6110a95760405163034992a760e51b815260040160405180910390fd5b6000606081855160028111156135c8576135c86147cc565b036136a35760408581015181516001600160a01b03878116602483015230604483015260648083019390935283518083039093018352608490910183526020820180516001600160e01b03166323b872dd60e01b17905291519185169161362f91906154ba565b6000604051808303816000865af19150503d806000811461366c576040519150601f19603f3d011682016040523d82523d6000602084013e613671565b606091505b50909250905081801561369c57508051158061369c57508080602001905181019061369c9190615250565b91506136fc565b6001855160028111156136b8576136b86147cc565b036136cd5761369c8385308860200151613ee3565b6002855160028111156136e2576136e26147cc565b036133605761369c83853088602001518960400151613f91565b816137225784843085604051639d2e4c6760e01b8152600401610c5e94939291906154d6565b5050505050565b6137996040805160a08101825260008082526020808301829052835160608082018652838252818301849052818601849052848601919091528451808201865283815280830184905280860184905281850152845190810185528281529081018290529283015290608082015290565b83815260006020820181905250604080820180516001600160a01b039788169052602080890151825190891690820152905146908301528751606084018051918916909152805195909716940193909352935182015292909201516080820152919050565b6040805161190160f01b6020808301919091526022820185905260428083018590528351808403909101815260629092019092528051910120600090611115565b6000806000613856607d546001600160601b031690565b905061386181612f62565b92506000866002811115613877576138776147cc565b036138c6576001600160a01b03851660009081526039602052604090205484106138a7576138a481614045565b92505b6001600160a01b0385166000908152603a602052604090205484101591505b50935093915050565b60006138de6201518042615370565b6001600160a01b0384166000908152603e602052604090205490915081111561392d576001600160a01b03929092166000908152603e6020908152604080832094909455603d90529190912055565b6001600160a01b0383166000908152603d60205260408120805484929061395590849061535d565b9091555050505050565b600082600001828154811061397657613976614d0b565b9060005260206000200154905092915050565b604080517f353bdd8d69b9e3185b3972e08b03845c0c14a21a390215302776a7a34b0e8764815282516020808301919091528301518183015291015160608201526080902090565b600080845160028111156139e7576139e76147cc565b03613a02576139fb8284866040015161405d565b9050613a2c565b600184516002811115613a1757613a176147cc565b03613360576139fb8230858760200151613ee3565b80610cfb578383836040516341bd7d9160e11b8152600401610c5e9392919061550c565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b03166340c10f1960e01b1790529151600092861691613aa8916154ba565b6000604051808303816000865af19150503d8060008114613ae5576040519150601f19603f3d011682016040523d82523d6000602084013e613aea565b606091505b509095945050505050565b6000613b0384308585613ee3565b90508061111557613b15848484613a50565b9050611115565b6000613b2b8530868686613f91565b905080613b4157613b3e85858585614130565b90505b949350505050565b60006001600160e01b03198216637965db0b60e01b1480610c1a57506301ffc9a760e01b6001600160e01b0319831614610c1a565b60606000613b8d8360026150aa565b613b9890600261535d565b6001600160401b03811115613baf57613baf6145e2565b6040519080825280601f01601f191660200182016040528015613bd9576020820181803683370190505b509050600360fc1b81600081518110613bf457613bf4614d0b565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613c2357613c23614d0b565b60200101906001600160f81b031916908160001a9053506000613c478460026150aa565b613c5290600161535d565b90505b6001811115613cca576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613c8657613c86614d0b565b1a60f81b828281518110613c9c57613c9c614d0b565b60200101906001600160f81b031916908160001a90535060049490941c93613cc38161553c565b9050613c55565b5083156111155760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610c5e565b6000818152600183016020526040812054613d6057508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610c1a565b506000610c1a565b60008181526001830160205260408120548015613e51576000613d8c600183615097565b8554909150600090613da090600190615097565b9050818114613e05576000866000018281548110613dc057613dc0614d0b565b9060005260206000200154905080876000018481548110613de357613de3614d0b565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080613e1657613e16615553565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610c1a565b6000915050610c1a565b60008082516002811115613e7157613e716147cc565b148015613e82575060008260400151115b8015610c1a575050602001511590565b6000600182516002811115613ea957613ea96147cc565b148015610c1a575050604001511590565b6000600282516002811115613ed157613ed16147cc565b148015610c1a57505060400151151590565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b1790529151600092871691613f43916154ba565b6000604051808303816000865af19150503d8060008114613f80576040519150601f19603f3d011682016040523d82523d6000602084013e613f85565b606091505b50909695505050505050565b604080516000808252602082019092526001600160a01b03871690613fc190879087908790879060448101615569565b60408051601f198184030181529181526020820180516001600160e01b0316637921219560e11b17905251613ff691906154ba565b6000604051808303816000865af19150503d8060008114614033576040519150601f19603f3d011682016040523d82523d6000602084013e614038565b606091505b5090979650505050505050565b6000603854600160385484603754612f7a91906150aa565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b1790529151600092606092908716916140ba91906154ba565b6000604051808303816000865af19150503d80600081146140f7576040519150601f19603f3d011682016040523d82523d6000602084013e6140fc565b606091505b5090925090508180156141275750805115806141275750808060200190518101906141279190615250565b95945050505050565b604080516000808252602082019092526001600160a01b0386169061415e90869086908690604481016155ae565b60408051601f198184030181529181526020820180516001600160e01b031663731133e960e01b17905251613f4391906154ba565b60408051606081018252600080825260208201529081016141cf6040805160608101909152806000815260200160008152602001600081525090565b905290565b6000602082840312156141e657600080fd5b81356001600160e01b03198116811461111557600080fd5b6001600160a01b03811681146110a957600080fd5b60006020828403121561422557600080fd5b8135611115816141fe565b60008083601f84011261424257600080fd5b5081356001600160401b0381111561425957600080fd5b6020830191508360208260051b85010111156118db57600080fd5b6000806000806040858703121561428a57600080fd5b84356001600160401b03808211156142a157600080fd5b6142ad88838901614230565b909650945060208701359150808211156142c657600080fd5b506142d387828801614230565b95989497509550505050565b600080600080600080606087890312156142f857600080fd5b86356001600160401b038082111561430f57600080fd5b61431b8a838b01614230565b9098509650602089013591508082111561433457600080fd5b6143408a838b01614230565b9096509450604089013591508082111561435957600080fd5b5061436689828a01614230565b979a9699509497509295939492505050565b80356119ec816141fe565b60006020828403121561439557600080fd5b5035919050565b600080604083850312156143af57600080fd5b8235915060208301356143c1816141fe565b809150509250929050565b600060a082840312156143de57600080fd5b50919050565b600061016082840312156143de57600080fd5b6000806000610180848603121561440d57600080fd5b61441785856143e4565b92506101608401356001600160401b038082111561443457600080fd5b818601915086601f83011261444857600080fd5b81358181111561445757600080fd5b87602060608302850101111561446c57600080fd5b6020830194508093505050509250925092565b8060608101831015610c1a57600080fd5b8060808101831015610c1a57600080fd5b6000806000806000806000806000806101208b8d0312156144c157600080fd5b6144ca8b614378565b99506144d860208c01614378565b985060408b0135975060608b0135965060808b0135955060a08b0135945060c08b01356001600160401b038082111561451057600080fd5b61451c8e838f0161447f565b955060e08d013591508082111561453257600080fd5b61453e8e838f01614490565b94506101008d013591508082111561455557600080fd5b506145628d828e01614230565b915080935050809150509295989b9194979a5092959850565b6000806040838503121561458e57600080fd5b8235614599816141fe565b946020939093013593505050565b8035601081106119ec57600080fd5b600080604083850312156145c957600080fd5b6145d2836145a7565b915060208301356143c1816141fe565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b038111828210171561461a5761461a6145e2565b60405290565b604051601f8201601f191681016001600160401b0381118282101715614648576146486145e2565b604052919050565b60006001600160401b03821115614669576146696145e2565b5060051b60200190565b80151581146110a957600080fd5b60008060008060006060868803121561469957600080fd5b85356001600160401b03808211156146b057600080fd5b6146bc89838a01614230565b90975095506020915087820135818111156146d657600080fd5b6146e28a828b01614230565b9096509450506040880135818111156146fa57600080fd5b88019050601f8101891361470d57600080fd5b803561472061471b82614650565b614620565b81815260059190911b8201830190838101908b83111561473f57600080fd5b928401925b8284101561476657833561475781614673565b82529284019290840190614744565b80955050505050509295509295909350565b6001600160e01b031991909116815260200190565b600080604083850312156147a057600080fd5b50508035926020909101359150565b600061016082840312156147c257600080fd5b61111583836143e4565b634e487b7160e01b600052602160045260246000fd5b600381106147f2576147f26147cc565b9052565b60006040820190506148098284516147e2565b6020928301516001600160a01b0316919092015290565b600082601f83011261483157600080fd5b8135602061484161471b83614650565b8083825260208201915060208460051b87010193508684111561486357600080fd5b602086015b8481101561487f5780358352918301918301614868565b509695505050505050565b600082601f83011261489b57600080fd5b81356001600160401b038111156148b4576148b46145e2565b6148c7601f8201601f1916602001614620565b8181528460208386010111156148dc57600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a0868803121561491157600080fd5b853561491c816141fe565b9450602086013561492c816141fe565b935060408601356001600160401b038082111561494857600080fd5b61495489838a01614820565b9450606088013591508082111561496a57600080fd5b61497689838a01614820565b9350608088013591508082111561498c57600080fd5b506149998882890161488a565b9150509295509295909350565b6000602082840312156149b857600080fd5b611115826145a7565b60008060008060008060006080888a0312156149dc57600080fd5b87356001600160401b03808211156149f357600080fd5b6149ff8b838c01614230565b909950975060208a0135915080821115614a1857600080fd5b614a248b838c01614230565b909750955060408a0135915080821115614a3d57600080fd5b614a498b838c01614230565b909550935060608a0135915080821115614a6257600080fd5b50614a6f8a828b01614490565b91505092959891949750929550565b60008060208385031215614a9157600080fd5b82356001600160401b0380821115614aa857600080fd5b818501915085601f830112614abc57600080fd5b813581811115614acb57600080fd5b86602060a083028501011115614ae057600080fd5b60209290920196919550909350505050565b600080600080600060a08688031215614b0a57600080fd5b8535614b15816141fe565b94506020860135614b25816141fe565b9350604086013592506060860135915060808601356001600160401b03811115614b4e57600080fd5b6149998882890161488a565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b600082601f830112614bb957600080fd5b81516020614bc961471b83614650565b8083825260208201915060208460051b870101935086841115614beb57600080fd5b602086015b8481101561487f578051614c03816141fe565b8352918301918301614bf0565b6001600160601b03811681146110a957600080fd5b600080600060608486031215614c3a57600080fd5b83516001600160401b0380821115614c5157600080fd5b614c5d87838801614ba8565b9450602091508186015181811115614c7457600080fd5b614c8088828901614ba8565b945050604086015181811115614c9557600080fd5b86019050601f81018713614ca857600080fd5b8051614cb661471b82614650565b81815260059190911b82018301908381019089831115614cd557600080fd5b928401925b82841015614cfc578351614ced81614c10565b82529284019290840190614cda565b80955050505050509250925092565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6001600160601b03818116838216019080821115612f5b57612f5b614d21565b8035600381106119ec57600080fd5b600060608284031215614d7857600080fd5b614d806145f8565b9050614d8b82614d57565b8152602082013560208201526040820135604082015292915050565b600060a08284031215614db957600080fd5b614dc16145f8565b8235614dcc816141fe565b81526020830135614ddc816141fe565b6020820152614dee8460408501614d66565b60408201529392505050565b600060608284031215614e0c57600080fd5b614e146145f8565b823560ff81168114614e2557600080fd5b8152602083810135908201526040928301359281019290925250919050565b6000808335601e19843603018112614e5b57600080fd5b8301803591506001600160401b03821115614e7557600080fd5b6020019150600581901b36038213156118db57600080fd5b600060208284031215614e9f57600080fd5b813561111581614c10565b8035600281106119ec57600080fd5b600060608284031215614ecb57600080fd5b614ed36145f8565b90508135614ee0816141fe565b81526020820135614ef0816141fe565b806020830152506040820135604082015292915050565b60006101608284031215614f1a57600080fd5b60405160a081018181106001600160401b0382111715614f3c57614f3c6145e2565b60405282358152614f4f60208401614eaa565b6020820152614f618460408501614eb9565b6040820152614f738460a08501614eb9565b6060820152614f86846101008501614d66565b60808201529392505050565b600281106147f2576147f26147cc565b8035614fad816141fe565b6001600160a01b039081168352602082013590614fc9826141fe565b166020830152604090810135910152565b60006101808201905083825282356020830152614ff960208401614eaa565b6150066040840182614f92565b506150176060830160408501614fa2565b61502760c0830160a08501614fa2565b61012061504281840161503d6101008701614d57565b6147e2565b61014081850135818501528085013561016085015250509392505050565b60006020828403121561507257600080fd5b61111582614d57565b60006060828403121561508d57600080fd5b6111158383614d66565b81810381811115610c1a57610c1a614d21565b8082028115828204841417610c1a57610c1a614d21565b6000602082840312156150d357600080fd5b813561111581614673565b6001600160601b03828116828216039080821115612f5b57612f5b614d21565b601081106147f2576147f26147cc565b60208101610c1a82846150fe565b6001600160e01b03198316815260408101600b831061513d5761513d6147cc565b8260208301529392505050565b8183526000602080850194508260005b8581101561518857813561516d816141fe565b6001600160a01b03168752958201959082019060010161515a565b509495945050505050565b6040815260006151a760408301868861514a565b82810360208401528381526001600160fb1b038411156151c657600080fd5b8360051b80866020840137016020019695505050505050565b6060815260006151f360608301888a61514a565b6020838203602085015261520882888a61514a565b848103604086015285815286925060200160005b86811015615241576152318261503d86614d57565b928201929082019060010161521c565b509a9950505050505050505050565b60006020828403121561526257600080fd5b815161111581614673565b60006001820161527f5761527f614d21565b5060010190565b6152918282516147e2565b60208181015190830152604090810151910152565b6000610180820190508382528251602083015260208301516152cb6040840182614f92565b5060408381015180516001600160a01b03908116606086015260208201511660808501529081015160a084015250606083015180516001600160a01b0390811660c085015260208201511660e0840152604081015161010084015250608083015161533a610120840182615286565b509392505050565b60006020828403121561535457600080fd5b61111582614eaa565b80820180821115610c1a57610c1a614d21565b60008261538d57634e487b7160e01b600052601260045260246000fd5b500490565b6001600160e01b031984168152606081016153b060208301856150fe565b6001600160a01b03929092166040919091015292915050565b6000602082840312156153db57600080fd5b5051919050565b60005b838110156153fd5781810151838201526020016153e5565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161543e8160178501602088016153e2565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161546f8160288401602088016153e2565b01602801949350505050565b600081518084526154938160208601602086016153e2565b601f01601f19169290920160200192915050565b602081526000611115602083018461547b565b600082516154cc8184602087016153e2565b9190910192915050565b60c081016154e48287615286565b6001600160a01b0394851660608301529284166080820152921660a090920191909152919050565b60a0810161551a8286615286565b6001600160a01b03938416606083015291909216608090920191909152919050565b60008161554b5761554b614d21565b506000190190565b634e487b7160e01b600052603160045260246000fd5b6001600160a01b03868116825285166020820152604081018490526060810183905260a0608082018190526000906155a39083018461547b565b979650505050505050565b60018060a01b03851681528360208201528260408201526080606082015260006155db608083018461547b565b969550505050505056fe7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498a2646970667358221220adc544fca693cfd23fbe440435aafb94a2ad08c9840546710b0fb29a782fcc0e64736f6c63430008170033
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.