More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 13,475 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Resolve | 637912 | 1 sec ago | IN | 0 S | 0.00010201 | ||||
Resolve | 637911 | 2 secs ago | IN | 0 S | 0.00007708 | ||||
Resolve | 637888 | 26 secs ago | IN | 0 S | 0.00007701 | ||||
Resolve | 637853 | 55 secs ago | IN | 0 S | 0.00010198 | ||||
Resolve | 637851 | 56 secs ago | IN | 0 S | 0.00010201 | ||||
Resolve | 637813 | 1 min ago | IN | 0 S | 0.00013998 | ||||
Resolve | 637776 | 2 mins ago | IN | 0 S | 0.00010196 | ||||
Resolve | 637761 | 2 mins ago | IN | 0 S | 0.00010205 | ||||
Resolve | 637746 | 2 mins ago | IN | 0 S | 0.00007703 | ||||
Resolve | 637738 | 2 mins ago | IN | 0 S | 0.00011494 | ||||
Resolve | 637723 | 3 mins ago | IN | 0 S | 0.00008548 | ||||
Resolve | 637685 | 3 mins ago | IN | 0 S | 0.00013992 | ||||
Resolve | 637677 | 3 mins ago | IN | 0 S | 0.00008995 | ||||
Resolve | 637676 | 3 mins ago | IN | 0 S | 0.00010202 | ||||
Deposit | 637657 | 4 mins ago | IN | 1,011 S | 0.00004149 | ||||
Resolve | 637627 | 4 mins ago | IN | 0 S | 0.00007697 | ||||
Resolve | 637619 | 4 mins ago | IN | 0 S | 0.00008993 | ||||
Deposit | 637598 | 4 mins ago | IN | 258 S | 0.00004356 | ||||
Resolve | 637580 | 5 mins ago | IN | 0 S | 0.00013936 | ||||
Deposit | 637573 | 5 mins ago | IN | 304 S | 0.00004149 | ||||
Resolve | 637561 | 5 mins ago | IN | 0 S | 0.00010203 | ||||
Deposit | 637557 | 5 mins ago | IN | 46.5 S | 0.00004232 | ||||
Resolve | 637548 | 5 mins ago | IN | 0 S | 0.00010201 | ||||
Resolve | 637545 | 5 mins ago | IN | 0 S | 0.00011492 | ||||
Resolve | 637521 | 5 mins ago | IN | 0 S | 0.00007698 |
Latest 25 internal transactions (View All)
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
637888 | 26 secs ago | 399.9 S | ||||
637853 | 55 secs ago | 19.9 S | ||||
637851 | 56 secs ago | 7.2 S | ||||
637813 | 1 min ago | 69.9 S | ||||
637813 | 1 min ago | 2,740.36426542 S | ||||
637776 | 2 mins ago | 7.9 S | ||||
637761 | 2 mins ago | 746.37892394 S | ||||
637746 | 2 mins ago | 35,969.9 S | ||||
637738 | 2 mins ago | 26.9 S | ||||
637738 | 2 mins ago | 9.9 S | ||||
637723 | 3 mins ago | 0.9 S | ||||
637685 | 3 mins ago | 100.9 S | ||||
637685 | 3 mins ago | 6.9 S | ||||
637677 | 3 mins ago | 3.3 S | ||||
637677 | 3 mins ago | 4,099.9 S | ||||
637676 | 3 mins ago | 914.93083684 S | ||||
637627 | 4 mins ago | 4.8 S | ||||
637619 | 4 mins ago | 75.24636111 S | ||||
637619 | 4 mins ago | 2.97 S | ||||
637580 | 5 mins ago | 2,774.9 S | ||||
637561 | 5 mins ago | 138 S | ||||
637548 | 5 mins ago | 149.07387964 S | ||||
637545 | 5 mins ago | 9.9 S | ||||
637545 | 5 mins ago | 0.9 S | ||||
637521 | 5 mins ago | 11.75 S |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
OperaBridge
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 200 runs
Other Settings:
london EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; import {BridgeErrors} from "./BridgeErrors.sol"; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; import {AccessControlDefaultAdminRules} from "@openzeppelin/contracts/access/extensions/AccessControlDefaultAdminRules.sol"; import {Pausable} from "@openzeppelin/contracts/utils/Pausable.sol"; import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; /// @dev OperaBridge is a contract to handle bridging of native tokens between Opera and Sonic chains. /// @custom:security-contact [email protected] contract OperaBridge is AccessControlDefaultAdminRules, Pausable, ReentrancyGuard { uint256 public signatureThreshold; // number of valid signatures required to process a batch uint256 public depositFee; // amount subtracted from a deposit as a flat fee; prevents abuse uint256 public minDepositAmount; // minimal amount of tokens to be deposited; prevents dust swaps uint256 public maxDepositAmount; // maximal amount of tokens to be deposited uint256 public reserveBalance; // the max amount of liquidity supposed to be kept on the bridge contract address public reserveDrain; // the address to be used to drain excessive liquidity to uint256 public immutable peerChainID; // chain ID of the deposits to be resolved here uint256 public lastBatchID; // the latest processed batch ID uint256 public lastResolvedDepositID; // the ID of the latest processed/resolved deposit uint256 public lastDepositID; // monotonic self chain deposit ID /// @dev Role for the validators signing the batch of deposits. bytes32 public constant VALIDATOR_ROLE = keccak256("VALIDATOR_ROLE"); /// @dev Role for the pause/unpause operations. bytes32 public constant PAUSE_ROLE = keccak256("PAUSE_ROLE"); struct Deposit { uint256 id; // deposit ID address recipient; // recipient of the deposit uint256 amount; // amount of the deposit } /// @dev Maps deposit ID of a failed deposit settlement to the original deposit record for later processing. mapping(uint256 depositID => Deposit deposit) public unresolvedDeposit; /// @dev Emitted when the tokens are deposited to the bridge contract. /// @param recipient The recipient of the deposit. /// @param id The deposit ID. /// @param amount The amount of the deposit. /// @param fee The fee subtracted from the deposit. event Deposited(address indexed recipient, uint256 indexed id, uint256 amount, uint256 fee); /// @dev Emitted when the deposit is resolved on the peer chain. /// @param recipient The recipient of the deposit. /// @param id The deposit ID. event Resolved(address indexed recipient, uint256 indexed id); /// @dev Emitted when a deposit is not resolved due to a settlement sub-call revert. /// This may happen if a contract was deployed on the recipient EOA address via EIP-7702. /// @param recipient The recipient of the failed deposit. /// @param id The deposit ID. event Failed(address indexed recipient, uint256 indexed id); /// @dev Emitted when the batch of deposits is processed. /// @param id The batch ID. event BatchProcessed(uint256 indexed id); /// @dev Emitted when the required signature threshold for batch processing gets updated. /// @param newSignatureThreshold The new number of signatures required to confirm a batch. event SignatureThresholdUpdated(uint256 newSignatureThreshold); /// @dev Emitted when the amount of fee deducted from a deposited amount gets updated. /// @param newDepositFee The new amount of fee to be deducted from deposits. event DepositFeeUpdated(uint256 newDepositFee); /// @dev Emitted when the required minimal deposited amount gets updated. /// @param newMinimalDepositAmount The new minimal required amount of deposit. event MinimalDepositAmountUpdated(uint256 newMinimalDepositAmount); /// @dev Emitted when the required maximal deposited amount gets updated. /// @param newMaximalDepositAmount The new maximal required amount of deposit. event MaximalDepositAmountUpdated(uint256 newMaximalDepositAmount); /// @dev Emitted when the maximal reserve amount and the excessive reserve drain address gets updated. /// @param newReserveAmount The new maximal amount of liquidity reserve to be kept on contract. /// @param newReserveDrain The new excessive reserve balance recipient address. event ReserveBalanceUpdated(uint256 newReserveAmount, address newReserveDrain); /// @dev Initializes the bridge contract with the given parameters. /// @param _cfgAdmin The address of the configuration admin. /// @param _peerChainID The chain ID of the deposits to be resolved. /// @param _fee The deposit fee. /// @param _minDeposit The minimal deposit amount. /// @param _sigThreshold The signature threshold to process a batch. /// @param _batchCheckpoint The checkpoint of the last processed batch. constructor( address _cfgAdmin, uint256 _peerChainID, uint256 _fee, uint256 _minDeposit, uint256 _sigThreshold, uint256 _batchCheckpoint) AccessControlDefaultAdminRules(5 days, _cfgAdmin) ReentrancyGuard() { if (_minDeposit <= _fee) { revert BridgeErrors.InvalidMinDepositToFee(_minDeposit, _fee); } if (_sigThreshold == 0) { revert BridgeErrors.InvalidSignatureThreshold(); } peerChainID = _peerChainID; depositFee = _fee; minDepositAmount = _minDeposit; // prevent large deposits after deployment, desired amount will be set later maxDepositAmount = _minDeposit + 1 ether; signatureThreshold = _sigThreshold; lastBatchID = _batchCheckpoint; } /// @dev Fallback function to reject any incoming value. receive() external payable { // reject implicit deposit and/or refill; included to revert with custom error revert BridgeErrors.InvalidImplicitDeposit(msg.value); } /// @dev Deposits the tokens to the bridge contract to be resolved on the peer chain. /// @param fee The fee valid at the time of deposit. function deposit(uint256 fee) external payable whenNotPaused { if (msg.value < minDepositAmount) { revert BridgeErrors.DepositBelowLimit(minDepositAmount, msg.value); } if (msg.value > maxDepositAmount) { revert BridgeErrors.DepositAboveLimit(maxDepositAmount, msg.value); } if (fee != depositFee) { revert BridgeErrors.FeeChanged(depositFee, fee); } if (msg.sender != tx.origin) { revert BridgeErrors.InvalidRecipient(msg.sender, tx.origin); } lastDepositID++; // no deposit #0 emit Deposited(msg.sender, lastDepositID, msg.value - depositFee, depositFee); } /// @dev Resolves the batch of deposits on the peer chain. /// The batch has to be signed by the validators to be resolved. /// @param batchID The batch ID of the deposits to be resolved. /// @param total The total amount of the deposits in the batch. /// @param deposits The array of deposits to be resolved. /// @param signatures The array of signatures to be verified. function resolve(uint256 batchID, uint256 total, Deposit[] calldata deposits, bytes[] calldata signatures) external { // fail early on relay of an old batch if (!_isValidBatchSequence(lastBatchID, batchID)) { revert BridgeErrors.InvalidBatchSequence(lastBatchID, batchID); } // fail early on balance deficit so we can retry the batch later if (address(this).balance < total) { revert BridgeErrors.InsufficientLiquidity(address(this).balance, total); } uint256 sig = _verifySignatures(batchID, total, deposits, signatures); if (sig < signatureThreshold) { revert BridgeErrors.SignatureDeficit(signatureThreshold, sig); } _processBatch(batchID, total, deposits); emit BatchProcessed(batchID); } /// @dev Processes the batch of deposits on the peer chain. /// The batch is processed by transferring the tokens to the recipients. /// @param batchID The batch ID of the deposits to be processed. /// @param total The total amount of the deposits in the batch. /// @param deposits The array of deposits to be processed. function _processBatch(uint256 batchID, uint256 total, Deposit[] calldata deposits) internal nonReentrant { uint256 depositSum; lastBatchID = batchID; uint256 _lastResolvedDeposit = lastResolvedDepositID; for (uint256 i; i < deposits.length; i++) { if (deposits[i].id != _lastResolvedDeposit + 1) { revert BridgeErrors.InvalidDepositSequence(_lastResolvedDeposit, deposits[i].id); } _lastResolvedDeposit = deposits[i].id; depositSum += deposits[i].amount; // the recipient is enforced to be EOA by deposit(); this is expected not to fail // potentially, EIP-7702 allows to deploy a code on the recipient EOA; this code may reject the call // failed settlements are stored to be resolved later by the recipient using the claim() function (bool _success,) = payable(deposits[i].recipient).call{value: deposits[i].amount, gas: 0}(""); if (!_success) { unresolvedDeposit[deposits[i].id] = deposits[i]; emit Failed(deposits[i].recipient, deposits[i].id); continue; } emit Resolved(deposits[i].recipient, deposits[i].id); } if (depositSum != total) { revert BridgeErrors.InvalidDepositSum(total, depositSum); } lastResolvedDepositID = _lastResolvedDeposit; } /// @dev Allows to resolve a failed deposit to a different receiver, if the original recipient can not receive /// settlement transaction because of a code deployed via EIP-7702 after deposit() and before resolve(). /// The claim must be submitted by the original sender/recipient of the deposit to succeed. /// @param depositID The ID of an unresolved deposit waiting to be claimed. /// @param receiver The new recipient of the failed deposit amount. function claim(uint256 depositID, address receiver) external nonReentrant { // the failed settlement must exist if (unresolvedDeposit[depositID].id != depositID) { revert BridgeErrors.DepositNotFound(depositID); } // the claim must be made by the original recipient; may be a contract due to EIP-7702 if (unresolvedDeposit[depositID].recipient != msg.sender) { revert BridgeErrors.InvalidClaimRequests(unresolvedDeposit[depositID].recipient); } uint256 amount = unresolvedDeposit[depositID].amount; if (address(this).balance < amount) { revert BridgeErrors.InsufficientLiquidity(address(this).balance, amount); } delete unresolvedDeposit[depositID]; (bool _success,) = payable(receiver).call{value: amount}(""); if (!_success) { revert BridgeErrors.DepositSettlementFailed(receiver, amount); } emit Resolved(receiver, depositID); } /// @dev Checks if the batch ID is valid and follows the expected sequence. /// The batch ID is [4]uint64{ peer chainID, sequenceID, blockID, deposit event/log index }. /// This encoding allows stateless relays to synchronise on the same batch start without additional communication. /// @param _last The last batch ID. /// @param _new The new batch ID. /// @return True if the batch ID is valid and follows the sequence. function _isValidBatchSequence(uint256 _last, uint256 _new) internal view returns (bool) { return (uint128(_new) > uint128(_last)) && /* monotonic progression is enforced */ (_new >> 192 == peerChainID) && /* the batch must come from the expected peer chain */ (uint64(_new >> 128) == uint64(_last >> 128) + 1); /* the sequence must follow after the previous one */ } /// @dev Verifies the signatures of the validators for given deposits in a batch. /// The batchID approves the intended peer chain origin and the local Chain ID and contract address ensures /// the signatures are intended to be used specifically on this chain and contract. This prevents /// a potential speculative replay attack in case of several deployments of the bridge. /// @param batchID The batch ID of the deposits to be resolved. /// @param total The total amount of the deposits in the batch. /// @param deposits The array of deposits to be resolved. /// @param signatures The array of signatures to be verified. /// @return The number of valid signatures. function _verifySignatures(uint256 batchID, uint256 total, Deposit[] calldata deposits, bytes[] calldata signatures) internal view returns (uint256) { bytes32 msgHash = keccak256(abi.encode(block.chainid, address(this), batchID, total, deposits)); uint256 valid; address lastSigner; // signatures must be sorted by address; it simplifies check for unique signature for (uint256 i; i < signatures.length; i++) { address signer = ECDSA.recover(msgHash, signatures[i]); if (signer > lastSigner && hasRole(VALIDATOR_ROLE, signer)) { lastSigner = signer; valid++; } } return valid; } /// @dev Drains the excessive liquidity from the bridge contract to the reserve drain address. function drain() external { if (reserveDrain == address(0)) { revert BridgeErrors.InvalidDrainAddress(); } if (address(this).balance <= reserveBalance) { revert BridgeErrors.BalanceBelowLimit(reserveBalance, address(this).balance); } // the recipient is managed by DEFAULT_ADMIN_ROLE; we assume it's safe to transfer there (bool _success,) = payable(reserveDrain).call{value: (address(this).balance - reserveBalance), gas: 0}(""); if (!_success) { revert BridgeErrors.DrainFailed(reserveDrain, (address(this).balance - reserveBalance)); } } /// @dev Refills the bridge contract with the liquidity. function refill() external payable { if (address(this).balance > reserveBalance) { revert BridgeErrors.BalanceOverLimit(reserveBalance, address(this).balance); } } /// @dev Sets the signature threshold to process a batch. /// @param _threshold The new signature threshold. function setSignatureThreshold(uint256 _threshold) external onlyRole(DEFAULT_ADMIN_ROLE) { if (_threshold == 0) { revert BridgeErrors.InvalidSignatureThreshold(); } signatureThreshold = _threshold; emit SignatureThresholdUpdated(_threshold); } /// @dev Sets the deposit fee. /// @param _fee The new deposit fee. function setDepositFee(uint256 _fee) external onlyRole(DEFAULT_ADMIN_ROLE) { if (_fee >= minDepositAmount) { revert BridgeErrors.InvalidMinDepositToFee(minDepositAmount, _fee); } depositFee = _fee; emit DepositFeeUpdated(_fee); } /// @dev Sets the minimal deposit amount. /// @param _min The new minimal deposit amount. function setMinimalDeposit(uint256 _min) external onlyRole(DEFAULT_ADMIN_ROLE) { if (_min <= depositFee) { revert BridgeErrors.InvalidMinDepositToFee(_min, depositFee); } minDepositAmount = _min; emit MinimalDepositAmountUpdated(_min); } /// @dev Sets the maximal deposit amount. /// @param _max The new maximal deposit amount. function setMaximalDeposit(uint256 _max) external onlyRole(DEFAULT_ADMIN_ROLE) { if (_max < minDepositAmount) { revert BridgeErrors.InvalidMaxDepositToMinDeposit(_max, minDepositAmount); } maxDepositAmount = _max; emit MaximalDepositAmountUpdated(_max); } /// @dev Sets the reserve balance and the address to drain excessive liquidity to. /// @param _balance The new reserve balance. /// @param _drain The new reserve drain address. function setReserveBalance(uint256 _balance, address _drain) external onlyRole(DEFAULT_ADMIN_ROLE) { if (_drain == address(0)) { revert BridgeErrors.InvalidDrainAddress(); } reserveBalance = _balance; reserveDrain = _drain; emit ReserveBalanceUpdated(_balance, _drain); } /// @dev Pauses the contract. function pause() external onlyRole(PAUSE_ROLE) { _pause(); } /// @dev Unpauses the contract. function unpause() external onlyRole(PAUSE_ROLE) { _unpause(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol) pragma solidity ^0.8.20; import {IAccessControl} from "./IAccessControl.sol"; import {Context} from "../utils/Context.sol"; import {ERC165} from "../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: * * ```solidity * 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}: * * ```solidity * 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. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address account => bool) hasRole; bytes32 adminRole; } mapping(bytes32 role => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with an {AccessControlUnauthorizedAccount} error including the required role. */ 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 returns (bool) { return _roles[role].hasRole[account]; } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()` * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier. */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account` * is missing `role`. */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert AccessControlUnauthorizedAccount(account, role); } } /** * @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 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 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 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 `callerConfirmation`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address callerConfirmation) public virtual { if (callerConfirmation != _msgSender()) { revert AccessControlBadConfirmation(); } _revokeRole(role, callerConfirmation); } /** * @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 Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual returns (bool) { if (!hasRole(role, account)) { _roles[role].hasRole[account] = true; emit RoleGranted(role, account, _msgSender()); return true; } else { return false; } } /** * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual returns (bool) { if (hasRole(role, account)) { _roles[role].hasRole[account] = false; emit RoleRevoked(role, account, _msgSender()); return true; } else { return false; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlDefaultAdminRules.sol) pragma solidity ^0.8.20; import {IAccessControlDefaultAdminRules} from "./IAccessControlDefaultAdminRules.sol"; import {AccessControl, IAccessControl} from "../AccessControl.sol"; import {SafeCast} from "../../utils/math/SafeCast.sol"; import {Math} from "../../utils/math/Math.sol"; import {IERC5313} from "../../interfaces/IERC5313.sol"; /** * @dev Extension of {AccessControl} that allows specifying special rules to manage * the `DEFAULT_ADMIN_ROLE` holder, which is a sensitive role with special permissions * over other roles that may potentially have privileged rights in the system. * * If a specific role doesn't have an admin role assigned, the holder of the * `DEFAULT_ADMIN_ROLE` will have the ability to grant it and revoke it. * * This contract implements the following risk mitigations on top of {AccessControl}: * * * Only one account holds the `DEFAULT_ADMIN_ROLE` since deployment until it's potentially renounced. * * Enforces a 2-step process to transfer the `DEFAULT_ADMIN_ROLE` to another account. * * Enforces a configurable delay between the two steps, with the ability to cancel before the transfer is accepted. * * The delay can be changed by scheduling, see {changeDefaultAdminDelay}. * * It is not possible to use another role to manage the `DEFAULT_ADMIN_ROLE`. * * Example usage: * * ```solidity * contract MyToken is AccessControlDefaultAdminRules { * constructor() AccessControlDefaultAdminRules( * 3 days, * msg.sender // Explicit initial `DEFAULT_ADMIN_ROLE` holder * ) {} * } * ``` */ abstract contract AccessControlDefaultAdminRules is IAccessControlDefaultAdminRules, IERC5313, AccessControl { // pending admin pair read/written together frequently address private _pendingDefaultAdmin; uint48 private _pendingDefaultAdminSchedule; // 0 == unset uint48 private _currentDelay; address private _currentDefaultAdmin; // pending delay pair read/written together frequently uint48 private _pendingDelay; uint48 private _pendingDelaySchedule; // 0 == unset /** * @dev Sets the initial values for {defaultAdminDelay} and {defaultAdmin} address. */ constructor(uint48 initialDelay, address initialDefaultAdmin) { if (initialDefaultAdmin == address(0)) { revert AccessControlInvalidDefaultAdmin(address(0)); } _currentDelay = initialDelay; _grantRole(DEFAULT_ADMIN_ROLE, initialDefaultAdmin); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlDefaultAdminRules).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC5313-owner}. */ function owner() public view virtual returns (address) { return defaultAdmin(); } /// /// Override AccessControl role management /// /** * @dev See {AccessControl-grantRole}. Reverts for `DEFAULT_ADMIN_ROLE`. */ function grantRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { if (role == DEFAULT_ADMIN_ROLE) { revert AccessControlEnforcedDefaultAdminRules(); } super.grantRole(role, account); } /** * @dev See {AccessControl-revokeRole}. Reverts for `DEFAULT_ADMIN_ROLE`. */ function revokeRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { if (role == DEFAULT_ADMIN_ROLE) { revert AccessControlEnforcedDefaultAdminRules(); } super.revokeRole(role, account); } /** * @dev See {AccessControl-renounceRole}. * * For the `DEFAULT_ADMIN_ROLE`, it only allows renouncing in two steps by first calling * {beginDefaultAdminTransfer} to the `address(0)`, so it's required that the {pendingDefaultAdmin} schedule * has also passed when calling this function. * * After its execution, it will not be possible to call `onlyRole(DEFAULT_ADMIN_ROLE)` functions. * * NOTE: Renouncing `DEFAULT_ADMIN_ROLE` will leave the contract without a {defaultAdmin}, * thereby disabling any functionality that is only available for it, and the possibility of reassigning a * non-administrated role. */ function renounceRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { if (role == DEFAULT_ADMIN_ROLE && account == defaultAdmin()) { (address newDefaultAdmin, uint48 schedule) = pendingDefaultAdmin(); if (newDefaultAdmin != address(0) || !_isScheduleSet(schedule) || !_hasSchedulePassed(schedule)) { revert AccessControlEnforcedDefaultAdminDelay(schedule); } delete _pendingDefaultAdminSchedule; } super.renounceRole(role, account); } /** * @dev See {AccessControl-_grantRole}. * * For `DEFAULT_ADMIN_ROLE`, it only allows granting if there isn't already a {defaultAdmin} or if the * role has been previously renounced. * * NOTE: Exposing this function through another mechanism may make the `DEFAULT_ADMIN_ROLE` * assignable again. Make sure to guarantee this is the expected behavior in your implementation. */ function _grantRole(bytes32 role, address account) internal virtual override returns (bool) { if (role == DEFAULT_ADMIN_ROLE) { if (defaultAdmin() != address(0)) { revert AccessControlEnforcedDefaultAdminRules(); } _currentDefaultAdmin = account; } return super._grantRole(role, account); } /** * @dev See {AccessControl-_revokeRole}. */ function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) { if (role == DEFAULT_ADMIN_ROLE && account == defaultAdmin()) { delete _currentDefaultAdmin; } return super._revokeRole(role, account); } /** * @dev See {AccessControl-_setRoleAdmin}. Reverts for `DEFAULT_ADMIN_ROLE`. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual override { if (role == DEFAULT_ADMIN_ROLE) { revert AccessControlEnforcedDefaultAdminRules(); } super._setRoleAdmin(role, adminRole); } /// /// AccessControlDefaultAdminRules accessors /// /** * @inheritdoc IAccessControlDefaultAdminRules */ function defaultAdmin() public view virtual returns (address) { return _currentDefaultAdmin; } /** * @inheritdoc IAccessControlDefaultAdminRules */ function pendingDefaultAdmin() public view virtual returns (address newAdmin, uint48 schedule) { return (_pendingDefaultAdmin, _pendingDefaultAdminSchedule); } /** * @inheritdoc IAccessControlDefaultAdminRules */ function defaultAdminDelay() public view virtual returns (uint48) { uint48 schedule = _pendingDelaySchedule; return (_isScheduleSet(schedule) && _hasSchedulePassed(schedule)) ? _pendingDelay : _currentDelay; } /** * @inheritdoc IAccessControlDefaultAdminRules */ function pendingDefaultAdminDelay() public view virtual returns (uint48 newDelay, uint48 schedule) { schedule = _pendingDelaySchedule; return (_isScheduleSet(schedule) && !_hasSchedulePassed(schedule)) ? (_pendingDelay, schedule) : (0, 0); } /** * @inheritdoc IAccessControlDefaultAdminRules */ function defaultAdminDelayIncreaseWait() public view virtual returns (uint48) { return 5 days; } /// /// AccessControlDefaultAdminRules public and internal setters for defaultAdmin/pendingDefaultAdmin /// /** * @inheritdoc IAccessControlDefaultAdminRules */ function beginDefaultAdminTransfer(address newAdmin) public virtual onlyRole(DEFAULT_ADMIN_ROLE) { _beginDefaultAdminTransfer(newAdmin); } /** * @dev See {beginDefaultAdminTransfer}. * * Internal function without access restriction. */ function _beginDefaultAdminTransfer(address newAdmin) internal virtual { uint48 newSchedule = SafeCast.toUint48(block.timestamp) + defaultAdminDelay(); _setPendingDefaultAdmin(newAdmin, newSchedule); emit DefaultAdminTransferScheduled(newAdmin, newSchedule); } /** * @inheritdoc IAccessControlDefaultAdminRules */ function cancelDefaultAdminTransfer() public virtual onlyRole(DEFAULT_ADMIN_ROLE) { _cancelDefaultAdminTransfer(); } /** * @dev See {cancelDefaultAdminTransfer}. * * Internal function without access restriction. */ function _cancelDefaultAdminTransfer() internal virtual { _setPendingDefaultAdmin(address(0), 0); } /** * @inheritdoc IAccessControlDefaultAdminRules */ function acceptDefaultAdminTransfer() public virtual { (address newDefaultAdmin, ) = pendingDefaultAdmin(); if (_msgSender() != newDefaultAdmin) { // Enforce newDefaultAdmin explicit acceptance. revert AccessControlInvalidDefaultAdmin(_msgSender()); } _acceptDefaultAdminTransfer(); } /** * @dev See {acceptDefaultAdminTransfer}. * * Internal function without access restriction. */ function _acceptDefaultAdminTransfer() internal virtual { (address newAdmin, uint48 schedule) = pendingDefaultAdmin(); if (!_isScheduleSet(schedule) || !_hasSchedulePassed(schedule)) { revert AccessControlEnforcedDefaultAdminDelay(schedule); } _revokeRole(DEFAULT_ADMIN_ROLE, defaultAdmin()); _grantRole(DEFAULT_ADMIN_ROLE, newAdmin); delete _pendingDefaultAdmin; delete _pendingDefaultAdminSchedule; } /// /// AccessControlDefaultAdminRules public and internal setters for defaultAdminDelay/pendingDefaultAdminDelay /// /** * @inheritdoc IAccessControlDefaultAdminRules */ function changeDefaultAdminDelay(uint48 newDelay) public virtual onlyRole(DEFAULT_ADMIN_ROLE) { _changeDefaultAdminDelay(newDelay); } /** * @dev See {changeDefaultAdminDelay}. * * Internal function without access restriction. */ function _changeDefaultAdminDelay(uint48 newDelay) internal virtual { uint48 newSchedule = SafeCast.toUint48(block.timestamp) + _delayChangeWait(newDelay); _setPendingDelay(newDelay, newSchedule); emit DefaultAdminDelayChangeScheduled(newDelay, newSchedule); } /** * @inheritdoc IAccessControlDefaultAdminRules */ function rollbackDefaultAdminDelay() public virtual onlyRole(DEFAULT_ADMIN_ROLE) { _rollbackDefaultAdminDelay(); } /** * @dev See {rollbackDefaultAdminDelay}. * * Internal function without access restriction. */ function _rollbackDefaultAdminDelay() internal virtual { _setPendingDelay(0, 0); } /** * @dev Returns the amount of seconds to wait after the `newDelay` will * become the new {defaultAdminDelay}. * * The value returned guarantees that if the delay is reduced, it will go into effect * after a wait that honors the previously set delay. * * See {defaultAdminDelayIncreaseWait}. */ function _delayChangeWait(uint48 newDelay) internal view virtual returns (uint48) { uint48 currentDelay = defaultAdminDelay(); // When increasing the delay, we schedule the delay change to occur after a period of "new delay" has passed, up // to a maximum given by defaultAdminDelayIncreaseWait, by default 5 days. For example, if increasing from 1 day // to 3 days, the new delay will come into effect after 3 days. If increasing from 1 day to 10 days, the new // delay will come into effect after 5 days. The 5 day wait period is intended to be able to fix an error like // using milliseconds instead of seconds. // // When decreasing the delay, we wait the difference between "current delay" and "new delay". This guarantees // that an admin transfer cannot be made faster than "current delay" at the time the delay change is scheduled. // For example, if decreasing from 10 days to 3 days, the new delay will come into effect after 7 days. return newDelay > currentDelay ? uint48(Math.min(newDelay, defaultAdminDelayIncreaseWait())) // no need to safecast, both inputs are uint48 : currentDelay - newDelay; } /// /// Private setters /// /** * @dev Setter of the tuple for pending admin and its schedule. * * May emit a DefaultAdminTransferCanceled event. */ function _setPendingDefaultAdmin(address newAdmin, uint48 newSchedule) private { (, uint48 oldSchedule) = pendingDefaultAdmin(); _pendingDefaultAdmin = newAdmin; _pendingDefaultAdminSchedule = newSchedule; // An `oldSchedule` from `pendingDefaultAdmin()` is only set if it hasn't been accepted. if (_isScheduleSet(oldSchedule)) { // Emit for implicit cancellations when another default admin was scheduled. emit DefaultAdminTransferCanceled(); } } /** * @dev Setter of the tuple for pending delay and its schedule. * * May emit a DefaultAdminDelayChangeCanceled event. */ function _setPendingDelay(uint48 newDelay, uint48 newSchedule) private { uint48 oldSchedule = _pendingDelaySchedule; if (_isScheduleSet(oldSchedule)) { if (_hasSchedulePassed(oldSchedule)) { // Materialize a virtual delay _currentDelay = _pendingDelay; } else { // Emit for implicit cancellations when another delay was scheduled. emit DefaultAdminDelayChangeCanceled(); } } _pendingDelay = newDelay; _pendingDelaySchedule = newSchedule; } /// /// Private helpers /// /** * @dev Defines if an `schedule` is considered set. For consistency purposes. */ function _isScheduleSet(uint48 schedule) private pure returns (bool) { return schedule != 0; } /** * @dev Defines if an `schedule` is considered passed. For consistency purposes. */ function _hasSchedulePassed(uint48 schedule) private view returns (bool) { return schedule < block.timestamp; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlDefaultAdminRules.sol) pragma solidity ^0.8.20; import {IAccessControl} from "../IAccessControl.sol"; /** * @dev External interface of AccessControlDefaultAdminRules declared to support ERC165 detection. */ interface IAccessControlDefaultAdminRules is IAccessControl { /** * @dev The new default admin is not a valid default admin. */ error AccessControlInvalidDefaultAdmin(address defaultAdmin); /** * @dev At least one of the following rules was violated: * * - The `DEFAULT_ADMIN_ROLE` must only be managed by itself. * - The `DEFAULT_ADMIN_ROLE` must only be held by one account at the time. * - Any `DEFAULT_ADMIN_ROLE` transfer must be in two delayed steps. */ error AccessControlEnforcedDefaultAdminRules(); /** * @dev The delay for transferring the default admin delay is enforced and * the operation must wait until `schedule`. * * NOTE: `schedule` can be 0 indicating there's no transfer scheduled. */ error AccessControlEnforcedDefaultAdminDelay(uint48 schedule); /** * @dev Emitted when a {defaultAdmin} transfer is started, setting `newAdmin` as the next * address to become the {defaultAdmin} by calling {acceptDefaultAdminTransfer} only after `acceptSchedule` * passes. */ event DefaultAdminTransferScheduled(address indexed newAdmin, uint48 acceptSchedule); /** * @dev Emitted when a {pendingDefaultAdmin} is reset if it was never accepted, regardless of its schedule. */ event DefaultAdminTransferCanceled(); /** * @dev Emitted when a {defaultAdminDelay} change is started, setting `newDelay` as the next * delay to be applied between default admin transfer after `effectSchedule` has passed. */ event DefaultAdminDelayChangeScheduled(uint48 newDelay, uint48 effectSchedule); /** * @dev Emitted when a {pendingDefaultAdminDelay} is reset if its schedule didn't pass. */ event DefaultAdminDelayChangeCanceled(); /** * @dev Returns the address of the current `DEFAULT_ADMIN_ROLE` holder. */ function defaultAdmin() external view returns (address); /** * @dev Returns a tuple of a `newAdmin` and an accept schedule. * * After the `schedule` passes, the `newAdmin` will be able to accept the {defaultAdmin} role * by calling {acceptDefaultAdminTransfer}, completing the role transfer. * * A zero value only in `acceptSchedule` indicates no pending admin transfer. * * NOTE: A zero address `newAdmin` means that {defaultAdmin} is being renounced. */ function pendingDefaultAdmin() external view returns (address newAdmin, uint48 acceptSchedule); /** * @dev Returns the delay required to schedule the acceptance of a {defaultAdmin} transfer started. * * This delay will be added to the current timestamp when calling {beginDefaultAdminTransfer} to set * the acceptance schedule. * * NOTE: If a delay change has been scheduled, it will take effect as soon as the schedule passes, making this * function returns the new delay. See {changeDefaultAdminDelay}. */ function defaultAdminDelay() external view returns (uint48); /** * @dev Returns a tuple of `newDelay` and an effect schedule. * * After the `schedule` passes, the `newDelay` will get into effect immediately for every * new {defaultAdmin} transfer started with {beginDefaultAdminTransfer}. * * A zero value only in `effectSchedule` indicates no pending delay change. * * NOTE: A zero value only for `newDelay` means that the next {defaultAdminDelay} * will be zero after the effect schedule. */ function pendingDefaultAdminDelay() external view returns (uint48 newDelay, uint48 effectSchedule); /** * @dev Starts a {defaultAdmin} transfer by setting a {pendingDefaultAdmin} scheduled for acceptance * after the current timestamp plus a {defaultAdminDelay}. * * Requirements: * * - Only can be called by the current {defaultAdmin}. * * Emits a DefaultAdminRoleChangeStarted event. */ function beginDefaultAdminTransfer(address newAdmin) external; /** * @dev Cancels a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}. * * A {pendingDefaultAdmin} not yet accepted can also be cancelled with this function. * * Requirements: * * - Only can be called by the current {defaultAdmin}. * * May emit a DefaultAdminTransferCanceled event. */ function cancelDefaultAdminTransfer() external; /** * @dev Completes a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}. * * After calling the function: * * - `DEFAULT_ADMIN_ROLE` should be granted to the caller. * - `DEFAULT_ADMIN_ROLE` should be revoked from the previous holder. * - {pendingDefaultAdmin} should be reset to zero values. * * Requirements: * * - Only can be called by the {pendingDefaultAdmin}'s `newAdmin`. * - The {pendingDefaultAdmin}'s `acceptSchedule` should've passed. */ function acceptDefaultAdminTransfer() external; /** * @dev Initiates a {defaultAdminDelay} update by setting a {pendingDefaultAdminDelay} scheduled for getting * into effect after the current timestamp plus a {defaultAdminDelay}. * * This function guarantees that any call to {beginDefaultAdminTransfer} done between the timestamp this * method is called and the {pendingDefaultAdminDelay} effect schedule will use the current {defaultAdminDelay} * set before calling. * * The {pendingDefaultAdminDelay}'s effect schedule is defined in a way that waiting until the schedule and then * calling {beginDefaultAdminTransfer} with the new delay will take at least the same as another {defaultAdmin} * complete transfer (including acceptance). * * The schedule is designed for two scenarios: * * - When the delay is changed for a larger one the schedule is `block.timestamp + newDelay` capped by * {defaultAdminDelayIncreaseWait}. * - When the delay is changed for a shorter one, the schedule is `block.timestamp + (current delay - new delay)`. * * A {pendingDefaultAdminDelay} that never got into effect will be canceled in favor of a new scheduled change. * * Requirements: * * - Only can be called by the current {defaultAdmin}. * * Emits a DefaultAdminDelayChangeScheduled event and may emit a DefaultAdminDelayChangeCanceled event. */ function changeDefaultAdminDelay(uint48 newDelay) external; /** * @dev Cancels a scheduled {defaultAdminDelay} change. * * Requirements: * * - Only can be called by the current {defaultAdmin}. * * May emit a DefaultAdminDelayChangeCanceled event. */ function rollbackDefaultAdminDelay() external; /** * @dev Maximum time in seconds for an increase to {defaultAdminDelay} (that is scheduled using {changeDefaultAdminDelay}) * to take effect. Default to 5 days. * * When the {defaultAdminDelay} is scheduled to be increased, it goes into effect after the new delay has passed with * the purpose of giving enough time for reverting any accidental change (i.e. using milliseconds instead of seconds) * that may lock the contract. However, to avoid excessive schedules, the wait is capped by this function and it can * be overrode for a custom {defaultAdminDelay} increase scheduling. * * IMPORTANT: Make sure to add a reasonable amount of time while overriding this value, otherwise, * there's a risk of setting a high new delay that goes into effect almost immediately without the * possibility of human intervention in the case of an input error (eg. set milliseconds instead of seconds). */ function defaultAdminDelayIncreaseWait() external view returns (uint48); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol) pragma solidity ^0.8.20; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev The `account` is missing a role. */ error AccessControlUnauthorizedAccount(address account, bytes32 neededRole); /** * @dev The caller of a function is not the expected one. * * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}. */ error AccessControlBadConfirmation(); /** * @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. */ 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 `callerConfirmation`. */ function renounceRole(bytes32 role, address callerConfirmation) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5313.sol) pragma solidity ^0.8.20; /** * @dev Interface for the Light Contract Ownership Standard. * * A standardized minimal interface required to identify an account that controls a contract */ interface IERC5313 { /** * @dev Gets the address of the owner. */ function owner() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @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; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.20; /** * @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 } /** * @dev The signature derives the `address(0)`. */ error ECDSAInvalidSignature(); /** * @dev The signature has an invalid length. */ error ECDSAInvalidSignatureLength(uint256 length); /** * @dev The signature has an S value that is in the upper half order. */ error ECDSAInvalidSignatureS(bytes32 s); /** * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not * return address(0) without also returning an error description. Errors are documented using an enum (error type) * and a bytes32 providing additional information about the error. * * If no error is returned, then the address can be used for verification purposes. * * The `ecrecover` EVM precompile 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 {MessageHashUtils-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] */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) { 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, bytes32(signature.length)); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM precompile 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 {MessageHashUtils-toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature); _throwError(error, errorArg); 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] */ function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) { unchecked { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); // We do not check for an overflow here since the shift operation results in 0 or 1. 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. */ function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs); _throwError(error, errorArg); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError, bytes32) { // 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, s); } // 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, bytes32(0)); } return (signer, RecoverError.NoError, bytes32(0)); } /** * @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, bytes32 errorArg) = tryRecover(hash, v, r, s); _throwError(error, errorArg); return recovered; } /** * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided. */ function _throwError(RecoverError error, bytes32 errorArg) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert ECDSAInvalidSignature(); } else if (error == RecoverError.InvalidSignatureLength) { revert ECDSAInvalidSignatureLength(uint256(errorArg)); } else if (error == RecoverError.InvalidSignatureS) { revert ECDSAInvalidSignatureS(errorArg); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "./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); * } * ``` */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @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 // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.20; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeCast { /** * @dev Value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value); /** * @dev An int value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedIntToUint(int256 value); /** * @dev Value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedIntDowncast(uint8 bits, int256 value); /** * @dev An uint value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedUintToInt(uint256 value); /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits */ function toUint248(uint256 value) internal pure returns (uint248) { if (value > type(uint248).max) { revert SafeCastOverflowedUintDowncast(248, value); } return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits */ function toUint240(uint256 value) internal pure returns (uint240) { if (value > type(uint240).max) { revert SafeCastOverflowedUintDowncast(240, value); } return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits */ function toUint232(uint256 value) internal pure returns (uint232) { if (value > type(uint232).max) { revert SafeCastOverflowedUintDowncast(232, value); } return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { if (value > type(uint224).max) { revert SafeCastOverflowedUintDowncast(224, value); } return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits */ function toUint216(uint256 value) internal pure returns (uint216) { if (value > type(uint216).max) { revert SafeCastOverflowedUintDowncast(216, value); } return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits */ function toUint208(uint256 value) internal pure returns (uint208) { if (value > type(uint208).max) { revert SafeCastOverflowedUintDowncast(208, value); } return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits */ function toUint200(uint256 value) internal pure returns (uint200) { if (value > type(uint200).max) { revert SafeCastOverflowedUintDowncast(200, value); } return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits */ function toUint192(uint256 value) internal pure returns (uint192) { if (value > type(uint192).max) { revert SafeCastOverflowedUintDowncast(192, value); } return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits */ function toUint184(uint256 value) internal pure returns (uint184) { if (value > type(uint184).max) { revert SafeCastOverflowedUintDowncast(184, value); } return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits */ function toUint176(uint256 value) internal pure returns (uint176) { if (value > type(uint176).max) { revert SafeCastOverflowedUintDowncast(176, value); } return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits */ function toUint168(uint256 value) internal pure returns (uint168) { if (value > type(uint168).max) { revert SafeCastOverflowedUintDowncast(168, value); } return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits */ function toUint160(uint256 value) internal pure returns (uint160) { if (value > type(uint160).max) { revert SafeCastOverflowedUintDowncast(160, value); } return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits */ function toUint152(uint256 value) internal pure returns (uint152) { if (value > type(uint152).max) { revert SafeCastOverflowedUintDowncast(152, value); } return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits */ function toUint144(uint256 value) internal pure returns (uint144) { if (value > type(uint144).max) { revert SafeCastOverflowedUintDowncast(144, value); } return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits */ function toUint136(uint256 value) internal pure returns (uint136) { if (value > type(uint136).max) { revert SafeCastOverflowedUintDowncast(136, value); } return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { if (value > type(uint128).max) { revert SafeCastOverflowedUintDowncast(128, value); } return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits */ function toUint120(uint256 value) internal pure returns (uint120) { if (value > type(uint120).max) { revert SafeCastOverflowedUintDowncast(120, value); } return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits */ function toUint112(uint256 value) internal pure returns (uint112) { if (value > type(uint112).max) { revert SafeCastOverflowedUintDowncast(112, value); } return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits */ function toUint104(uint256 value) internal pure returns (uint104) { if (value > type(uint104).max) { revert SafeCastOverflowedUintDowncast(104, value); } return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { if (value > type(uint96).max) { revert SafeCastOverflowedUintDowncast(96, value); } return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits */ function toUint88(uint256 value) internal pure returns (uint88) { if (value > type(uint88).max) { revert SafeCastOverflowedUintDowncast(88, value); } return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits */ function toUint80(uint256 value) internal pure returns (uint80) { if (value > type(uint80).max) { revert SafeCastOverflowedUintDowncast(80, value); } return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits */ function toUint72(uint256 value) internal pure returns (uint72) { if (value > type(uint72).max) { revert SafeCastOverflowedUintDowncast(72, value); } return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { if (value > type(uint64).max) { revert SafeCastOverflowedUintDowncast(64, value); } return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits */ function toUint56(uint256 value) internal pure returns (uint56) { if (value > type(uint56).max) { revert SafeCastOverflowedUintDowncast(56, value); } return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits */ function toUint48(uint256 value) internal pure returns (uint48) { if (value > type(uint48).max) { revert SafeCastOverflowedUintDowncast(48, value); } return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits */ function toUint40(uint256 value) internal pure returns (uint40) { if (value > type(uint40).max) { revert SafeCastOverflowedUintDowncast(40, value); } return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { if (value > type(uint32).max) { revert SafeCastOverflowedUintDowncast(32, value); } return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits */ function toUint24(uint256 value) internal pure returns (uint24) { if (value > type(uint24).max) { revert SafeCastOverflowedUintDowncast(24, value); } return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { if (value > type(uint16).max) { revert SafeCastOverflowedUintDowncast(16, value); } return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits */ function toUint8(uint256 value) internal pure returns (uint8) { if (value > type(uint8).max) { revert SafeCastOverflowedUintDowncast(8, value); } return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { if (value < 0) { revert SafeCastOverflowedIntToUint(value); } return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(248, value); } } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(240, value); } } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(232, value); } } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(224, value); } } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(216, value); } } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(208, value); } } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(200, value); } } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(192, value); } } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(184, value); } } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(176, value); } } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(168, value); } } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(160, value); } } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(152, value); } } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(144, value); } } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(136, value); } } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(128, value); } } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(120, value); } } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(112, value); } } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(104, value); } } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(96, value); } } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(88, value); } } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(80, value); } } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(72, value); } } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(64, value); } } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(56, value); } } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(48, value); } } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(40, value); } } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(32, value); } } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(24, value); } } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(16, value); } } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(8, value); } } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive if (value > uint256(type(int256).max)) { revert SafeCastOverflowedUintToInt(value); } return int256(value); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol) pragma solidity ^0.8.20; import {Context} from "../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 { bool private _paused; /** * @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); /** * @dev The operation failed because the contract is paused. */ error EnforcedPause(); /** * @dev The operation failed because the contract is not paused. */ error ExpectedPause(); /** * @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 { if (paused()) { revert EnforcedPause(); } } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { if (!paused()) { revert ExpectedPause(); } } /** * @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 // OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; /** * @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; /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); 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() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be NOT_ENTERED if (_status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail _status = ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == ENTERED; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; /// @dev BridgeErrors defines the errors reported by the bridge contract. /// @custom:security-contact [email protected] interface BridgeErrors { // deposit error InvalidImplicitDeposit(uint256 amount); error InvalidRecipient(address recipient, address sender); error DepositBelowLimit(uint256 expected, uint256 received); error DepositAboveLimit(uint256 expected, uint256 received); error FeeChanged(uint256 expected, uint256 received); // balance control error BalanceBelowLimit(uint256 limit, uint256 balance); error BalanceOverLimit(uint256 limit, uint256 balance); error DrainFailed(address target, uint256 amount); // batch processing error InvalidBatchSequence(uint256 lastID, uint256 currentID); error InsufficientLiquidity(uint256 available, uint256 needed); error SignatureDeficit(uint256 threshold, uint256 received); error InvalidDepositSequence(uint256 lastID, uint256 receivedID); error InvalidDepositSum(uint256 expected, uint256 received); error DepositNotFound(uint256 depositID); error InvalidClaimRequests(address expectedSender); error DepositSettlementFailed(address recipient, uint256 amount); // config error InvalidSignatureThreshold(); error InvalidMinDepositToFee(uint256 minDeposit, uint256 fee); error InvalidMaxDepositToMinDeposit(uint256 maxDeposit, uint256 minDeposit); error InvalidDrainAddress(); }
{ "evmVersion": "london", "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_cfgAdmin","type":"address"},{"internalType":"uint256","name":"_peerChainID","type":"uint256"},{"internalType":"uint256","name":"_fee","type":"uint256"},{"internalType":"uint256","name":"_minDeposit","type":"uint256"},{"internalType":"uint256","name":"_sigThreshold","type":"uint256"},{"internalType":"uint256","name":"_batchCheckpoint","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"uint48","name":"schedule","type":"uint48"}],"name":"AccessControlEnforcedDefaultAdminDelay","type":"error"},{"inputs":[],"name":"AccessControlEnforcedDefaultAdminRules","type":"error"},{"inputs":[{"internalType":"address","name":"defaultAdmin","type":"address"}],"name":"AccessControlInvalidDefaultAdmin","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"uint256","name":"limit","type":"uint256"},{"internalType":"uint256","name":"balance","type":"uint256"}],"name":"BalanceBelowLimit","type":"error"},{"inputs":[{"internalType":"uint256","name":"limit","type":"uint256"},{"internalType":"uint256","name":"balance","type":"uint256"}],"name":"BalanceOverLimit","type":"error"},{"inputs":[{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"received","type":"uint256"}],"name":"DepositAboveLimit","type":"error"},{"inputs":[{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"received","type":"uint256"}],"name":"DepositBelowLimit","type":"error"},{"inputs":[{"internalType":"uint256","name":"depositID","type":"uint256"}],"name":"DepositNotFound","type":"error"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DepositSettlementFailed","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DrainFailed","type":"error"},{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"received","type":"uint256"}],"name":"FeeChanged","type":"error"},{"inputs":[{"internalType":"uint256","name":"available","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"InsufficientLiquidity","type":"error"},{"inputs":[{"internalType":"uint256","name":"lastID","type":"uint256"},{"internalType":"uint256","name":"currentID","type":"uint256"}],"name":"InvalidBatchSequence","type":"error"},{"inputs":[{"internalType":"address","name":"expectedSender","type":"address"}],"name":"InvalidClaimRequests","type":"error"},{"inputs":[{"internalType":"uint256","name":"lastID","type":"uint256"},{"internalType":"uint256","name":"receivedID","type":"uint256"}],"name":"InvalidDepositSequence","type":"error"},{"inputs":[{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"received","type":"uint256"}],"name":"InvalidDepositSum","type":"error"},{"inputs":[],"name":"InvalidDrainAddress","type":"error"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"InvalidImplicitDeposit","type":"error"},{"inputs":[{"internalType":"uint256","name":"maxDeposit","type":"uint256"},{"internalType":"uint256","name":"minDeposit","type":"uint256"}],"name":"InvalidMaxDepositToMinDeposit","type":"error"},{"inputs":[{"internalType":"uint256","name":"minDeposit","type":"uint256"},{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"InvalidMinDepositToFee","type":"error"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"sender","type":"address"}],"name":"InvalidRecipient","type":"error"},{"inputs":[],"name":"InvalidSignatureThreshold","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[{"internalType":"uint256","name":"threshold","type":"uint256"},{"internalType":"uint256","name":"received","type":"uint256"}],"name":"SignatureDeficit","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"BatchProcessed","type":"event"},{"anonymous":false,"inputs":[],"name":"DefaultAdminDelayChangeCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint48","name":"newDelay","type":"uint48"},{"indexed":false,"internalType":"uint48","name":"effectSchedule","type":"uint48"}],"name":"DefaultAdminDelayChangeScheduled","type":"event"},{"anonymous":false,"inputs":[],"name":"DefaultAdminTransferCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newAdmin","type":"address"},{"indexed":false,"internalType":"uint48","name":"acceptSchedule","type":"uint48"}],"name":"DefaultAdminTransferScheduled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newDepositFee","type":"uint256"}],"name":"DepositFeeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"Failed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newMaximalDepositAmount","type":"uint256"}],"name":"MaximalDepositAmountUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newMinimalDepositAmount","type":"uint256"}],"name":"MinimalDepositAmountUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newReserveAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"newReserveDrain","type":"address"}],"name":"ReserveBalanceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"Resolved","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":false,"internalType":"uint256","name":"newSignatureThreshold","type":"uint256"}],"name":"SignatureThresholdUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSE_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VALIDATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"beginDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cancelDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint48","name":"newDelay","type":"uint48"}],"name":"changeDefaultAdminDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"depositID","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"defaultAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultAdminDelay","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultAdminDelayIncreaseWait","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"depositFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"drain","outputs":[],"stateMutability":"nonpayable","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":"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":[],"name":"lastBatchID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastDepositID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastResolvedDepositID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxDepositAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minDepositAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"peerChainID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDefaultAdmin","outputs":[{"internalType":"address","name":"newAdmin","type":"address"},{"internalType":"uint48","name":"schedule","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDefaultAdminDelay","outputs":[{"internalType":"uint48","name":"newDelay","type":"uint48"},{"internalType":"uint48","name":"schedule","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"refill","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":[],"name":"reserveBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"reserveDrain","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"batchID","type":"uint256"},{"internalType":"uint256","name":"total","type":"uint256"},{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct OperaBridge.Deposit[]","name":"deposits","type":"tuple[]"},{"internalType":"bytes[]","name":"signatures","type":"bytes[]"}],"name":"resolve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rollbackDefaultAdminDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fee","type":"uint256"}],"name":"setDepositFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_max","type":"uint256"}],"name":"setMaximalDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_min","type":"uint256"}],"name":"setMinimalDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_balance","type":"uint256"},{"internalType":"address","name":"_drain","type":"address"}],"name":"setReserveBalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_threshold","type":"uint256"}],"name":"setSignatureThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"signatureThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"depositID","type":"uint256"}],"name":"unresolvedDeposit","outputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60a060405234801561001057600080fd5b5060405161272f38038061272f83398101604081905261002f9161023c565b62069780866001600160a01b03811661006357604051636116401160e11b8152600060048201526024015b60405180910390fd5b600180546001600160d01b0316600160d01b65ffffffffffff85160217905561008d600082610121565b50506003805460ff191690555060016004558383116100c9576040516396586b8760e01b8152600481018490526024810185905260440161005a565b816000036100ea576040516312b6623f60e01b815260040160405180910390fd5b60808590526006849055600783905561010b83670de0b6b3a764000061029b565b600855600591909155600b55506102bc92505050565b60008261017f57600061013c6002546001600160a01b031690565b6001600160a01b03161461016357604051631fe1e13d60e11b815260040160405180910390fd5b600280546001600160a01b0319166001600160a01b0384161790555b6101898383610192565b90505b92915050565b6000828152602081815260408083206001600160a01b038516845290915281205460ff16610234576000838152602081815260408083206001600160a01b03861684529091529020805460ff191660011790556101ec3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161018c565b50600061018c565b60008060008060008060c0878903121561025557600080fd5b86516001600160a01b038116811461026c57600080fd5b6020880151604089015160608a015160808b015160a0909b0151939c929b509099909850965090945092505050565b8082018082111561018c57634e487b7160e01b600052601160045260246000fd5b6080516124516102de600039600081816104ab015261138301526124516000f3fe60806040526004361061026b5760003560e01c80638ed8327111610144578063bbde5374116100b6578063cc8463c81161007a578063cc8463c81461077e578063cefc142914610793578063cf6eefb7146107a8578063d547741f146107e3578063d602b9fd14610803578063ddd5e1b21461081857600080fd5b8063bbde5374146106de578063c00436a9146106fe578063c3c8b97e14610714578063c49baebe1461072a578063c57a47641461075e57600080fd5b8063a217fddf11610108578063a217fddf14610640578063a82f2e2614610655578063acbbbfea1461066b578063adb1dcac1461068b578063b57d4c6b146106ab578063b6b55f25146106cb57600080fd5b80638ed83271146105ab57806391d14854146105c15780639890220b146105e1578063a10954fe146105f6578063a1eda53c1461060c57600080fd5b8063538e0759116101dd578063649a5ec7116101a1578063649a5ec71461050357806367a52793146105235780637a8a3082146105395780638456cb591461054f57806384ef8ffc146105645780638da5cb5b1461059657600080fd5b8063538e0759146104795780635c975abb1461048157806361c8641714610499578063634e93da146104cd578063645006ca146104ed57600080fd5b80632f2ff15d1161022f5780632f2ff15d146103b057806336568abe146103d0578063389ed267146103f05780633e5ce67b146104245780633f4ba83a14610444578063490ae2101461045957600080fd5b806301ffc9a714610295578063022d63fb146102ca5780630aa6220b146102f3578063248a9ca31461030a5780632e9f9fa41461034857600080fd5b3661029057604051630651316560e51b81523460048201526024015b60405180910390fd5b600080fd5b3480156102a157600080fd5b506102b56102b0366004612057565b610838565b60405190151581526020015b60405180910390f35b3480156102d657600080fd5b50620697805b60405165ffffffffffff90911681526020016102c1565b3480156102ff57600080fd5b50610308610863565b005b34801561031657600080fd5b5061033a610325366004612081565b60009081526020819052604090206001015490565b6040519081526020016102c1565b34801561035457600080fd5b5061038d610363366004612081565b600e6020526000908152604090208054600182015460029092015490916001600160a01b03169083565b604080519384526001600160a01b039092166020840152908201526060016102c1565b3480156103bc57600080fd5b506103086103cb3660046120af565b610879565b3480156103dc57600080fd5b506103086103eb3660046120af565b6108a5565b3480156103fc57600080fd5b5061033a7f139c2898040ef16910dc9f44dc697df79363da767d8bc92f2e310312b816e46d81565b34801561043057600080fd5b5061030861043f36600461212b565b61094c565b34801561045057600080fd5b50610308610a30565b34801561046557600080fd5b50610308610474366004612081565b610a62565b610308610ada565b34801561048d57600080fd5b5060035460ff166102b5565b3480156104a557600080fd5b5061033a7f000000000000000000000000000000000000000000000000000000000000000081565b3480156104d957600080fd5b506103086104e83660046121e8565b610b0c565b3480156104f957600080fd5b5061033a60075481565b34801561050f57600080fd5b5061030861051e366004612205565b610b20565b34801561052f57600080fd5b5061033a60065481565b34801561054557600080fd5b5061033a600b5481565b34801561055b57600080fd5b50610308610b34565b34801561057057600080fd5b506002546001600160a01b03165b6040516001600160a01b0390911681526020016102c1565b3480156105a257600080fd5b5061057e610b66565b3480156105b757600080fd5b5061033a60085481565b3480156105cd57600080fd5b506102b56105dc3660046120af565b610b7f565b3480156105ed57600080fd5b50610308610ba8565b34801561060257600080fd5b5061033a60095481565b34801561061857600080fd5b50610621610cb1565b6040805165ffffffffffff9384168152929091166020830152016102c1565b34801561064c57600080fd5b5061033a600081565b34801561066157600080fd5b5061033a60055481565b34801561067757600080fd5b50610308610686366004612081565b610d05565b34801561069757600080fd5b506103086106a6366004612081565b610d75565b3480156106b757600080fd5b506103086106c63660046120af565b610de6565b6103086106d9366004612081565b610e7a565b3480156106ea57600080fd5b506103086106f9366004612081565b610fa1565b34801561070a57600080fd5b5061033a600c5481565b34801561072057600080fd5b5061033a600d5481565b34801561073657600080fd5b5061033a7f21702c8af46127c7fa207f89d0b0a8441bb32959a0ac7df790e9ab1a25c9892681565b34801561076a57600080fd5b50600a5461057e906001600160a01b031681565b34801561078a57600080fd5b506102dc611002565b34801561079f57600080fd5b50610308611061565b3480156107b457600080fd5b506107bd6110a1565b604080516001600160a01b03909316835265ffffffffffff9091166020830152016102c1565b3480156107ef57600080fd5b506103086107fe3660046120af565b6110c2565b34801561080f57600080fd5b506103086110ea565b34801561082457600080fd5b506103086108333660046120af565b6110fd565b60006001600160e01b031982166318a4c3c360e11b148061085d575061085d826112b6565b92915050565b600061086e816112eb565b6108766112f5565b50565b8161089757604051631fe1e13d60e11b815260040160405180910390fd5b6108a18282611300565b5050565b811580156108c057506002546001600160a01b038281169116145b15610942576000806108d06110a1565b90925090506001600160a01b0382161515806108f2575065ffffffffffff8116155b8061090557504265ffffffffffff821610155b1561092d576040516319ca5ebb60e01b815265ffffffffffff82166004820152602401610287565b50506001805465ffffffffffff60a01b191690555b6108a1828261132b565b610958600b5487611363565b61098357600b5460405163681099c360e11b8152600481019190915260248101879052604401610287565b844710156109ad5760405163a17e11d560e01b815247600482015260248101869052604401610287565b60006109bd8787878787876113e1565b90506005548110156109f057600554604051630ed801d560e11b8152600481019190915260248101829052604401610287565b6109fc878787876114ff565b60405187907ff563fdb95d8ba3f4669716ecc8559d8995059570a1324ffddf9f8094d2896c0890600090a250505050505050565b7f139c2898040ef16910dc9f44dc697df79363da767d8bc92f2e310312b816e46d610a5a816112eb565b610876611804565b6000610a6d816112eb565b6007548210610a9d576007546040516396586b8760e01b8152600481019190915260248101839052604401610287565b60068290556040518281527f206dd15151fcc83315419fbe53a71fcf9c09da803767d3dd05f7874e1b9bf645906020015b60405180910390a15050565b600954471115610b0a5760095460405163fa23a3e360e01b81526004810191909152476024820152604401610287565b565b6000610b17816112eb565b6108a182611856565b6000610b2b816112eb565b6108a1826118c9565b7f139c2898040ef16910dc9f44dc697df79363da767d8bc92f2e310312b816e46d610b5e816112eb565b610876611932565b6000610b7a6002546001600160a01b031690565b905090565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b600a546001600160a01b0316610bd1576040516302b2dc7f60e21b815260040160405180910390fd5b6009544711610c0057600954604051630ed7ae9560e11b81526004810191909152476024820152604401610287565b600a546009546000916001600160a01b031690610c1d9047612243565b6040516000919082818181858883f193505050503d8060008114610c5d576040519150601f19603f3d011682016040523d82523d6000602084013e610c62565b606091505b505090508061087657600a546009546001600160a01b0390911690610c879047612243565b604051631355925760e31b81526001600160a01b0390921660048301526024820152604401610287565b600254600090600160d01b900465ffffffffffff168015158015610cdd57504265ffffffffffff821610155b610ce957600080610cfd565b600254600160a01b900465ffffffffffff16815b915091509091565b6000610d10816112eb565b6006548211610d40576006546040516396586b8760e01b8152610287918491600401918252602082015260400190565b60078290556040518281527f058cb2f1a91090d70063f1f7af66c5d974c6d4dcfd4bf967538892a95dd4979790602001610ace565b6000610d80816112eb565b600754821015610db1576007546040516363ba9e6f60e11b8152610287918491600401918252602082015260400190565b60088290556040518281527fa6ee2e636ebc53d5cc22771ccfb6abd1682f43e7bee40375240a90aec1f76fa190602001610ace565b6000610df1816112eb565b6001600160a01b038216610e18576040516302b2dc7f60e21b815260040160405180910390fd5b6009839055600a80546001600160a01b0319166001600160a01b0384169081179091556040805185815260208101929092527f7145944b0a6cf6d9d01701c216d562e7b1b87a8d8a91bac87bf8273a4a34f581910160405180910390a1505050565b610e8261196f565b600754341015610eb2576007546040516325bb718b60e21b81526004810191909152346024820152604401610287565b600854341115610ee257600854604051634ce3352f60e01b81526004810191909152346024820152604401610287565b6006548114610f1257600654604051632fe231ed60e11b8152600481019190915260248101829052604401610287565b333214610f3a5760405163506b73ad60e11b8152336004820152326024820152604401610287565b600d8054906000610f4a83612256565b9091555050600d5460065433907f91ede45f04a37a7c170f5c1207df3b6bc748dc1e04ad5e917a241d0f52feada390610f839034612243565b6006546040805192835260208301919091520160405180910390a350565b6000610fac816112eb565b81600003610fcd576040516312b6623f60e01b815260040160405180910390fd5b60058290556040518281527f39ce3315d9f111fa5678229b9c648aaeec7c85c1f6695a497ac4e9a75f9469f290602001610ace565b600254600090600160d01b900465ffffffffffff16801515801561102d57504265ffffffffffff8216105b61104857600154600160d01b900465ffffffffffff1661105b565b600254600160a01b900465ffffffffffff165b91505090565b600061106b6110a1565b509050336001600160a01b0382161461109957604051636116401160e11b8152336004820152602401610287565b610876611993565b6001546001600160a01b03811691600160a01b90910465ffffffffffff1690565b816110e057604051631fe1e13d60e11b815260040160405180910390fd5b6108a18282611a2c565b60006110f5816112eb565b610876611a51565b611105611a5c565b6000828152600e6020526040902054821461113657604051631585bdab60e31b815260048101839052602401610287565b6000828152600e60205260409020600101546001600160a01b0316331461118f576000828152600e6020526040908190206001015490516356d78c3360e01b81526001600160a01b039091166004820152602401610287565b6000828152600e6020526040902060020154478111156111cb5760405163a17e11d560e01b815247600482015260248101829052604401610287565b6000838152600e60205260408082208281556001810180546001600160a01b0319169055600201829055516001600160a01b0384169083908381818185875af1925050503d806000811461123b576040519150601f19603f3d011682016040523d82523d6000602084013e611240565b606091505b505090508061127457604051631f13d50760e01b81526001600160a01b038416600482015260248101839052604401610287565b60405184906001600160a01b038516907f2e52bea68b967d05289fe0d069a066198bcd450dbac0bd00f371539cd308a6f090600090a350506108a16001600455565b60006001600160e01b03198216637965db0b60e01b148061085d57506301ffc9a760e01b6001600160e01b031983161461085d565b6108768133611a86565b610b0a600080611abf565b60008281526020819052604090206001015461131b816112eb565b6113258383611b7f565b50505050565b6001600160a01b03811633146113545760405163334bd91960e11b815260040160405180910390fd5b61135e8282611be7565b505050565b6000826001600160801b0316826001600160801b03161180156113a957507f000000000000000000000000000000000000000000000000000000000000000060c083901c145b80156113da57506113bf608084901c600161226f565b67ffffffffffffffff16608083901c67ffffffffffffffff16145b9392505050565b6000804630898989896040516020016113ff9695949392919061228f565b60405160208183030381529060405280519060200120905060008060005b858110156114f05760006114898589898581811061143d5761143d612318565b905060200281019061144f919061232e565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611c2492505050565b9050826001600160a01b0316816001600160a01b03161180156114d157506114d17f21702c8af46127c7fa207f89d0b0a8441bb32959a0ac7df790e9ab1a25c9892682610b7f565b156114e757915081836114e381612256565b9450505b5060010161141d565b50909998505050505050505050565b611507611a5c565b600b849055600c54600090815b838110156117cb57611527826001612375565b85858381811061153957611539612318565b9050606002016000013514611586578185858381811061155b5761155b612318565b60405163c8d2231560e01b815260048101949094526060029190910135602483015250604401610287565b84848281811061159857611598612318565b9050606002016000013591508484828181106115b6576115b6612318565b90506060020160400135836115cb9190612375565b925060008585838181106115e1576115e1612318565b90506060020160200160208101906115f991906121e8565b6001600160a01b031686868481811061161457611614612318565b90506060020160400135600090604051600060405180830381858888f193505050503d8060008114611662576040519150601f19603f3d011682016040523d82523d6000602084013e611667565b606091505b50509050806117465785858381811061168257611682612318565b905060600201600e600088888681811061169e5761169e612318565b90506060020160000135815260200190815260200160002081816116c29190612388565b9050508585838181106116d7576116d7612318565b905060600201600001358686848181106116f3576116f3612318565b905060600201602001602081019061170b91906121e8565b6001600160a01b03167f325cf12a5a810dd6b21d7aedc0fc5e08fc623604ee1d61fdba2a60e7719f646260405160405180910390a3506117c3565b85858381811061175857611758612318565b9050606002016000013586868481811061177457611774612318565b905060600201602001602081019061178c91906121e8565b6001600160a01b03167f2e52bea68b967d05289fe0d069a066198bcd450dbac0bd00f371539cd308a6f060405160405180910390a3505b600101611514565b508482146117f6576040516319a5344d60e11b81526004810186905260248101839052604401610287565b600c55506113256001600455565b61180c611c4e565b6003805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6000611860611002565b61186942611c71565b61187391906123c9565b905061187f8282611ca8565b60405165ffffffffffff821681526001600160a01b038316907f3377dc44241e779dd06afab5b788a35ca5f3b778836e2990bdb26a2a4b2e5ed69060200160405180910390a25050565b60006118d482611d27565b6118dd42611c71565b6118e791906123c9565b90506118f38282611abf565b6040805165ffffffffffff8085168252831660208201527ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b9101610ace565b61193a61196f565b6003805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586118393390565b60035460ff1615610b0a5760405163d93c066560e01b815260040160405180910390fd5b60008061199e6110a1565b915091506119b38165ffffffffffff16151590565b15806119c757504265ffffffffffff821610155b156119ef576040516319ca5ebb60e01b815265ffffffffffff82166004820152602401610287565b611a0b6000611a066002546001600160a01b031690565b611be7565b50611a17600083611b7f565b5050600180546001600160d01b031916905550565b600082815260208190526040902060010154611a47816112eb565b6113258383611be7565b610b0a600080611ca8565b600260045403611a7f57604051633ee5aeb560e01b815260040160405180910390fd5b6002600455565b611a908282610b7f565b6108a15760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610287565b600254600160d01b900465ffffffffffff168015611b42574265ffffffffffff82161015611b1857600254600180546001600160d01b0316600160a01b90920465ffffffffffff16600160d01b02919091179055611b42565b6040517f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec590600090a15b50600280546001600160a01b0316600160a01b65ffffffffffff948516026001600160d01b031617600160d01b9290931691909102919091179055565b600082611bdd576000611b9a6002546001600160a01b031690565b6001600160a01b031614611bc157604051631fe1e13d60e11b815260040160405180910390fd5b600280546001600160a01b0319166001600160a01b0384161790555b6113da8383611d6f565b600082158015611c0457506002546001600160a01b038381169116145b15611c1a57600280546001600160a01b03191690555b6113da8383611e01565b600080600080611c348686611e6c565b925092509250611c448282611eb9565b5090949350505050565b60035460ff16610b0a57604051638dfc202b60e01b815260040160405180910390fd5b600065ffffffffffff821115611ca4576040516306dfcc6560e41b81526030600482015260248101839052604401610287565b5090565b6000611cb26110a1565b6001805465ffffffffffff8616600160a01b026001600160d01b03199091166001600160a01b038816171790559150611cf490508165ffffffffffff16151590565b1561135e576040517f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a960510990600090a1505050565b600080611d32611002565b90508065ffffffffffff168365ffffffffffff1611611d5a57611d5583826123e7565b6113da565b6113da65ffffffffffff841662069780611f72565b6000611d7b8383610b7f565b611df9576000838152602081815260408083206001600160a01b03861684529091529020805460ff19166001179055611db13390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161085d565b50600061085d565b6000611e0d8383610b7f565b15611df9576000838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a450600161085d565b60008060008351604103611ea65760208401516040850151606086015160001a611e9888828585611f88565b955095509550505050611eb2565b50508151600091506002905b9250925092565b6000826003811115611ecd57611ecd612405565b03611ed6575050565b6001826003811115611eea57611eea612405565b03611f085760405163f645eedf60e01b815260040160405180910390fd5b6002826003811115611f1c57611f1c612405565b03611f3d5760405163fce698f760e01b815260048101829052602401610287565b6003826003811115611f5157611f51612405565b036108a1576040516335e2f38360e21b815260048101829052602401610287565b6000818310611f8157816113da565b5090919050565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841115611fc3575060009150600390508261204d565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015612017573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166120435750600092506001915082905061204d565b9250600091508190505b9450945094915050565b60006020828403121561206957600080fd5b81356001600160e01b0319811681146113da57600080fd5b60006020828403121561209357600080fd5b5035919050565b6001600160a01b038116811461087657600080fd5b600080604083850312156120c257600080fd5b8235915060208301356120d48161209a565b809150509250929050565b60008083601f8401126120f157600080fd5b50813567ffffffffffffffff81111561210957600080fd5b6020830191508360208260051b850101111561212457600080fd5b9250929050565b6000806000806000806080878903121561214457600080fd5b8635955060208701359450604087013567ffffffffffffffff81111561216957600080fd5b8701601f8101891361217a57600080fd5b803567ffffffffffffffff81111561219157600080fd5b8960206060830284010111156121a657600080fd5b60209190910194509250606087013567ffffffffffffffff8111156121ca57600080fd5b6121d689828a016120df565b979a9699509497509295939492505050565b6000602082840312156121fa57600080fd5b81356113da8161209a565b60006020828403121561221757600080fd5b813565ffffffffffff811681146113da57600080fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561085d5761085d61222d565b6000600182016122685761226861222d565b5060010190565b67ffffffffffffffff818116838216019081111561085d5761085d61222d565b8681526001600160a01b0386166020820152604081018590526060810184905260a060808201819052810182905260008360c08301825b8581101561230a578235825260208301356122e08161209a565b6001600160a01b0316602083015260408381013590830152606092830192909101906001016122c6565b509998505050505050505050565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261234557600080fd5b83018035915067ffffffffffffffff82111561236057600080fd5b60200191503681900382131561212457600080fd5b8082018082111561085d5761085d61222d565b8135815560018101602083013561239e8161209a565b81546001600160a01b0319166001600160a01b03919091161790556040919091013560029190910155565b65ffffffffffff818116838216019081111561085d5761085d61222d565b65ffffffffffff828116828216039081111561085d5761085d61222d565b634e487b7160e01b600052602160045260246000fdfea2646970667358221220e9a867f23ab589652e0d6c4899467e0bb7f635055657d6492dfbd62c8727916d64736f6c634300081c0033000000000000000000000000f8fc6d1289734fdffe8b58d8d394b33fe8cc545f00000000000000000000000000000000000000000000000000000000000000fa00000000000000000000000000000000000000000000000000071afd498d0000000000000000000000000000000000000000000000000000016345785d8a0000000000000000000000000000000000000000000000000000000000000000000300000000000000fa00000000000000000000000005e9075d0000000000000000
Deployed Bytecode
0x60806040526004361061026b5760003560e01c80638ed8327111610144578063bbde5374116100b6578063cc8463c81161007a578063cc8463c81461077e578063cefc142914610793578063cf6eefb7146107a8578063d547741f146107e3578063d602b9fd14610803578063ddd5e1b21461081857600080fd5b8063bbde5374146106de578063c00436a9146106fe578063c3c8b97e14610714578063c49baebe1461072a578063c57a47641461075e57600080fd5b8063a217fddf11610108578063a217fddf14610640578063a82f2e2614610655578063acbbbfea1461066b578063adb1dcac1461068b578063b57d4c6b146106ab578063b6b55f25146106cb57600080fd5b80638ed83271146105ab57806391d14854146105c15780639890220b146105e1578063a10954fe146105f6578063a1eda53c1461060c57600080fd5b8063538e0759116101dd578063649a5ec7116101a1578063649a5ec71461050357806367a52793146105235780637a8a3082146105395780638456cb591461054f57806384ef8ffc146105645780638da5cb5b1461059657600080fd5b8063538e0759146104795780635c975abb1461048157806361c8641714610499578063634e93da146104cd578063645006ca146104ed57600080fd5b80632f2ff15d1161022f5780632f2ff15d146103b057806336568abe146103d0578063389ed267146103f05780633e5ce67b146104245780633f4ba83a14610444578063490ae2101461045957600080fd5b806301ffc9a714610295578063022d63fb146102ca5780630aa6220b146102f3578063248a9ca31461030a5780632e9f9fa41461034857600080fd5b3661029057604051630651316560e51b81523460048201526024015b60405180910390fd5b600080fd5b3480156102a157600080fd5b506102b56102b0366004612057565b610838565b60405190151581526020015b60405180910390f35b3480156102d657600080fd5b50620697805b60405165ffffffffffff90911681526020016102c1565b3480156102ff57600080fd5b50610308610863565b005b34801561031657600080fd5b5061033a610325366004612081565b60009081526020819052604090206001015490565b6040519081526020016102c1565b34801561035457600080fd5b5061038d610363366004612081565b600e6020526000908152604090208054600182015460029092015490916001600160a01b03169083565b604080519384526001600160a01b039092166020840152908201526060016102c1565b3480156103bc57600080fd5b506103086103cb3660046120af565b610879565b3480156103dc57600080fd5b506103086103eb3660046120af565b6108a5565b3480156103fc57600080fd5b5061033a7f139c2898040ef16910dc9f44dc697df79363da767d8bc92f2e310312b816e46d81565b34801561043057600080fd5b5061030861043f36600461212b565b61094c565b34801561045057600080fd5b50610308610a30565b34801561046557600080fd5b50610308610474366004612081565b610a62565b610308610ada565b34801561048d57600080fd5b5060035460ff166102b5565b3480156104a557600080fd5b5061033a7f00000000000000000000000000000000000000000000000000000000000000fa81565b3480156104d957600080fd5b506103086104e83660046121e8565b610b0c565b3480156104f957600080fd5b5061033a60075481565b34801561050f57600080fd5b5061030861051e366004612205565b610b20565b34801561052f57600080fd5b5061033a60065481565b34801561054557600080fd5b5061033a600b5481565b34801561055b57600080fd5b50610308610b34565b34801561057057600080fd5b506002546001600160a01b03165b6040516001600160a01b0390911681526020016102c1565b3480156105a257600080fd5b5061057e610b66565b3480156105b757600080fd5b5061033a60085481565b3480156105cd57600080fd5b506102b56105dc3660046120af565b610b7f565b3480156105ed57600080fd5b50610308610ba8565b34801561060257600080fd5b5061033a60095481565b34801561061857600080fd5b50610621610cb1565b6040805165ffffffffffff9384168152929091166020830152016102c1565b34801561064c57600080fd5b5061033a600081565b34801561066157600080fd5b5061033a60055481565b34801561067757600080fd5b50610308610686366004612081565b610d05565b34801561069757600080fd5b506103086106a6366004612081565b610d75565b3480156106b757600080fd5b506103086106c63660046120af565b610de6565b6103086106d9366004612081565b610e7a565b3480156106ea57600080fd5b506103086106f9366004612081565b610fa1565b34801561070a57600080fd5b5061033a600c5481565b34801561072057600080fd5b5061033a600d5481565b34801561073657600080fd5b5061033a7f21702c8af46127c7fa207f89d0b0a8441bb32959a0ac7df790e9ab1a25c9892681565b34801561076a57600080fd5b50600a5461057e906001600160a01b031681565b34801561078a57600080fd5b506102dc611002565b34801561079f57600080fd5b50610308611061565b3480156107b457600080fd5b506107bd6110a1565b604080516001600160a01b03909316835265ffffffffffff9091166020830152016102c1565b3480156107ef57600080fd5b506103086107fe3660046120af565b6110c2565b34801561080f57600080fd5b506103086110ea565b34801561082457600080fd5b506103086108333660046120af565b6110fd565b60006001600160e01b031982166318a4c3c360e11b148061085d575061085d826112b6565b92915050565b600061086e816112eb565b6108766112f5565b50565b8161089757604051631fe1e13d60e11b815260040160405180910390fd5b6108a18282611300565b5050565b811580156108c057506002546001600160a01b038281169116145b15610942576000806108d06110a1565b90925090506001600160a01b0382161515806108f2575065ffffffffffff8116155b8061090557504265ffffffffffff821610155b1561092d576040516319ca5ebb60e01b815265ffffffffffff82166004820152602401610287565b50506001805465ffffffffffff60a01b191690555b6108a1828261132b565b610958600b5487611363565b61098357600b5460405163681099c360e11b8152600481019190915260248101879052604401610287565b844710156109ad5760405163a17e11d560e01b815247600482015260248101869052604401610287565b60006109bd8787878787876113e1565b90506005548110156109f057600554604051630ed801d560e11b8152600481019190915260248101829052604401610287565b6109fc878787876114ff565b60405187907ff563fdb95d8ba3f4669716ecc8559d8995059570a1324ffddf9f8094d2896c0890600090a250505050505050565b7f139c2898040ef16910dc9f44dc697df79363da767d8bc92f2e310312b816e46d610a5a816112eb565b610876611804565b6000610a6d816112eb565b6007548210610a9d576007546040516396586b8760e01b8152600481019190915260248101839052604401610287565b60068290556040518281527f206dd15151fcc83315419fbe53a71fcf9c09da803767d3dd05f7874e1b9bf645906020015b60405180910390a15050565b600954471115610b0a5760095460405163fa23a3e360e01b81526004810191909152476024820152604401610287565b565b6000610b17816112eb565b6108a182611856565b6000610b2b816112eb565b6108a1826118c9565b7f139c2898040ef16910dc9f44dc697df79363da767d8bc92f2e310312b816e46d610b5e816112eb565b610876611932565b6000610b7a6002546001600160a01b031690565b905090565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b600a546001600160a01b0316610bd1576040516302b2dc7f60e21b815260040160405180910390fd5b6009544711610c0057600954604051630ed7ae9560e11b81526004810191909152476024820152604401610287565b600a546009546000916001600160a01b031690610c1d9047612243565b6040516000919082818181858883f193505050503d8060008114610c5d576040519150601f19603f3d011682016040523d82523d6000602084013e610c62565b606091505b505090508061087657600a546009546001600160a01b0390911690610c879047612243565b604051631355925760e31b81526001600160a01b0390921660048301526024820152604401610287565b600254600090600160d01b900465ffffffffffff168015158015610cdd57504265ffffffffffff821610155b610ce957600080610cfd565b600254600160a01b900465ffffffffffff16815b915091509091565b6000610d10816112eb565b6006548211610d40576006546040516396586b8760e01b8152610287918491600401918252602082015260400190565b60078290556040518281527f058cb2f1a91090d70063f1f7af66c5d974c6d4dcfd4bf967538892a95dd4979790602001610ace565b6000610d80816112eb565b600754821015610db1576007546040516363ba9e6f60e11b8152610287918491600401918252602082015260400190565b60088290556040518281527fa6ee2e636ebc53d5cc22771ccfb6abd1682f43e7bee40375240a90aec1f76fa190602001610ace565b6000610df1816112eb565b6001600160a01b038216610e18576040516302b2dc7f60e21b815260040160405180910390fd5b6009839055600a80546001600160a01b0319166001600160a01b0384169081179091556040805185815260208101929092527f7145944b0a6cf6d9d01701c216d562e7b1b87a8d8a91bac87bf8273a4a34f581910160405180910390a1505050565b610e8261196f565b600754341015610eb2576007546040516325bb718b60e21b81526004810191909152346024820152604401610287565b600854341115610ee257600854604051634ce3352f60e01b81526004810191909152346024820152604401610287565b6006548114610f1257600654604051632fe231ed60e11b8152600481019190915260248101829052604401610287565b333214610f3a5760405163506b73ad60e11b8152336004820152326024820152604401610287565b600d8054906000610f4a83612256565b9091555050600d5460065433907f91ede45f04a37a7c170f5c1207df3b6bc748dc1e04ad5e917a241d0f52feada390610f839034612243565b6006546040805192835260208301919091520160405180910390a350565b6000610fac816112eb565b81600003610fcd576040516312b6623f60e01b815260040160405180910390fd5b60058290556040518281527f39ce3315d9f111fa5678229b9c648aaeec7c85c1f6695a497ac4e9a75f9469f290602001610ace565b600254600090600160d01b900465ffffffffffff16801515801561102d57504265ffffffffffff8216105b61104857600154600160d01b900465ffffffffffff1661105b565b600254600160a01b900465ffffffffffff165b91505090565b600061106b6110a1565b509050336001600160a01b0382161461109957604051636116401160e11b8152336004820152602401610287565b610876611993565b6001546001600160a01b03811691600160a01b90910465ffffffffffff1690565b816110e057604051631fe1e13d60e11b815260040160405180910390fd5b6108a18282611a2c565b60006110f5816112eb565b610876611a51565b611105611a5c565b6000828152600e6020526040902054821461113657604051631585bdab60e31b815260048101839052602401610287565b6000828152600e60205260409020600101546001600160a01b0316331461118f576000828152600e6020526040908190206001015490516356d78c3360e01b81526001600160a01b039091166004820152602401610287565b6000828152600e6020526040902060020154478111156111cb5760405163a17e11d560e01b815247600482015260248101829052604401610287565b6000838152600e60205260408082208281556001810180546001600160a01b0319169055600201829055516001600160a01b0384169083908381818185875af1925050503d806000811461123b576040519150601f19603f3d011682016040523d82523d6000602084013e611240565b606091505b505090508061127457604051631f13d50760e01b81526001600160a01b038416600482015260248101839052604401610287565b60405184906001600160a01b038516907f2e52bea68b967d05289fe0d069a066198bcd450dbac0bd00f371539cd308a6f090600090a350506108a16001600455565b60006001600160e01b03198216637965db0b60e01b148061085d57506301ffc9a760e01b6001600160e01b031983161461085d565b6108768133611a86565b610b0a600080611abf565b60008281526020819052604090206001015461131b816112eb565b6113258383611b7f565b50505050565b6001600160a01b03811633146113545760405163334bd91960e11b815260040160405180910390fd5b61135e8282611be7565b505050565b6000826001600160801b0316826001600160801b03161180156113a957507f00000000000000000000000000000000000000000000000000000000000000fa60c083901c145b80156113da57506113bf608084901c600161226f565b67ffffffffffffffff16608083901c67ffffffffffffffff16145b9392505050565b6000804630898989896040516020016113ff9695949392919061228f565b60405160208183030381529060405280519060200120905060008060005b858110156114f05760006114898589898581811061143d5761143d612318565b905060200281019061144f919061232e565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611c2492505050565b9050826001600160a01b0316816001600160a01b03161180156114d157506114d17f21702c8af46127c7fa207f89d0b0a8441bb32959a0ac7df790e9ab1a25c9892682610b7f565b156114e757915081836114e381612256565b9450505b5060010161141d565b50909998505050505050505050565b611507611a5c565b600b849055600c54600090815b838110156117cb57611527826001612375565b85858381811061153957611539612318565b9050606002016000013514611586578185858381811061155b5761155b612318565b60405163c8d2231560e01b815260048101949094526060029190910135602483015250604401610287565b84848281811061159857611598612318565b9050606002016000013591508484828181106115b6576115b6612318565b90506060020160400135836115cb9190612375565b925060008585838181106115e1576115e1612318565b90506060020160200160208101906115f991906121e8565b6001600160a01b031686868481811061161457611614612318565b90506060020160400135600090604051600060405180830381858888f193505050503d8060008114611662576040519150601f19603f3d011682016040523d82523d6000602084013e611667565b606091505b50509050806117465785858381811061168257611682612318565b905060600201600e600088888681811061169e5761169e612318565b90506060020160000135815260200190815260200160002081816116c29190612388565b9050508585838181106116d7576116d7612318565b905060600201600001358686848181106116f3576116f3612318565b905060600201602001602081019061170b91906121e8565b6001600160a01b03167f325cf12a5a810dd6b21d7aedc0fc5e08fc623604ee1d61fdba2a60e7719f646260405160405180910390a3506117c3565b85858381811061175857611758612318565b9050606002016000013586868481811061177457611774612318565b905060600201602001602081019061178c91906121e8565b6001600160a01b03167f2e52bea68b967d05289fe0d069a066198bcd450dbac0bd00f371539cd308a6f060405160405180910390a3505b600101611514565b508482146117f6576040516319a5344d60e11b81526004810186905260248101839052604401610287565b600c55506113256001600455565b61180c611c4e565b6003805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6000611860611002565b61186942611c71565b61187391906123c9565b905061187f8282611ca8565b60405165ffffffffffff821681526001600160a01b038316907f3377dc44241e779dd06afab5b788a35ca5f3b778836e2990bdb26a2a4b2e5ed69060200160405180910390a25050565b60006118d482611d27565b6118dd42611c71565b6118e791906123c9565b90506118f38282611abf565b6040805165ffffffffffff8085168252831660208201527ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b9101610ace565b61193a61196f565b6003805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586118393390565b60035460ff1615610b0a5760405163d93c066560e01b815260040160405180910390fd5b60008061199e6110a1565b915091506119b38165ffffffffffff16151590565b15806119c757504265ffffffffffff821610155b156119ef576040516319ca5ebb60e01b815265ffffffffffff82166004820152602401610287565b611a0b6000611a066002546001600160a01b031690565b611be7565b50611a17600083611b7f565b5050600180546001600160d01b031916905550565b600082815260208190526040902060010154611a47816112eb565b6113258383611be7565b610b0a600080611ca8565b600260045403611a7f57604051633ee5aeb560e01b815260040160405180910390fd5b6002600455565b611a908282610b7f565b6108a15760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610287565b600254600160d01b900465ffffffffffff168015611b42574265ffffffffffff82161015611b1857600254600180546001600160d01b0316600160a01b90920465ffffffffffff16600160d01b02919091179055611b42565b6040517f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec590600090a15b50600280546001600160a01b0316600160a01b65ffffffffffff948516026001600160d01b031617600160d01b9290931691909102919091179055565b600082611bdd576000611b9a6002546001600160a01b031690565b6001600160a01b031614611bc157604051631fe1e13d60e11b815260040160405180910390fd5b600280546001600160a01b0319166001600160a01b0384161790555b6113da8383611d6f565b600082158015611c0457506002546001600160a01b038381169116145b15611c1a57600280546001600160a01b03191690555b6113da8383611e01565b600080600080611c348686611e6c565b925092509250611c448282611eb9565b5090949350505050565b60035460ff16610b0a57604051638dfc202b60e01b815260040160405180910390fd5b600065ffffffffffff821115611ca4576040516306dfcc6560e41b81526030600482015260248101839052604401610287565b5090565b6000611cb26110a1565b6001805465ffffffffffff8616600160a01b026001600160d01b03199091166001600160a01b038816171790559150611cf490508165ffffffffffff16151590565b1561135e576040517f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a960510990600090a1505050565b600080611d32611002565b90508065ffffffffffff168365ffffffffffff1611611d5a57611d5583826123e7565b6113da565b6113da65ffffffffffff841662069780611f72565b6000611d7b8383610b7f565b611df9576000838152602081815260408083206001600160a01b03861684529091529020805460ff19166001179055611db13390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161085d565b50600061085d565b6000611e0d8383610b7f565b15611df9576000838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a450600161085d565b60008060008351604103611ea65760208401516040850151606086015160001a611e9888828585611f88565b955095509550505050611eb2565b50508151600091506002905b9250925092565b6000826003811115611ecd57611ecd612405565b03611ed6575050565b6001826003811115611eea57611eea612405565b03611f085760405163f645eedf60e01b815260040160405180910390fd5b6002826003811115611f1c57611f1c612405565b03611f3d5760405163fce698f760e01b815260048101829052602401610287565b6003826003811115611f5157611f51612405565b036108a1576040516335e2f38360e21b815260048101829052602401610287565b6000818310611f8157816113da565b5090919050565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841115611fc3575060009150600390508261204d565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015612017573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166120435750600092506001915082905061204d565b9250600091508190505b9450945094915050565b60006020828403121561206957600080fd5b81356001600160e01b0319811681146113da57600080fd5b60006020828403121561209357600080fd5b5035919050565b6001600160a01b038116811461087657600080fd5b600080604083850312156120c257600080fd5b8235915060208301356120d48161209a565b809150509250929050565b60008083601f8401126120f157600080fd5b50813567ffffffffffffffff81111561210957600080fd5b6020830191508360208260051b850101111561212457600080fd5b9250929050565b6000806000806000806080878903121561214457600080fd5b8635955060208701359450604087013567ffffffffffffffff81111561216957600080fd5b8701601f8101891361217a57600080fd5b803567ffffffffffffffff81111561219157600080fd5b8960206060830284010111156121a657600080fd5b60209190910194509250606087013567ffffffffffffffff8111156121ca57600080fd5b6121d689828a016120df565b979a9699509497509295939492505050565b6000602082840312156121fa57600080fd5b81356113da8161209a565b60006020828403121561221757600080fd5b813565ffffffffffff811681146113da57600080fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561085d5761085d61222d565b6000600182016122685761226861222d565b5060010190565b67ffffffffffffffff818116838216019081111561085d5761085d61222d565b8681526001600160a01b0386166020820152604081018590526060810184905260a060808201819052810182905260008360c08301825b8581101561230a578235825260208301356122e08161209a565b6001600160a01b0316602083015260408381013590830152606092830192909101906001016122c6565b509998505050505050505050565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261234557600080fd5b83018035915067ffffffffffffffff82111561236057600080fd5b60200191503681900382131561212457600080fd5b8082018082111561085d5761085d61222d565b8135815560018101602083013561239e8161209a565b81546001600160a01b0319166001600160a01b03919091161790556040919091013560029190910155565b65ffffffffffff818116838216019081111561085d5761085d61222d565b65ffffffffffff828116828216039081111561085d5761085d61222d565b634e487b7160e01b600052602160045260246000fdfea2646970667358221220e9a867f23ab589652e0d6c4899467e0bb7f635055657d6492dfbd62c8727916d64736f6c634300081c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000f8fc6d1289734fdffe8b58d8d394b33fe8cc545f00000000000000000000000000000000000000000000000000000000000000fa00000000000000000000000000000000000000000000000000071afd498d0000000000000000000000000000000000000000000000000000016345785d8a0000000000000000000000000000000000000000000000000000000000000000000300000000000000fa00000000000000000000000005e9075d0000000000000000
-----Decoded View---------------
Arg [0] : _cfgAdmin (address): 0xf8Fc6d1289734Fdffe8B58d8D394b33fe8CC545F
Arg [1] : _peerChainID (uint256): 250
Arg [2] : _fee (uint256): 2000000000000000
Arg [3] : _minDeposit (uint256): 100000000000000000
Arg [4] : _sigThreshold (uint256): 3
Arg [5] : _batchCheckpoint (uint256): 1569275433846670190958947355801918433165126050628892463464448
-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 000000000000000000000000f8fc6d1289734fdffe8b58d8d394b33fe8cc545f
Arg [1] : 00000000000000000000000000000000000000000000000000000000000000fa
Arg [2] : 00000000000000000000000000000000000000000000000000071afd498d0000
Arg [3] : 000000000000000000000000000000000000000000000000016345785d8a0000
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000003
Arg [5] : 00000000000000fa00000000000000000000000005e9075d0000000000000000
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
FTM | 100.00% | $1.13 | 84,255,077.8806 | $95,188,945.2 |
[ Download: CSV Export ]
[ Download: CSV Export ]
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.