Source Code
Latest 25 from a total of 13,146 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Fulfill Query | 43196682 | 1 min ago | IN | 0 ETH | 0.00000321 | ||||
| Fulfill Query | 43196578 | 5 mins ago | IN | 0 ETH | 0.00000361 | ||||
| Fulfill Query | 43196475 | 8 mins ago | IN | 0 ETH | 0.00000207 | ||||
| Fulfill Query | 43196372 | 12 mins ago | IN | 0 ETH | 0.00000217 | ||||
| Fulfill Query | 43196269 | 15 mins ago | IN | 0 ETH | 0.00000319 | ||||
| Fulfill Query | 43196167 | 19 mins ago | IN | 0 ETH | 0.00000364 | ||||
| Fulfill Query | 43196063 | 22 mins ago | IN | 0 ETH | 0.00000205 | ||||
| Fulfill Query | 43195960 | 26 mins ago | IN | 0 ETH | 0.00000217 | ||||
| Fulfill Query | 43195857 | 29 mins ago | IN | 0 ETH | 0.00000319 | ||||
| Fulfill Query | 43195755 | 32 mins ago | IN | 0 ETH | 0.00000369 | ||||
| Fulfill Query | 43195651 | 36 mins ago | IN | 0 ETH | 0.00000203 | ||||
| Fulfill Query | 43195548 | 39 mins ago | IN | 0 ETH | 0.00000222 | ||||
| Fulfill Query | 43195446 | 43 mins ago | IN | 0 ETH | 0.00000319 | ||||
| Fulfill Query | 43195343 | 46 mins ago | IN | 0 ETH | 0.0000036 | ||||
| Fulfill Query | 43195240 | 50 mins ago | IN | 0 ETH | 0.00000203 | ||||
| Fulfill Query | 43195136 | 53 mins ago | IN | 0 ETH | 0.00000222 | ||||
| Fulfill Query | 43195033 | 56 mins ago | IN | 0 ETH | 0.0000032 | ||||
| Fulfill Query | 43194931 | 1 hr ago | IN | 0 ETH | 0.00000395 | ||||
| Fulfill Query | 43194827 | 1 hr ago | IN | 0 ETH | 0.00000207 | ||||
| Fulfill Query | 43194724 | 1 hr ago | IN | 0 ETH | 0.00000217 | ||||
| Fulfill Query | 43194621 | 1 hr ago | IN | 0 ETH | 0.00000316 | ||||
| Fulfill Query | 43194519 | 1 hr ago | IN | 0 ETH | 0.00000369 | ||||
| Fulfill Query | 43194415 | 1 hr ago | IN | 0 ETH | 0.00000204 | ||||
| Fulfill Query | 43194312 | 1 hr ago | IN | 0 ETH | 0.00000222 | ||||
| Fulfill Query | 43194209 | 1 hr ago | IN | 0 ETH | 0.00000313 |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
QueryRouter
Compiler Version
v0.8.30+commit.73712a01
Optimization Enabled:
Yes with 4294967295 runs
Other Settings:
prague EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
import {
AccessControlDefaultAdminRules
} from "@openzeppelin-contracts-5.2.0/access/extensions/AccessControlDefaultAdminRules.sol";
import {IERC20} from "@openzeppelin-contracts-5.2.0/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin-contracts-5.2.0/token/ERC20/utils/SafeERC20.sol";
import {ICallbackExecutor} from "./interfaces/ICallbackExecutor.sol";
import {IQueryRouter} from "./interfaces/IQueryRouter.sol";
import {IVerify} from "./interfaces/IVerify.sol";
/// @title QueryRouter
/// @author Placeholder
/// @notice Implementation of the QueryRouter for managing query requests and fulfillments
contract QueryRouter is IQueryRouter, AccessControlDefaultAdminRules {
using SafeERC20 for IERC20;
/// @notice Role for accounts that can edit versions
bytes32 public constant VERSION_EDITOR_ROLE = keccak256("VERSION_EDITOR_ROLE");
/// @notice Role for accounts that can fulfill queries when fulfillment is not open
bytes32 public constant FULFILLER_ROLE = keccak256("FULFILLER_ROLE");
/// @notice The executor contract used for callbacks (immutable)
ICallbackExecutor public immutable EXECUTOR;
/// @notice The ERC20 token used for payments (immutable)
IERC20 public immutable PAYMENT_TOKEN;
/// @notice Mapping from version hash to verifier contract address
/// @dev If mapping returns address(0), the version hash may encode an address
mapping(bytes32 versionHash => address verifier) public versions;
/// @notice Base cost for a query (in payment token units)
uint256 public baseCost;
/// @notice Mapping of query IDs to the hash of the pending payment information
mapping(bytes32 queryId => bytes32 paymentHash) public pendingPayments;
/// @notice Current nonce for generating unique query IDs
uint64 internal _queryNonce;
/// @notice Whether fulfillment is open
bool public openFulfillment;
/// @notice Constructor to set the payment token, executor, and admin
/// @param paymentToken Address of the ERC20 token to use for payments
/// @param executor Address of the executor contract
/// @param initialAdmin Address of the initial admin
constructor(address paymentToken, ICallbackExecutor executor, address initialAdmin)
AccessControlDefaultAdminRules(0, initialAdmin)
{
PAYMENT_TOKEN = IERC20(paymentToken);
EXECUTOR = executor;
}
/// @inheritdoc IQueryRouter
function setBaseCost(uint256 newBaseCost)
external
override
onlyRole(DEFAULT_ADMIN_ROLE) // aderyn-ignore(centralization-risk)
{
baseCost = newBaseCost;
emit BaseCostUpdated(newBaseCost);
}
/// @inheritdoc IQueryRouter
function registerVerifierToVersion(string calldata version, address verifier)
external
override
onlyRole(VERSION_EDITOR_ROLE) // aderyn-ignore(centralization-risk)
{
// forge-lint: disable-next-line(asm-keccak256)
bytes32 versionHash = keccak256(bytes(version));
versions[versionHash] = verifier;
emit VersionSet(version, versionHash, verifier);
}
/// @inheritdoc IQueryRouter
function requestQuery(Query calldata query, Callback calldata callback, Payment calldata payment)
external
override
returns (bytes32 queryId)
{
uint64 queryNonce = _queryNonce;
++_queryNonce;
queryId = _hashQueryId(query, callback, queryNonce);
pendingPayments[queryId] = _hashPayment(payment);
if (payment.paymentAmount > 0) {
PAYMENT_TOKEN.safeTransferFrom(msg.sender, address(this), payment.paymentAmount);
}
emit QueryRequested({
queryId: queryId,
queryNonce: queryNonce,
requester: msg.sender,
query: query,
callback: callback,
payment: payment
});
}
/// @inheritdoc IQueryRouter
function fulfillQuery(
Query calldata query,
Callback calldata callback,
Payment calldata payment,
uint64 queryNonce,
bytes calldata proof
) external override {
uint256 gasBefore = gasleft();
if (!openFulfillment) {
_checkRole(FULFILLER_ROLE);
}
bytes32 queryId = _hashQueryId(query, callback, queryNonce);
if (pendingPayments[queryId] != _hashPayment(payment)) {
revert QueryNotFound();
}
delete pendingPayments[queryId];
bytes memory result = _verifyQuery(query, proof);
emit QueryFulfilled(queryId, msg.sender, result);
// Note: the additional gas used doesn't need to be perfect, but it does include the verification gas cost
uint256 additionalGasUsed = gasBefore - gasleft();
// slither-disable-next-line reentrancy-events
uint256 callbackGasCost = EXECUTOR.execute({
target: callback.callbackContract,
data: abi.encodeWithSelector(callback.selector, queryId, result, callback.callbackData),
gasLimit: callback.gasLimit,
maxGasPrice: callback.maxGasPrice,
additionalGasUsed: additionalGasUsed
});
uint256 fulfillmentCost = baseCost + callbackGasCost;
uint256 fulfillerPayment = payment.paymentAmount < fulfillmentCost ? payment.paymentAmount : fulfillmentCost;
uint256 refundAmount = payment.paymentAmount - fulfillerPayment;
if (fulfillerPayment > 0) {
PAYMENT_TOKEN.safeTransfer(msg.sender, fulfillerPayment);
}
if (refundAmount > 0) {
PAYMENT_TOKEN.safeTransfer(payment.refundTo, refundAmount);
}
emit PayoutOccurred({
queryId: queryId,
fulfiller: msg.sender,
refundRecipient: payment.refundTo,
fulfillerAmount: fulfillerPayment,
refundAmount: refundAmount
});
}
/// @inheritdoc IQueryRouter
function cancelQuery(bytes32 queryId, Payment calldata payment) external override {
if (pendingPayments[queryId] != _hashPayment(payment)) {
revert QueryNotFound();
}
// solhint-disable-next-line not-rely-on-time
if (block.timestamp < payment.timeout) {
revert QueryTimeoutNotReached();
}
delete pendingPayments[queryId];
if (payment.paymentAmount > 0) {
PAYMENT_TOKEN.safeTransfer(payment.refundTo, payment.paymentAmount);
}
emit QueryCancelled(queryId, payment.refundTo, payment.paymentAmount);
}
/// @inheritdoc IQueryRouter
function setOpenFulfillment(bool enabled)
external
override
onlyRole(DEFAULT_ADMIN_ROLE) // aderyn-ignore(centralization-risk)
{
openFulfillment = enabled;
emit OpenFulfillmentToggled(enabled);
}
/// @inheritdoc IQueryRouter
function verifyQuery(Query calldata query, bytes calldata proof)
external
view
override
returns (bytes memory result)
{
return _verifyQuery(query, proof);
}
/// @notice Internal verification helper to avoid external call overhead
/// @param query The original Query struct to verify
/// @param proof The encoded proof bytes to verify
/// @return result The bytes returned by the verifier's verify method
function _verifyQuery(Query calldata query, bytes calldata proof) private view returns (bytes memory result) {
address verifier = versions[query.version];
if (verifier == address(0)) {
uint256 rawVersion = uint256(query.version);
// forge-lint: disable-next-line(unsafe-typecast)
uint160 truncated = uint160(rawVersion);
if (rawVersion == uint256(truncated)) {
verifier = address(truncated);
} else {
revert UnsupportedQueryVersion();
}
}
result = IVerify(verifier).verify(query, proof);
}
/// @notice Internal helper to hash query ID using assembly for gas efficiency
/// @param queryData Query struct
/// @param callback Callback struct
/// @param queryNonce Nonce for the query
/// @return queryId The computed query ID hash
function _hashQueryId(Query calldata queryData, Callback calldata callback, uint64 queryNonce)
private
view
returns (bytes32 queryId)
{
queryId = keccak256(abi.encode(block.chainid, address(this), queryNonce, queryData, callback));
}
/// @notice Internal helper to hash a Payment struct
/// @param payment Payment struct
/// @return paymentHash The computed payment hash
function _hashPayment(Payment calldata payment) private pure returns (bytes32 paymentHash) {
paymentHash = keccak256(abi.encode(payment));
}
}// 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.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
import {GasCost} from "../libraries/GasCost.sol";
/// @title ICallbackExecutor
/// @author Placeholder
/// @notice Interface for the CallbackExecutor contract
interface ICallbackExecutor {
/// @notice Emitted when gas cost config is updated
/// @param newConfig The new gas cost configuration
event GasCostConfigUpdated(GasCost.GasCostConfig newConfig);
/// @notice Emitted when a callback execution fails
/// @param target The address of the target contract
/// @param returnData First four bytes of return data from the failed call
event CallbackFailed(address indexed target, bytes returnData);
/// @notice Emitted when execute is called on an address without a contract
/// @param target The address that had no contract
event NoCallbackContract(address indexed target);
/// @notice Emitted when the max gas limit is updated
/// @param newMax The new max gas limit
event MaxGasLimitUpdated(uint256 indexed newMax);
/// @notice Allows admin to update the gas cost configuration
/// @param newConfig New gas cost configuration struct
function setGasCostConfig(GasCost.GasCostConfig calldata newConfig) external;
/// @notice Set the maximum gas limit that may be passed to `execute`
/// @param newMax The new maximum gas limit (0 disables callbacks with gas)
function setMaxGasLimit(uint256 newMax) external;
/// @notice Executes a call to the target contract with a gas limit and returns gas used
/// @param target The address of the target contract
/// @param data The data to send to the target contract
/// @param gasLimit The gas limit for the call
/// @param maxGasPrice The max gas price for the call
/// @param additionalGasUsed Additional gas used to account for overhead/external factors
/// @return gasUsed The amount of gas used for the call
function execute(
address target,
bytes calldata data,
uint256 gasLimit,
uint256 maxGasPrice,
uint256 additionalGasUsed
) external returns (uint256 gasUsed);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
/// @title IQueryRouter
/// @author Placeholder
/// @notice Interface for querying external data sources with cryptographic proofs
interface IQueryRouter {
/// @notice Query details
/// @param version Query version identifier
/// @param innerQuery Encoded, version-dependent query payload
/// @param parameters Encoded parameters for the query
/// @param metadata Encoded metadata for the query
struct Query {
bytes32 version;
bytes innerQuery;
bytes parameters;
bytes metadata;
}
/// @notice Callback execution details
/// @param maxGasPrice Max native gas price allowed for the callback
/// @param gasLimit Gas limit forwarded to the callback contract
/// @param callbackContract Address of the contract to call back
/// @param selector Function selector to call on the callback contract
/// @param callbackData Opaque callback-specific data passed to the callback
struct Callback {
uint256 maxGasPrice;
uint64 gasLimit;
address callbackContract;
bytes4 selector;
bytes callbackData;
}
/// @notice Payment info for queries
/// @param paymentAmount Funds held when pending fulfillment
/// @param refundTo Recipient of refunds or excess payment returns
/// @param timeout Timestamp after which cancellation is allowed
struct Payment {
uint256 paymentAmount;
address refundTo;
uint64 timeout;
}
/// @notice Emitted when a query is requested
/// @param queryId Unique identifier for the query
/// @param queryNonce Nonce used when the query was created
/// @param requester Address that requested the query
/// @param query Query details
/// @param callback Callback details
/// @param payment Payment details
event QueryRequested(
bytes32 indexed queryId,
uint64 indexed queryNonce,
address indexed requester,
Query query,
Callback callback,
Payment payment
);
/// @notice Emitted when a query has been fulfilled (logical fulfillment/result)
/// @param queryId Unique identifier for the query
/// @param fulfiller Address that fulfilled the query
/// @param result The query result data
event QueryFulfilled(bytes32 indexed queryId, address indexed fulfiller, bytes result);
/// @notice Emitted when a payout for a fulfilled query occurred (payments/refunds)
/// @param queryId Unique identifier for the query
/// @param fulfiller Address that fulfilled the query
/// @param refundRecipient Address that received a refund (if any)
/// @param fulfillerAmount Amount paid to the fulfiller for this fulfillment
/// @param refundAmount Amount refunded to the refundRecipient (if any)
event PayoutOccurred(
bytes32 indexed queryId,
address indexed fulfiller,
address indexed refundRecipient,
uint256 fulfillerAmount,
uint256 refundAmount
); // solhint-disable-line gas-indexed-events
/// @notice Emitted when a query is cancelled
/// @param queryId Unique identifier for the query
/// @param refundRecipient Address that received the refund
/// @param refundAmount Amount refunded
event QueryCancelled(bytes32 indexed queryId, address indexed refundRecipient, uint256 indexed refundAmount);
/// @notice Emitted when open fulfillment is toggled
/// @param enabled Whether open fulfillment is now enabled
event OpenFulfillmentToggled(bool indexed enabled);
/// @notice Emitted when the base cost used by the router is updated
/// @param newBaseCost The new base cost value
event BaseCostUpdated(uint256 indexed newBaseCost);
/// @notice Emitted when a version is set
/// @param version The string version
/// @param versionHash The keccak256 hash of the version
/// @param verifier The verifier contract address associated with the version
event VersionSet(string version, bytes32 indexed versionHash, address indexed verifier);
/// @notice Thrown when a query is not found or unauthorized cancellation is attempted
error QueryNotFound();
/// @notice Thrown when a query cancellation is attempted before the timeout
error QueryTimeoutNotReached();
/// @notice Thrown when the query version is not supported by the router
error UnsupportedQueryVersion();
/// @notice Register a verifier contract address to a version string
/// @param version The string version to hash
/// @param verifier The contract address to associate with the version
function registerVerifierToVersion(string calldata version, address verifier) external;
/// @notice Set the base cost for queries
/// @param newBaseCost The new base cost
function setBaseCost(uint256 newBaseCost) external;
/// @notice Cancel a pending query and refund the payment
/// @param queryId Unique identifier for the query to cancel
/// @param payment Payment struct for the original request.
function cancelQuery(bytes32 queryId, Payment calldata payment) external;
/// @notice Request a query to be executed.
/// @param query Query struct containing query string, parameters, and version.
/// @param callback Callback struct containing callback details.
/// @param payment Payment struct containing payment details.
/// @return queryId Unique ID for this query.
function requestQuery(Query calldata query, Callback calldata callback, Payment calldata payment)
external
returns (bytes32 queryId);
/// @notice Fulfill a query by providing its data and proof.
/// @param query Query struct for the original request.
/// @param callback Callback struct for the original request.
/// @param payment Payment struct for the original request.
/// @param queryNonce Nonce used when the query was created.
/// @param proof Encoded proof containing the query result and cryptographic proof.
function fulfillQuery(
Query calldata query,
Callback calldata callback,
Payment calldata payment,
uint64 queryNonce,
bytes calldata proof
) external;
/// @notice Toggle open fulfillment on or off
/// @param enabled True to allow anyone to fulfill, false to restrict to FULFILLER_ROLE
function setOpenFulfillment(bool enabled) external;
/// @notice Verify a query result without executing its callback.
/// @param query Query struct for the original request.
/// @param proof Encoded proof containing the query result and cryptographic proof.
/// @return result The query result data extracted from the proof.
function verifyQuery(Query calldata query, bytes calldata proof) external view returns (bytes memory result);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
import {IQueryRouter} from "./IQueryRouter.sol";
/// @title IVerify
/// @author Placeholder
/// @notice Minimal verifier interface that exposes exactly the verify method
interface IVerify {
/// @notice Verify a query result and return the extracted result bytes
/// @param queryData The original query struct
/// @param proof Encoded proof containing the query result and cryptographic proof
/// @return result The query result data extracted from the proof
function verify(IQueryRouter.Query calldata queryData, bytes calldata proof)
external
view
returns (bytes memory result);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/extensions/IAccessControlDefaultAdminRules.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "../IAccessControl.sol";
/**
* @dev External interface of AccessControlDefaultAdminRules declared to support ERC-165 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/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.1.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/bool 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);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
assembly ("memory-safe") {
u := iszero(iszero(b))
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
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 success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
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 success flag (no division by zero).
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * SafeCast.toUint(condition));
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(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.
Panic.panic(Panic.DIVISION_BY_ZERO);
}
// The following calculation ensures accurate ceiling division without overflow.
// Since a is non-zero, (a - 1) / b will not overflow.
// The largest possible result occurs when (a - 1) / b is type(uint256).max,
// but the largest value we can obtain is type(uint256).max - 1, which happens
// when a = type(uint256).max and b = 1.
unchecked {
return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
}
}
/**
* @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
*
* 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²⁵⁶ and mod 2²⁵⁶ - 1, then use
// the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2²⁵⁶ + 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²⁵⁶. Also prevents denominator == 0.
if (denominator <= prod1) {
Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
}
///////////////////////////////////////////////
// 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²⁵⁶ / 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²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
// that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv ≡ 1 mod 2⁴.
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⁸
inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
inverse *= 2 - denominator * inverse; // inverse mod 2³²
inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶
// 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²⁵⁶. Since the preconditions guarantee that the outcome is
// less than 2²⁵⁶, 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;
}
}
/**
* @dev 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) {
return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
}
/**
* @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
*
* If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
* If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
*
* If the input value is not inversible, 0 is returned.
*
* NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
* inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
*/
function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
unchecked {
if (n == 0) return 0;
// The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
// Used to compute integers x and y such that: ax + ny = gcd(a, n).
// When the gcd is 1, then the inverse of a modulo n exists and it's x.
// ax + ny = 1
// ax = 1 + (-y)n
// ax ≡ 1 (mod n) # x is the inverse of a modulo n
// If the remainder is 0 the gcd is n right away.
uint256 remainder = a % n;
uint256 gcd = n;
// Therefore the initial coefficients are:
// ax + ny = gcd(a, n) = n
// 0a + 1n = n
int256 x = 0;
int256 y = 1;
while (remainder != 0) {
uint256 quotient = gcd / remainder;
(gcd, remainder) = (
// The old remainder is the next gcd to try.
remainder,
// Compute the next remainder.
// Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
// where gcd is at most n (capped to type(uint256).max)
gcd - remainder * quotient
);
(x, y) = (
// Increment the coefficient of a.
y,
// Decrement the coefficient of n.
// Can overflow, but the result is casted to uint256 so that the
// next value of y is "wrapped around" to a value between 0 and n - 1.
x - y * int256(quotient)
);
}
if (gcd != 1) return 0; // No inverse exists.
return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
}
}
/**
* @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
*
* From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
* prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
* `a**(p-2)` is the modular multiplicative inverse of a in Fp.
*
* NOTE: this function does NOT check that `p` is a prime greater than `2`.
*/
function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
unchecked {
return Math.modExp(a, p - 2, p);
}
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
*
* Requirements:
* - modulus can't be zero
* - underlying staticcall to precompile must succeed
*
* IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
* sure the chain you're using it on supports the precompiled contract for modular exponentiation
* at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
* the underlying function will succeed given the lack of a revert, but the result may be incorrectly
* interpreted as 0.
*/
function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
(bool success, uint256 result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
* It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
* to operate modulo 0 or if the underlying precompile reverted.
*
* IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
* you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
* https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
* of a revert, but the result may be incorrectly interpreted as 0.
*/
function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
if (m == 0) return (false, 0);
assembly ("memory-safe") {
let ptr := mload(0x40)
// | Offset | Content | Content (Hex) |
// |-----------|------------|--------------------------------------------------------------------|
// | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x60:0x7f | value of b | 0x<.............................................................b> |
// | 0x80:0x9f | value of e | 0x<.............................................................e> |
// | 0xa0:0xbf | value of m | 0x<.............................................................m> |
mstore(ptr, 0x20)
mstore(add(ptr, 0x20), 0x20)
mstore(add(ptr, 0x40), 0x20)
mstore(add(ptr, 0x60), b)
mstore(add(ptr, 0x80), e)
mstore(add(ptr, 0xa0), m)
// Given the result < m, it's guaranteed to fit in 32 bytes,
// so we can use the memory scratch space located at offset 0.
success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
result := mload(0x00)
}
}
/**
* @dev Variant of {modExp} that supports inputs of arbitrary length.
*/
function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
(bool success, bytes memory result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Variant of {tryModExp} that supports inputs of arbitrary length.
*/
function tryModExp(
bytes memory b,
bytes memory e,
bytes memory m
) internal view returns (bool success, bytes memory result) {
if (_zeroBytes(m)) return (false, new bytes(0));
uint256 mLen = m.length;
// Encode call args in result and move the free memory pointer
result = abi.encodePacked(b.length, e.length, mLen, b, e, m);
assembly ("memory-safe") {
let dataPtr := add(result, 0x20)
// Write result on top of args to avoid allocating extra memory.
success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
// Overwrite the length.
// result.length > returndatasize() is guaranteed because returndatasize() == m.length
mstore(result, mLen)
// Set the memory pointer after the returned data.
mstore(0x40, add(dataPtr, mLen))
}
}
/**
* @dev Returns whether the provided byte array is zero.
*/
function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
for (uint256 i = 0; i < byteArray.length; ++i) {
if (byteArray[i] != 0) {
return false;
}
}
return true;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* This method is based on Newton's method for computing square roots; the algorithm is restricted to only
* using integer operations.
*/
function sqrt(uint256 a) internal pure returns (uint256) {
unchecked {
// Take care of easy edge cases when a == 0 or a == 1
if (a <= 1) {
return a;
}
// In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
// sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
// the current value as `ε_n = | x_n - sqrt(a) |`.
//
// For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
// of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
// bigger than any uint256.
//
// By noticing that
// `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
// we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
// to the msb function.
uint256 aa = a;
uint256 xn = 1;
if (aa >= (1 << 128)) {
aa >>= 128;
xn <<= 64;
}
if (aa >= (1 << 64)) {
aa >>= 64;
xn <<= 32;
}
if (aa >= (1 << 32)) {
aa >>= 32;
xn <<= 16;
}
if (aa >= (1 << 16)) {
aa >>= 16;
xn <<= 8;
}
if (aa >= (1 << 8)) {
aa >>= 8;
xn <<= 4;
}
if (aa >= (1 << 4)) {
aa >>= 4;
xn <<= 2;
}
if (aa >= (1 << 2)) {
xn <<= 1;
}
// We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
//
// We can refine our estimation by noticing that the middle of that interval minimizes the error.
// If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
// This is going to be our x_0 (and ε_0)
xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)
// From here, Newton's method give us:
// x_{n+1} = (x_n + a / x_n) / 2
//
// One should note that:
// x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
// = ((x_n² + a) / (2 * x_n))² - a
// = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
// = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
// = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
// = (x_n² - a)² / (2 * x_n)²
// = ((x_n² - a) / (2 * x_n))²
// ≥ 0
// Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
//
// This gives us the proof of quadratic convergence of the sequence:
// ε_{n+1} = | x_{n+1} - sqrt(a) |
// = | (x_n + a / x_n) / 2 - sqrt(a) |
// = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
// = | (x_n - sqrt(a))² / (2 * x_n) |
// = | ε_n² / (2 * x_n) |
// = ε_n² / | (2 * x_n) |
//
// For the first iteration, we have a special case where x_0 is known:
// ε_1 = ε_0² / | (2 * x_0) |
// ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
// ≤ 2**(2*e-4) / (3 * 2**(e-1))
// ≤ 2**(e-3) / 3
// ≤ 2**(e-3-log2(3))
// ≤ 2**(e-4.5)
//
// For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
// ε_{n+1} = ε_n² / | (2 * x_n) |
// ≤ (2**(e-k))² / (2 * 2**(e-1))
// ≤ 2**(2*e-2*k) / 2**e
// ≤ 2**(e-2*k)
xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above
xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5
xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9
xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18
xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36
xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72
// Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
// ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
// sqrt(a) or sqrt(a) + 1.
return xn - SafeCast.toUint(xn > a / xn);
}
}
/**
* @dev 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
}
}
/**
* @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;
uint256 exp;
unchecked {
exp = 128 * SafeCast.toUint(value > (1 << 128) - 1);
value >>= exp;
result += exp;
exp = 64 * SafeCast.toUint(value > (1 << 64) - 1);
value >>= exp;
result += exp;
exp = 32 * SafeCast.toUint(value > (1 << 32) - 1);
value >>= exp;
result += exp;
exp = 16 * SafeCast.toUint(value > (1 << 16) - 1);
value >>= exp;
result += exp;
exp = 8 * SafeCast.toUint(value > (1 << 8) - 1);
value >>= exp;
result += exp;
exp = 4 * SafeCast.toUint(value > (1 << 4) - 1);
value >>= exp;
result += exp;
exp = 2 * SafeCast.toUint(value > (1 << 2) - 1);
value >>= exp;
result += exp;
result += SafeCast.toUint(value > 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
}
}
/**
* @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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
}
}
/**
* @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;
uint256 isGt;
unchecked {
isGt = SafeCast.toUint(value > (1 << 128) - 1);
value >>= isGt * 128;
result += isGt * 16;
isGt = SafeCast.toUint(value > (1 << 64) - 1);
value >>= isGt * 64;
result += isGt * 8;
isGt = SafeCast.toUint(value > (1 << 32) - 1);
value >>= isGt * 32;
result += isGt * 4;
isGt = SafeCast.toUint(value > (1 << 16) - 1);
value >>= isGt * 16;
result += isGt * 2;
result += SafeCast.toUint(value > (1 << 8) - 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
}
}
/**
* @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) (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.1.0) (interfaces/IERC1363.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
import {
AggregatorV3Interface
} from "smartcontractkit-chainlink-evm-1.5.0/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol";
/// @title GasCost
/// @author Placeholder
/// @notice Library for converting gas cost to token amount using Chainlink price feeds
library GasCost {
using GasCost for GasCost.GasCostConfig;
/// @notice Gas cost configuration
/// @param nativeUsdFeed Chainlink native token / USD feed address
/// @param nativeStaleThreshold Max seconds before native feed is stale
/// @param tokenUsdFeed Chainlink payment token / USD feed address
/// @param tokenStaleThreshold Max seconds before token feed is stale
/// @param scalingFactor Multiplier to scale USD value; 0 allows free gas
struct GasCostConfig {
address nativeUsdFeed;
uint64 nativeStaleThreshold;
address tokenUsdFeed;
uint64 tokenStaleThreshold;
uint256 scalingFactor;
}
/// @dev Constant for the zero address
address internal constant ZERO_ADDRESS = address(0);
/// @dev Constant for the smallest positive value for Chainlink price feeds
int256 internal constant SMALLEST_POSITIVE_VALUE = 1;
/// @notice Thrown when Chainlink price feed data is invalid
error InvalidPriceFeedData();
/// @notice Thrown when Chainlink price feed data is stale
error StalePriceFeedData();
/// @notice Thrown when GasCostConfig is invalid
error InvalidGasCostConfig();
/// @notice Validate and return the latest price from a Chainlink feed
/// @param feed Address of the Chainlink price feed
/// @param staleThreshold Threshold in seconds for staleness
/// @return price The validated price from the feed
function checkedPrice(address feed, uint256 staleThreshold) internal view returns (uint256 price) {
// slither-disable-next-line unused-return
(, int256 answer, uint256 startedAt, uint256 updatedAt,) = AggregatorV3Interface(feed).latestRoundData();
if (answer < SMALLEST_POSITIVE_VALUE || startedAt == 0) {
revert InvalidPriceFeedData();
}
// solhint-disable-next-line not-rely-on-time
if (updatedAt + staleThreshold < block.timestamp) {
revert StalePriceFeedData();
}
// forge-lint: disable-next-line(unsafe-typecast)
price = uint256(answer);
}
/// @notice Calculate scaled gas cost in USD and token USD price
/// @param config GasCostConfig with feed addresses and thresholds
/// @param maxGasPrice Maximum gas price to use for calculation
/// @return scaledGasCostInUsd Scaled gas cost in USD
/// @return tokenUsdPrice Token price in USD
function gasCost(GasCostConfig storage config, uint256 maxGasPrice)
internal
view
returns (uint256 scaledGasCostInUsd, uint256 tokenUsdPrice)
{
if (config.scalingFactor == 0) {
scaledGasCostInUsd = 0;
tokenUsdPrice = 100;
} else {
uint256 effectiveGasPrice = tx.gasprice < maxGasPrice ? tx.gasprice : maxGasPrice;
uint256 nativeUsdPrice = checkedPrice(config.nativeUsdFeed, config.nativeStaleThreshold);
scaledGasCostInUsd = effectiveGasPrice * nativeUsdPrice * config.scalingFactor;
tokenUsdPrice = checkedPrice(config.tokenUsdFeed, config.tokenStaleThreshold);
}
}
/// @notice Validate a GasCostConfig for contract use
/// @param config GasCostConfig to validate
/// @dev Reverts if any feed address or threshold is zero
function validateConfig(GasCostConfig memory config) internal pure {
if (config.nativeUsdFeed == ZERO_ADDRESS) revert InvalidGasCostConfig();
if (config.nativeStaleThreshold == 0) revert InvalidGasCostConfig();
if (config.tokenUsdFeed == ZERO_ADDRESS) revert InvalidGasCostConfig();
if (config.tokenStaleThreshold == 0) revert InvalidGasCostConfig();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/IAccessControl.sol)
pragma solidity ^0.8.20;
/**
* @dev External interface of AccessControl declared to support ERC-165 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. This account bears the admin role (for the granted role).
* Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
*/
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.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.1.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 ERC-165 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.1.0) (utils/Panic.sol)
pragma solidity ^0.8.20;
/**
* @dev Helper library for emitting standardized panic codes.
*
* ```solidity
* contract Example {
* using Panic for uint256;
*
* // Use any of the declared internal constants
* function foo() { Panic.GENERIC.panic(); }
*
* // Alternatively
* function foo() { Panic.panic(Panic.GENERIC); }
* }
* ```
*
* Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
*
* _Available since v5.1._
*/
// slither-disable-next-line unused-state
library Panic {
/// @dev generic / unspecified error
uint256 internal constant GENERIC = 0x00;
/// @dev used by the assert() builtin
uint256 internal constant ASSERT = 0x01;
/// @dev arithmetic underflow or overflow
uint256 internal constant UNDER_OVERFLOW = 0x11;
/// @dev division or modulo by zero
uint256 internal constant DIVISION_BY_ZERO = 0x12;
/// @dev enum conversion error
uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
/// @dev invalid encoding in storage
uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
/// @dev empty array pop
uint256 internal constant EMPTY_ARRAY_POP = 0x31;
/// @dev array out of bounds access
uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
/// @dev resource error (too large allocation or too large array)
uint256 internal constant RESOURCE_ERROR = 0x41;
/// @dev calling invalid internal function
uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;
/// @dev Reverts with a panic code. Recommended to use with
/// the internal constants with predefined codes.
function panic(uint256 code) internal pure {
assembly ("memory-safe") {
mstore(0x00, 0x4e487b71)
mstore(0x20, code)
revert(0x1c, 0x24)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// solhint-disable-next-line interface-starts-with-i
interface AggregatorV3Interface {
function decimals() external view returns (uint8);
function description() external view returns (string memory);
function version() external view returns (uint256);
function getRoundData(
uint80 _roundId
) external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
function latestRoundData()
external
view
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* 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[ERC 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);
}{
"remappings": [
"@openzeppelin/contracts/=dependencies/@openzeppelin-contracts-5.2.0/",
"forge-std/=dependencies/forge-std-1.9.7/",
"smartcontractkit-chainlink-evm-1.5.0/=dependencies/smartcontractkit-chainlink-evm-1.5.0/",
"sxt-proof-of-sql/=dependencies/sxt-proof-of-sql-0.123.10/",
"@openzeppelin-contracts-5.2.0/=dependencies/@openzeppelin-contracts-5.2.0/",
"forge-std-1.10.0/=dependencies/forge-std-1.10.0/src/",
"forge-std-1.9.7/=dependencies/forge-std-1.9.7/src/",
"sxt-proof-of-sql-0.123.10/=dependencies/sxt-proof-of-sql-0.123.10/src/"
],
"optimizer": {
"enabled": true,
"runs": 4294967295
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "prague",
"viaIR": true
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"contract ICallbackExecutor","name":"executor","type":"address"},{"internalType":"address","name":"initialAdmin","type":"address"}],"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":[],"name":"QueryNotFound","type":"error"},{"inputs":[],"name":"QueryTimeoutNotReached","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"UnsupportedQueryVersion","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"newBaseCost","type":"uint256"}],"name":"BaseCostUpdated","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":true,"internalType":"bool","name":"enabled","type":"bool"}],"name":"OpenFulfillmentToggled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"queryId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"fulfiller","type":"address"},{"indexed":true,"internalType":"address","name":"refundRecipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"fulfillerAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"refundAmount","type":"uint256"}],"name":"PayoutOccurred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"queryId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"refundRecipient","type":"address"},{"indexed":true,"internalType":"uint256","name":"refundAmount","type":"uint256"}],"name":"QueryCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"queryId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"fulfiller","type":"address"},{"indexed":false,"internalType":"bytes","name":"result","type":"bytes"}],"name":"QueryFulfilled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"queryId","type":"bytes32"},{"indexed":true,"internalType":"uint64","name":"queryNonce","type":"uint64"},{"indexed":true,"internalType":"address","name":"requester","type":"address"},{"components":[{"internalType":"bytes32","name":"version","type":"bytes32"},{"internalType":"bytes","name":"innerQuery","type":"bytes"},{"internalType":"bytes","name":"parameters","type":"bytes"},{"internalType":"bytes","name":"metadata","type":"bytes"}],"indexed":false,"internalType":"struct IQueryRouter.Query","name":"query","type":"tuple"},{"components":[{"internalType":"uint256","name":"maxGasPrice","type":"uint256"},{"internalType":"uint64","name":"gasLimit","type":"uint64"},{"internalType":"address","name":"callbackContract","type":"address"},{"internalType":"bytes4","name":"selector","type":"bytes4"},{"internalType":"bytes","name":"callbackData","type":"bytes"}],"indexed":false,"internalType":"struct IQueryRouter.Callback","name":"callback","type":"tuple"},{"components":[{"internalType":"uint256","name":"paymentAmount","type":"uint256"},{"internalType":"address","name":"refundTo","type":"address"},{"internalType":"uint64","name":"timeout","type":"uint64"}],"indexed":false,"internalType":"struct IQueryRouter.Payment","name":"payment","type":"tuple"}],"name":"QueryRequested","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":"string","name":"version","type":"string"},{"indexed":true,"internalType":"bytes32","name":"versionHash","type":"bytes32"},{"indexed":true,"internalType":"address","name":"verifier","type":"address"}],"name":"VersionSet","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EXECUTOR","outputs":[{"internalType":"contract ICallbackExecutor","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FULFILLER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAYMENT_TOKEN","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION_EDITOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"baseCost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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":"bytes32","name":"queryId","type":"bytes32"},{"components":[{"internalType":"uint256","name":"paymentAmount","type":"uint256"},{"internalType":"address","name":"refundTo","type":"address"},{"internalType":"uint64","name":"timeout","type":"uint64"}],"internalType":"struct IQueryRouter.Payment","name":"payment","type":"tuple"}],"name":"cancelQuery","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint48","name":"newDelay","type":"uint48"}],"name":"changeDefaultAdminDelay","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":[{"components":[{"internalType":"bytes32","name":"version","type":"bytes32"},{"internalType":"bytes","name":"innerQuery","type":"bytes"},{"internalType":"bytes","name":"parameters","type":"bytes"},{"internalType":"bytes","name":"metadata","type":"bytes"}],"internalType":"struct IQueryRouter.Query","name":"query","type":"tuple"},{"components":[{"internalType":"uint256","name":"maxGasPrice","type":"uint256"},{"internalType":"uint64","name":"gasLimit","type":"uint64"},{"internalType":"address","name":"callbackContract","type":"address"},{"internalType":"bytes4","name":"selector","type":"bytes4"},{"internalType":"bytes","name":"callbackData","type":"bytes"}],"internalType":"struct IQueryRouter.Callback","name":"callback","type":"tuple"},{"components":[{"internalType":"uint256","name":"paymentAmount","type":"uint256"},{"internalType":"address","name":"refundTo","type":"address"},{"internalType":"uint64","name":"timeout","type":"uint64"}],"internalType":"struct IQueryRouter.Payment","name":"payment","type":"tuple"},{"internalType":"uint64","name":"queryNonce","type":"uint64"},{"internalType":"bytes","name":"proof","type":"bytes"}],"name":"fulfillQuery","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":"openFulfillment","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"internalType":"bytes32","name":"queryId","type":"bytes32"}],"name":"pendingPayments","outputs":[{"internalType":"bytes32","name":"paymentHash","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"version","type":"string"},{"internalType":"address","name":"verifier","type":"address"}],"name":"registerVerifierToVersion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"version","type":"bytes32"},{"internalType":"bytes","name":"innerQuery","type":"bytes"},{"internalType":"bytes","name":"parameters","type":"bytes"},{"internalType":"bytes","name":"metadata","type":"bytes"}],"internalType":"struct IQueryRouter.Query","name":"query","type":"tuple"},{"components":[{"internalType":"uint256","name":"maxGasPrice","type":"uint256"},{"internalType":"uint64","name":"gasLimit","type":"uint64"},{"internalType":"address","name":"callbackContract","type":"address"},{"internalType":"bytes4","name":"selector","type":"bytes4"},{"internalType":"bytes","name":"callbackData","type":"bytes"}],"internalType":"struct IQueryRouter.Callback","name":"callback","type":"tuple"},{"components":[{"internalType":"uint256","name":"paymentAmount","type":"uint256"},{"internalType":"address","name":"refundTo","type":"address"},{"internalType":"uint64","name":"timeout","type":"uint64"}],"internalType":"struct IQueryRouter.Payment","name":"payment","type":"tuple"}],"name":"requestQuery","outputs":[{"internalType":"bytes32","name":"queryId","type":"bytes32"}],"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":"newBaseCost","type":"uint256"}],"name":"setBaseCost","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setOpenFulfillment","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"version","type":"bytes32"},{"internalType":"bytes","name":"innerQuery","type":"bytes"},{"internalType":"bytes","name":"parameters","type":"bytes"},{"internalType":"bytes","name":"metadata","type":"bytes"}],"internalType":"struct IQueryRouter.Query","name":"query","type":"tuple"},{"internalType":"bytes","name":"proof","type":"bytes"}],"name":"verifyQuery","outputs":[{"internalType":"bytes","name":"result","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"versionHash","type":"bytes32"}],"name":"versions","outputs":[{"internalType":"address","name":"verifier","type":"address"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60c03461012057601f612afb38819003918201601f19168301916001600160401b03831184841017610124578084926060946040528339810103126101205761004781610138565b6020820151916001600160a01b03831683036101205760406100699101610138565b6001600160a01b03811690811561010d57600180546001600160d01b03169055600254916001600160a01b0383166100fe576100b19260018060a01b0319161760025561014c565b506001600160a01b031660a05260805260405161290590816101d68239608051818181610e010152611701015260a05181818161097301528181610a6401528181610f9801526117cd0152f35b631fe1e13d60e11b5f5260045ffd5b636116401160e11b5f525f60045260245ffd5b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b51906001600160a01b038216820361012057565b6001600160a01b0381165f9081525f516020612adb5f395f51905f52602052604090205460ff166101d0576001600160a01b03165f8181525f516020612adb5f395f51905f5260205260408120805460ff191660011790553391907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8180a4600190565b505f9056fe6080806040526004361015610012575f80fd5b5f3560e01c90816301ffc9a714611c3457508063022d63fb14611bf95780630aa6220b14611b1557806312ab054214611a6457806313b90d74146118c357806317b33ef014611397578063248a9ca3146113475780632b5dc91f146112e35780632f2ff15d1461128257806336568abe146110f75780633b7f0345146110b45780634a0cb8dd146110115780634e8d0f8d14610e7d5780634fd331c614610e25578063630dc7cb14610db7578063634e93da14610c88578063649a5ec714610a8857806384ef8ffc146109c9578063877c86fb14610a1a5780638da5cb5b146109c95780639165fb7f1461072857806391d14854146106b45780639382255714610679578063a1eda53c146105f3578063a217fddf146105bb578063a8e9ba7d14610563578063c7cec7f814610505578063cc8463c8146104bd578063cefc142914610384578063cf6eefb7146102fa578063d547741f1461026a578063d602b9fd146101d35763e7bcaed914610187575f80fd5b346101cf5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf576004355f526005602052602060405f2054604051908152f35b5f80fd5b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf576102096120fc565b600180547fffffffffffff0000000000000000000000000000000000000000000000000000811690915560a01c65ffffffffffff1661024457005b7f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a96051095f80a1005b346101cf5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf576004356102a4611d94565b81156102d257816102cb6102c66102d0945f525f602052600160405f20015490565b612164565b612677565b005b7f3fc3c27a000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf57604065ffffffffffff61035e6001549065ffffffffffff73ffffffffffffffffffffffffffffffffffffffff83169260a01c1690565b73ffffffffffffffffffffffffffffffffffffffff849392935193168352166020820152f35b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760015473ffffffffffffffffffffffffffffffffffffffff1633036104915760015460a081901c65ffffffffffff169073ffffffffffffffffffffffffffffffffffffffff1681158015610487575b61045b576104309061042a73ffffffffffffffffffffffffffffffffffffffff6002541661260a565b5061252f565b50600180547fffffffffffff0000000000000000000000000000000000000000000000000000169055005b507f19ca5ebb000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b5042821015610401565b7fc22c8022000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760206104f56120c3565b65ffffffffffff60405191168152f35b346101cf5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf576004355f526003602052602073ffffffffffffffffffffffffffffffffffffffff60405f205416604051908152f35b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760206040517ffee50fa0fe41a985a4fb439159472d2e1052f1a39d61515e5e1052c61c5fbdf18152f35b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760206040515f8152f35b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf576002548060d01c908115158061066f575b156106655760a01c65ffffffffffff165b6040805165ffffffffffff9283168152929091166020830152819081015b0390f35b50505f5f90610643565b5042821015610632565b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf576020600454604051908152f35b346101cf5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf576106eb611d94565b6004355f525f60205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060ff60405f2054166040519015158152f35b346101cf5760a07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760043567ffffffffffffffff81116101cf5760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8260040192360301126101cf5760243567ffffffffffffffff81116101cf5760a07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8260040192360301126101cf5760607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc3601126101cf576006549067ffffffffffffffff82169167ffffffffffffffff831461099c577fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000166001830167ffffffffffffffff1617600655610863828285612363565b9161086c612404565b835f52600560205260405f20556108a96044359283610924575b61089b6040519660a0885260a0880190611f76565b908682036020880152611fdc565b91604085015260643573ffffffffffffffffffffffffffffffffffffffff81168091036101cf5760608501526084359367ffffffffffffffff85168095036101cf577fd17b54c85e6601f5249bfc8505e1f10fbea15c1089cea9f1fc39c867859d71d4816020966080879401528033950390a4604051908152f35b6109976040517f23b872dd00000000000000000000000000000000000000000000000000000000602082015233602482015230604482015285606482015260648152610971608482611ded565b7f00000000000000000000000000000000000000000000000000000000000000006124a8565b610886565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf57602073ffffffffffffffffffffffffffffffffffffffff60025416604051908152f35b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf57602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b346101cf5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760043565ffffffffffff8116908181036101cf57610ad36120fc565b610adc426126ed565b9165ffffffffffff610aec6120c3565b1680821115610c4e57507ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b9265ffffffffffff826206978080610b3995109118026206978018169061248a565b906002548060d01c80610bcb575b50506002805473ffffffffffffffffffffffffffffffffffffffff1660a083901b79ffffffffffff0000000000000000000000000000000000000000161760d084901b7fffffffffffff0000000000000000000000000000000000000000000000000000161790556040805165ffffffffffff9283168152919092166020820152a1005b421115610c245779ffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffff00000000000000000000000000000000000000000000000000006001549260301b169116176001555b8380610b47565b507f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec55f80a1610c1d565b0365ffffffffffff811161099c577ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b92610b39919061248a565b346101cf5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760043573ffffffffffffffffffffffffffffffffffffffff81168091036101cf57610ce06120fc565b7f3377dc44241e779dd06afab5b788a35ca5f3b778836e2990bdb26a2a4b2e5ed66020610d1d610d0f426126ed565b610d176120c3565b9061248a565b600180547fffffffffffff00000000000000000000000000000000000000000000000000008116861760a084811b79ffffffffffff00000000000000000000000000000000000000001691909117909255901c65ffffffffffff16610d8e575b65ffffffffffff60405191168152a2005b7f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a96051095f80a1610d7d565b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf57602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760206040517f5fd84582b30bace1cbb5cc91a75b8ee48a0e84da1e64c2d880c8c865c813444f8152f35b346101cf5760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760043560607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc3601126101cf57805f52600560205260405f20546040516020810190610ef982602461207c565b60608152610f08608082611ded565b51902003610fe95760643567ffffffffffffffff8116908181036101cf57504210610fc157805f5260056020525f60408120556024359081610f8a575b73ffffffffffffffffffffffffffffffffffffffff610f62611f03565b16907fb752bdb82419db9ee27a3fee1122d4a832bb8bcd90f1dca317121f0cc5c763f15f80a4005b610fbc82610f96611f03565b7f0000000000000000000000000000000000000000000000000000000000000000612426565b610f45565b7f79e27e47000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fef6ef787000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101cf5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf576004358015158091036101cf576110556120fc565b6006547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff68ff00000000000000008360401b169116176006557f0c941ec7abfb4aa5dcb9b616f13e0f57123caf41199d5db4715d5a712cae02ba5f80a2005b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf57602060ff60065460401c166040519015158152f35b346101cf5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf57600435611131611d94565b81158061124b575b61118c575b3373ffffffffffffffffffffffffffffffffffffffff821603611164576102d091612677565b7f6697b232000000000000000000000000000000000000000000000000000000005f5260045ffd5b60015465ffffffffffff60a082901c169073ffffffffffffffffffffffffffffffffffffffff161580159061123b575b8015611229575b6111f557507fffffffffffff000000000000ffffffffffffffffffffffffffffffffffffffff6001541660015561113e565b65ffffffffffff907f19ca5ebb000000000000000000000000000000000000000000000000000000005f521660045260245ffd5b504265ffffffffffff821610156111c3565b5065ffffffffffff8116156111bc565b5073ffffffffffffffffffffffffffffffffffffffff6002541673ffffffffffffffffffffffffffffffffffffffff821614611139565b346101cf5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf576004356112bc611d94565b81156102d257816112de6102c66102d0945f525f602052600160405f20015490565b612596565b346101cf5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760043561131d6120fc565b806004557f803c7b50a7d1ccd172c4d64c9749ab73a7dd19e9a4ee78500bfdf7ccb85c475e5f80a2005b346101cf5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf57602061138f6004355f525f602052600160405f20015490565b604051908152f35b346101cf5760e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760043567ffffffffffffffff81116101cf5760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8260040192360301126101cf5760243567ffffffffffffffff81116101cf5780600401908036039060a07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8301126101cf5760607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc3601126101cf5760a4359067ffffffffffffffff821682036101cf5760c43567ffffffffffffffff81116101cf576114ac903690600401611d23565b955a9360ff60065460401c161561183e575b6114c9908783612363565b96875f52600560205260405f20546114df612404565b03610fe957611543926114ff92895f5260056020525f60408120556121ca565b9260405160208152877f8c3063d9f171d4998251d77e616d4662a65edaca284a344e632258c420def118339280611539602082018a611d51565b0390a35a90611ed3565b9260448201359173ffffffffffffffffffffffffffffffffffffffff8316928381036101cf57506064810135917fffffffff00000000000000000000000000000000000000000000000000000000831683036101cf577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdd608483013591018112156101cf5781019160048301359267ffffffffffffffff84116101cf576024019083360382136101cf5761164b6116779260249561161b604051998a9560208701528d89870152606060448701526084860190611d51565b917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc858403016064860152611e95565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101865285611ded565b01359267ffffffffffffffff8416908185036101cf576116d6956020955060405196879586957fad3e063e000000000000000000000000000000000000000000000000000000008752600487015260a0602487015260a4860190611d51565b926044850152356064840152608483015203815f73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165af1908115611833575f91611801575b5060045490810180911161099c5760443590808210156117f657506117568180611ed3565b91816117c6575b826117b5575b73ffffffffffffffffffffffffffffffffffffffff611780611ee0565b169260405192835260208301527f81409ecadb65c66c281ee2cd4a0c4be15fca40c806e64ad5ef997825aaee4d4860403393a4005b6117c183610f96611ee0565b611763565b6117f182337f0000000000000000000000000000000000000000000000000000000000000000612426565b61175d565b611756908092611ed3565b90506020813d60201161182b575b8161181c60209383611ded565b810103126101cf575182611731565b3d915061180f565b6040513d5f823e3d90fd5b335f9081527ffe498231a00100fd8a31ae424706cade1ce16b4e5bc849a7878cde337210f4d8602052604090205460ff166114be577fe2517d3f000000000000000000000000000000000000000000000000000000005f52336004527f5fd84582b30bace1cbb5cc91a75b8ee48a0e84da1e64c2d880c8c865c813444f60245260445ffd5b346101cf5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760043567ffffffffffffffff81116101cf57611912903690600401611d23565b61191a611d94565b335f9081527fd3b7096dcfc1a973faf4de921a31b97854136943a7202f46736caf7bf11c8f3b602052604090205490929060ff1615611a145761195c82611e5b565b9061196a6040519283611ded565b8282526020820136848301116101cf577f7d68cf470cdc7f6f231c1476ca8605a92d74532d25c4e879fd02698d94462fd092848383375f6020868301015251902092835f52600360205273ffffffffffffffffffffffffffffffffffffffff60405f20951694857fffffffffffffffffffffffff0000000000000000000000000000000000000000825416179055611a0f604051928392602084526020840191611e95565b0390a3005b7fe2517d3f000000000000000000000000000000000000000000000000000000005f52336004527ffee50fa0fe41a985a4fb439159472d2e1052f1a39d61515e5e1052c61c5fbdf160245260445ffd5b346101cf5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760043567ffffffffffffffff81116101cf5760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc82360301126101cf5760243567ffffffffffffffff81116101cf5761066191611af8611b01923690600401611d23565b916004016121ca565b604051918291602083526020830190611d51565b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf57611b4b6120fc565b6002548060d01c80611b76575b6002805473ffffffffffffffffffffffffffffffffffffffff169055005b421115611bcf5779ffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffff00000000000000000000000000000000000000000000000000006001549260301b169116176001555b8080611b58565b507f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec55f80a1611bc8565b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf576020604051620697808152f35b346101cf5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf57600435907fffffffff0000000000000000000000000000000000000000000000000000000082168092036101cf57817f314987860000000000000000000000000000000000000000000000000000000060209314908115611cc6575b5015158152f35b7f7965db0b00000000000000000000000000000000000000000000000000000000811491508115611cf9575b5083611cbf565b7f01ffc9a70000000000000000000000000000000000000000000000000000000091501483611cf2565b9181601f840112156101cf5782359167ffffffffffffffff83116101cf57602083818601950101116101cf57565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602080948051918291828752018686015e5f8582860101520116010190565b6024359073ffffffffffffffffffffffffffffffffffffffff821682036101cf57565b359073ffffffffffffffffffffffffffffffffffffffff821682036101cf57565b359067ffffffffffffffff821682036101cf57565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff821117611e2e57604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b67ffffffffffffffff8111611e2e57601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe093818652868601375f8582860101520116010190565b9190820391821161099c57565b60643573ffffffffffffffffffffffffffffffffffffffff811681036101cf5790565b60443573ffffffffffffffffffffffffffffffffffffffff811681036101cf5790565b90357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1823603018112156101cf57016020813591019167ffffffffffffffff82116101cf5781360383136101cf57565b611fd99181358152611fcb611fc0611fa5611f946020860186611f26565b608060208701526080860191611e95565b611fb26040860186611f26565b908583036040870152611e95565b926060810190611f26565b916060818503910152611e95565b90565b908135815267ffffffffffffffff611ff660208401611dd8565b16602082015273ffffffffffffffffffffffffffffffffffffffff61201d60408401611db7565b1660408201526060820135917fffffffff0000000000000000000000000000000000000000000000000000000083168093036101cf5761206c60a091611fd99460608501526080810190611f26565b9190928160808201520191611e95565b67ffffffffffffffff6120bd604080938035865273ffffffffffffffffffffffffffffffffffffffff6120b160208301611db7565b16602087015201611dd8565b16910152565b6002548060d01c80151590816120f2575b50156120e85760a01c65ffffffffffff1690565b5060015460d01c90565b905042115f6120d4565b335f9081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff161561213457565b7fe2517d3f000000000000000000000000000000000000000000000000000000005f52336004525f60245260445ffd5b805f525f60205260405f2073ffffffffffffffffffffffffffffffffffffffff33165f5260205260ff60405f2054161561219b5750565b7fe2517d3f000000000000000000000000000000000000000000000000000000005f523360045260245260445ffd5b9091813591825f52600360205273ffffffffffffffffffffffffffffffffffffffff60405f205416928315612314575b509161225773ffffffffffffffffffffffffffffffffffffffff5f94612287604051978896879586947fdd71257c000000000000000000000000000000000000000000000000000000008652604060048701526044860190611f76565b917ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc858403016024860152611e95565b0392165afa908115611833575f9161229d575090565b90503d805f833e6122ae8183611ded565b8101906020818303126101cf5780519067ffffffffffffffff82116101cf570181601f820112156101cf578051906122e582611e5b565b926122f36040519485611ded565b828452602083830101116101cf57815f9260208093018386015e8301015290565b73ffffffffffffffffffffffffffffffffffffffff81169350830361233b576122576121fa565b7fba50ad0a000000000000000000000000000000000000000000000000000000005f5260045ffd5b6123fe906123d26123a29360405194859367ffffffffffffffff6020860198468a5230604088015216606086015260a0608086015260c0850190611f76565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08483030160a0850152611fdc565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101835282611ded565b51902090565b604051602081019061241782604461207c565b606081526123fe608082611ded565b6124889273ffffffffffffffffffffffffffffffffffffffff604051937fa9059cbb000000000000000000000000000000000000000000000000000000006020860152166024840152604483015260448252612483606483611ded565b6124a8565b565b9065ffffffffffff8091169116019065ffffffffffff821161099c57565b905f602091828151910182855af115611833575f513d612526575073ffffffffffffffffffffffffffffffffffffffff81163b155b6124e45750565b73ffffffffffffffffffffffffffffffffffffffff907f5274afe7000000000000000000000000000000000000000000000000000000005f521660045260245ffd5b600114156124dd565b6002549073ffffffffffffffffffffffffffffffffffffffff82166102d257611fd9917fffffffffffffffffffffffff000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff83169116176002555f612735565b9081156125a7575b611fd991612735565b6002549173ffffffffffffffffffffffffffffffffffffffff83166102d2577fffffffffffffffffffffffff000000000000000000000000000000000000000090921673ffffffffffffffffffffffffffffffffffffffff82161760025561259e565b611fd99073ffffffffffffffffffffffffffffffffffffffff6002541673ffffffffffffffffffffffffffffffffffffffff82161461264a575b5f612807565b7fffffffffffffffffffffffff000000000000000000000000000000000000000060025416600255612644565b90611fd9918015806126b6575b15612807577fffffffffffffffffffffffff000000000000000000000000000000000000000060025416600255612807565b5073ffffffffffffffffffffffffffffffffffffffff6002541673ffffffffffffffffffffffffffffffffffffffff831614612684565b65ffffffffffff81116127055765ffffffffffff1690565b7f6dfcc650000000000000000000000000000000000000000000000000000000005f52603060045260245260445ffd5b805f525f60205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260ff60405f205416155f1461280157805f525f60205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260405f2060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0082541617905573ffffffffffffffffffffffffffffffffffffffff339216907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d5f80a4600190565b50505f90565b805f525f60205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260ff60405f2054165f1461280157805f525f60205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260405f207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00815416905573ffffffffffffffffffffffffffffffffffffffff339216907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b5f80a460019056fea26469706673582212205eb4c224df9b87b0bbeea4524c70aa956c406bbbe21954b129e46b10f34a6f1064736f6c634300081e0033ad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5000000000000000000000000a2c22252cdc8b7cddee1b0b2e242818509fcf7b8000000000000000000000000acf075862425a0c839844369ac20e334b3710e4700000000000000000000000000f8b1cc17ea5fb9983d069ed2b71ea9d07d700f
Deployed Bytecode
0x6080806040526004361015610012575f80fd5b5f3560e01c90816301ffc9a714611c3457508063022d63fb14611bf95780630aa6220b14611b1557806312ab054214611a6457806313b90d74146118c357806317b33ef014611397578063248a9ca3146113475780632b5dc91f146112e35780632f2ff15d1461128257806336568abe146110f75780633b7f0345146110b45780634a0cb8dd146110115780634e8d0f8d14610e7d5780634fd331c614610e25578063630dc7cb14610db7578063634e93da14610c88578063649a5ec714610a8857806384ef8ffc146109c9578063877c86fb14610a1a5780638da5cb5b146109c95780639165fb7f1461072857806391d14854146106b45780639382255714610679578063a1eda53c146105f3578063a217fddf146105bb578063a8e9ba7d14610563578063c7cec7f814610505578063cc8463c8146104bd578063cefc142914610384578063cf6eefb7146102fa578063d547741f1461026a578063d602b9fd146101d35763e7bcaed914610187575f80fd5b346101cf5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf576004355f526005602052602060405f2054604051908152f35b5f80fd5b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf576102096120fc565b600180547fffffffffffff0000000000000000000000000000000000000000000000000000811690915560a01c65ffffffffffff1661024457005b7f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a96051095f80a1005b346101cf5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf576004356102a4611d94565b81156102d257816102cb6102c66102d0945f525f602052600160405f20015490565b612164565b612677565b005b7f3fc3c27a000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf57604065ffffffffffff61035e6001549065ffffffffffff73ffffffffffffffffffffffffffffffffffffffff83169260a01c1690565b73ffffffffffffffffffffffffffffffffffffffff849392935193168352166020820152f35b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760015473ffffffffffffffffffffffffffffffffffffffff1633036104915760015460a081901c65ffffffffffff169073ffffffffffffffffffffffffffffffffffffffff1681158015610487575b61045b576104309061042a73ffffffffffffffffffffffffffffffffffffffff6002541661260a565b5061252f565b50600180547fffffffffffff0000000000000000000000000000000000000000000000000000169055005b507f19ca5ebb000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b5042821015610401565b7fc22c8022000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760206104f56120c3565b65ffffffffffff60405191168152f35b346101cf5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf576004355f526003602052602073ffffffffffffffffffffffffffffffffffffffff60405f205416604051908152f35b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760206040517ffee50fa0fe41a985a4fb439159472d2e1052f1a39d61515e5e1052c61c5fbdf18152f35b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760206040515f8152f35b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf576002548060d01c908115158061066f575b156106655760a01c65ffffffffffff165b6040805165ffffffffffff9283168152929091166020830152819081015b0390f35b50505f5f90610643565b5042821015610632565b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf576020600454604051908152f35b346101cf5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf576106eb611d94565b6004355f525f60205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060ff60405f2054166040519015158152f35b346101cf5760a07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760043567ffffffffffffffff81116101cf5760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8260040192360301126101cf5760243567ffffffffffffffff81116101cf5760a07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8260040192360301126101cf5760607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc3601126101cf576006549067ffffffffffffffff82169167ffffffffffffffff831461099c577fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000166001830167ffffffffffffffff1617600655610863828285612363565b9161086c612404565b835f52600560205260405f20556108a96044359283610924575b61089b6040519660a0885260a0880190611f76565b908682036020880152611fdc565b91604085015260643573ffffffffffffffffffffffffffffffffffffffff81168091036101cf5760608501526084359367ffffffffffffffff85168095036101cf577fd17b54c85e6601f5249bfc8505e1f10fbea15c1089cea9f1fc39c867859d71d4816020966080879401528033950390a4604051908152f35b6109976040517f23b872dd00000000000000000000000000000000000000000000000000000000602082015233602482015230604482015285606482015260648152610971608482611ded565b7f000000000000000000000000a2c22252cdc8b7cddee1b0b2e242818509fcf7b86124a8565b610886565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf57602073ffffffffffffffffffffffffffffffffffffffff60025416604051908152f35b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf57602060405173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000a2c22252cdc8b7cddee1b0b2e242818509fcf7b8168152f35b346101cf5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760043565ffffffffffff8116908181036101cf57610ad36120fc565b610adc426126ed565b9165ffffffffffff610aec6120c3565b1680821115610c4e57507ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b9265ffffffffffff826206978080610b3995109118026206978018169061248a565b906002548060d01c80610bcb575b50506002805473ffffffffffffffffffffffffffffffffffffffff1660a083901b79ffffffffffff0000000000000000000000000000000000000000161760d084901b7fffffffffffff0000000000000000000000000000000000000000000000000000161790556040805165ffffffffffff9283168152919092166020820152a1005b421115610c245779ffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffff00000000000000000000000000000000000000000000000000006001549260301b169116176001555b8380610b47565b507f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec55f80a1610c1d565b0365ffffffffffff811161099c577ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b92610b39919061248a565b346101cf5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760043573ffffffffffffffffffffffffffffffffffffffff81168091036101cf57610ce06120fc565b7f3377dc44241e779dd06afab5b788a35ca5f3b778836e2990bdb26a2a4b2e5ed66020610d1d610d0f426126ed565b610d176120c3565b9061248a565b600180547fffffffffffff00000000000000000000000000000000000000000000000000008116861760a084811b79ffffffffffff00000000000000000000000000000000000000001691909117909255901c65ffffffffffff16610d8e575b65ffffffffffff60405191168152a2005b7f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a96051095f80a1610d7d565b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf57602060405173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000acf075862425a0c839844369ac20e334b3710e47168152f35b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760206040517f5fd84582b30bace1cbb5cc91a75b8ee48a0e84da1e64c2d880c8c865c813444f8152f35b346101cf5760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760043560607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc3601126101cf57805f52600560205260405f20546040516020810190610ef982602461207c565b60608152610f08608082611ded565b51902003610fe95760643567ffffffffffffffff8116908181036101cf57504210610fc157805f5260056020525f60408120556024359081610f8a575b73ffffffffffffffffffffffffffffffffffffffff610f62611f03565b16907fb752bdb82419db9ee27a3fee1122d4a832bb8bcd90f1dca317121f0cc5c763f15f80a4005b610fbc82610f96611f03565b7f000000000000000000000000a2c22252cdc8b7cddee1b0b2e242818509fcf7b8612426565b610f45565b7f79e27e47000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fef6ef787000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101cf5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf576004358015158091036101cf576110556120fc565b6006547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff68ff00000000000000008360401b169116176006557f0c941ec7abfb4aa5dcb9b616f13e0f57123caf41199d5db4715d5a712cae02ba5f80a2005b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf57602060ff60065460401c166040519015158152f35b346101cf5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf57600435611131611d94565b81158061124b575b61118c575b3373ffffffffffffffffffffffffffffffffffffffff821603611164576102d091612677565b7f6697b232000000000000000000000000000000000000000000000000000000005f5260045ffd5b60015465ffffffffffff60a082901c169073ffffffffffffffffffffffffffffffffffffffff161580159061123b575b8015611229575b6111f557507fffffffffffff000000000000ffffffffffffffffffffffffffffffffffffffff6001541660015561113e565b65ffffffffffff907f19ca5ebb000000000000000000000000000000000000000000000000000000005f521660045260245ffd5b504265ffffffffffff821610156111c3565b5065ffffffffffff8116156111bc565b5073ffffffffffffffffffffffffffffffffffffffff6002541673ffffffffffffffffffffffffffffffffffffffff821614611139565b346101cf5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf576004356112bc611d94565b81156102d257816112de6102c66102d0945f525f602052600160405f20015490565b612596565b346101cf5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760043561131d6120fc565b806004557f803c7b50a7d1ccd172c4d64c9749ab73a7dd19e9a4ee78500bfdf7ccb85c475e5f80a2005b346101cf5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf57602061138f6004355f525f602052600160405f20015490565b604051908152f35b346101cf5760e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760043567ffffffffffffffff81116101cf5760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8260040192360301126101cf5760243567ffffffffffffffff81116101cf5780600401908036039060a07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8301126101cf5760607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc3601126101cf5760a4359067ffffffffffffffff821682036101cf5760c43567ffffffffffffffff81116101cf576114ac903690600401611d23565b955a9360ff60065460401c161561183e575b6114c9908783612363565b96875f52600560205260405f20546114df612404565b03610fe957611543926114ff92895f5260056020525f60408120556121ca565b9260405160208152877f8c3063d9f171d4998251d77e616d4662a65edaca284a344e632258c420def118339280611539602082018a611d51565b0390a35a90611ed3565b9260448201359173ffffffffffffffffffffffffffffffffffffffff8316928381036101cf57506064810135917fffffffff00000000000000000000000000000000000000000000000000000000831683036101cf577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdd608483013591018112156101cf5781019160048301359267ffffffffffffffff84116101cf576024019083360382136101cf5761164b6116779260249561161b604051998a9560208701528d89870152606060448701526084860190611d51565b917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc858403016064860152611e95565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101865285611ded565b01359267ffffffffffffffff8416908185036101cf576116d6956020955060405196879586957fad3e063e000000000000000000000000000000000000000000000000000000008752600487015260a0602487015260a4860190611d51565b926044850152356064840152608483015203815f73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000acf075862425a0c839844369ac20e334b3710e47165af1908115611833575f91611801575b5060045490810180911161099c5760443590808210156117f657506117568180611ed3565b91816117c6575b826117b5575b73ffffffffffffffffffffffffffffffffffffffff611780611ee0565b169260405192835260208301527f81409ecadb65c66c281ee2cd4a0c4be15fca40c806e64ad5ef997825aaee4d4860403393a4005b6117c183610f96611ee0565b611763565b6117f182337f000000000000000000000000a2c22252cdc8b7cddee1b0b2e242818509fcf7b8612426565b61175d565b611756908092611ed3565b90506020813d60201161182b575b8161181c60209383611ded565b810103126101cf575182611731565b3d915061180f565b6040513d5f823e3d90fd5b335f9081527ffe498231a00100fd8a31ae424706cade1ce16b4e5bc849a7878cde337210f4d8602052604090205460ff166114be577fe2517d3f000000000000000000000000000000000000000000000000000000005f52336004527f5fd84582b30bace1cbb5cc91a75b8ee48a0e84da1e64c2d880c8c865c813444f60245260445ffd5b346101cf5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760043567ffffffffffffffff81116101cf57611912903690600401611d23565b61191a611d94565b335f9081527fd3b7096dcfc1a973faf4de921a31b97854136943a7202f46736caf7bf11c8f3b602052604090205490929060ff1615611a145761195c82611e5b565b9061196a6040519283611ded565b8282526020820136848301116101cf577f7d68cf470cdc7f6f231c1476ca8605a92d74532d25c4e879fd02698d94462fd092848383375f6020868301015251902092835f52600360205273ffffffffffffffffffffffffffffffffffffffff60405f20951694857fffffffffffffffffffffffff0000000000000000000000000000000000000000825416179055611a0f604051928392602084526020840191611e95565b0390a3005b7fe2517d3f000000000000000000000000000000000000000000000000000000005f52336004527ffee50fa0fe41a985a4fb439159472d2e1052f1a39d61515e5e1052c61c5fbdf160245260445ffd5b346101cf5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf5760043567ffffffffffffffff81116101cf5760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc82360301126101cf5760243567ffffffffffffffff81116101cf5761066191611af8611b01923690600401611d23565b916004016121ca565b604051918291602083526020830190611d51565b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf57611b4b6120fc565b6002548060d01c80611b76575b6002805473ffffffffffffffffffffffffffffffffffffffff169055005b421115611bcf5779ffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffff00000000000000000000000000000000000000000000000000006001549260301b169116176001555b8080611b58565b507f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec55f80a1611bc8565b346101cf575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf576020604051620697808152f35b346101cf5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101cf57600435907fffffffff0000000000000000000000000000000000000000000000000000000082168092036101cf57817f314987860000000000000000000000000000000000000000000000000000000060209314908115611cc6575b5015158152f35b7f7965db0b00000000000000000000000000000000000000000000000000000000811491508115611cf9575b5083611cbf565b7f01ffc9a70000000000000000000000000000000000000000000000000000000091501483611cf2565b9181601f840112156101cf5782359167ffffffffffffffff83116101cf57602083818601950101116101cf57565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602080948051918291828752018686015e5f8582860101520116010190565b6024359073ffffffffffffffffffffffffffffffffffffffff821682036101cf57565b359073ffffffffffffffffffffffffffffffffffffffff821682036101cf57565b359067ffffffffffffffff821682036101cf57565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff821117611e2e57604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b67ffffffffffffffff8111611e2e57601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe093818652868601375f8582860101520116010190565b9190820391821161099c57565b60643573ffffffffffffffffffffffffffffffffffffffff811681036101cf5790565b60443573ffffffffffffffffffffffffffffffffffffffff811681036101cf5790565b90357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1823603018112156101cf57016020813591019167ffffffffffffffff82116101cf5781360383136101cf57565b611fd99181358152611fcb611fc0611fa5611f946020860186611f26565b608060208701526080860191611e95565b611fb26040860186611f26565b908583036040870152611e95565b926060810190611f26565b916060818503910152611e95565b90565b908135815267ffffffffffffffff611ff660208401611dd8565b16602082015273ffffffffffffffffffffffffffffffffffffffff61201d60408401611db7565b1660408201526060820135917fffffffff0000000000000000000000000000000000000000000000000000000083168093036101cf5761206c60a091611fd99460608501526080810190611f26565b9190928160808201520191611e95565b67ffffffffffffffff6120bd604080938035865273ffffffffffffffffffffffffffffffffffffffff6120b160208301611db7565b16602087015201611dd8565b16910152565b6002548060d01c80151590816120f2575b50156120e85760a01c65ffffffffffff1690565b5060015460d01c90565b905042115f6120d4565b335f9081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff161561213457565b7fe2517d3f000000000000000000000000000000000000000000000000000000005f52336004525f60245260445ffd5b805f525f60205260405f2073ffffffffffffffffffffffffffffffffffffffff33165f5260205260ff60405f2054161561219b5750565b7fe2517d3f000000000000000000000000000000000000000000000000000000005f523360045260245260445ffd5b9091813591825f52600360205273ffffffffffffffffffffffffffffffffffffffff60405f205416928315612314575b509161225773ffffffffffffffffffffffffffffffffffffffff5f94612287604051978896879586947fdd71257c000000000000000000000000000000000000000000000000000000008652604060048701526044860190611f76565b917ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc858403016024860152611e95565b0392165afa908115611833575f9161229d575090565b90503d805f833e6122ae8183611ded565b8101906020818303126101cf5780519067ffffffffffffffff82116101cf570181601f820112156101cf578051906122e582611e5b565b926122f36040519485611ded565b828452602083830101116101cf57815f9260208093018386015e8301015290565b73ffffffffffffffffffffffffffffffffffffffff81169350830361233b576122576121fa565b7fba50ad0a000000000000000000000000000000000000000000000000000000005f5260045ffd5b6123fe906123d26123a29360405194859367ffffffffffffffff6020860198468a5230604088015216606086015260a0608086015260c0850190611f76565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08483030160a0850152611fdc565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101835282611ded565b51902090565b604051602081019061241782604461207c565b606081526123fe608082611ded565b6124889273ffffffffffffffffffffffffffffffffffffffff604051937fa9059cbb000000000000000000000000000000000000000000000000000000006020860152166024840152604483015260448252612483606483611ded565b6124a8565b565b9065ffffffffffff8091169116019065ffffffffffff821161099c57565b905f602091828151910182855af115611833575f513d612526575073ffffffffffffffffffffffffffffffffffffffff81163b155b6124e45750565b73ffffffffffffffffffffffffffffffffffffffff907f5274afe7000000000000000000000000000000000000000000000000000000005f521660045260245ffd5b600114156124dd565b6002549073ffffffffffffffffffffffffffffffffffffffff82166102d257611fd9917fffffffffffffffffffffffff000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff83169116176002555f612735565b9081156125a7575b611fd991612735565b6002549173ffffffffffffffffffffffffffffffffffffffff83166102d2577fffffffffffffffffffffffff000000000000000000000000000000000000000090921673ffffffffffffffffffffffffffffffffffffffff82161760025561259e565b611fd99073ffffffffffffffffffffffffffffffffffffffff6002541673ffffffffffffffffffffffffffffffffffffffff82161461264a575b5f612807565b7fffffffffffffffffffffffff000000000000000000000000000000000000000060025416600255612644565b90611fd9918015806126b6575b15612807577fffffffffffffffffffffffff000000000000000000000000000000000000000060025416600255612807565b5073ffffffffffffffffffffffffffffffffffffffff6002541673ffffffffffffffffffffffffffffffffffffffff831614612684565b65ffffffffffff81116127055765ffffffffffff1690565b7f6dfcc650000000000000000000000000000000000000000000000000000000005f52603060045260245260445ffd5b805f525f60205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260ff60405f205416155f1461280157805f525f60205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260405f2060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0082541617905573ffffffffffffffffffffffffffffffffffffffff339216907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d5f80a4600190565b50505f90565b805f525f60205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260ff60405f2054165f1461280157805f525f60205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260405f207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00815416905573ffffffffffffffffffffffffffffffffffffffff339216907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b5f80a460019056fea26469706673582212205eb4c224df9b87b0bbeea4524c70aa956c406bbbe21954b129e46b10f34a6f1064736f6c634300081e0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000a2c22252cdc8b7cddee1b0b2e242818509fcf7b8000000000000000000000000acf075862425a0c839844369ac20e334b3710e4700000000000000000000000000f8b1cc17ea5fb9983d069ed2b71ea9d07d700f
-----Decoded View---------------
Arg [0] : paymentToken (address): 0xA2c22252cDc8b7cDdEe1B0b2E242818509fCf7b8
Arg [1] : executor (address): 0xaCf075862425A0c839844369ac20e334B3710e47
Arg [2] : initialAdmin (address): 0x00f8B1Cc17EA5fb9983d069ED2B71Ea9D07D700F
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000a2c22252cdc8b7cddee1b0b2e242818509fcf7b8
Arg [1] : 000000000000000000000000acf075862425a0c839844369ac20e334b3710e47
Arg [2] : 00000000000000000000000000f8b1cc17ea5fb9983d069ed2b71ea9d07d700f
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$94.76
Net Worth in ETH
0.046694
Token Allocations
SXT
100.00%
Multichain Portfolio | 33 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|---|---|---|---|---|
| ETH | 100.00% | $0.020511 | 4,620 | $94.76 |
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ 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.