Source Code
Latest 7 from a total of 7 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Set Send Fees | 27973355 | 81 days ago | IN | 0 FRAX | 0.00004317 | ||||
| Set Send Fees | 27877638 | 83 days ago | IN | 0 FRAX | 0.00010201 | ||||
| Set Send Fees | 27779646 | 86 days ago | IN | 0 FRAX | 0.00037552 | ||||
| Set Send Fees | 27779611 | 86 days ago | IN | 0 FRAX | 0.0003869 | ||||
| Set Send Fees | 27779574 | 86 days ago | IN | 0 FRAX | 0.00068356 | ||||
| Set Send Fees | 27779574 | 86 days ago | IN | 0 FRAX | 0.00040618 | ||||
| Grant Role | 27443489 | 93 days ago | IN | 0 FRAX | 0.00012777 |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
ReactorFeeManager
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 10000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.28;
import {AccessControlDefaultAdminRules} from "@openzeppelin/contracts/access/extensions/AccessControlDefaultAdminRules.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IReactorFeeManager} from "./interfaces/IReactorFeeManager.sol";
contract ReactorFeeManager is IReactorFeeManager, AccessControlDefaultAdminRules
{
using SafeERC20 for IERC20;
bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
bytes32 public constant FEE_MANAGER_ROLE = keccak256("FEE_MANAGER_ROLE");
uint256 public maxPayloadSize;
mapping(string _action => mapping(address _paymentToken => uint256 _fee)) public actionFeeDiscounts;
mapping(string _destinationName => mapping(string _action => mapping(address _paymentToken => uint256 _fee))) public actionFees;
mapping(address _caller => mapping(address _paymentToken => uint256 _fee)) public callerFeeDiscounts;
mapping(string _destinationName => mapping(address _caller => mapping(address _paymentToken => uint256 _fee))) public callerFees;
mapping(string _destinationName => mapping(address _paymentToken => uint256 _fee)) public destinationFeeDiscounts;
mapping(address _paymentToken => uint256 _fee) public feeDiscounts;
mapping(string _destinationName => mapping(address _paymentToken => uint256 _fee)) public feesPerByte;
mapping(address _paymentToken => bool _enabled) public paymentTokens;
mapping(string _destinationName => mapping(address _paymentToken => uint256 _fee)) public sendFees;
event ActionFeeSet(string indexed destinationName, string indexed action, address indexed token, uint256 fee);
event CallerFeeSet(string indexed destinationName, address indexed caller, address indexed token, uint256 fee);
event FeePerByteSet(string indexed destinationName, address indexed token, uint256 fee);
event MaxPayloadSizeSet(uint256 newSize);
event PaymentTokenDisabled(address token);
event PaymentTokenEnabled(address token);
event SendFeeSet(string indexed destinationName, address indexed token, uint256 fee);
event SetActionFeeDiscount(string indexed action, address indexed token, uint256 discount);
event SetCallerFeeDiscount(address indexed caller, address indexed token, uint256 discount);
event SetDestinationFeeDiscount(string indexed destinationName, address indexed token, uint256 discount);
event SetFeeDiscount(address indexed token, uint256 discount);
error InvalidAction();
error InvalidBeneficiary();
error InvalidCaller();
error InvalidCharacterToLowercase();
error InvalidDestination();
error InvalidMaxPayloadSize();
error InvalidWithdrawToken();
error MaxPayloadSizeExceeded();
error MismatchedLengthsForParameters(string message);
error PaymentTokenNotEnabled(address token);
error TokenAlreadyEnabled(address token);
error TokenNotEnabled(address token);
error WithdrawFailedNative();
constructor(address _reactor, address _wrappedNative) AccessControlDefaultAdminRules(3 days, msg.sender)
{
maxPayloadSize = 500;
paymentTokens[address(0)] = true;
paymentTokens[_reactor] = true;
paymentTokens[_wrappedNative] = true;
_grantRole(ADMIN_ROLE, msg.sender);
_grantRole(FEE_MANAGER_ROLE, msg.sender);
}
function _toLowercase(string memory s) internal pure returns (string memory) {
bytes memory b = bytes(s);
for(uint i; i < b.length; i++) {
uint8 c = uint8(b[i]);
if(c >= 65 && c <= 90) b[i] = bytes1(c + 32);
if(c > 0x7F) revert InvalidCharacterToLowercase();
}
return string(b);
}
function _isEmpty(string memory s) internal pure returns (bool) {
return bytes(s).length == 0;
}
function withdrawNative(address _beneficiary) public onlyRole(ADMIN_ROLE)
{
if(_beneficiary == address(0)) revert InvalidBeneficiary();
uint256 amount = address(this).balance;
(bool sent, ) = _beneficiary.call{value: amount}("");
if(!sent) revert WithdrawFailedNative();
}
function withdrawToken(address _beneficiary, address _token) public onlyRole(ADMIN_ROLE)
{
if(_beneficiary == address(0)) revert InvalidBeneficiary();
if(_token == address(0)) revert InvalidWithdrawToken();
uint256 amount = IERC20(_token).balanceOf(address(this));
IERC20(_token).safeTransfer(_beneficiary, amount);
}
function setMaxPayloadSize(uint256 _maxPayloadSize) external onlyRole(ADMIN_ROLE)
{
if(_maxPayloadSize == 0) revert InvalidMaxPayloadSize();
maxPayloadSize = _maxPayloadSize;
emit MaxPayloadSizeSet(_maxPayloadSize);
}
function enablePaymentToken(address _paymentToken) external onlyRole(FEE_MANAGER_ROLE)
{
if(paymentTokens[_paymentToken]) revert TokenAlreadyEnabled(_paymentToken);
paymentTokens[_paymentToken] = true;
emit PaymentTokenEnabled(_paymentToken);
}
function disablePaymentToken(address _paymentToken) external onlyRole(FEE_MANAGER_ROLE)
{
if(!paymentTokens[_paymentToken]) revert TokenNotEnabled(_paymentToken);
delete paymentTokens[_paymentToken];
emit PaymentTokenDisabled(_paymentToken);
}
function setCallerFees(string[] calldata _destinationNames, address[] calldata _callers, address[] calldata _paymentTokens, uint256[] calldata _fees) external onlyRole(FEE_MANAGER_ROLE)
{
if(_destinationNames.length != _callers.length) revert MismatchedLengthsForParameters("Destinations and Callers");
if(_destinationNames.length != _paymentTokens.length) revert MismatchedLengthsForParameters("Destinations and Payment Tokens");
if(_destinationNames.length != _fees.length) revert MismatchedLengthsForParameters("Destinations and Fees");
for (uint i = 0; i < _paymentTokens.length; i++) {
if(_isEmpty(_destinationNames[i])) revert InvalidDestination();
if(_callers[i] == address(0)) revert InvalidCaller();
if(!paymentTokens[_paymentTokens[i]]) revert PaymentTokenNotEnabled(_paymentTokens[i]);
string memory destinationName = _toLowercase(_destinationNames[i]);
callerFees[destinationName][_callers[i]][_paymentTokens[i]] = _fees[i];
emit CallerFeeSet(destinationName, _callers[i], _paymentTokens[i], _fees[i]);
}
}
function setActionFees(string[] calldata _destinationNames, string[] calldata _actions, address[] calldata _paymentTokens, uint256[] calldata _fees) external onlyRole(FEE_MANAGER_ROLE)
{
if(_destinationNames.length != _actions.length) revert MismatchedLengthsForParameters("Destinations and Actions");
if(_destinationNames.length != _paymentTokens.length) revert MismatchedLengthsForParameters("Destinations and Payment Tokens");
if(_destinationNames.length != _fees.length) revert MismatchedLengthsForParameters("Destinations and Fees");
for (uint i = 0; i < _paymentTokens.length; i++) {
if(_isEmpty(_destinationNames[i])) revert InvalidDestination();
if(_isEmpty(_actions[i])) revert InvalidAction();
if(!paymentTokens[_paymentTokens[i]]) revert PaymentTokenNotEnabled(_paymentTokens[i]);
string memory destinationName = _toLowercase(_destinationNames[i]);
string memory action = _toLowercase(_actions[i]);
actionFees[destinationName][action][_paymentTokens[i]] = _fees[i];
emit ActionFeeSet(destinationName, action, _paymentTokens[i], _fees[i]);
}
}
function setFeesPerByte(string[] calldata _destinationNames, address[] calldata _paymentTokens, uint256[] calldata _fees) external onlyRole(FEE_MANAGER_ROLE)
{
if(_destinationNames.length != _paymentTokens.length) revert MismatchedLengthsForParameters("Destinations and Payment Tokens");
if(_destinationNames.length != _fees.length) revert MismatchedLengthsForParameters("Destinations and Fees");
for(uint i = 0; i < _paymentTokens.length; i++) {
if(_isEmpty(_destinationNames[i])) revert InvalidDestination();
if(!paymentTokens[_paymentTokens[i]]) revert PaymentTokenNotEnabled(_paymentTokens[i]);
string memory destinationName = _toLowercase(_destinationNames[i]);
feesPerByte[destinationName][_paymentTokens[i]] = _fees[i];
emit FeePerByteSet(destinationName, _paymentTokens[i], _fees[i]);
}
}
function setSendFees(string[] calldata _destinationNames, address[] calldata _paymentTokens, uint256[] calldata _fees) external onlyRole(FEE_MANAGER_ROLE)
{
if(_destinationNames.length != _paymentTokens.length) revert MismatchedLengthsForParameters("Destinations and Payment Tokens");
if(_destinationNames.length != _fees.length) revert MismatchedLengthsForParameters("Destinations and Fees");
for (uint i = 0; i < _paymentTokens.length; i++) {
if(_isEmpty(_destinationNames[i])) revert InvalidDestination();
if(!paymentTokens[_paymentTokens[i]]) revert PaymentTokenNotEnabled(_paymentTokens[i]);
string memory destinationName = _toLowercase(_destinationNames[i]);
sendFees[destinationName][_paymentTokens[i]] = _fees[i];
emit SendFeeSet(destinationName, _paymentTokens[i], _fees[i]);
}
}
function setFeeDiscounts(address[] calldata _paymentTokens, uint256[] calldata _discounts) external onlyRole(FEE_MANAGER_ROLE)
{
if(_paymentTokens.length != _discounts.length) revert MismatchedLengthsForParameters("Payment Tokens and Discounts");
for(uint i = 0; i < _paymentTokens.length; i++) {
if(!paymentTokens[_paymentTokens[i]]) revert PaymentTokenNotEnabled(_paymentTokens[i]);
feeDiscounts[_paymentTokens[i]] = _discounts[i];
emit SetFeeDiscount(_paymentTokens[i], _discounts[i]);
}
}
function setDestinationFeeDiscounts(string[] calldata _destinationNames, address[] calldata _paymentTokens, uint256[] calldata _discounts) external onlyRole(FEE_MANAGER_ROLE)
{
if(_destinationNames.length != _paymentTokens.length) revert MismatchedLengthsForParameters("Destinations and Payment Tokens");
if(_destinationNames.length != _discounts.length) revert MismatchedLengthsForParameters("Destinations and Discounts");
for(uint i = 0; i < _destinationNames.length; i++) {
if(_isEmpty(_destinationNames[i])) revert InvalidDestination();
if(!paymentTokens[_paymentTokens[i]]) revert PaymentTokenNotEnabled(_paymentTokens[i]);
string memory destinationName = _toLowercase(_destinationNames[i]);
destinationFeeDiscounts[destinationName][_paymentTokens[i]] = _discounts[i];
emit SetDestinationFeeDiscount(destinationName, _paymentTokens[i], _discounts[i]);
}
}
function setCallerFeeDiscounts(address[] calldata _callers, address[] calldata _paymentTokens, uint256[] calldata _discounts) external onlyRole(FEE_MANAGER_ROLE)
{
if(_callers.length != _paymentTokens.length) revert MismatchedLengthsForParameters("Callers and Payment Tokens");
if(_callers.length != _discounts.length) revert MismatchedLengthsForParameters("Callers and Discounts");
for(uint i = 0; i < _paymentTokens.length; i++) {
if(_callers[i] == address(0)) revert InvalidCaller();
if(!paymentTokens[_paymentTokens[i]]) revert PaymentTokenNotEnabled(_paymentTokens[i]);
callerFeeDiscounts[_callers[i]][_paymentTokens[i]] = _discounts[i];
emit SetCallerFeeDiscount(_callers[i], _paymentTokens[i], _discounts[i]);
}
}
function setActionFeeDiscounts(string[] calldata _actions, address[] calldata _paymentTokens, uint256[] calldata _discounts) external onlyRole(FEE_MANAGER_ROLE)
{
if(_actions.length != _paymentTokens.length) revert MismatchedLengthsForParameters("Actions and Payment Tokens");
if(_actions.length != _discounts.length) revert MismatchedLengthsForParameters("Actions and Discounts");
for(uint i = 0; i < _actions.length; i++) {
if(_isEmpty(_actions[i])) revert InvalidAction();
if(!paymentTokens[_paymentTokens[i]]) revert PaymentTokenNotEnabled(_paymentTokens[i]);
string memory action = _toLowercase(_actions[i]);
actionFeeDiscounts[action][_paymentTokens[i]] = _discounts[i];
emit SetActionFeeDiscount(action, _paymentTokens[i], _discounts[i]);
}
}
function getSendFee(string calldata _destinationName, string calldata _action, address _caller, address _paymentToken, uint256 _payloadSize) public view returns(uint256)
{
if(_isEmpty(_destinationName)) revert InvalidDestination();
if(_isEmpty(_action)) revert InvalidAction();
if(_caller == address(0)) revert InvalidCaller();
if(!paymentTokens[_paymentToken]) revert PaymentTokenNotEnabled(_paymentToken);
if(_payloadSize > maxPayloadSize) revert MaxPayloadSizeExceeded();
string memory destinationName = _toLowercase(_destinationName);
string memory action = _toLowercase(_action);
uint256 sendFee = sendFees[destinationName][_paymentToken];
uint256 feePerByte = feesPerByte[destinationName][_paymentToken] * _payloadSize;
uint256 callerFee = callerFees[destinationName][_caller][_paymentToken];
uint256 actionFee = actionFees[destinationName][action][_paymentToken];
uint256 feeDiscountAmount = feeDiscounts[_paymentToken];
feeDiscountAmount += callerFeeDiscounts[_caller][_paymentToken];
feeDiscountAmount += destinationFeeDiscounts[destinationName][_paymentToken];
feeDiscountAmount += actionFeeDiscounts[action][_paymentToken];
uint256 totalFee = sendFee + feePerByte + callerFee + actionFee;
if(totalFee <= feeDiscountAmount) {
return 0;
}
return totalFee - feeDiscountAmount;
}
receive() external payable {}
fallback() external payable {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
mapping(bytes32 role => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
return _roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
if (!hasRole(role, account)) {
_roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
if (hasRole(role, account)) {
_roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlDefaultAdminRules.sol)
pragma solidity ^0.8.20;
import {IAccessControlDefaultAdminRules} from "./IAccessControlDefaultAdminRules.sol";
import {AccessControl, IAccessControl} from "../AccessControl.sol";
import {SafeCast} from "../../utils/math/SafeCast.sol";
import {Math} from "../../utils/math/Math.sol";
import {IERC5313} from "../../interfaces/IERC5313.sol";
/**
* @dev Extension of {AccessControl} that allows specifying special rules to manage
* the `DEFAULT_ADMIN_ROLE` holder, which is a sensitive role with special permissions
* over other roles that may potentially have privileged rights in the system.
*
* If a specific role doesn't have an admin role assigned, the holder of the
* `DEFAULT_ADMIN_ROLE` will have the ability to grant it and revoke it.
*
* This contract implements the following risk mitigations on top of {AccessControl}:
*
* * Only one account holds the `DEFAULT_ADMIN_ROLE` since deployment until it's potentially renounced.
* * Enforces a 2-step process to transfer the `DEFAULT_ADMIN_ROLE` to another account.
* * Enforces a configurable delay between the two steps, with the ability to cancel before the transfer is accepted.
* * The delay can be changed by scheduling, see {changeDefaultAdminDelay}.
* * It is not possible to use another role to manage the `DEFAULT_ADMIN_ROLE`.
*
* Example usage:
*
* ```solidity
* contract MyToken is AccessControlDefaultAdminRules {
* constructor() AccessControlDefaultAdminRules(
* 3 days,
* msg.sender // Explicit initial `DEFAULT_ADMIN_ROLE` holder
* ) {}
* }
* ```
*/
abstract contract AccessControlDefaultAdminRules is IAccessControlDefaultAdminRules, IERC5313, AccessControl {
// pending admin pair read/written together frequently
address private _pendingDefaultAdmin;
uint48 private _pendingDefaultAdminSchedule; // 0 == unset
uint48 private _currentDelay;
address private _currentDefaultAdmin;
// pending delay pair read/written together frequently
uint48 private _pendingDelay;
uint48 private _pendingDelaySchedule; // 0 == unset
/**
* @dev Sets the initial values for {defaultAdminDelay} and {defaultAdmin} address.
*/
constructor(uint48 initialDelay, address initialDefaultAdmin) {
if (initialDefaultAdmin == address(0)) {
revert AccessControlInvalidDefaultAdmin(address(0));
}
_currentDelay = initialDelay;
_grantRole(DEFAULT_ADMIN_ROLE, initialDefaultAdmin);
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlDefaultAdminRules).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC5313-owner}.
*/
function owner() public view virtual returns (address) {
return defaultAdmin();
}
///
/// Override AccessControl role management
///
/**
* @dev See {AccessControl-grantRole}. Reverts for `DEFAULT_ADMIN_ROLE`.
*/
function grantRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
if (role == DEFAULT_ADMIN_ROLE) {
revert AccessControlEnforcedDefaultAdminRules();
}
super.grantRole(role, account);
}
/**
* @dev See {AccessControl-revokeRole}. Reverts for `DEFAULT_ADMIN_ROLE`.
*/
function revokeRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
if (role == DEFAULT_ADMIN_ROLE) {
revert AccessControlEnforcedDefaultAdminRules();
}
super.revokeRole(role, account);
}
/**
* @dev See {AccessControl-renounceRole}.
*
* For the `DEFAULT_ADMIN_ROLE`, it only allows renouncing in two steps by first calling
* {beginDefaultAdminTransfer} to the `address(0)`, so it's required that the {pendingDefaultAdmin} schedule
* has also passed when calling this function.
*
* After its execution, it will not be possible to call `onlyRole(DEFAULT_ADMIN_ROLE)` functions.
*
* NOTE: Renouncing `DEFAULT_ADMIN_ROLE` will leave the contract without a {defaultAdmin},
* thereby disabling any functionality that is only available for it, and the possibility of reassigning a
* non-administrated role.
*/
function renounceRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
if (role == DEFAULT_ADMIN_ROLE && account == defaultAdmin()) {
(address newDefaultAdmin, uint48 schedule) = pendingDefaultAdmin();
if (newDefaultAdmin != address(0) || !_isScheduleSet(schedule) || !_hasSchedulePassed(schedule)) {
revert AccessControlEnforcedDefaultAdminDelay(schedule);
}
delete _pendingDefaultAdminSchedule;
}
super.renounceRole(role, account);
}
/**
* @dev See {AccessControl-_grantRole}.
*
* For `DEFAULT_ADMIN_ROLE`, it only allows granting if there isn't already a {defaultAdmin} or if the
* role has been previously renounced.
*
* NOTE: Exposing this function through another mechanism may make the `DEFAULT_ADMIN_ROLE`
* assignable again. Make sure to guarantee this is the expected behavior in your implementation.
*/
function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {
if (role == DEFAULT_ADMIN_ROLE) {
if (defaultAdmin() != address(0)) {
revert AccessControlEnforcedDefaultAdminRules();
}
_currentDefaultAdmin = account;
}
return super._grantRole(role, account);
}
/**
* @dev See {AccessControl-_revokeRole}.
*/
function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {
if (role == DEFAULT_ADMIN_ROLE && account == defaultAdmin()) {
delete _currentDefaultAdmin;
}
return super._revokeRole(role, account);
}
/**
* @dev See {AccessControl-_setRoleAdmin}. Reverts for `DEFAULT_ADMIN_ROLE`.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual override {
if (role == DEFAULT_ADMIN_ROLE) {
revert AccessControlEnforcedDefaultAdminRules();
}
super._setRoleAdmin(role, adminRole);
}
///
/// AccessControlDefaultAdminRules accessors
///
/**
* @inheritdoc IAccessControlDefaultAdminRules
*/
function defaultAdmin() public view virtual returns (address) {
return _currentDefaultAdmin;
}
/**
* @inheritdoc IAccessControlDefaultAdminRules
*/
function pendingDefaultAdmin() public view virtual returns (address newAdmin, uint48 schedule) {
return (_pendingDefaultAdmin, _pendingDefaultAdminSchedule);
}
/**
* @inheritdoc IAccessControlDefaultAdminRules
*/
function defaultAdminDelay() public view virtual returns (uint48) {
uint48 schedule = _pendingDelaySchedule;
return (_isScheduleSet(schedule) && _hasSchedulePassed(schedule)) ? _pendingDelay : _currentDelay;
}
/**
* @inheritdoc IAccessControlDefaultAdminRules
*/
function pendingDefaultAdminDelay() public view virtual returns (uint48 newDelay, uint48 schedule) {
schedule = _pendingDelaySchedule;
return (_isScheduleSet(schedule) && !_hasSchedulePassed(schedule)) ? (_pendingDelay, schedule) : (0, 0);
}
/**
* @inheritdoc IAccessControlDefaultAdminRules
*/
function defaultAdminDelayIncreaseWait() public view virtual returns (uint48) {
return 5 days;
}
///
/// AccessControlDefaultAdminRules public and internal setters for defaultAdmin/pendingDefaultAdmin
///
/**
* @inheritdoc IAccessControlDefaultAdminRules
*/
function beginDefaultAdminTransfer(address newAdmin) public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
_beginDefaultAdminTransfer(newAdmin);
}
/**
* @dev See {beginDefaultAdminTransfer}.
*
* Internal function without access restriction.
*/
function _beginDefaultAdminTransfer(address newAdmin) internal virtual {
uint48 newSchedule = SafeCast.toUint48(block.timestamp) + defaultAdminDelay();
_setPendingDefaultAdmin(newAdmin, newSchedule);
emit DefaultAdminTransferScheduled(newAdmin, newSchedule);
}
/**
* @inheritdoc IAccessControlDefaultAdminRules
*/
function cancelDefaultAdminTransfer() public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
_cancelDefaultAdminTransfer();
}
/**
* @dev See {cancelDefaultAdminTransfer}.
*
* Internal function without access restriction.
*/
function _cancelDefaultAdminTransfer() internal virtual {
_setPendingDefaultAdmin(address(0), 0);
}
/**
* @inheritdoc IAccessControlDefaultAdminRules
*/
function acceptDefaultAdminTransfer() public virtual {
(address newDefaultAdmin, ) = pendingDefaultAdmin();
if (_msgSender() != newDefaultAdmin) {
// Enforce newDefaultAdmin explicit acceptance.
revert AccessControlInvalidDefaultAdmin(_msgSender());
}
_acceptDefaultAdminTransfer();
}
/**
* @dev See {acceptDefaultAdminTransfer}.
*
* Internal function without access restriction.
*/
function _acceptDefaultAdminTransfer() internal virtual {
(address newAdmin, uint48 schedule) = pendingDefaultAdmin();
if (!_isScheduleSet(schedule) || !_hasSchedulePassed(schedule)) {
revert AccessControlEnforcedDefaultAdminDelay(schedule);
}
_revokeRole(DEFAULT_ADMIN_ROLE, defaultAdmin());
_grantRole(DEFAULT_ADMIN_ROLE, newAdmin);
delete _pendingDefaultAdmin;
delete _pendingDefaultAdminSchedule;
}
///
/// AccessControlDefaultAdminRules public and internal setters for defaultAdminDelay/pendingDefaultAdminDelay
///
/**
* @inheritdoc IAccessControlDefaultAdminRules
*/
function changeDefaultAdminDelay(uint48 newDelay) public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
_changeDefaultAdminDelay(newDelay);
}
/**
* @dev See {changeDefaultAdminDelay}.
*
* Internal function without access restriction.
*/
function _changeDefaultAdminDelay(uint48 newDelay) internal virtual {
uint48 newSchedule = SafeCast.toUint48(block.timestamp) + _delayChangeWait(newDelay);
_setPendingDelay(newDelay, newSchedule);
emit DefaultAdminDelayChangeScheduled(newDelay, newSchedule);
}
/**
* @inheritdoc IAccessControlDefaultAdminRules
*/
function rollbackDefaultAdminDelay() public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
_rollbackDefaultAdminDelay();
}
/**
* @dev See {rollbackDefaultAdminDelay}.
*
* Internal function without access restriction.
*/
function _rollbackDefaultAdminDelay() internal virtual {
_setPendingDelay(0, 0);
}
/**
* @dev Returns the amount of seconds to wait after the `newDelay` will
* become the new {defaultAdminDelay}.
*
* The value returned guarantees that if the delay is reduced, it will go into effect
* after a wait that honors the previously set delay.
*
* See {defaultAdminDelayIncreaseWait}.
*/
function _delayChangeWait(uint48 newDelay) internal view virtual returns (uint48) {
uint48 currentDelay = defaultAdminDelay();
// When increasing the delay, we schedule the delay change to occur after a period of "new delay" has passed, up
// to a maximum given by defaultAdminDelayIncreaseWait, by default 5 days. For example, if increasing from 1 day
// to 3 days, the new delay will come into effect after 3 days. If increasing from 1 day to 10 days, the new
// delay will come into effect after 5 days. The 5 day wait period is intended to be able to fix an error like
// using milliseconds instead of seconds.
//
// When decreasing the delay, we wait the difference between "current delay" and "new delay". This guarantees
// that an admin transfer cannot be made faster than "current delay" at the time the delay change is scheduled.
// For example, if decreasing from 10 days to 3 days, the new delay will come into effect after 7 days.
return
newDelay > currentDelay
? uint48(Math.min(newDelay, defaultAdminDelayIncreaseWait())) // no need to safecast, both inputs are uint48
: currentDelay - newDelay;
}
///
/// Private setters
///
/**
* @dev Setter of the tuple for pending admin and its schedule.
*
* May emit a DefaultAdminTransferCanceled event.
*/
function _setPendingDefaultAdmin(address newAdmin, uint48 newSchedule) private {
(, uint48 oldSchedule) = pendingDefaultAdmin();
_pendingDefaultAdmin = newAdmin;
_pendingDefaultAdminSchedule = newSchedule;
// An `oldSchedule` from `pendingDefaultAdmin()` is only set if it hasn't been accepted.
if (_isScheduleSet(oldSchedule)) {
// Emit for implicit cancellations when another default admin was scheduled.
emit DefaultAdminTransferCanceled();
}
}
/**
* @dev Setter of the tuple for pending delay and its schedule.
*
* May emit a DefaultAdminDelayChangeCanceled event.
*/
function _setPendingDelay(uint48 newDelay, uint48 newSchedule) private {
uint48 oldSchedule = _pendingDelaySchedule;
if (_isScheduleSet(oldSchedule)) {
if (_hasSchedulePassed(oldSchedule)) {
// Materialize a virtual delay
_currentDelay = _pendingDelay;
} else {
// Emit for implicit cancellations when another delay was scheduled.
emit DefaultAdminDelayChangeCanceled();
}
}
_pendingDelay = newDelay;
_pendingDelaySchedule = newSchedule;
}
///
/// Private helpers
///
/**
* @dev Defines if an `schedule` is considered set. For consistency purposes.
*/
function _isScheduleSet(uint48 schedule) private pure returns (bool) {
return schedule != 0;
}
/**
* @dev Defines if an `schedule` is considered passed. For consistency purposes.
*/
function _hasSchedulePassed(uint48 schedule) private view returns (bool) {
return schedule < block.timestamp;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.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.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.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
// 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
// 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/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) (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
// 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/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);
}// 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.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/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: BUSL-1.1
pragma solidity 0.8.28;
interface IReactorFeeManager {
function actionFeeDiscounts(string calldata _action, address _paymentToken) external view returns (uint256);
function actionFees(string calldata _destinationName, string calldata _action, address _paymentToken) external view returns (uint256);
function callerFeeDiscounts(address _caller, address _paymentToken) external view returns (uint256);
function callerFees(string calldata _destinationName, address _caller, address _paymentToken) external view returns (uint256);
function destinationFeeDiscounts(string calldata _destinationName, address _paymentToken) external view returns (uint256);
function disablePaymentToken(address _paymentToken) external;
function enablePaymentToken(address _paymentToken) external;
function feeDiscounts(address _paymentToken) external view returns (uint256);
function feesPerByte(string calldata _destinationName, address _paymentToken) external view returns (uint256);
function getSendFee(string calldata _destinationName, string calldata _action, address _caller, address _paymentToken, uint256 _payloadSize) external view returns(uint256);
function maxPayloadSize() external view returns (uint256);
function paymentTokens(address _paymentToken) external view returns (bool);
function sendFees(string calldata _destinationName, address _paymentToken) external view returns (uint256);
function setActionFeeDiscounts(string[] calldata _actions, address[] calldata _paymentTokens, uint256[] calldata _discounts) external;
function setActionFees(string[] calldata _destinationNames, string[] calldata _actions, address[] calldata _paymentTokens, uint256[] calldata _fees) external;
function setCallerFeeDiscounts(address[] calldata _callers, address[] calldata _paymentTokens, uint256[] calldata _discounts) external;
function setCallerFees(string[] calldata _destinationNames, address[] calldata _callers, address[] calldata _paymentTokens, uint256[] calldata _fees) external;
function setDestinationFeeDiscounts(string[] calldata _destinationNames, address[] calldata _paymentTokens, uint256[] calldata _discounts) external;
function setFeeDiscounts(address[] calldata _paymentTokens, uint256[] calldata _discounts) external;
function setFeesPerByte(string[] calldata _destinationNames, address[] calldata _paymentTokens, uint256[] calldata _fees) external;
function setMaxPayloadSize(uint256 _maxPayloadSize) external;
function setSendFees(string[] calldata _destinationNames, address[] calldata _paymentTokens, uint256[] calldata _fees) external;
}{
"optimizer": {
"enabled": true,
"runs": 10000
},
"viaIR": true,
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_reactor","type":"address"},{"internalType":"address","name":"_wrappedNative","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":"InvalidAction","type":"error"},{"inputs":[],"name":"InvalidBeneficiary","type":"error"},{"inputs":[],"name":"InvalidCaller","type":"error"},{"inputs":[],"name":"InvalidCharacterToLowercase","type":"error"},{"inputs":[],"name":"InvalidDestination","type":"error"},{"inputs":[],"name":"InvalidMaxPayloadSize","type":"error"},{"inputs":[],"name":"InvalidWithdrawToken","type":"error"},{"inputs":[],"name":"MaxPayloadSizeExceeded","type":"error"},{"inputs":[{"internalType":"string","name":"message","type":"string"}],"name":"MismatchedLengthsForParameters","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"PaymentTokenNotEnabled","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":[{"internalType":"address","name":"token","type":"address"}],"name":"TokenAlreadyEnabled","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"TokenNotEnabled","type":"error"},{"inputs":[],"name":"WithdrawFailedNative","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"destinationName","type":"string"},{"indexed":true,"internalType":"string","name":"action","type":"string"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"ActionFeeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"destinationName","type":"string"},{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"CallerFeeSet","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":"string","name":"destinationName","type":"string"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"FeePerByteSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newSize","type":"uint256"}],"name":"MaxPayloadSizeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"PaymentTokenDisabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"PaymentTokenEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"destinationName","type":"string"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"SendFeeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"action","type":"string"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"discount","type":"uint256"}],"name":"SetActionFeeDiscount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"discount","type":"uint256"}],"name":"SetCallerFeeDiscount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"destinationName","type":"string"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"discount","type":"uint256"}],"name":"SetDestinationFeeDiscount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"discount","type":"uint256"}],"name":"SetFeeDiscount","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEE_MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_action","type":"string"},{"internalType":"address","name":"_paymentToken","type":"address"}],"name":"actionFeeDiscounts","outputs":[{"internalType":"uint256","name":"_fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_destinationName","type":"string"},{"internalType":"string","name":"_action","type":"string"},{"internalType":"address","name":"_paymentToken","type":"address"}],"name":"actionFees","outputs":[{"internalType":"uint256","name":"_fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"beginDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_caller","type":"address"},{"internalType":"address","name":"_paymentToken","type":"address"}],"name":"callerFeeDiscounts","outputs":[{"internalType":"uint256","name":"_fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_destinationName","type":"string"},{"internalType":"address","name":"_caller","type":"address"},{"internalType":"address","name":"_paymentToken","type":"address"}],"name":"callerFees","outputs":[{"internalType":"uint256","name":"_fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancelDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint48","name":"newDelay","type":"uint48"}],"name":"changeDefaultAdminDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"defaultAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultAdminDelay","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultAdminDelayIncreaseWait","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_destinationName","type":"string"},{"internalType":"address","name":"_paymentToken","type":"address"}],"name":"destinationFeeDiscounts","outputs":[{"internalType":"uint256","name":"_fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_paymentToken","type":"address"}],"name":"disablePaymentToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_paymentToken","type":"address"}],"name":"enablePaymentToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_paymentToken","type":"address"}],"name":"feeDiscounts","outputs":[{"internalType":"uint256","name":"_fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_destinationName","type":"string"},{"internalType":"address","name":"_paymentToken","type":"address"}],"name":"feesPerByte","outputs":[{"internalType":"uint256","name":"_fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_destinationName","type":"string"},{"internalType":"string","name":"_action","type":"string"},{"internalType":"address","name":"_caller","type":"address"},{"internalType":"address","name":"_paymentToken","type":"address"},{"internalType":"uint256","name":"_payloadSize","type":"uint256"}],"name":"getSendFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxPayloadSize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_paymentToken","type":"address"}],"name":"paymentTokens","outputs":[{"internalType":"bool","name":"_enabled","type":"bool"}],"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":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rollbackDefaultAdminDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_destinationName","type":"string"},{"internalType":"address","name":"_paymentToken","type":"address"}],"name":"sendFees","outputs":[{"internalType":"uint256","name":"_fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string[]","name":"_actions","type":"string[]"},{"internalType":"address[]","name":"_paymentTokens","type":"address[]"},{"internalType":"uint256[]","name":"_discounts","type":"uint256[]"}],"name":"setActionFeeDiscounts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string[]","name":"_destinationNames","type":"string[]"},{"internalType":"string[]","name":"_actions","type":"string[]"},{"internalType":"address[]","name":"_paymentTokens","type":"address[]"},{"internalType":"uint256[]","name":"_fees","type":"uint256[]"}],"name":"setActionFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_callers","type":"address[]"},{"internalType":"address[]","name":"_paymentTokens","type":"address[]"},{"internalType":"uint256[]","name":"_discounts","type":"uint256[]"}],"name":"setCallerFeeDiscounts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string[]","name":"_destinationNames","type":"string[]"},{"internalType":"address[]","name":"_callers","type":"address[]"},{"internalType":"address[]","name":"_paymentTokens","type":"address[]"},{"internalType":"uint256[]","name":"_fees","type":"uint256[]"}],"name":"setCallerFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string[]","name":"_destinationNames","type":"string[]"},{"internalType":"address[]","name":"_paymentTokens","type":"address[]"},{"internalType":"uint256[]","name":"_discounts","type":"uint256[]"}],"name":"setDestinationFeeDiscounts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_paymentTokens","type":"address[]"},{"internalType":"uint256[]","name":"_discounts","type":"uint256[]"}],"name":"setFeeDiscounts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string[]","name":"_destinationNames","type":"string[]"},{"internalType":"address[]","name":"_paymentTokens","type":"address[]"},{"internalType":"uint256[]","name":"_fees","type":"uint256[]"}],"name":"setFeesPerByte","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxPayloadSize","type":"uint256"}],"name":"setMaxPayloadSize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string[]","name":"_destinationNames","type":"string[]"},{"internalType":"address[]","name":"_paymentTokens","type":"address[]"},{"internalType":"uint256[]","name":"_fees","type":"uint256[]"}],"name":"setSendFees","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":[{"internalType":"address","name":"_beneficiary","type":"address"}],"name":"withdrawNative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_beneficiary","type":"address"},{"internalType":"address","name":"_token","type":"address"}],"name":"withdrawToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
60803461011c57601f6132a938819003918201601f19168301916001600160401b0383118484101761012157808492604094855283398101031261011c57610052602061004b83610137565b9201610137565b90331561010657600180546001600160d01b03166107e960d71b1790556100783361014b565b506101f4600355600b6020527fdf7de25b7f1fd6d0b5205f0e18f1f35bd7b8d84cce336588d184533ce43a6f768054600160ff1991821681179092556001600160a01b039283166000908152604080822080548416851790559490931683529290912080549092161790556100ec33610196565b506100f6336101c0565b5060405161303790816102728239f35b636116401160e11b600052600060045260246000fd5b600080fd5b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b038216820361011c57565b600254906001600160a01b038216610185576001600160a01b03199091166001600160a01b038216176002556101829060006101e6565b90565b631fe1e13d60e11b60005260046000fd5b610182907fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756101e6565b610182907f6c0757dc3e6b28b2580c03fd9e96c274acf4f99d91fbec9b418fa1d70604ff1c5b6000818152602081815260408083206001600160a01b038616845290915290205460ff1661026a576000818152602081815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b505060009056fe60806040526004361015610010575b005b60003560e01c806301d152ab1461228c57806301ffc9a7146121b8578063022d63fb1461219a578063040a4f421461216057806305db2f41146121255780630aa6220b1461206a5780631463193314611e8457806320adead214611e49578063248a9ca314611e1c5780632bd79f4414611c945780632f2ff15d14611c4e5780632f622e6b14611bb557806336568abe14611a785780633aeac4e1146118b85780634f9ead271461186057806358e3e94c14611842578063634e93da14611723578063649a5ec71461151e57806375b238fc146114e35780637b9f684e146112ae5780637f55b98d1461121e5780637fb486c714610feb57806384ef8ffc14610f3c5780638d51850f14610f635780638da5cb5b14610f3c57806391d1485414610eee5780639c7aa7f814610e20578063a1eda53c14610dbd578063a217fddf14610da1578063bfd84fb414610cd1578063c0f51fad14610a87578063c3b88b4214610a48578063cc8463c814610a1d578063cefc142914610924578063cf6eefb7146108d1578063d27235861461068f578063d547741f1461061a578063d602b9fd1461059f578063db77c81714610503578063dffbaf3e146104c8578063e143b5031461048d578063e79dd62314610444578063f636b3ef1461027b5763fe8e37a30361000e573461027657602060031936011261027657600435610215612b2b565b801561024c576020817f3c3e5e9e455616f9d506743269a7d961c595945b2f1cea6ee4ca96c7ccd2b47492600355604051908152a1005b7f1d8e7a4a0000000000000000000000000000000000000000000000000000000060005260046000fd5b600080fd5b346102765760406003193601126102765760043567ffffffffffffffff8111610276576102ac9036906004016123b6565b60243567ffffffffffffffff8111610276576102cc9036906004016123b6565b6102d4612a34565b8083036103e65760005b8381106102e757005b6001600160a01b036103026102fd838789612778565b612788565b16600052600b60205260ff60406000205416156103a257806103276001928486612778565b356001600160a01b0361033e6102fd84898b612778565b16600052600960205260406000205561035b6102fd828789612778565b7f6429c5a6f7a6ff31c7c2ce696e5c134528983ae32fe6f1d99756019bd6a15a1e60206001600160a01b0361039185888a612778565b35936040519485521692a2016102de565b6103b86102fd6001600160a01b03928688612778565b7fffd6ce64000000000000000000000000000000000000000000000000000000006000521660045260246000fd5b60646040517f50e4188700000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f5061796d656e7420546f6b656e7320616e6420446973636f756e7473000000006044820152fd5b346102765760206001600160a01b0361046d61045f3661259d565b9390604051928380926125df565b600c81520301902091166000526020526020604060002054604051908152f35b346102765760206001600160a01b036104a861045f3661259d565b600a81520301902091166000526020526020604060002054604051908152f35b346102765760206001600160a01b036104e361045f3661259d565b600881520301902091166000526020526020604060002054604051908152f35b346102765760606003193601126102765760043567ffffffffffffffff81116102765761053490369060040161257f565b60243567ffffffffffffffff81116102765761058761055f6001600160a01b0392369060040161257f565b610579602061056c612488565b95604051928380926125df565b60058152030190209061260a565b91166000526020526020604060002054604051908152f35b34610276576000600319360112610276576105b8612abf565b600180547fffffffffffff0000000000000000000000000000000000000000000000000000811690915560a01c65ffffffffffff166105f357005b7f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a9605109600080a1005b3461027657604060031936011261027657600435610636612472565b8115610665578161066061065b61000e94600052600060205260016040600020015490565b612bb6565b612dfd565b7f3fc3c27a0000000000000000000000000000000000000000000000000000000060005260046000fd5b346102765761069d366123e7565b929091936106a9612a34565b848103610872578381036108135760005b8581106106c357005b6106d86106d182848a6126e9565b3691612548565b51156107e9576001600160a01b036106f46102fd838987612778565b16600052600b60205260ff60406000205416156107d3578061072461071f6106d1600194868c6126e9565b612c27565b61072f828888612778565b356040805160208161074181876125df565b600a8152030190206107576102fd868d8b612778565b906001600160a01b0360009216825260205220556107796102fd838a88612778565b7f64d3caf73fc9dc8e8924ebe16fd740500b6a77bf88834650373f90bcd3ac1bd160206001600160a01b036107c06107b2878d8d612778565b3595604051918280926125df565b039020936040519586521693a3016106ba565b6103b86102fd6001600160a01b03928886612778565b7fac6b05f50000000000000000000000000000000000000000000000000000000060005260046000fd5b6040517f50e4188700000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f44657374696e6174696f6e7320616e64204665657300000000000000000000006044820152606490fd5b6040517f50e4188700000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f44657374696e6174696f6e7320616e64205061796d656e7420546f6b656e73006044820152606490fd5b3461027657600060031936011261027657604065ffffffffffff61090b6001549065ffffffffffff6001600160a01b0383169260a01c1690565b6001600160a01b03849392935193168352166020820152f35b34610276576000600319360112610276576001546001600160a01b031633036109ef5760015460a081901c65ffffffffffff16906001600160a01b0316811580156109e5575b6109b75761098c906109866001600160a01b0360025416612da9565b50612d01565b50600180547fffffffffffff0000000000000000000000000000000000000000000000000000169055005b507f19ca5ebb0000000000000000000000000000000000000000000000000000000060005260045260246000fd5b504282101561096a565b7fc22c8022000000000000000000000000000000000000000000000000000000006000523360045260246000fd5b34610276576000600319360112610276576020610a386129fb565b65ffffffffffff60405191168152f35b34610276576020600319360112610276576001600160a01b03610a6961245c565b16600052600b602052602060ff604060002054166040519015158152f35b3461027657610a9536612627565b949092919395610aa3612a34565b868103610c7357848103610872578581036108135760005b858110610ac457005b610ad26106d182848c6126e9565b51156107e957610ae66106d1828a866126e9565b5115610c49576001600160a01b03610b026102fd838988612778565b16600052600b60205260ff6040600020541615610c3357610b2481838b6126e9565b3690610b2f92612548565b610b3890612c27565b610b43828a866126e9565b3690610b4e92612548565b610b5790612c27565b610b62838a89612778565b3560405180610b7181866125df565b60058152036020019020610b85908361260a565b610b90858b8a612778565b610b9990612788565b906000916001600160a01b031682526020526040902055610bbb838988612778565b610bc490612788565b90610bd0848b8a612778565b3592604051610be08180936125df565b03902090604051610bf28180936125df565b039020916040519384526001600160a01b03169260207fbff18059c68d8e2c08b5dc210c9fea60e85ed45cfda51bfea443b43ca10b779691a4600101610abb565b6103b86102fd6001600160a01b03928887612778565b7f4a7f394f0000000000000000000000000000000000000000000000000000000060005260046000fd5b60646040517f50e4188700000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f44657374696e6174696f6e7320616e6420416374696f6e7300000000000000006044820152fd5b34610276576020600319360112610276576001600160a01b03610cf261245c565b610cfa612a34565b1680600052600b60205260ff60406000205416610d74576020817f91b78cafb5dd0a087406b7d0aee2bf1fd4ccf9a383318656bf5da8a94df1f21592600052600b8252604060002060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00825416179055604051908152a1005b7fe368180a0000000000000000000000000000000000000000000000000000000060005260045260246000fd5b3461027657600060031936011261027657602060405160008152f35b34610276576000600319360112610276576002548060d01c9081151580610e16575b15610e0c5760a01c65ffffffffffff165b6040805165ffffffffffff928316815292909116602083015290f35b5050600080610df0565b5042821015610ddf565b34610276576020600319360112610276576001600160a01b03610e4161245c565b610e49612a34565b1680600052600b60205260ff6040600020541615610ec1576020817f232e9482fd54f74ed68bdd8d9a1853859abb3e017967ac72f952845c6e54294e92600052600b825260406000207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008154169055604051908152a1005b7fd334e6bd0000000000000000000000000000000000000000000000000000000060005260045260246000fd5b3461027657604060031936011261027657610f07612472565b60043560005260006020526001600160a01b0360406000209116600052602052602060ff604060002054166040519015158152f35b346102765760006003193601126102765760206001600160a01b0360025416604051908152f35b346102765760a06003193601126102765760043567ffffffffffffffff811161027657610f949036906004016126bb565b60243567ffffffffffffffff811161027657610fb49036906004016126bb565b610fbf939193612488565b606435916001600160a01b038316830361027657602095610fe395608435956127a9565b604051908152f35b3461027657610ff9366123e7565b9493611006929192612a34565b8181036111c0578581036111625760005b82811061102057005b6001600160a01b036110366102fd83858a612778565b1615611138576001600160a01b036110526102fd838689612778565b16600052600b60205260ff6040600020541615611122578085887fb614572536932c14436386c2712cab524f2ce97a838ca9b5cf41767f284cb4d560206001600160a01b038061110f876111088f828f8f908f60019f6102fd918f968f9760406110c3856102fd9b61110299612778565b35918e6110d46102fd888888612778565b166000526020600690526110f06102fd878b8560002094612778565b908f6000921682526020522055612778565b9b612778565b968d612778565b359460405195865216941692a301611017565b6103b86102fd6001600160a01b03928588612778565b7f48f5c3ed0000000000000000000000000000000000000000000000000000000060005260046000fd5b60646040517f50e4188700000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f43616c6c65727320616e6420446973636f756e747300000000000000000000006044820152fd5b60646040517f50e4188700000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f43616c6c65727320616e64205061796d656e7420546f6b656e730000000000006044820152fd5b346102765760606003193601126102765760043567ffffffffffffffff81116102765761124f90369060040161257f565b611257612472565b6001600160a01b03611279602061126c612488565b94604051928380926125df565b600781520301902091166000526020526001600160a01b03604060002091166000526020526020604060002054604051908152f35b34610276576112bc36612627565b9394909291956112ca612a34565b85810361148557868103610872578481036108135760005b8781106112eb57005b6112f96106d182848c6126e9565b51156107e9576001600160a01b036113156102fd838a87612778565b1615611138576001600160a01b036113316102fd838b88612778565b16600052600b60205260ff604060002054161561146f5761135381838b6126e9565b369061135e92612548565b61136790612c27565b611372828888612778565b356040518061138181856125df565b60078152036020019020611396848b88612778565b61139f90612788565b906000916001600160a01b03168252602052604090206113c0848c89612778565b6113c990612788565b906000916001600160a01b0316825260205260409020556113eb828986612778565b6113f490612788565b90611400838b88612778565b61140990612788565b611414848a8a612778565b35916040516114248180936125df565b039020906040519283526001600160a01b0316926001600160a01b03169160207f286df78ae19abfb5b8bc037b840889828b1ec1036a6b56b007ccadf1b342c68791a46001016112e2565b6103b86102fd6001600160a01b03928a87612778565b60646040517f50e4188700000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f44657374696e6174696f6e7320616e642043616c6c65727300000000000000006044820152fd5b346102765760006003193601126102765760206040517fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217758152f35b346102765760206003193601126102765760043565ffffffffffff8116908181036102765761154b612abf565b61155442612e59565b9165ffffffffffff6115646129fb565b16808211156116ba57507ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b9265ffffffffffff8262069780806115b1951091180262069780181690612ce3565b906002548060d01c80611636575b5050600280546001600160a01b031660a083901b79ffffffffffff0000000000000000000000000000000000000000161760d084901b7fffffffffffff0000000000000000000000000000000000000000000000000000161790556040805165ffffffffffff9283168152919092166020820152a1005b42111561168f5779ffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffff00000000000000000000000000000000000000000000000000006001549260301b169116176001555b83806115bf565b507f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec5600080a1611688565b0365ffffffffffff81116116f4577ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b926115b19190612ce3565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b346102765760206003193601126102765761173c61245c565b611744612abf565b7f3377dc44241e779dd06afab5b788a35ca5f3b778836e2990bdb26a2a4b2e5ed6602061178161177342612e59565b61177b6129fb565b90612ce3565b65ffffffffffff6001600160a01b036117b06001549065ffffffffffff6001600160a01b0383169260a01c1690565b9690501694600154867fffffffffffff000000000000000000000000000000000000000000000000000079ffffffffffff00000000000000000000000000000000000000008660a01b169216171760015516611818575b65ffffffffffff60405191168152a2005b7f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a9605109600080a1611807565b34610276576000600319360112610276576020600354604051908152f35b346102765760406003193601126102765761187961245c565b6001600160a01b03611889612472565b911660005260066020526001600160a01b03604060002091166000526020526020604060002054604051908152f35b34610276576040600319360112610276576118d161245c565b6001600160a01b036118e1612472565b916118ea612b2b565b16908115611a4e576001600160a01b0316908115611a24576040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152602081602481865afa9081156119e5576000916119f1575b5060209160009160405190848201927fa9059cbb000000000000000000000000000000000000000000000000000000008452602483015260448201526044815261199160648261249e565b519082855af1156119e5576000513d6119dc5750803b155b6119af57005b7f5274afe70000000000000000000000000000000000000000000000000000000060005260045260246000fd5b600114156119a9565b6040513d6000823e3d90fd5b90506020813d602011611a1c575b81611a0c6020938361249e565b8101031261027657516020611946565b3d91506119ff565b7fa7cc99060000000000000000000000000000000000000000000000000000000060005260046000fd5b7f5566df5c0000000000000000000000000000000000000000000000000000000060005260046000fd5b3461027657604060031936011261027657600435611a94612472565b811580611b98575b611ae4575b336001600160a01b03821603611aba5761000e91612dfd565b7f6697b2320000000000000000000000000000000000000000000000000000000060005260046000fd5b60015465ffffffffffff60a082901c16906001600160a01b031615801590611b88575b8015611b76575b611b4057507fffffffffffff000000000000ffffffffffffffffffffffffffffffffffffffff60015416600155611aa1565b65ffffffffffff907f19ca5ebb000000000000000000000000000000000000000000000000000000006000521660045260246000fd5b504265ffffffffffff82161015611b0e565b5065ffffffffffff811615611b07565b506001600160a01b03600254166001600160a01b03821614611a9c565b3461027657602060031936011261027657611bce61245c565b611bd6612b2b565b6001600160a01b03811615611a4e5760008080809347905af13d15611c49573d611bff8161250e565b90611c0d604051928361249e565b8152600060203d92013e5b15611c1f57005b7ffd26b8c50000000000000000000000000000000000000000000000000000000060005260046000fd5b611c18565b3461027657604060031936011261027657600435611c6a612472565b81156106655781611c8f61065b61000e94600052600060205260016040600020015490565b612d4f565b3461027657611ca2366123e7565b92909193611cae612a34565b84810361087257838103611dbe5760005b818110611cc857005b611cd66106d182848a6126e9565b51156107e9576001600160a01b03611cf26102fd838987612778565b16600052600b60205260ff60406000205416156107d35780611d1d61071f6106d1600194868c6126e9565b611d28828888612778565b3560408051602081611d3a81876125df565b6008815203019020611d506102fd868d8b612778565b906001600160a01b036000921682526020522055611d726102fd838a88612778565b7fa59915fdf53a3bc4a1b6631a71f19b55afe55efa662465eb6f12cb705dc2d7d860206001600160a01b03611dab6107b2878d8d612778565b039020936040519586521693a301611cbf565b60646040517f50e4188700000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f44657374696e6174696f6e7320616e6420446973636f756e74730000000000006044820152fd5b34610276576020600319360112610276576020610fe3600435600052600060205260016040600020015490565b346102765760206001600160a01b03611e6461045f3661259d565b600481520301902091166000526020526020604060002054604051908152f35b3461027657611e92366123e7565b92909193611e9e612a34565b84810361200c57838103611fae5760005b818110611eb857005b611ec66106d182848a6126e9565b5115610c49576001600160a01b03611ee26102fd838987612778565b16600052600b60205260ff60406000205416156107d35780611f0d61071f6106d1600194868c6126e9565b611f18828888612778565b3560408051602081611f2a81876125df565b6004815203019020611f406102fd868d8b612778565b906001600160a01b036000921682526020522055611f626102fd838a88612778565b7fd8cb72abaec71ae18fef1b66f277dc513c34be34ca5c2ccda6903fcdf391f54760206001600160a01b03611f9b6107b2878d8d612778565b039020936040519586521693a301611eaf565b60646040517f50e4188700000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f416374696f6e7320616e6420446973636f756e747300000000000000000000006044820152fd5b60646040517f50e4188700000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f416374696f6e7320616e64205061796d656e7420546f6b656e730000000000006044820152fd5b3461027657600060031936011261027657612083612abf565b6002548060d01c806120a1575b600280546001600160a01b03169055005b4211156120fa5779ffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffff00000000000000000000000000000000000000000000000000006001549260301b169116176001555b8080612090565b507f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec5600080a16120f3565b346102765760006003193601126102765760206040517f6c0757dc3e6b28b2580c03fd9e96c274acf4f99d91fbec9b418fa1d70604ff1c8152f35b34610276576020600319360112610276576001600160a01b0361218161245c565b1660005260096020526020604060002054604051908152f35b34610276576000600319360112610276576020604051620697808152f35b34610276576020600319360112610276576004357fffffffff00000000000000000000000000000000000000000000000000000000811680910361027657807f31498786000000000000000000000000000000000000000000000000000000006020921490811561222f575b506040519015158152f35b7f7965db0b00000000000000000000000000000000000000000000000000000000811491508115612262575b5082612224565b7f01ffc9a7000000000000000000000000000000000000000000000000000000009150148261225b565b346102765761229a366123e7565b929091936122a6612a34565b848103610872578381036108135760005b8581106122c057005b6122ce6106d182848a6126e9565b51156107e9576001600160a01b036122ea6102fd838987612778565b16600052600b60205260ff60406000205416156107d3578061231561071f6106d1600194868c6126e9565b612320828888612778565b356040805160208161233281876125df565b600c8152030190206123486102fd868d8b612778565b906001600160a01b03600092168252602052205561236a6102fd838a88612778565b7fe33e827e9a46dcb24ff7e7a13a3eb111bcf6b74c1e4d32f3fe96e3dd037aa92160206001600160a01b036123a36107b2878d8d612778565b039020936040519586521693a3016122b7565b9181601f840112156102765782359167ffffffffffffffff8311610276576020808501948460051b01011161027657565b60606003198201126102765760043567ffffffffffffffff81116102765781612412916004016123b6565b9290929160243567ffffffffffffffff81116102765781612435916004016123b6565b929092916044359067ffffffffffffffff821161027657612458916004016123b6565b9091565b600435906001600160a01b038216820361027657565b602435906001600160a01b038216820361027657565b604435906001600160a01b038216820361027657565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176124df57604052565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b67ffffffffffffffff81116124df57601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b9291926125548261250e565b91612562604051938461249e565b829481845281830111610276578281602093846000960137010152565b9080601f830112156102765781602061259a93359101612548565b90565b6040600319820112610276576004359067ffffffffffffffff8211610276576125c89160040161257f565b906024356001600160a01b03811681036102765790565b9081519160005b8381106125f7575050016000815290565b80602080928401015181850152016125e6565b60209061261d92604051938480936125df565b9081520301902090565b60806003198201126102765760043567ffffffffffffffff81116102765781612652916004016123b6565b9290929160243567ffffffffffffffff81116102765781612675916004016123b6565b9290929160443567ffffffffffffffff81116102765781612698916004016123b6565b929092916064359067ffffffffffffffff821161027657612458916004016123b6565b9181601f840112156102765782359167ffffffffffffffff8311610276576020838186019501011161027657565b91908110156127495760051b810135907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18136030182121561027657019081359167ffffffffffffffff8311610276576020018236038113610276579190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b91908110156127495760051b0190565b356001600160a01b03811681036102765790565b919082018092116116f457565b91929594936127b9368385612548565b51156107e9576127ca368886612548565b5115610c49576001600160a01b0316938415611138576001600160a01b03169283600052600b60205260ff60406000205416156129cd5760035486116129a35761281f61071f6128279461071f943691612548565b963691612548565b9360405160208161283881856125df565b600c815203019020826000526020526040600020549460405160208161285e81866125df565b600a815203019020836000526020526040600020548581029581870414901517156116f4576129879461297c61298292612982956040516020816128a2818a6125df565b6007815203019020886000526020526040600020816000526020526129616020612954604060002054986128ec60405184816128de81866125df565b60058152030190208761260a565b85600052835261293a8361292d6040600020549e8860005260098352604060002054906000526006835260406000208960005283526040600020549061279c565b92604051928380926125df565b60088152030190208560005283526040600020549061279c565b93604051928380926125df565b6004815203019020906000526020526040600020549061279c565b9661279c565b61279c565b908082111561299c5781039081116116f45790565b5050600090565b7f245482c00000000000000000000000000000000000000000000000000000000060005260046000fd5b837fffd6ce640000000000000000000000000000000000000000000000000000000060005260045260246000fd5b6002548060d01c8015159081612a2a575b5015612a205760a01c65ffffffffffff1690565b5060015460d01c90565b9050421138612a0c565b3360009081527f175e50102ecf9cfc73f21ab2786f3296b7cae96dee56a3f6a84b3c656d591ada602052604090205460ff1615612a6d57565b7fe2517d3f00000000000000000000000000000000000000000000000000000000600052336004527f6c0757dc3e6b28b2580c03fd9e96c274acf4f99d91fbec9b418fa1d70604ff1c60245260446000fd5b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff1615612af857565b7fe2517d3f0000000000000000000000000000000000000000000000000000000060005233600452600060245260446000fd5b3360009081527f7d7ffb7a348e1c6a02869081a26547b49160dd3df72d1d75a570eb9b698292ec602052604090205460ff1615612b6457565b7fe2517d3f00000000000000000000000000000000000000000000000000000000600052336004527fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177560245260446000fd5b80600052600060205260406000206001600160a01b03331660005260205260ff6040600020541615612be55750565b7fe2517d3f000000000000000000000000000000000000000000000000000000006000523360045260245260446000fd5b908151811015612749570160200190565b60005b8151811015612cdf57612c3d8183612c16565b5160f81c604181101580612cd4575b612c8a575b607f10612c6057600101612c2a565b7f6fef1c030000000000000000000000000000000000000000000000000000000060005260046000fd5b602081019060ff82116116f4577fff00000000000000000000000000000000000000000000000000000000000000607f9260f81b1660001a612ccc8486612c16565b539050612c51565b50605a811115612c4c565b5090565b9065ffffffffffff8091169116019065ffffffffffff82116116f457565b600254906001600160a01b0382166106655761259a917fffffffffffffffffffffffff00000000000000000000000000000000000000006001600160a01b0383169116176002556000612ea3565b908115612d60575b61259a91612ea3565b600254916001600160a01b038316610665577fffffffffffffffffffffffff00000000000000000000000000000000000000009092166001600160a01b03821617600255612d57565b61259a906001600160a01b03600254166001600160a01b03821614612dd0575b6000612f54565b7fffffffffffffffffffffffff000000000000000000000000000000000000000060025416600255612dc9565b9061259a91801580612e3c575b15612f54577fffffffffffffffffffffffff000000000000000000000000000000000000000060025416600255612f54565b506001600160a01b03600254166001600160a01b03831614612e0a565b65ffffffffffff8111612e715765ffffffffffff1690565b7f6dfcc65000000000000000000000000000000000000000000000000000000000600052603060045260245260446000fd5b80600052600060205260406000206001600160a01b03831660005260205260ff604060002054161560001461299c5780600052600060205260406000206001600160a01b038316600052602052604060002060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008254161790556001600160a01b03339216907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d600080a4600190565b80600052600060205260406000206001600160a01b03831660005260205260ff6040600020541660001461299c5780600052600060205260406000206001600160a01b03831660005260205260406000207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0081541690556001600160a01b03339216907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b600080a460019056fea26469706673582212209caf79d9e39262d7ad9215b1c295449935b2fa961c8ff525865087656cb458bc64736f6c634300081c0033000000000000000000000000eca664d0a5635ba676a71b8b960532f4e55bd118000000000000000000000000fc00000000000000000000000000000000000002
Deployed Bytecode
0x60806040526004361015610010575b005b60003560e01c806301d152ab1461228c57806301ffc9a7146121b8578063022d63fb1461219a578063040a4f421461216057806305db2f41146121255780630aa6220b1461206a5780631463193314611e8457806320adead214611e49578063248a9ca314611e1c5780632bd79f4414611c945780632f2ff15d14611c4e5780632f622e6b14611bb557806336568abe14611a785780633aeac4e1146118b85780634f9ead271461186057806358e3e94c14611842578063634e93da14611723578063649a5ec71461151e57806375b238fc146114e35780637b9f684e146112ae5780637f55b98d1461121e5780637fb486c714610feb57806384ef8ffc14610f3c5780638d51850f14610f635780638da5cb5b14610f3c57806391d1485414610eee5780639c7aa7f814610e20578063a1eda53c14610dbd578063a217fddf14610da1578063bfd84fb414610cd1578063c0f51fad14610a87578063c3b88b4214610a48578063cc8463c814610a1d578063cefc142914610924578063cf6eefb7146108d1578063d27235861461068f578063d547741f1461061a578063d602b9fd1461059f578063db77c81714610503578063dffbaf3e146104c8578063e143b5031461048d578063e79dd62314610444578063f636b3ef1461027b5763fe8e37a30361000e573461027657602060031936011261027657600435610215612b2b565b801561024c576020817f3c3e5e9e455616f9d506743269a7d961c595945b2f1cea6ee4ca96c7ccd2b47492600355604051908152a1005b7f1d8e7a4a0000000000000000000000000000000000000000000000000000000060005260046000fd5b600080fd5b346102765760406003193601126102765760043567ffffffffffffffff8111610276576102ac9036906004016123b6565b60243567ffffffffffffffff8111610276576102cc9036906004016123b6565b6102d4612a34565b8083036103e65760005b8381106102e757005b6001600160a01b036103026102fd838789612778565b612788565b16600052600b60205260ff60406000205416156103a257806103276001928486612778565b356001600160a01b0361033e6102fd84898b612778565b16600052600960205260406000205561035b6102fd828789612778565b7f6429c5a6f7a6ff31c7c2ce696e5c134528983ae32fe6f1d99756019bd6a15a1e60206001600160a01b0361039185888a612778565b35936040519485521692a2016102de565b6103b86102fd6001600160a01b03928688612778565b7fffd6ce64000000000000000000000000000000000000000000000000000000006000521660045260246000fd5b60646040517f50e4188700000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f5061796d656e7420546f6b656e7320616e6420446973636f756e7473000000006044820152fd5b346102765760206001600160a01b0361046d61045f3661259d565b9390604051928380926125df565b600c81520301902091166000526020526020604060002054604051908152f35b346102765760206001600160a01b036104a861045f3661259d565b600a81520301902091166000526020526020604060002054604051908152f35b346102765760206001600160a01b036104e361045f3661259d565b600881520301902091166000526020526020604060002054604051908152f35b346102765760606003193601126102765760043567ffffffffffffffff81116102765761053490369060040161257f565b60243567ffffffffffffffff81116102765761058761055f6001600160a01b0392369060040161257f565b610579602061056c612488565b95604051928380926125df565b60058152030190209061260a565b91166000526020526020604060002054604051908152f35b34610276576000600319360112610276576105b8612abf565b600180547fffffffffffff0000000000000000000000000000000000000000000000000000811690915560a01c65ffffffffffff166105f357005b7f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a9605109600080a1005b3461027657604060031936011261027657600435610636612472565b8115610665578161066061065b61000e94600052600060205260016040600020015490565b612bb6565b612dfd565b7f3fc3c27a0000000000000000000000000000000000000000000000000000000060005260046000fd5b346102765761069d366123e7565b929091936106a9612a34565b848103610872578381036108135760005b8581106106c357005b6106d86106d182848a6126e9565b3691612548565b51156107e9576001600160a01b036106f46102fd838987612778565b16600052600b60205260ff60406000205416156107d3578061072461071f6106d1600194868c6126e9565b612c27565b61072f828888612778565b356040805160208161074181876125df565b600a8152030190206107576102fd868d8b612778565b906001600160a01b0360009216825260205220556107796102fd838a88612778565b7f64d3caf73fc9dc8e8924ebe16fd740500b6a77bf88834650373f90bcd3ac1bd160206001600160a01b036107c06107b2878d8d612778565b3595604051918280926125df565b039020936040519586521693a3016106ba565b6103b86102fd6001600160a01b03928886612778565b7fac6b05f50000000000000000000000000000000000000000000000000000000060005260046000fd5b6040517f50e4188700000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f44657374696e6174696f6e7320616e64204665657300000000000000000000006044820152606490fd5b6040517f50e4188700000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f44657374696e6174696f6e7320616e64205061796d656e7420546f6b656e73006044820152606490fd5b3461027657600060031936011261027657604065ffffffffffff61090b6001549065ffffffffffff6001600160a01b0383169260a01c1690565b6001600160a01b03849392935193168352166020820152f35b34610276576000600319360112610276576001546001600160a01b031633036109ef5760015460a081901c65ffffffffffff16906001600160a01b0316811580156109e5575b6109b75761098c906109866001600160a01b0360025416612da9565b50612d01565b50600180547fffffffffffff0000000000000000000000000000000000000000000000000000169055005b507f19ca5ebb0000000000000000000000000000000000000000000000000000000060005260045260246000fd5b504282101561096a565b7fc22c8022000000000000000000000000000000000000000000000000000000006000523360045260246000fd5b34610276576000600319360112610276576020610a386129fb565b65ffffffffffff60405191168152f35b34610276576020600319360112610276576001600160a01b03610a6961245c565b16600052600b602052602060ff604060002054166040519015158152f35b3461027657610a9536612627565b949092919395610aa3612a34565b868103610c7357848103610872578581036108135760005b858110610ac457005b610ad26106d182848c6126e9565b51156107e957610ae66106d1828a866126e9565b5115610c49576001600160a01b03610b026102fd838988612778565b16600052600b60205260ff6040600020541615610c3357610b2481838b6126e9565b3690610b2f92612548565b610b3890612c27565b610b43828a866126e9565b3690610b4e92612548565b610b5790612c27565b610b62838a89612778565b3560405180610b7181866125df565b60058152036020019020610b85908361260a565b610b90858b8a612778565b610b9990612788565b906000916001600160a01b031682526020526040902055610bbb838988612778565b610bc490612788565b90610bd0848b8a612778565b3592604051610be08180936125df565b03902090604051610bf28180936125df565b039020916040519384526001600160a01b03169260207fbff18059c68d8e2c08b5dc210c9fea60e85ed45cfda51bfea443b43ca10b779691a4600101610abb565b6103b86102fd6001600160a01b03928887612778565b7f4a7f394f0000000000000000000000000000000000000000000000000000000060005260046000fd5b60646040517f50e4188700000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f44657374696e6174696f6e7320616e6420416374696f6e7300000000000000006044820152fd5b34610276576020600319360112610276576001600160a01b03610cf261245c565b610cfa612a34565b1680600052600b60205260ff60406000205416610d74576020817f91b78cafb5dd0a087406b7d0aee2bf1fd4ccf9a383318656bf5da8a94df1f21592600052600b8252604060002060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00825416179055604051908152a1005b7fe368180a0000000000000000000000000000000000000000000000000000000060005260045260246000fd5b3461027657600060031936011261027657602060405160008152f35b34610276576000600319360112610276576002548060d01c9081151580610e16575b15610e0c5760a01c65ffffffffffff165b6040805165ffffffffffff928316815292909116602083015290f35b5050600080610df0565b5042821015610ddf565b34610276576020600319360112610276576001600160a01b03610e4161245c565b610e49612a34565b1680600052600b60205260ff6040600020541615610ec1576020817f232e9482fd54f74ed68bdd8d9a1853859abb3e017967ac72f952845c6e54294e92600052600b825260406000207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008154169055604051908152a1005b7fd334e6bd0000000000000000000000000000000000000000000000000000000060005260045260246000fd5b3461027657604060031936011261027657610f07612472565b60043560005260006020526001600160a01b0360406000209116600052602052602060ff604060002054166040519015158152f35b346102765760006003193601126102765760206001600160a01b0360025416604051908152f35b346102765760a06003193601126102765760043567ffffffffffffffff811161027657610f949036906004016126bb565b60243567ffffffffffffffff811161027657610fb49036906004016126bb565b610fbf939193612488565b606435916001600160a01b038316830361027657602095610fe395608435956127a9565b604051908152f35b3461027657610ff9366123e7565b9493611006929192612a34565b8181036111c0578581036111625760005b82811061102057005b6001600160a01b036110366102fd83858a612778565b1615611138576001600160a01b036110526102fd838689612778565b16600052600b60205260ff6040600020541615611122578085887fb614572536932c14436386c2712cab524f2ce97a838ca9b5cf41767f284cb4d560206001600160a01b038061110f876111088f828f8f908f60019f6102fd918f968f9760406110c3856102fd9b61110299612778565b35918e6110d46102fd888888612778565b166000526020600690526110f06102fd878b8560002094612778565b908f6000921682526020522055612778565b9b612778565b968d612778565b359460405195865216941692a301611017565b6103b86102fd6001600160a01b03928588612778565b7f48f5c3ed0000000000000000000000000000000000000000000000000000000060005260046000fd5b60646040517f50e4188700000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f43616c6c65727320616e6420446973636f756e747300000000000000000000006044820152fd5b60646040517f50e4188700000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f43616c6c65727320616e64205061796d656e7420546f6b656e730000000000006044820152fd5b346102765760606003193601126102765760043567ffffffffffffffff81116102765761124f90369060040161257f565b611257612472565b6001600160a01b03611279602061126c612488565b94604051928380926125df565b600781520301902091166000526020526001600160a01b03604060002091166000526020526020604060002054604051908152f35b34610276576112bc36612627565b9394909291956112ca612a34565b85810361148557868103610872578481036108135760005b8781106112eb57005b6112f96106d182848c6126e9565b51156107e9576001600160a01b036113156102fd838a87612778565b1615611138576001600160a01b036113316102fd838b88612778565b16600052600b60205260ff604060002054161561146f5761135381838b6126e9565b369061135e92612548565b61136790612c27565b611372828888612778565b356040518061138181856125df565b60078152036020019020611396848b88612778565b61139f90612788565b906000916001600160a01b03168252602052604090206113c0848c89612778565b6113c990612788565b906000916001600160a01b0316825260205260409020556113eb828986612778565b6113f490612788565b90611400838b88612778565b61140990612788565b611414848a8a612778565b35916040516114248180936125df565b039020906040519283526001600160a01b0316926001600160a01b03169160207f286df78ae19abfb5b8bc037b840889828b1ec1036a6b56b007ccadf1b342c68791a46001016112e2565b6103b86102fd6001600160a01b03928a87612778565b60646040517f50e4188700000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f44657374696e6174696f6e7320616e642043616c6c65727300000000000000006044820152fd5b346102765760006003193601126102765760206040517fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217758152f35b346102765760206003193601126102765760043565ffffffffffff8116908181036102765761154b612abf565b61155442612e59565b9165ffffffffffff6115646129fb565b16808211156116ba57507ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b9265ffffffffffff8262069780806115b1951091180262069780181690612ce3565b906002548060d01c80611636575b5050600280546001600160a01b031660a083901b79ffffffffffff0000000000000000000000000000000000000000161760d084901b7fffffffffffff0000000000000000000000000000000000000000000000000000161790556040805165ffffffffffff9283168152919092166020820152a1005b42111561168f5779ffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffff00000000000000000000000000000000000000000000000000006001549260301b169116176001555b83806115bf565b507f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec5600080a1611688565b0365ffffffffffff81116116f4577ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b926115b19190612ce3565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b346102765760206003193601126102765761173c61245c565b611744612abf565b7f3377dc44241e779dd06afab5b788a35ca5f3b778836e2990bdb26a2a4b2e5ed6602061178161177342612e59565b61177b6129fb565b90612ce3565b65ffffffffffff6001600160a01b036117b06001549065ffffffffffff6001600160a01b0383169260a01c1690565b9690501694600154867fffffffffffff000000000000000000000000000000000000000000000000000079ffffffffffff00000000000000000000000000000000000000008660a01b169216171760015516611818575b65ffffffffffff60405191168152a2005b7f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a9605109600080a1611807565b34610276576000600319360112610276576020600354604051908152f35b346102765760406003193601126102765761187961245c565b6001600160a01b03611889612472565b911660005260066020526001600160a01b03604060002091166000526020526020604060002054604051908152f35b34610276576040600319360112610276576118d161245c565b6001600160a01b036118e1612472565b916118ea612b2b565b16908115611a4e576001600160a01b0316908115611a24576040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152602081602481865afa9081156119e5576000916119f1575b5060209160009160405190848201927fa9059cbb000000000000000000000000000000000000000000000000000000008452602483015260448201526044815261199160648261249e565b519082855af1156119e5576000513d6119dc5750803b155b6119af57005b7f5274afe70000000000000000000000000000000000000000000000000000000060005260045260246000fd5b600114156119a9565b6040513d6000823e3d90fd5b90506020813d602011611a1c575b81611a0c6020938361249e565b8101031261027657516020611946565b3d91506119ff565b7fa7cc99060000000000000000000000000000000000000000000000000000000060005260046000fd5b7f5566df5c0000000000000000000000000000000000000000000000000000000060005260046000fd5b3461027657604060031936011261027657600435611a94612472565b811580611b98575b611ae4575b336001600160a01b03821603611aba5761000e91612dfd565b7f6697b2320000000000000000000000000000000000000000000000000000000060005260046000fd5b60015465ffffffffffff60a082901c16906001600160a01b031615801590611b88575b8015611b76575b611b4057507fffffffffffff000000000000ffffffffffffffffffffffffffffffffffffffff60015416600155611aa1565b65ffffffffffff907f19ca5ebb000000000000000000000000000000000000000000000000000000006000521660045260246000fd5b504265ffffffffffff82161015611b0e565b5065ffffffffffff811615611b07565b506001600160a01b03600254166001600160a01b03821614611a9c565b3461027657602060031936011261027657611bce61245c565b611bd6612b2b565b6001600160a01b03811615611a4e5760008080809347905af13d15611c49573d611bff8161250e565b90611c0d604051928361249e565b8152600060203d92013e5b15611c1f57005b7ffd26b8c50000000000000000000000000000000000000000000000000000000060005260046000fd5b611c18565b3461027657604060031936011261027657600435611c6a612472565b81156106655781611c8f61065b61000e94600052600060205260016040600020015490565b612d4f565b3461027657611ca2366123e7565b92909193611cae612a34565b84810361087257838103611dbe5760005b818110611cc857005b611cd66106d182848a6126e9565b51156107e9576001600160a01b03611cf26102fd838987612778565b16600052600b60205260ff60406000205416156107d35780611d1d61071f6106d1600194868c6126e9565b611d28828888612778565b3560408051602081611d3a81876125df565b6008815203019020611d506102fd868d8b612778565b906001600160a01b036000921682526020522055611d726102fd838a88612778565b7fa59915fdf53a3bc4a1b6631a71f19b55afe55efa662465eb6f12cb705dc2d7d860206001600160a01b03611dab6107b2878d8d612778565b039020936040519586521693a301611cbf565b60646040517f50e4188700000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f44657374696e6174696f6e7320616e6420446973636f756e74730000000000006044820152fd5b34610276576020600319360112610276576020610fe3600435600052600060205260016040600020015490565b346102765760206001600160a01b03611e6461045f3661259d565b600481520301902091166000526020526020604060002054604051908152f35b3461027657611e92366123e7565b92909193611e9e612a34565b84810361200c57838103611fae5760005b818110611eb857005b611ec66106d182848a6126e9565b5115610c49576001600160a01b03611ee26102fd838987612778565b16600052600b60205260ff60406000205416156107d35780611f0d61071f6106d1600194868c6126e9565b611f18828888612778565b3560408051602081611f2a81876125df565b6004815203019020611f406102fd868d8b612778565b906001600160a01b036000921682526020522055611f626102fd838a88612778565b7fd8cb72abaec71ae18fef1b66f277dc513c34be34ca5c2ccda6903fcdf391f54760206001600160a01b03611f9b6107b2878d8d612778565b039020936040519586521693a301611eaf565b60646040517f50e4188700000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f416374696f6e7320616e6420446973636f756e747300000000000000000000006044820152fd5b60646040517f50e4188700000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f416374696f6e7320616e64205061796d656e7420546f6b656e730000000000006044820152fd5b3461027657600060031936011261027657612083612abf565b6002548060d01c806120a1575b600280546001600160a01b03169055005b4211156120fa5779ffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffff00000000000000000000000000000000000000000000000000006001549260301b169116176001555b8080612090565b507f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec5600080a16120f3565b346102765760006003193601126102765760206040517f6c0757dc3e6b28b2580c03fd9e96c274acf4f99d91fbec9b418fa1d70604ff1c8152f35b34610276576020600319360112610276576001600160a01b0361218161245c565b1660005260096020526020604060002054604051908152f35b34610276576000600319360112610276576020604051620697808152f35b34610276576020600319360112610276576004357fffffffff00000000000000000000000000000000000000000000000000000000811680910361027657807f31498786000000000000000000000000000000000000000000000000000000006020921490811561222f575b506040519015158152f35b7f7965db0b00000000000000000000000000000000000000000000000000000000811491508115612262575b5082612224565b7f01ffc9a7000000000000000000000000000000000000000000000000000000009150148261225b565b346102765761229a366123e7565b929091936122a6612a34565b848103610872578381036108135760005b8581106122c057005b6122ce6106d182848a6126e9565b51156107e9576001600160a01b036122ea6102fd838987612778565b16600052600b60205260ff60406000205416156107d3578061231561071f6106d1600194868c6126e9565b612320828888612778565b356040805160208161233281876125df565b600c8152030190206123486102fd868d8b612778565b906001600160a01b03600092168252602052205561236a6102fd838a88612778565b7fe33e827e9a46dcb24ff7e7a13a3eb111bcf6b74c1e4d32f3fe96e3dd037aa92160206001600160a01b036123a36107b2878d8d612778565b039020936040519586521693a3016122b7565b9181601f840112156102765782359167ffffffffffffffff8311610276576020808501948460051b01011161027657565b60606003198201126102765760043567ffffffffffffffff81116102765781612412916004016123b6565b9290929160243567ffffffffffffffff81116102765781612435916004016123b6565b929092916044359067ffffffffffffffff821161027657612458916004016123b6565b9091565b600435906001600160a01b038216820361027657565b602435906001600160a01b038216820361027657565b604435906001600160a01b038216820361027657565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176124df57604052565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b67ffffffffffffffff81116124df57601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b9291926125548261250e565b91612562604051938461249e565b829481845281830111610276578281602093846000960137010152565b9080601f830112156102765781602061259a93359101612548565b90565b6040600319820112610276576004359067ffffffffffffffff8211610276576125c89160040161257f565b906024356001600160a01b03811681036102765790565b9081519160005b8381106125f7575050016000815290565b80602080928401015181850152016125e6565b60209061261d92604051938480936125df565b9081520301902090565b60806003198201126102765760043567ffffffffffffffff81116102765781612652916004016123b6565b9290929160243567ffffffffffffffff81116102765781612675916004016123b6565b9290929160443567ffffffffffffffff81116102765781612698916004016123b6565b929092916064359067ffffffffffffffff821161027657612458916004016123b6565b9181601f840112156102765782359167ffffffffffffffff8311610276576020838186019501011161027657565b91908110156127495760051b810135907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18136030182121561027657019081359167ffffffffffffffff8311610276576020018236038113610276579190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b91908110156127495760051b0190565b356001600160a01b03811681036102765790565b919082018092116116f457565b91929594936127b9368385612548565b51156107e9576127ca368886612548565b5115610c49576001600160a01b0316938415611138576001600160a01b03169283600052600b60205260ff60406000205416156129cd5760035486116129a35761281f61071f6128279461071f943691612548565b963691612548565b9360405160208161283881856125df565b600c815203019020826000526020526040600020549460405160208161285e81866125df565b600a815203019020836000526020526040600020548581029581870414901517156116f4576129879461297c61298292612982956040516020816128a2818a6125df565b6007815203019020886000526020526040600020816000526020526129616020612954604060002054986128ec60405184816128de81866125df565b60058152030190208761260a565b85600052835261293a8361292d6040600020549e8860005260098352604060002054906000526006835260406000208960005283526040600020549061279c565b92604051928380926125df565b60088152030190208560005283526040600020549061279c565b93604051928380926125df565b6004815203019020906000526020526040600020549061279c565b9661279c565b61279c565b908082111561299c5781039081116116f45790565b5050600090565b7f245482c00000000000000000000000000000000000000000000000000000000060005260046000fd5b837fffd6ce640000000000000000000000000000000000000000000000000000000060005260045260246000fd5b6002548060d01c8015159081612a2a575b5015612a205760a01c65ffffffffffff1690565b5060015460d01c90565b9050421138612a0c565b3360009081527f175e50102ecf9cfc73f21ab2786f3296b7cae96dee56a3f6a84b3c656d591ada602052604090205460ff1615612a6d57565b7fe2517d3f00000000000000000000000000000000000000000000000000000000600052336004527f6c0757dc3e6b28b2580c03fd9e96c274acf4f99d91fbec9b418fa1d70604ff1c60245260446000fd5b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff1615612af857565b7fe2517d3f0000000000000000000000000000000000000000000000000000000060005233600452600060245260446000fd5b3360009081527f7d7ffb7a348e1c6a02869081a26547b49160dd3df72d1d75a570eb9b698292ec602052604090205460ff1615612b6457565b7fe2517d3f00000000000000000000000000000000000000000000000000000000600052336004527fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177560245260446000fd5b80600052600060205260406000206001600160a01b03331660005260205260ff6040600020541615612be55750565b7fe2517d3f000000000000000000000000000000000000000000000000000000006000523360045260245260446000fd5b908151811015612749570160200190565b60005b8151811015612cdf57612c3d8183612c16565b5160f81c604181101580612cd4575b612c8a575b607f10612c6057600101612c2a565b7f6fef1c030000000000000000000000000000000000000000000000000000000060005260046000fd5b602081019060ff82116116f4577fff00000000000000000000000000000000000000000000000000000000000000607f9260f81b1660001a612ccc8486612c16565b539050612c51565b50605a811115612c4c565b5090565b9065ffffffffffff8091169116019065ffffffffffff82116116f457565b600254906001600160a01b0382166106655761259a917fffffffffffffffffffffffff00000000000000000000000000000000000000006001600160a01b0383169116176002556000612ea3565b908115612d60575b61259a91612ea3565b600254916001600160a01b038316610665577fffffffffffffffffffffffff00000000000000000000000000000000000000009092166001600160a01b03821617600255612d57565b61259a906001600160a01b03600254166001600160a01b03821614612dd0575b6000612f54565b7fffffffffffffffffffffffff000000000000000000000000000000000000000060025416600255612dc9565b9061259a91801580612e3c575b15612f54577fffffffffffffffffffffffff000000000000000000000000000000000000000060025416600255612f54565b506001600160a01b03600254166001600160a01b03831614612e0a565b65ffffffffffff8111612e715765ffffffffffff1690565b7f6dfcc65000000000000000000000000000000000000000000000000000000000600052603060045260245260446000fd5b80600052600060205260406000206001600160a01b03831660005260205260ff604060002054161560001461299c5780600052600060205260406000206001600160a01b038316600052602052604060002060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008254161790556001600160a01b03339216907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d600080a4600190565b80600052600060205260406000206001600160a01b03831660005260205260ff6040600020541660001461299c5780600052600060205260406000206001600160a01b03831660005260205260406000207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0081541690556001600160a01b03339216907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b600080a460019056fea26469706673582212209caf79d9e39262d7ad9215b1c295449935b2fa961c8ff525865087656cb458bc64736f6c634300081c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000eca664d0a5635ba676a71b8b960532f4e55bd118000000000000000000000000fc00000000000000000000000000000000000002
-----Decoded View---------------
Arg [0] : _reactor (address): 0xEcA664D0A5635Ba676a71b8b960532F4E55BD118
Arg [1] : _wrappedNative (address): 0xFc00000000000000000000000000000000000002
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000eca664d0a5635ba676a71b8b960532f4e55bd118
Arg [1] : 000000000000000000000000fc00000000000000000000000000000000000002
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in FRAX
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
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.