diff --git a/script/production/README.md b/script/production/README.md index b8ca5b7..a82e665 100644 --- a/script/production/README.md +++ b/script/production/README.md @@ -96,3 +96,7 @@ corresponding production integration or role is not configured at execution time All commands require an RPC URL supplied at runtime; this runbook and the scripts contain no RPC endpoint or signing secret. + +## Deployment records + +- [Polygon Polymarket V2 custom whitelist, 2026-10-15](deployments/polygon-poly-v2-whitelist-2026-10-15/README.md): deployed address, ownership, sole proxy member, successful receipts and runtime/source provenance. diff --git a/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/README.md b/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/README.md new file mode 100644 index 0000000..e1c9c6e --- /dev/null +++ b/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/README.md @@ -0,0 +1,79 @@ +# Polygon Polymarket V2 custom whitelist + +Deployed and configured on 2026-10-15 on Polygon (chain ID 137). +This is a request-specific proposer whitelist for the initializer's atomic +AccessManager path. It does not replace the ManagedOO default whitelist. + +| Contract | Address | +|---|---| +| Custom AddressWhitelist | `0x0044C7b41206A4EB4183C1b37D6Ba65261173c42` | +| Owner and only member: SignedProposer proxy | `0x632dA7EcAD445C090DaFe1B03c24c113bD0edD13` | +| SignedProposer implementation at verification | `0x1307Ce44A51AF6D84AD2e346D7655f1B7D20D856` | +| AccessManager | `0xfa6f0Ff6c719001Cba691Ff12CeaA9c49aCDCb66` | +| ManagedOptimisticOracleV2 | `0x2C0367a9DB231dDeBd88a94b4f6461a6e47C58B1` | +| OOReporter proxy | `0x53703Dd6129d723066b6362510E5aE2fECd48218` | + +## Executed transactions + +All three receipts succeeded. Ownership transfer is immediate; no acceptance +transaction is required. The deployer was +`0x9A8f92a830A5cB89a3816e3D267CB7791c16b04D`. + +| Operation | Nonce | Block | Transaction | +|---|---|---|---| +| Deploy AddressWhitelist | 14944 | 95570673 | [Receipt](https://polygonscan.com/tx/0x7b8b4a1c5f5ff149cf84af9d1323892ff82d9d5202a67eee862a1b3cc13870b4) | +| Add SignedProposer proxy | 14945 | 95570755 | [Receipt](https://polygonscan.com/tx/0x5658e6d4e666d14d6afe29e6e156a9ed4d6f1fc82e8af8760ae9d929d2fa302f) | +| Transfer ownership to proxy | 14946 | 95570769 | [Receipt](https://polygonscan.com/tx/0x9ad99421fdcc1126ef7a2bf69f6d9a81199d4d5cb81f24167bc15e1e7bf7377d) | + +[deployment.json](deployment.json) records receipt block hashes and logs, +configuration calldata, source revisions, compiler settings and verified state. +At block `95573288` (`0xfa7f5ccfc98241b34e95586909c3606e6a7473a1bf142f1938de59541598dd9c`), +`owner()` and `getWhitelist()` returned the proxy above and a one-element list, +respectively; `isWhitelistEnabled()` returned `true`. Thus the implementation +address is not a member. The deployed runtime exactly matched the pinned build, +including metadata; its Keccak-256 is `0x086f94e78f61895eb3b08f67be1b92989ff5b7e233abdaca63e7217ce2f2a7e7`. + +## Build and implementation provenance + +The whitelist was compiled from managed-oracle commit +`886c23b88e7210dc3eac16f03a900ac36811862d`, contract +`src/common/implementation/AddressWhitelist.sol:AddressWhitelist`, with no +constructor arguments. Solidity 0.8.30, Prague, optimizer runs 1 and viaIR were +used with the dependency revisions recorded in `deployment.json`. Compiler +remappings are recorded in `deployment.json`; changing remappings can change metadata hashes. + +[verified-code-pins.json](verified-code-pins.json) records the AccessManager +runtime pin and the effective SignedProposer implementation runtime pin. +[bytecode-reproduction.json](bytecode-reproduction.json) includes the exact +compiler settings and immutable offsets; [reviewed-source-provenance.json](reviewed-source-provenance.json) +contains source hashes and matching revisions. The two `*-standard-input.json` +files retain the verified source closures and compiler inputs. Compile them +with Solidity `0.8.30+commit.73712a01` using standard JSON, requesting deployed +bytecode and immutable references; for SignedProposer, fill the two documented +`__self` locations with the implementation address before comparing the entire +runtime, including metadata, with `eth_getCode` at the recorded block. + +AccessManager matches canonical OpenZeppelin Contracts v5.6.1; it is outside +the UMA-specific OOReporter/SignedProposer diff audit. SignedProposer matches +release `24a5930ba82bb9a91fb3251d8d7ff243b5d95a7a` and the reviewed PR79 fixes. +The [audit](https://audits.openzeppelin.com/risk-labs/uma-26-retainer-01-ooreporter-consolidation-and-signedproposer-batching) +resolved N-03/N-04; L-05 remains acknowledged under the trusted relayer model. +These checks establish deployment provenance, not a new integration audit. + +## Initializer handoff + +The compatible initializer in [MCP-OTB PR2540](https://github.com/UMAprotocol/mcp-otb/pull/2540) +assigns this custom whitelist and initializes each request through +AccessManager in one transaction. The existing initializer HSM is +`0x2964a637fEaeA99edf573087E8C3C0C1917D553C`; the permissions batch maps role 11 to the +ManagedOO whitelist selector and role 12 to OOReporter initialization. +The configured proposer API relayer is +`0xE6018D3913ff69ce30C467144442ba3E57cE3743`. + +Before activation, verify that the Safe authorization of AccessManager in +OOReporter and the selector-role batch have executed, recheck the effective +implementation and pins, release the compatible initializer, and stop/drain +old direct initialization transactions before recording the inclusive +`HISTORICAL_DIRECT_MAX_BLOCK`. The deployment receipts here do not establish +that those separate governance or runtime steps have completed. This record +neither assigns the whitelist to existing requests nor activates the worker. diff --git a/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/access-manager-standard-input.json b/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/access-manager-standard-input.json new file mode 100644 index 0000000..f184282 --- /dev/null +++ b/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/access-manager-standard-input.json @@ -0,0 +1,86 @@ +{ + "language": "Solidity", + "sources": { + "lib/openzeppelin-contracts/contracts/access/manager/AccessManager.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.5.0) (access/manager/AccessManager.sol)\n\npragma solidity ^0.8.20;\n\nimport {IAccessManager} from \"./IAccessManager.sol\";\nimport {IAccessManaged} from \"./IAccessManaged.sol\";\nimport {Address} from \"../../utils/Address.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {Multicall} from \"../../utils/Multicall.sol\";\nimport {Math} from \"../../utils/math/Math.sol\";\nimport {Time} from \"../../utils/types/Time.sol\";\nimport {Hashes} from \"../../utils/cryptography/Hashes.sol\";\n\n/**\n * @dev AccessManager is a central contract to store the permissions of a system.\n *\n * A smart contract under the control of an AccessManager instance is known as a target, and will inherit from the\n * {AccessManaged} contract, be connected to this contract as its manager and implement the {AccessManaged-restricted}\n * modifier on a set of functions selected to be permissioned. Note that any function without this setup won't be\n * effectively restricted.\n *\n * The restriction rules for such functions are defined in terms of \"roles\" identified by an `uint64` and scoped\n * by target (`address`) and function selectors (`bytes4`). These roles are stored in this contract and can be\n * configured by admins (`ADMIN_ROLE` members) after a delay (see {getTargetAdminDelay}).\n *\n * For each target contract, admins can configure the following without any delay:\n *\n * * The target's {AccessManaged-authority} via {updateAuthority}.\n * * Close or open a target via {setTargetClosed} keeping the permissions intact.\n * * The roles that are allowed (or disallowed) to call a given function (identified by its selector) through {setTargetFunctionRole}.\n *\n * By default every address is member of the `PUBLIC_ROLE` and every target function is restricted to the `ADMIN_ROLE` until configured otherwise.\n * Additionally, each role has the following configuration options restricted to this manager's admins:\n *\n * * A role's admin role via {setRoleAdmin} who can grant or revoke roles.\n * * A role's guardian role via {setRoleGuardian} who's allowed to cancel operations.\n * * A delay in which a role takes effect after being granted through {setGrantDelay}.\n * * A delay of any target's admin action via {setTargetAdminDelay}.\n * * A role label for discoverability purposes with {labelRole}.\n *\n * Any account can be added and removed into any number of these roles by using the {grantRole} and {revokeRole} functions\n * restricted to each role's admin (see {getRoleAdmin}).\n *\n * Since all the permissions of the managed system can be modified by the admins of this instance, it is expected that\n * they will be highly secured (e.g., a multisig or a well-configured DAO).\n *\n * NOTE: This contract implements a form of the {IAuthority} interface, but {canCall} has additional return data so it\n * doesn't inherit `IAuthority`. It is however compatible with the `IAuthority` interface since the first 32 bytes of\n * the return data are a boolean as expected by that interface.\n *\n * NOTE: Systems that implement other access control mechanisms (for example using {Ownable}) can be paired with an\n * {AccessManager} by transferring permissions (ownership in the case of {Ownable}) directly to the {AccessManager}.\n * Users will be able to interact with these contracts through the {execute} function, following the access rules\n * registered in the {AccessManager}. Keep in mind that in that context, the msg.sender seen by restricted functions\n * will be {AccessManager} itself.\n *\n * WARNING: When granting permissions over an {Ownable} or {AccessControl} contract to an {AccessManager}, be very\n * mindful of the danger associated with functions such as {Ownable-renounceOwnership} or\n * {AccessControl-renounceRole}.\n */\ncontract AccessManager is Context, Multicall, IAccessManager {\n using Time for *;\n\n // Structure that stores the details for a target contract.\n struct TargetConfig {\n mapping(bytes4 selector => uint64 roleId) allowedRoles;\n Time.Delay adminDelay;\n bool closed;\n }\n\n // Structure that stores the details for a role/account pair. This structure fits into a single slot.\n struct Access {\n // Timepoint at which the user gets the permission.\n // If this is either 0 or in the future, then the role permission is not available.\n uint48 since;\n // Delay for execution. Only applies to restricted() / execute() calls.\n Time.Delay delay;\n }\n\n // Structure that stores the details of a role.\n struct Role {\n // Members of the role.\n mapping(address user => Access access) members;\n // Admin who can grant or revoke permissions.\n uint64 admin;\n // Guardian who can cancel operations targeting functions that need this role.\n uint64 guardian;\n // Delay in which the role takes effect after being granted.\n Time.Delay grantDelay;\n }\n\n // Structure that stores the details for a scheduled operation. This structure fits into a single slot.\n struct Schedule {\n // Moment at which the operation can be executed.\n uint48 timepoint;\n // Operation nonce to allow third-party contracts to identify the operation.\n uint32 nonce;\n }\n\n /**\n * @dev The identifier of the admin role. Required to perform most configuration operations including\n * other roles' management and target restrictions.\n */\n uint64 public constant ADMIN_ROLE = type(uint64).min; // 0\n\n /**\n * @dev The identifier of the public role. Automatically granted to all addresses with no delay.\n */\n uint64 public constant PUBLIC_ROLE = type(uint64).max; // 2**64-1\n\n mapping(address target => TargetConfig mode) private _targets;\n mapping(uint64 roleId => Role) private _roles;\n mapping(bytes32 operationId => Schedule) private _schedules;\n\n // Used to identify operations that are currently being executed via {execute}.\n // This should be transient storage when supported by the EVM.\n bytes32 private _executionId;\n\n /**\n * @dev Check that the caller is authorized to perform the operation.\n * See {AccessManager} description for a detailed breakdown of the authorization logic.\n */\n modifier onlyAuthorized() {\n _checkAuthorized();\n _;\n }\n\n constructor(address initialAdmin) {\n if (initialAdmin == address(0)) {\n revert AccessManagerInvalidInitialAdmin(address(0));\n }\n\n // admin is active immediately and without any execution delay.\n _grantRole(ADMIN_ROLE, initialAdmin, 0, 0);\n }\n\n // =================================================== GETTERS ====================================================\n /// @inheritdoc IAccessManager\n function canCall(\n address caller,\n address target,\n bytes4 selector\n ) public view virtual returns (bool immediate, uint32 delay) {\n if (isTargetClosed(target)) {\n return (false, 0);\n } else if (caller == address(this)) {\n // Caller is AccessManager, this means the call was sent through {execute} and it already checked\n // permissions. We verify that the call \"identifier\", which is set during {execute}, is correct.\n return (_isExecuting(target, selector), 0);\n } else {\n uint64 roleId = getTargetFunctionRole(target, selector);\n (bool isMember, uint32 currentDelay) = hasRole(roleId, caller);\n return isMember ? (currentDelay == 0, currentDelay) : (false, 0);\n }\n }\n\n /// @inheritdoc IAccessManager\n function expiration() public view virtual returns (uint32) {\n return 1 weeks;\n }\n\n /// @inheritdoc IAccessManager\n function minSetback() public view virtual returns (uint32) {\n return 5 days;\n }\n\n /// @inheritdoc IAccessManager\n function isTargetClosed(address target) public view virtual returns (bool) {\n return _targets[target].closed;\n }\n\n /// @inheritdoc IAccessManager\n function getTargetFunctionRole(address target, bytes4 selector) public view virtual returns (uint64) {\n return _targets[target].allowedRoles[selector];\n }\n\n /// @inheritdoc IAccessManager\n function getTargetAdminDelay(address target) public view virtual returns (uint32) {\n return _targets[target].adminDelay.get();\n }\n\n /// @inheritdoc IAccessManager\n function getRoleAdmin(uint64 roleId) public view virtual returns (uint64) {\n return _roles[roleId].admin;\n }\n\n /// @inheritdoc IAccessManager\n function getRoleGuardian(uint64 roleId) public view virtual returns (uint64) {\n return _roles[roleId].guardian;\n }\n\n /// @inheritdoc IAccessManager\n function getRoleGrantDelay(uint64 roleId) public view virtual returns (uint32) {\n return _roles[roleId].grantDelay.get();\n }\n\n /// @inheritdoc IAccessManager\n function getAccess(\n uint64 roleId,\n address account\n ) public view virtual returns (uint48 since, uint32 currentDelay, uint32 pendingDelay, uint48 effect) {\n Access storage access = _roles[roleId].members[account];\n\n since = access.since;\n (currentDelay, pendingDelay, effect) = access.delay.getFull();\n\n return (since, currentDelay, pendingDelay, effect);\n }\n\n /// @inheritdoc IAccessManager\n function hasRole(\n uint64 roleId,\n address account\n ) public view virtual returns (bool isMember, uint32 executionDelay) {\n if (roleId == PUBLIC_ROLE) {\n return (true, 0);\n } else {\n (uint48 hasRoleSince, uint32 currentDelay, , ) = getAccess(roleId, account);\n return (hasRoleSince != 0 && hasRoleSince <= Time.timestamp(), currentDelay);\n }\n }\n\n // =============================================== ROLE MANAGEMENT ===============================================\n /// @inheritdoc IAccessManager\n function labelRole(uint64 roleId, string calldata label) public virtual onlyAuthorized {\n if (roleId == ADMIN_ROLE || roleId == PUBLIC_ROLE) {\n revert AccessManagerLockedRole(roleId);\n }\n emit RoleLabel(roleId, label);\n }\n\n /// @inheritdoc IAccessManager\n function grantRole(uint64 roleId, address account, uint32 executionDelay) public virtual onlyAuthorized {\n _grantRole(roleId, account, getRoleGrantDelay(roleId), executionDelay);\n }\n\n /// @inheritdoc IAccessManager\n function revokeRole(uint64 roleId, address account) public virtual onlyAuthorized {\n _revokeRole(roleId, account);\n }\n\n /// @inheritdoc IAccessManager\n function renounceRole(uint64 roleId, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessManagerBadConfirmation();\n }\n _revokeRole(roleId, callerConfirmation);\n }\n\n /// @inheritdoc IAccessManager\n function setRoleAdmin(uint64 roleId, uint64 admin) public virtual onlyAuthorized {\n _setRoleAdmin(roleId, admin);\n }\n\n /// @inheritdoc IAccessManager\n function setRoleGuardian(uint64 roleId, uint64 guardian) public virtual onlyAuthorized {\n _setRoleGuardian(roleId, guardian);\n }\n\n /// @inheritdoc IAccessManager\n function setGrantDelay(uint64 roleId, uint32 newDelay) public virtual onlyAuthorized {\n _setGrantDelay(roleId, newDelay);\n }\n\n /**\n * @dev Internal version of {grantRole} without access control. Returns true if the role was newly granted.\n *\n * Emits a {RoleGranted} event.\n */\n function _grantRole(\n uint64 roleId,\n address account,\n uint32 grantDelay,\n uint32 executionDelay\n ) internal virtual returns (bool) {\n if (roleId == PUBLIC_ROLE) {\n revert AccessManagerLockedRole(roleId);\n }\n\n bool newMember = _roles[roleId].members[account].since == 0;\n uint48 since;\n\n if (newMember) {\n since = Time.timestamp() + grantDelay;\n _roles[roleId].members[account] = Access({since: since, delay: executionDelay.toDelay()});\n } else {\n // No setback here. Value can be reset by doing revoke + grant, effectively allowing the admin to perform\n // any change to the execution delay within the duration of the role admin delay.\n (_roles[roleId].members[account].delay, since) = _roles[roleId].members[account].delay.withUpdate(\n executionDelay,\n 0\n );\n }\n\n emit RoleGranted(roleId, account, executionDelay, since, newMember);\n return newMember;\n }\n\n /**\n * @dev Internal version of {revokeRole} without access control. This logic is also used by {renounceRole}.\n * Returns true if the role was previously granted.\n *\n * Emits a {RoleRevoked} event if the account had the role.\n */\n function _revokeRole(uint64 roleId, address account) internal virtual returns (bool) {\n if (roleId == PUBLIC_ROLE) {\n revert AccessManagerLockedRole(roleId);\n }\n\n if (_roles[roleId].members[account].since == 0) {\n return false;\n }\n\n delete _roles[roleId].members[account];\n\n emit RoleRevoked(roleId, account);\n return true;\n }\n\n /**\n * @dev Internal version of {setRoleAdmin} without access control.\n *\n * Emits a {RoleAdminChanged} event.\n *\n * NOTE: Setting the admin role as the `PUBLIC_ROLE` is allowed, but it will effectively allow\n * anyone to set grant or revoke such role.\n */\n function _setRoleAdmin(uint64 roleId, uint64 admin) internal virtual {\n if (roleId == ADMIN_ROLE || roleId == PUBLIC_ROLE) {\n revert AccessManagerLockedRole(roleId);\n }\n\n _roles[roleId].admin = admin;\n\n emit RoleAdminChanged(roleId, admin);\n }\n\n /**\n * @dev Internal version of {setRoleGuardian} without access control.\n *\n * Emits a {RoleGuardianChanged} event.\n *\n * NOTE: Setting the guardian role as the `PUBLIC_ROLE` is allowed, but it will effectively allow\n * anyone to cancel any scheduled operation for such role.\n */\n function _setRoleGuardian(uint64 roleId, uint64 guardian) internal virtual {\n if (roleId == ADMIN_ROLE || roleId == PUBLIC_ROLE) {\n revert AccessManagerLockedRole(roleId);\n }\n\n _roles[roleId].guardian = guardian;\n\n emit RoleGuardianChanged(roleId, guardian);\n }\n\n /**\n * @dev Internal version of {setGrantDelay} without access control.\n *\n * Emits a {RoleGrantDelayChanged} event.\n */\n function _setGrantDelay(uint64 roleId, uint32 newDelay) internal virtual {\n if (roleId == PUBLIC_ROLE) {\n revert AccessManagerLockedRole(roleId);\n }\n\n uint48 effect;\n (_roles[roleId].grantDelay, effect) = _roles[roleId].grantDelay.withUpdate(newDelay, minSetback());\n\n emit RoleGrantDelayChanged(roleId, newDelay, effect);\n }\n\n // ============================================= FUNCTION MANAGEMENT ==============================================\n /// @inheritdoc IAccessManager\n function setTargetFunctionRole(\n address target,\n bytes4[] calldata selectors,\n uint64 roleId\n ) public virtual onlyAuthorized {\n for (uint256 i = 0; i < selectors.length; ++i) {\n _setTargetFunctionRole(target, selectors[i], roleId);\n }\n }\n\n /**\n * @dev Internal version of {setTargetFunctionRole} without access control.\n *\n * Emits a {TargetFunctionRoleUpdated} event.\n */\n function _setTargetFunctionRole(address target, bytes4 selector, uint64 roleId) internal virtual {\n _targets[target].allowedRoles[selector] = roleId;\n emit TargetFunctionRoleUpdated(target, selector, roleId);\n }\n\n /// @inheritdoc IAccessManager\n function setTargetAdminDelay(address target, uint32 newDelay) public virtual onlyAuthorized {\n _setTargetAdminDelay(target, newDelay);\n }\n\n /**\n * @dev Internal version of {setTargetAdminDelay} without access control.\n *\n * Emits a {TargetAdminDelayUpdated} event.\n */\n function _setTargetAdminDelay(address target, uint32 newDelay) internal virtual {\n uint48 effect;\n (_targets[target].adminDelay, effect) = _targets[target].adminDelay.withUpdate(newDelay, minSetback());\n\n emit TargetAdminDelayUpdated(target, newDelay, effect);\n }\n\n // =============================================== MODE MANAGEMENT ================================================\n /// @inheritdoc IAccessManager\n function setTargetClosed(address target, bool closed) public virtual onlyAuthorized {\n _setTargetClosed(target, closed);\n }\n\n /**\n * @dev Set the closed flag for a contract. This is an internal setter with no access restrictions.\n *\n * Emits a {TargetClosed} event.\n */\n function _setTargetClosed(address target, bool closed) internal virtual {\n _targets[target].closed = closed;\n emit TargetClosed(target, closed);\n }\n\n // ============================================== DELAYED OPERATIONS ==============================================\n /// @inheritdoc IAccessManager\n function getSchedule(bytes32 id) public view virtual returns (uint48) {\n uint48 timepoint = _schedules[id].timepoint;\n return _isExpired(timepoint) ? 0 : timepoint;\n }\n\n /// @inheritdoc IAccessManager\n function getNonce(bytes32 id) public view virtual returns (uint32) {\n return _schedules[id].nonce;\n }\n\n /// @inheritdoc IAccessManager\n function schedule(\n address target,\n bytes calldata data,\n uint48 when\n ) public virtual returns (bytes32 operationId, uint32 nonce) {\n address caller = _msgSender();\n\n // Fetch restrictions that apply to the caller on the targeted function\n (, uint32 setback) = _canCallExtended(caller, target, data);\n\n uint48 minWhen = Time.timestamp() + setback;\n\n // If call with delay is not authorized, or if requested timing is too soon, revert\n if (setback == 0 || (when > 0 && when < minWhen)) {\n revert AccessManagerUnauthorizedCall(caller, target, _checkSelector(data));\n }\n\n // Reuse variable due to stack too deep\n when = uint48(Math.max(when, minWhen)); // cast is safe: both inputs are uint48\n\n // If caller is authorised, schedule operation\n operationId = hashOperation(caller, target, data);\n\n _checkNotScheduled(operationId);\n\n unchecked {\n // It's not feasible to overflow the nonce in less than 1000 years\n nonce = _schedules[operationId].nonce + 1;\n }\n _schedules[operationId].timepoint = when;\n _schedules[operationId].nonce = nonce;\n emit OperationScheduled(operationId, nonce, when, caller, target, data);\n\n // Using named return values because otherwise we get stack too deep\n }\n\n /**\n * @dev Reverts if the operation is currently scheduled and has not expired.\n *\n * NOTE: This function was introduced due to stack too deep errors in schedule.\n */\n function _checkNotScheduled(bytes32 operationId) private view {\n uint48 prevTimepoint = _schedules[operationId].timepoint;\n if (prevTimepoint != 0 && !_isExpired(prevTimepoint)) {\n revert AccessManagerAlreadyScheduled(operationId);\n }\n }\n\n /// @inheritdoc IAccessManager\n // Reentrancy is not an issue because permissions are checked on msg.sender. Additionally,\n // _consumeScheduledOp guarantees a scheduled operation is only executed once.\n // slither-disable-next-line reentrancy-no-eth\n function execute(address target, bytes calldata data) public payable virtual returns (uint32) {\n address caller = _msgSender();\n\n // Fetch restrictions that apply to the caller on the targeted function\n (bool immediate, uint32 setback) = _canCallExtended(caller, target, data);\n\n // If call is not authorized, revert\n if (!immediate && setback == 0) {\n revert AccessManagerUnauthorizedCall(caller, target, _checkSelector(data));\n }\n\n bytes32 operationId = hashOperation(caller, target, data);\n uint32 nonce;\n\n // If caller is authorised, check operation was scheduled early enough\n // Consume an available schedule even if there is no currently enforced delay\n if (setback != 0 || getSchedule(operationId) != 0) {\n nonce = _consumeScheduledOp(operationId);\n }\n\n // Mark the target and selector as authorised\n bytes32 executionIdBefore = _executionId;\n _executionId = _hashExecutionId(target, _checkSelector(data));\n\n // Perform call\n Address.functionCallWithValue(target, data, msg.value);\n\n // Reset execute identifier\n _executionId = executionIdBefore;\n\n return nonce;\n }\n\n /// @inheritdoc IAccessManager\n function cancel(address caller, address target, bytes calldata data) public virtual returns (uint32) {\n address msgsender = _msgSender();\n bytes4 selector = _checkSelector(data);\n\n bytes32 operationId = hashOperation(caller, target, data);\n if (_schedules[operationId].timepoint == 0) {\n revert AccessManagerNotScheduled(operationId);\n } else if (caller != msgsender) {\n // calls can only be canceled by the account that scheduled them, a global admin, or by a guardian of the required role.\n (bool isAdmin, ) = hasRole(ADMIN_ROLE, msgsender);\n (bool isGuardian, ) = hasRole(getRoleGuardian(getTargetFunctionRole(target, selector)), msgsender);\n if (!isAdmin && !isGuardian) {\n revert AccessManagerUnauthorizedCancel(msgsender, caller, target, selector);\n }\n }\n\n delete _schedules[operationId].timepoint; // reset the timepoint, keep the nonce\n uint32 nonce = _schedules[operationId].nonce;\n emit OperationCanceled(operationId, nonce);\n\n return nonce;\n }\n\n /// @inheritdoc IAccessManager\n function consumeScheduledOp(address caller, bytes calldata data) public virtual {\n address target = _msgSender();\n if (IAccessManaged(target).isConsumingScheduledOp() != IAccessManaged.isConsumingScheduledOp.selector) {\n revert AccessManagerUnauthorizedConsume(target);\n }\n _consumeScheduledOp(hashOperation(caller, target, data));\n }\n\n /**\n * @dev Internal variant of {consumeScheduledOp} that operates on bytes32 operationId.\n *\n * Returns the nonce of the scheduled operation that is consumed.\n */\n function _consumeScheduledOp(bytes32 operationId) internal virtual returns (uint32) {\n uint48 timepoint = _schedules[operationId].timepoint;\n uint32 nonce = _schedules[operationId].nonce;\n\n if (timepoint == 0) {\n revert AccessManagerNotScheduled(operationId);\n } else if (timepoint > Time.timestamp()) {\n revert AccessManagerNotReady(operationId);\n } else if (_isExpired(timepoint)) {\n revert AccessManagerExpired(operationId);\n }\n\n delete _schedules[operationId].timepoint; // reset the timepoint, keep the nonce\n emit OperationExecuted(operationId, nonce);\n\n return nonce;\n }\n\n /// @inheritdoc IAccessManager\n function hashOperation(address caller, address target, bytes calldata data) public view virtual returns (bytes32) {\n return keccak256(abi.encode(caller, target, data));\n }\n\n // ==================================================== OTHERS ====================================================\n /// @inheritdoc IAccessManager\n function updateAuthority(address target, address newAuthority) public virtual onlyAuthorized {\n IAccessManaged(target).setAuthority(newAuthority);\n }\n\n // ================================================= ADMIN LOGIC ==================================================\n /**\n * @dev Check if the current call is authorized according to admin and roles logic.\n *\n * WARNING: Carefully review the considerations of {AccessManaged-restricted} since they apply to this modifier.\n */\n function _checkAuthorized() private {\n address caller = _msgSender();\n (bool immediate, uint32 delay) = _canCallSelf(caller, _msgData());\n if (!immediate) {\n if (delay == 0) {\n (, uint64 requiredRole, ) = _getAdminRestrictions(_msgData());\n revert AccessManagerUnauthorizedAccount(caller, requiredRole);\n } else {\n _consumeScheduledOp(hashOperation(caller, address(this), _msgData()));\n }\n }\n }\n\n /**\n * @dev Get the admin restrictions of a given function call based on the function and arguments involved.\n *\n * Returns:\n * - bool restricted: does this data match a restricted operation\n * - uint64: which role is this operation restricted to\n * - uint32: minimum delay to enforce for that operation (max between operation's delay and admin's execution delay)\n */\n function _getAdminRestrictions(\n bytes calldata data\n ) private view returns (bool adminRestricted, uint64 roleAdminId, uint32 executionDelay) {\n if (data.length < 4) {\n return (false, 0, 0);\n }\n\n bytes4 selector = _checkSelector(data);\n\n // Restricted to ADMIN with no delay beside any execution delay the caller may have\n if (\n selector == this.labelRole.selector ||\n selector == this.setRoleAdmin.selector ||\n selector == this.setRoleGuardian.selector ||\n selector == this.setGrantDelay.selector ||\n selector == this.setTargetAdminDelay.selector\n ) {\n return (true, ADMIN_ROLE, 0);\n }\n\n // Restricted to ADMIN with the admin delay corresponding to the target\n if (\n selector == this.updateAuthority.selector ||\n selector == this.setTargetClosed.selector ||\n selector == this.setTargetFunctionRole.selector\n ) {\n // First argument is a target.\n address target = abi.decode(data[0x04:0x24], (address));\n uint32 delay = getTargetAdminDelay(target);\n return (true, ADMIN_ROLE, delay);\n }\n\n // Restricted to that role's admin with no delay beside any execution delay the caller may have.\n if (selector == this.grantRole.selector || selector == this.revokeRole.selector) {\n // First argument is a roleId.\n uint64 roleId = abi.decode(data[0x04:0x24], (uint64));\n return (true, getRoleAdmin(roleId), 0);\n }\n\n return (false, getTargetFunctionRole(address(this), selector), 0);\n }\n\n // =================================================== HELPERS ====================================================\n /**\n * @dev An extended version of {canCall} for internal usage that checks {_canCallSelf}\n * when the target is this contract.\n *\n * Returns:\n * - bool immediate: whether the operation can be executed immediately (with no delay)\n * - uint32 delay: the execution delay\n */\n function _canCallExtended(\n address caller,\n address target,\n bytes calldata data\n ) private view returns (bool immediate, uint32 delay) {\n if (target == address(this)) {\n return _canCallSelf(caller, data);\n } else {\n return data.length < 4 ? (false, 0) : canCall(caller, target, _checkSelector(data));\n }\n }\n\n /**\n * @dev A version of {canCall} that checks for restrictions in this contract.\n */\n function _canCallSelf(address caller, bytes calldata data) private view returns (bool immediate, uint32 delay) {\n if (data.length < 4) {\n return (false, 0);\n }\n\n if (caller == address(this)) {\n // Caller is AccessManager, this means the call was sent through {execute} and it already checked\n // permissions. We verify that the call \"identifier\", which is set during {execute}, is correct.\n return (_isExecuting(address(this), _checkSelector(data)), 0);\n }\n\n (bool adminRestricted, uint64 roleId, uint32 operationDelay) = _getAdminRestrictions(data);\n\n // isTargetClosed apply to non-admin-restricted function\n if (!adminRestricted && isTargetClosed(address(this))) {\n return (false, 0);\n }\n\n (bool inRole, uint32 executionDelay) = hasRole(roleId, caller);\n if (!inRole) {\n return (false, 0);\n }\n\n // downcast is safe because both options are uint32\n delay = uint32(Math.max(operationDelay, executionDelay));\n return (delay == 0, delay);\n }\n\n /**\n * @dev Returns true if a call with `target` and `selector` is being executed via {executed}.\n */\n function _isExecuting(address target, bytes4 selector) private view returns (bool) {\n return _executionId == _hashExecutionId(target, selector);\n }\n\n /**\n * @dev Returns true if a schedule timepoint is past its expiration deadline.\n */\n function _isExpired(uint48 timepoint) private view returns (bool) {\n return timepoint + expiration() <= Time.timestamp();\n }\n\n /**\n * @dev Extracts the selector from calldata. Panics if data is not at least 4 bytes\n */\n function _checkSelector(bytes calldata data) private pure returns (bytes4) {\n return bytes4(data[0:4]);\n }\n\n /**\n * @dev Hashing function for execute protection\n */\n function _hashExecutionId(address target, bytes4 selector) private pure returns (bytes32) {\n return Hashes.efficientKeccak256(bytes32(uint256(uint160(target))), selector);\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/access/manager/IAccessManager.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.6.0) (access/manager/IAccessManager.sol)\n\npragma solidity >=0.8.4;\n\ninterface IAccessManager {\n /**\n * @dev A delayed operation was scheduled.\n */\n event OperationScheduled(\n bytes32 indexed operationId,\n uint32 indexed nonce,\n uint48 schedule,\n address caller,\n address target,\n bytes data\n );\n\n /**\n * @dev A scheduled operation was executed.\n */\n event OperationExecuted(bytes32 indexed operationId, uint32 indexed nonce);\n\n /**\n * @dev A scheduled operation was canceled.\n */\n event OperationCanceled(bytes32 indexed operationId, uint32 indexed nonce);\n\n /**\n * @dev Informational labelling for a roleId.\n */\n event RoleLabel(uint64 indexed roleId, string label);\n\n /**\n * @dev Emitted when `account` is granted `roleId`.\n *\n * NOTE: The meaning of the `since` argument depends on the `newMember` argument.\n * If the role is granted to a new member, the `since` argument indicates when the account becomes a member of the role,\n * otherwise it indicates the timestamp when the execution delay update takes effect for this account and roleId.\n */\n event RoleGranted(uint64 indexed roleId, address indexed account, uint32 delay, uint48 since, bool newMember);\n\n /**\n * @dev Emitted when `account` membership or `roleId` is revoked. Unlike granting, revoking is instantaneous.\n */\n event RoleRevoked(uint64 indexed roleId, address indexed account);\n\n /**\n * @dev Role acting as admin over a given `roleId` is updated.\n */\n event RoleAdminChanged(uint64 indexed roleId, uint64 indexed admin);\n\n /**\n * @dev Role acting as guardian over a given `roleId` is updated.\n */\n event RoleGuardianChanged(uint64 indexed roleId, uint64 indexed guardian);\n\n /**\n * @dev Grant delay for a given `roleId` will be updated to `delay` when `since` is reached.\n */\n event RoleGrantDelayChanged(uint64 indexed roleId, uint32 delay, uint48 since);\n\n /**\n * @dev Target mode is updated (true = closed, false = open).\n */\n event TargetClosed(address indexed target, bool closed);\n\n /**\n * @dev Role required to invoke `selector` on `target` is updated to `roleId`.\n */\n event TargetFunctionRoleUpdated(address indexed target, bytes4 selector, uint64 indexed roleId);\n\n /**\n * @dev Admin delay for a given `target` will be updated to `delay` when `since` is reached.\n */\n event TargetAdminDelayUpdated(address indexed target, uint32 delay, uint48 since);\n\n error AccessManagerAlreadyScheduled(bytes32 operationId);\n error AccessManagerNotScheduled(bytes32 operationId);\n error AccessManagerNotReady(bytes32 operationId);\n error AccessManagerExpired(bytes32 operationId);\n error AccessManagerLockedRole(uint64 roleId);\n error AccessManagerBadConfirmation();\n error AccessManagerUnauthorizedAccount(address msgsender, uint64 roleId);\n error AccessManagerUnauthorizedCall(address caller, address target, bytes4 selector);\n error AccessManagerUnauthorizedConsume(address target);\n error AccessManagerUnauthorizedCancel(address msgsender, address caller, address target, bytes4 selector);\n error AccessManagerInvalidInitialAdmin(address initialAdmin);\n\n /**\n * @dev Check if an address (`caller`) is authorised to call a given function on a given contract directly (with\n * no restriction). Additionally, it returns the delay needed to perform the call indirectly through the {schedule}\n * & {execute} workflow.\n *\n * This function is usually called by the targeted contract to control immediate execution of restricted functions.\n * Therefore we only return true if the call can be performed without any delay. If the call is subject to a\n * previously set delay (not zero), then the function should return false and the caller should schedule the operation\n * for future execution.\n *\n * If `allowed` is true, the delay can be disregarded and the operation can be immediately executed, otherwise\n * the operation can be executed if and only if delay is greater than 0.\n *\n * NOTE: The IAuthority interface does not include the `uint32` delay. This is an extension of that interface that\n * is backward compatible. Some contracts may thus ignore the second return argument. In that case they will fail\n * to identify the indirect workflow, and will consider calls that require a delay to be forbidden.\n *\n * NOTE: This function does not report the permissions of the admin functions in the manager itself. These are defined by the\n * {AccessManager} documentation.\n */\n function canCall(\n address caller,\n address target,\n bytes4 selector\n ) external view returns (bool allowed, uint32 delay);\n\n /**\n * @dev Expiration delay for scheduled proposals. Defaults to 1 week.\n *\n * IMPORTANT: Avoid overriding the expiration with 0. Otherwise every contract proposal will be expired immediately,\n * disabling any scheduling usage.\n */\n function expiration() external view returns (uint32);\n\n /**\n * @dev Minimum setback for all delay updates, with the exception of execution delays. It\n * can be increased without setback (and reset via {revokeRole} in the event of an\n * accidental increase). Defaults to 5 days.\n */\n function minSetback() external view returns (uint32);\n\n /**\n * @dev Get whether the contract is closed disabling any access. Otherwise role permissions are applied.\n *\n * NOTE: When the manager itself is closed, admin functions are still accessible to avoid locking the contract.\n */\n function isTargetClosed(address target) external view returns (bool);\n\n /**\n * @dev Get the role required to call a function.\n */\n function getTargetFunctionRole(address target, bytes4 selector) external view returns (uint64);\n\n /**\n * @dev Get the admin delay for a target contract. Changes to contract configuration are subject to this delay.\n */\n function getTargetAdminDelay(address target) external view returns (uint32);\n\n /**\n * @dev Get the id of the role that acts as an admin for the given role.\n *\n * The admin permission is required to grant the role, revoke the role and update the execution delay to execute\n * an operation that is restricted to this role.\n */\n function getRoleAdmin(uint64 roleId) external view returns (uint64);\n\n /**\n * @dev Get the role that acts as a guardian for a given role.\n *\n * The guardian permission allows canceling operations that have been scheduled under the role.\n */\n function getRoleGuardian(uint64 roleId) external view returns (uint64);\n\n /**\n * @dev Get the role current grant delay.\n *\n * Its value may change at any point without an event emitted following a call to {setGrantDelay}.\n * Changes to this value, including effect timepoint are notified in advance by the {RoleGrantDelayChanged} event.\n */\n function getRoleGrantDelay(uint64 roleId) external view returns (uint32);\n\n /**\n * @dev Get the access details for a given account for a given role. These details include the timepoint at which\n * membership becomes active, and the delay applied to all operations by this user that requires this permission\n * level.\n *\n * Returns:\n * [0] Timestamp at which the account membership becomes valid. 0 means role is not granted.\n * [1] Current execution delay for the account.\n * [2] Pending execution delay for the account.\n * [3] Timestamp at which the pending execution delay will become active. 0 means no delay update is scheduled.\n */\n function getAccess(\n uint64 roleId,\n address account\n ) external view returns (uint48 since, uint32 currentDelay, uint32 pendingDelay, uint48 effect);\n\n /**\n * @dev Check if a given account currently has the permission level corresponding to a given role. Note that this\n * permission might be associated with an execution delay. {getAccess} can provide more details.\n */\n function hasRole(uint64 roleId, address account) external view returns (bool isMember, uint32 executionDelay);\n\n /**\n * @dev Give a label to a role, for improved role discoverability by UIs.\n *\n * Requirements:\n *\n * - the caller must be a global admin\n * - `roleId` must not be the `ADMIN_ROLE` or `PUBLIC_ROLE`\n *\n * Emits a {RoleLabel} event.\n */\n function labelRole(uint64 roleId, string calldata label) external;\n\n /**\n * @dev Add `account` to `roleId`, or change its execution delay.\n *\n * This gives the account the authorization to call any function that is restricted to this role. An optional\n * execution delay (in seconds) can be set. If that delay is non 0, the user is required to schedule any operation\n * that is restricted to members of this role. The user will only be able to execute the operation after the delay has\n * passed, before it has expired. During this period, admin and guardians can cancel the operation (see {cancel}).\n *\n * If the account has already been granted this role, the execution delay will be updated. This update is not\n * immediate and follows the delay rules. For example, if a user currently has a delay of 3 hours, and this is\n * called to reduce that delay to 1 hour, the new delay will take some time to take effect, enforcing that any\n * operation executed in the 3 hours that follows this update was indeed scheduled before this update.\n *\n * Requirements:\n *\n * - the caller must be an admin for the role (see {getRoleAdmin})\n * - granted role must not be the `PUBLIC_ROLE`\n *\n * Emits a {RoleGranted} event.\n */\n function grantRole(uint64 roleId, address account, uint32 executionDelay) external;\n\n /**\n * @dev Remove an account from a role, with immediate effect. If the account does not have the role, this call has\n * no effect.\n *\n * Requirements:\n *\n * - the caller must be an admin for the role (see {getRoleAdmin})\n * - revoked role must not be the `PUBLIC_ROLE`\n *\n * Emits a {RoleRevoked} event if the account had the role.\n */\n function revokeRole(uint64 roleId, address account) external;\n\n /**\n * @dev Renounce role permissions for the calling account with immediate effect. If the sender is not in\n * the role this call has no effect.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * Emits a {RoleRevoked} event if the account had the role.\n */\n function renounceRole(uint64 roleId, address callerConfirmation) external;\n\n /**\n * @dev Change admin role for a given role.\n *\n * Requirements:\n *\n * - the caller must be a global admin\n * - `roleId` must not be the `ADMIN_ROLE` or `PUBLIC_ROLE`\n *\n * Emits a {RoleAdminChanged} event\n */\n function setRoleAdmin(uint64 roleId, uint64 admin) external;\n\n /**\n * @dev Change guardian role for a given role.\n *\n * Requirements:\n *\n * - the caller must be a global admin\n * - `roleId` must not be the `ADMIN_ROLE` or `PUBLIC_ROLE`\n *\n * Emits a {RoleGuardianChanged} event\n */\n function setRoleGuardian(uint64 roleId, uint64 guardian) external;\n\n /**\n * @dev Update the delay for granting a `roleId`.\n *\n * Requirements:\n *\n * - the caller must be a global admin\n * - `roleId` must not be the `PUBLIC_ROLE`\n *\n * Emits a {RoleGrantDelayChanged} event.\n */\n function setGrantDelay(uint64 roleId, uint32 newDelay) external;\n\n /**\n * @dev Set the role required to call functions identified by the `selectors` in the `target` contract.\n *\n * Requirements:\n *\n * - the caller must be a global admin\n *\n * Emits a {TargetFunctionRoleUpdated} event per selector.\n */\n function setTargetFunctionRole(address target, bytes4[] calldata selectors, uint64 roleId) external;\n\n /**\n * @dev Set the delay for changing the configuration of a given target contract.\n *\n * Requirements:\n *\n * - the caller must be a global admin\n *\n * Emits a {TargetAdminDelayUpdated} event.\n */\n function setTargetAdminDelay(address target, uint32 newDelay) external;\n\n /**\n * @dev Set the closed flag for a contract.\n *\n * Closing the manager itself won't disable access to admin methods to avoid locking the contract.\n *\n * Requirements:\n *\n * - the caller must be a global admin\n *\n * Emits a {TargetClosed} event.\n */\n function setTargetClosed(address target, bool closed) external;\n\n /**\n * @dev Return the timepoint at which a scheduled operation will be ready for execution. This returns 0 if the\n * operation is not yet scheduled, has expired, was executed, or was canceled.\n */\n function getSchedule(bytes32 id) external view returns (uint48);\n\n /**\n * @dev Return the nonce for the latest scheduled operation with a given id. Returns 0 if the operation has never\n * been scheduled.\n */\n function getNonce(bytes32 id) external view returns (uint32);\n\n /**\n * @dev Schedule a delayed operation for future execution, and return the operation identifier. It is possible to\n * choose the timestamp at which the operation becomes executable as long as it satisfies the execution delays\n * required for the caller. The special value zero will automatically set the earliest possible time.\n *\n * Returns the `operationId` that was scheduled. Since this value is a hash of the parameters, it can reoccur when\n * the same parameters are used; if this is relevant, the returned `nonce` can be used to uniquely identify this\n * scheduled operation from other occurrences of the same `operationId` in invocations of {execute} and {cancel}.\n *\n * Emits a {OperationScheduled} event.\n *\n * NOTE: It is not possible to concurrently schedule more than one operation with the same `target` and `data`. If\n * this is necessary, a random byte can be appended to `data` to act as a salt that will be ignored by the target\n * contract if it is using standard Solidity ABI encoding.\n */\n function schedule(\n address target,\n bytes calldata data,\n uint48 when\n ) external returns (bytes32 operationId, uint32 nonce);\n\n /**\n * @dev Execute a function that is delay restricted, provided it was properly scheduled beforehand, or the\n * execution delay is 0.\n *\n * Returns the nonce that identifies the previously scheduled operation that is executed, or 0 if the\n * operation wasn't previously scheduled (if the caller doesn't have an execution delay).\n *\n * Emits an {OperationExecuted} event only if the call was scheduled and delayed.\n */\n function execute(address target, bytes calldata data) external payable returns (uint32);\n\n /**\n * @dev Cancel a scheduled (delayed) operation. Returns the nonce that identifies the previously scheduled\n * operation that is cancelled.\n *\n * Requirements:\n *\n * - the caller must be the proposer, a guardian of the targeted function, or a global admin\n *\n * Emits a {OperationCanceled} event.\n */\n function cancel(address caller, address target, bytes calldata data) external returns (uint32);\n\n /**\n * @dev Consume a scheduled operation targeting the caller. If such an operation exists, mark it as consumed\n * (emit an {OperationExecuted} event and clean the state). Otherwise, throw an error.\n *\n * This is useful for contracts that want to enforce that calls targeting them were scheduled on the manager,\n * with all the verifications that it implies.\n *\n * Emit a {OperationExecuted} event.\n */\n function consumeScheduledOp(address caller, bytes calldata data) external;\n\n /**\n * @dev Hashing function for delayed operations.\n */\n function hashOperation(address caller, address target, bytes calldata data) external view returns (bytes32);\n\n /**\n * @dev Changes the authority of a target managed by this manager instance.\n *\n * Requirements:\n *\n * - the caller must be a global admin\n */\n function updateAuthority(address target, address newAuthority) external;\n}\n" + }, + "lib/openzeppelin-contracts/contracts/access/manager/IAccessManaged.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (access/manager/IAccessManaged.sol)\n\npragma solidity >=0.8.4;\n\ninterface IAccessManaged {\n /**\n * @dev Authority that manages this contract was updated.\n */\n event AuthorityUpdated(address authority);\n\n error AccessManagedUnauthorized(address caller);\n error AccessManagedRequiredDelay(address caller, uint32 delay);\n error AccessManagedInvalidAuthority(address authority);\n\n /**\n * @dev Returns the current authority.\n */\n function authority() external view returns (address);\n\n /**\n * @dev Transfers control to a new authority. The caller must be the current authority.\n */\n function setAuthority(address) external;\n\n /**\n * @dev Returns true only in the context of a delayed restricted call, at the moment that the scheduled operation is\n * being consumed. Prevents denial of service for delayed restricted calls in the case that the contract performs\n * attacker controlled calls.\n */\n function isConsumingScheduledOp() external view returns (bytes4);\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.5.0) (utils/Address.sol)\n\npragma solidity ^0.8.20;\n\nimport {Errors} from \"./Errors.sol\";\nimport {LowLevelCall} from \"./LowLevelCall.sol\";\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance < amount) {\n revert Errors.InsufficientBalance(address(this).balance, amount);\n }\n if (LowLevelCall.callNoReturn(recipient, amount, \"\")) {\n // call successful, nothing to do\n return;\n } else if (LowLevelCall.returnDataSize() > 0) {\n LowLevelCall.bubbleRevert();\n } else {\n revert Errors.FailedCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {Errors.FailedCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance < value) {\n revert Errors.InsufficientBalance(address(this).balance, value);\n }\n bool success = LowLevelCall.callNoReturn(target, value, data);\n if (success && (LowLevelCall.returnDataSize() > 0 || target.code.length > 0)) {\n return LowLevelCall.returnData();\n } else if (success) {\n revert AddressEmptyCode(target);\n } else if (LowLevelCall.returnDataSize() > 0) {\n LowLevelCall.bubbleRevert();\n } else {\n revert Errors.FailedCall();\n }\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n bool success = LowLevelCall.staticcallNoReturn(target, data);\n if (success && (LowLevelCall.returnDataSize() > 0 || target.code.length > 0)) {\n return LowLevelCall.returnData();\n } else if (success) {\n revert AddressEmptyCode(target);\n } else if (LowLevelCall.returnDataSize() > 0) {\n LowLevelCall.bubbleRevert();\n } else {\n revert Errors.FailedCall();\n }\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n bool success = LowLevelCall.delegatecallNoReturn(target, data);\n if (success && (LowLevelCall.returnDataSize() > 0 || target.code.length > 0)) {\n return LowLevelCall.returnData();\n } else if (success) {\n revert AddressEmptyCode(target);\n } else if (LowLevelCall.returnDataSize() > 0) {\n LowLevelCall.bubbleRevert();\n } else {\n revert Errors.FailedCall();\n }\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case\n * of an unsuccessful call.\n *\n * NOTE: This function is DEPRECATED and may be removed in the next major release.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (success && (returndata.length > 0 || target.code.length > 0)) {\n return returndata;\n } else if (success) {\n revert AddressEmptyCode(target);\n } else if (returndata.length > 0) {\n LowLevelCall.bubbleRevert(returndata);\n } else {\n revert Errors.FailedCall();\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {Errors.FailedCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else if (returndata.length > 0) {\n LowLevelCall.bubbleRevert(returndata);\n } else {\n revert Errors.FailedCall();\n }\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/Multicall.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.5.0) (utils/Multicall.sol)\n\npragma solidity ^0.8.20;\n\nimport {Address} from \"./Address.sol\";\nimport {Context} from \"./Context.sol\";\n\n/**\n * @dev Provides a function to batch together multiple calls in a single external call.\n *\n * Consider any assumption about calldata validation performed by the sender may be violated if it's not especially\n * careful about sending transactions invoking {multicall}. For example, a relay address that filters function\n * selectors won't filter calls nested within a {multicall} operation.\n *\n * NOTE: Since 5.0.1 and 4.9.4, this contract identifies non-canonical contexts (i.e. `msg.sender` is not {Context-_msgSender}).\n * If a non-canonical context is identified, the following self `delegatecall` appends the last bytes of `msg.data`\n * to the subcall. This makes it safe to use with {ERC2771Context}. Contexts that don't affect the resolution of\n * {Context-_msgSender} are not propagated to subcalls.\n */\nabstract contract Multicall is Context {\n /**\n * @dev Receives and executes a batch of function calls on this contract.\n * @custom:oz-upgrades-unsafe-allow-reachable delegatecall\n */\n function multicall(bytes[] calldata data) public virtual returns (bytes[] memory results) {\n bytes memory context = msg.sender == _msgSender()\n ? new bytes(0)\n : msg.data[msg.data.length - _contextSuffixLength():];\n\n results = new bytes[](data.length);\n for (uint256 i = 0; i < data.length; i++) {\n results[i] = Address.functionDelegateCall(address(this), bytes.concat(data[i], context));\n }\n return results;\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/math/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.6.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\nimport {Panic} from \"../Panic.sol\";\nimport {SafeCast} from \"./SafeCast.sol\";\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n enum Rounding {\n Floor, // Toward negative infinity\n Ceil, // Toward positive infinity\n Trunc, // Toward zero\n Expand // Away from zero\n }\n\n /**\n * @dev Return the 512-bit addition of two uint256.\n *\n * The result is stored in two 256 variables such that sum = high * 2\u00b2\u2075\u2076 + low.\n */\n function add512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {\n assembly (\"memory-safe\") {\n low := add(a, b)\n high := lt(low, a)\n }\n }\n\n /**\n * @dev Return the 512-bit multiplication of two uint256.\n *\n * The result is stored in two 256 variables such that product = high * 2\u00b2\u2075\u2076 + low.\n */\n function mul512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {\n // 512-bit multiply [high low] = x * y. Compute the product mod 2\u00b2\u2075\u2076 and mod 2\u00b2\u2075\u2076 - 1, then use\n // the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = high * 2\u00b2\u2075\u2076 + low.\n assembly (\"memory-safe\") {\n let mm := mulmod(a, b, not(0))\n low := mul(a, b)\n high := sub(sub(mm, low), lt(mm, low))\n }\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, with a success flag (no overflow).\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n unchecked {\n uint256 c = a + b;\n success = c >= a;\n result = c * SafeCast.toUint(success);\n }\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, with a success flag (no overflow).\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n unchecked {\n uint256 c = a - b;\n success = c <= a;\n result = c * SafeCast.toUint(success);\n }\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with a success flag (no overflow).\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n unchecked {\n uint256 c = a * b;\n assembly (\"memory-safe\") {\n // Only true when the multiplication doesn't overflow\n // (c / a == b) || (a == 0)\n success := or(eq(div(c, a), b), iszero(a))\n }\n // equivalent to: success ? c : 0\n result = c * SafeCast.toUint(success);\n }\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a success flag (no division by zero).\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n unchecked {\n success = b > 0;\n assembly (\"memory-safe\") {\n // The `DIV` opcode returns zero when the denominator is 0.\n result := div(a, b)\n }\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n unchecked {\n success = b > 0;\n assembly (\"memory-safe\") {\n // The `MOD` opcode returns zero when the denominator is 0.\n result := mod(a, b)\n }\n }\n }\n\n /**\n * @dev Unsigned saturating addition, bounds to `2\u00b2\u2075\u2076 - 1` instead of overflowing.\n */\n function saturatingAdd(uint256 a, uint256 b) internal pure returns (uint256) {\n (bool success, uint256 result) = tryAdd(a, b);\n return ternary(success, result, type(uint256).max);\n }\n\n /**\n * @dev Unsigned saturating subtraction, bounds to zero instead of overflowing.\n */\n function saturatingSub(uint256 a, uint256 b) internal pure returns (uint256) {\n (, uint256 result) = trySub(a, b);\n return result;\n }\n\n /**\n * @dev Unsigned saturating multiplication, bounds to `2\u00b2\u2075\u2076 - 1` instead of overflowing.\n */\n function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256) {\n (bool success, uint256 result) = tryMul(a, b);\n return ternary(success, result, type(uint256).max);\n }\n\n /**\n * @dev Branchless ternary evaluation for `condition ? a : b`. Gas costs are constant.\n *\n * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.\n * However, the compiler may optimize Solidity ternary operations (i.e. `condition ? a : b`) to only compute\n * one branch when needed, making this function more expensive.\n */\n function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {\n unchecked {\n // branchless ternary works because:\n // b ^ (a ^ b) == a\n // b ^ 0 == b\n return b ^ ((a ^ b) * SafeCast.toUint(condition));\n }\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return ternary(a > b, a, b);\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return ternary(a < b, a, b);\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n unchecked {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds towards infinity instead\n * of rounding towards zero.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n if (b == 0) {\n // Guarantee the same behavior as in a regular Solidity division.\n Panic.panic(Panic.DIVISION_BY_ZERO);\n }\n\n // The following calculation ensures accurate ceiling division without overflow.\n // Since a is non-zero, (a - 1) / b will not overflow.\n // The largest possible result occurs when (a - 1) / b is type(uint256).max,\n // but the largest value we can obtain is type(uint256).max - 1, which happens\n // when a = type(uint256).max and b = 1.\n unchecked {\n return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);\n }\n }\n\n /**\n * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n * denominator == 0.\n *\n * Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n * Uniswap Labs also under MIT license.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n (uint256 high, uint256 low) = mul512(x, y);\n\n // Handle non-overflow cases, 256 by 256 division.\n if (high == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return low / denominator;\n }\n\n // Make sure the result is less than 2\u00b2\u2075\u2076. Also prevents denominator == 0.\n if (denominator <= high) {\n Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));\n }\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [high low].\n uint256 remainder;\n assembly (\"memory-safe\") {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n high := sub(high, gt(remainder, low))\n low := sub(low, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n uint256 twos = denominator & (0 - denominator);\n assembly (\"memory-safe\") {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [high low] by twos.\n low := div(low, twos)\n\n // Flip twos such that it is 2\u00b2\u2075\u2076 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from high into low.\n low |= high * twos;\n\n // Invert denominator mod 2\u00b2\u2075\u2076. Now that denominator is an odd number, it has an inverse modulo 2\u00b2\u2075\u2076 such\n // that denominator * inv \u2261 1 mod 2\u00b2\u2075\u2076. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv \u2261 1 mod 2\u2074.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\n // works in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2\u2078\n inverse *= 2 - denominator * inverse; // inverse mod 2\u00b9\u2076\n inverse *= 2 - denominator * inverse; // inverse mod 2\u00b3\u00b2\n inverse *= 2 - denominator * inverse; // inverse mod 2\u2076\u2074\n inverse *= 2 - denominator * inverse; // inverse mod 2\u00b9\u00b2\u2078\n inverse *= 2 - denominator * inverse; // inverse mod 2\u00b2\u2075\u2076\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2\u00b2\u2075\u2076. Since the preconditions guarantee that the outcome is\n // less than 2\u00b2\u2075\u2076, this is the final result. We don't need to compute the high bits of the result and high\n // is no longer required.\n result = low * inverse;\n return result;\n }\n }\n\n /**\n * @dev Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);\n }\n\n /**\n * @dev Calculates floor(x * y >> n) with full precision. Throws if result overflows a uint256.\n */\n function mulShr(uint256 x, uint256 y, uint8 n) internal pure returns (uint256 result) {\n unchecked {\n (uint256 high, uint256 low) = mul512(x, y);\n if (high >= 1 << n) {\n Panic.panic(Panic.UNDER_OVERFLOW);\n }\n return (high << (256 - n)) | (low >> n);\n }\n }\n\n /**\n * @dev Calculates x * y >> n with full precision, following the selected rounding direction.\n */\n function mulShr(uint256 x, uint256 y, uint8 n, Rounding rounding) internal pure returns (uint256) {\n return mulShr(x, y, n) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, 1 << n) > 0);\n }\n\n /**\n * @dev Calculate the modular multiplicative inverse of a number in Z/nZ.\n *\n * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.\n * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.\n *\n * If the input value is not inversible, 0 is returned.\n *\n * 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\n * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.\n */\n function invMod(uint256 a, uint256 n) internal pure returns (uint256) {\n unchecked {\n if (n == 0) return 0;\n\n // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)\n // Used to compute integers x and y such that: ax + ny = gcd(a, n).\n // When the gcd is 1, then the inverse of a modulo n exists and it's x.\n // ax + ny = 1\n // ax = 1 + (-y)n\n // ax \u2261 1 (mod n) # x is the inverse of a modulo n\n\n // If the remainder is 0 the gcd is n right away.\n uint256 remainder = a % n;\n uint256 gcd = n;\n\n // Therefore the initial coefficients are:\n // ax + ny = gcd(a, n) = n\n // 0a + 1n = n\n int256 x = 0;\n int256 y = 1;\n\n while (remainder != 0) {\n uint256 quotient = gcd / remainder;\n\n (gcd, remainder) = (\n // The old remainder is the next gcd to try.\n remainder,\n // Compute the next remainder.\n // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd\n // where gcd is at most n (capped to type(uint256).max)\n gcd - remainder * quotient\n );\n\n (x, y) = (\n // Increment the coefficient of a.\n y,\n // Decrement the coefficient of n.\n // Can overflow, but the result is casted to uint256 so that the\n // next value of y is \"wrapped around\" to a value between 0 and n - 1.\n x - y * int256(quotient)\n );\n }\n\n if (gcd != 1) return 0; // No inverse exists.\n return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.\n }\n }\n\n /**\n * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.\n *\n * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is\n * prime, then `a**(p-1) \u2261 1 mod p`. As a consequence, we have `a * a**(p-2) \u2261 1 mod p`, which means that\n * `a**(p-2)` is the modular multiplicative inverse of a in Fp.\n *\n * NOTE: this function does NOT check that `p` is a prime greater than `2`.\n */\n function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {\n unchecked {\n return Math.modExp(a, p - 2, p);\n }\n }\n\n /**\n * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)\n *\n * Requirements:\n * - modulus can't be zero\n * - underlying staticcall to precompile must succeed\n *\n * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make\n * sure the chain you're using it on supports the precompiled contract for modular exponentiation\n * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,\n * the underlying function will succeed given the lack of a revert, but the result may be incorrectly\n * interpreted as 0.\n */\n function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {\n (bool success, uint256 result) = tryModExp(b, e, m);\n if (!success) {\n Panic.panic(Panic.DIVISION_BY_ZERO);\n }\n return result;\n }\n\n /**\n * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).\n * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying\n * to operate modulo 0 or if the underlying precompile reverted.\n *\n * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain\n * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in\n * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack\n * of a revert, but the result may be incorrectly interpreted as 0.\n */\n function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {\n if (m == 0) return (false, 0);\n assembly (\"memory-safe\") {\n let ptr := mload(0x40)\n // | Offset | Content | Content (Hex) |\n // |-----------|------------|--------------------------------------------------------------------|\n // | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n // | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n // | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n // | 0x60:0x7f | value of b | 0x<.............................................................b> |\n // | 0x80:0x9f | value of e | 0x<.............................................................e> |\n // | 0xa0:0xbf | value of m | 0x<.............................................................m> |\n mstore(ptr, 0x20)\n mstore(add(ptr, 0x20), 0x20)\n mstore(add(ptr, 0x40), 0x20)\n mstore(add(ptr, 0x60), b)\n mstore(add(ptr, 0x80), e)\n mstore(add(ptr, 0xa0), m)\n\n // Given the result < m, it's guaranteed to fit in 32 bytes,\n // so we can use the memory scratch space located at offset 0.\n success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)\n result := mload(0x00)\n }\n }\n\n /**\n * @dev Variant of {modExp} that supports inputs of arbitrary length.\n */\n function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {\n (bool success, bytes memory result) = tryModExp(b, e, m);\n if (!success) {\n Panic.panic(Panic.DIVISION_BY_ZERO);\n }\n return result;\n }\n\n /**\n * @dev Variant of {tryModExp} that supports inputs of arbitrary length.\n */\n function tryModExp(\n bytes memory b,\n bytes memory e,\n bytes memory m\n ) internal view returns (bool success, bytes memory result) {\n if (_zeroBytes(m)) return (false, new bytes(0));\n\n uint256 mLen = m.length;\n\n // Encode call args in result and move the free memory pointer\n result = abi.encodePacked(b.length, e.length, mLen, b, e, m);\n\n assembly (\"memory-safe\") {\n let dataPtr := add(result, 0x20)\n // Write result on top of args to avoid allocating extra memory.\n success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)\n // Overwrite the length.\n // result.length > returndatasize() is guaranteed because returndatasize() == m.length\n mstore(result, mLen)\n // Set the memory pointer after the returned data.\n mstore(0x40, add(dataPtr, mLen))\n }\n }\n\n /**\n * @dev Returns whether the provided byte array is zero.\n */\n function _zeroBytes(bytes memory buffer) private pure returns (bool) {\n uint256 chunk;\n for (uint256 i = 0; i < buffer.length; i += 0x20) {\n // See _unsafeReadBytesOffset from utils/Bytes.sol\n assembly (\"memory-safe\") {\n chunk := mload(add(add(buffer, 0x20), i))\n }\n if (chunk >> (8 * saturatingSub(i + 0x20, buffer.length)) != 0) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\n * towards zero.\n *\n * This method is based on Newton's method for computing square roots; the algorithm is restricted to only\n * using integer operations.\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n unchecked {\n // Take care of easy edge cases when a == 0 or a == 1\n if (a <= 1) {\n return a;\n }\n\n // In this function, we use Newton's method to get a root of `f(x) := x\u00b2 - a`. It involves building a\n // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between\n // the current value as `\u03b5_n = | x_n - sqrt(a) |`.\n //\n // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root\n // of the target. (i.e. `2**(e-1) \u2264 sqrt(a) < 2**e`). We know that `e \u2264 128` because `(2\u00b9\u00b2\u2078)\u00b2 = 2\u00b2\u2075\u2076` is\n // bigger than any uint256.\n //\n // By noticing that\n // `2**(e-1) \u2264 sqrt(a) < 2**e \u2192 (2**(e-1))\u00b2 \u2264 a < (2**e)\u00b2 \u2192 2**(2*e-2) \u2264 a < 2**(2*e)`\n // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar\n // to the msb function.\n uint256 aa = a;\n uint256 xn = 1;\n\n if (aa >= (1 << 128)) {\n aa >>= 128;\n xn <<= 64;\n }\n if (aa >= (1 << 64)) {\n aa >>= 64;\n xn <<= 32;\n }\n if (aa >= (1 << 32)) {\n aa >>= 32;\n xn <<= 16;\n }\n if (aa >= (1 << 16)) {\n aa >>= 16;\n xn <<= 8;\n }\n if (aa >= (1 << 8)) {\n aa >>= 8;\n xn <<= 4;\n }\n if (aa >= (1 << 4)) {\n aa >>= 4;\n xn <<= 2;\n }\n if (aa >= (1 << 2)) {\n xn <<= 1;\n }\n\n // We now have x_n such that `x_n = 2**(e-1) \u2264 sqrt(a) < 2**e = 2 * x_n`. This implies \u03b5_n \u2264 2**(e-1).\n //\n // We can refine our estimation by noticing that the middle of that interval minimizes the error.\n // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to \u03b5_n \u2264 2**(e-2).\n // This is going to be our x_0 (and \u03b5_0)\n xn = (3 * xn) >> 1; // \u03b5_0 := | x_0 - sqrt(a) | \u2264 2**(e-2)\n\n // From here, Newton's method give us:\n // x_{n+1} = (x_n + a / x_n) / 2\n //\n // One should note that:\n // x_{n+1}\u00b2 - a = ((x_n + a / x_n) / 2)\u00b2 - a\n // = ((x_n\u00b2 + a) / (2 * x_n))\u00b2 - a\n // = (x_n\u2074 + 2 * a * x_n\u00b2 + a\u00b2) / (4 * x_n\u00b2) - a\n // = (x_n\u2074 + 2 * a * x_n\u00b2 + a\u00b2 - 4 * a * x_n\u00b2) / (4 * x_n\u00b2)\n // = (x_n\u2074 - 2 * a * x_n\u00b2 + a\u00b2) / (4 * x_n\u00b2)\n // = (x_n\u00b2 - a)\u00b2 / (2 * x_n)\u00b2\n // = ((x_n\u00b2 - a) / (2 * x_n))\u00b2\n // \u2265 0\n // Which proves that for all n \u2265 1, sqrt(a) \u2264 x_n\n //\n // This gives us the proof of quadratic convergence of the sequence:\n // \u03b5_{n+1} = | x_{n+1} - sqrt(a) |\n // = | (x_n + a / x_n) / 2 - sqrt(a) |\n // = | (x_n\u00b2 + a - 2*x_n*sqrt(a)) / (2 * x_n) |\n // = | (x_n - sqrt(a))\u00b2 / (2 * x_n) |\n // = | \u03b5_n\u00b2 / (2 * x_n) |\n // = \u03b5_n\u00b2 / | (2 * x_n) |\n //\n // For the first iteration, we have a special case where x_0 is known:\n // \u03b5_1 = \u03b5_0\u00b2 / | (2 * x_0) |\n // \u2264 (2**(e-2))\u00b2 / (2 * (2**(e-1) + 2**(e-2)))\n // \u2264 2**(2*e-4) / (3 * 2**(e-1))\n // \u2264 2**(e-3) / 3\n // \u2264 2**(e-3-log2(3))\n // \u2264 2**(e-4.5)\n //\n // For the following iterations, we use the fact that, 2**(e-1) \u2264 sqrt(a) \u2264 x_n:\n // \u03b5_{n+1} = \u03b5_n\u00b2 / | (2 * x_n) |\n // \u2264 (2**(e-k))\u00b2 / (2 * 2**(e-1))\n // \u2264 2**(2*e-2*k) / 2**e\n // \u2264 2**(e-2*k)\n xn = (xn + a / xn) >> 1; // \u03b5_1 := | x_1 - sqrt(a) | \u2264 2**(e-4.5) -- special case, see above\n xn = (xn + a / xn) >> 1; // \u03b5_2 := | x_2 - sqrt(a) | \u2264 2**(e-9) -- general case with k = 4.5\n xn = (xn + a / xn) >> 1; // \u03b5_3 := | x_3 - sqrt(a) | \u2264 2**(e-18) -- general case with k = 9\n xn = (xn + a / xn) >> 1; // \u03b5_4 := | x_4 - sqrt(a) | \u2264 2**(e-36) -- general case with k = 18\n xn = (xn + a / xn) >> 1; // \u03b5_5 := | x_5 - sqrt(a) | \u2264 2**(e-72) -- general case with k = 36\n xn = (xn + a / xn) >> 1; // \u03b5_6 := | x_6 - sqrt(a) | \u2264 2**(e-144) -- general case with k = 72\n\n // Because e \u2264 128 (as discussed during the first estimation phase), we know have reached a precision\n // \u03b5_6 \u2264 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either\n // sqrt(a) or sqrt(a) + 1.\n return xn - SafeCast.toUint(xn > a / xn);\n }\n }\n\n /**\n * @dev Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);\n }\n }\n\n /**\n * @dev Return the log in base 2 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log2(uint256 x) internal pure returns (uint256 r) {\n // If value has upper 128 bits set, log2 result is at least 128\n r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;\n // If upper 64 bits of 128-bit half set, add 64 to result\n r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;\n // If upper 32 bits of 64-bit half set, add 32 to result\n r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;\n // If upper 16 bits of 32-bit half set, add 16 to result\n r |= SafeCast.toUint((x >> r) > 0xffff) << 4;\n // If upper 8 bits of 16-bit half set, add 8 to result\n r |= SafeCast.toUint((x >> r) > 0xff) << 3;\n // If upper 4 bits of 8-bit half set, add 4 to result\n r |= SafeCast.toUint((x >> r) > 0xf) << 2;\n\n // Shifts value right by the current result and use it as an index into this lookup table:\n //\n // | x (4 bits) | index | table[index] = MSB position |\n // |------------|---------|-----------------------------|\n // | 0000 | 0 | table[0] = 0 |\n // | 0001 | 1 | table[1] = 0 |\n // | 0010 | 2 | table[2] = 1 |\n // | 0011 | 3 | table[3] = 1 |\n // | 0100 | 4 | table[4] = 2 |\n // | 0101 | 5 | table[5] = 2 |\n // | 0110 | 6 | table[6] = 2 |\n // | 0111 | 7 | table[7] = 2 |\n // | 1000 | 8 | table[8] = 3 |\n // | 1001 | 9 | table[9] = 3 |\n // | 1010 | 10 | table[10] = 3 |\n // | 1011 | 11 | table[11] = 3 |\n // | 1100 | 12 | table[12] = 3 |\n // | 1101 | 13 | table[13] = 3 |\n // | 1110 | 14 | table[14] = 3 |\n // | 1111 | 15 | table[15] = 3 |\n //\n // The lookup table is represented as a 32-byte value with the MSB positions for 0-15 in the first 16 bytes (most significant half).\n assembly (\"memory-safe\") {\n r := or(r, byte(shr(r, x), 0x0000010102020202030303030303030300000000000000000000000000000000))\n }\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);\n }\n }\n\n /**\n * @dev Return the log in base 10 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);\n }\n }\n\n /**\n * @dev Return the log in base 256 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 x) internal pure returns (uint256 r) {\n // If value has upper 128 bits set, log2 result is at least 128\n r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;\n // If upper 64 bits of 128-bit half set, add 64 to result\n r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;\n // If upper 32 bits of 64-bit half set, add 32 to result\n r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;\n // If upper 16 bits of 32-bit half set, add 16 to result\n r |= SafeCast.toUint((x >> r) > 0xffff) << 4;\n // Add 1 if upper 8 bits of 16-bit half set, and divide accumulated result by 8\n return (r >> 3) | SafeCast.toUint((x >> r) > 0xff);\n }\n\n /**\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);\n }\n }\n\n /**\n * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n */\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n return uint8(rounding) % 2 == 1;\n }\n\n /**\n * @dev Counts the number of leading zero bits in a uint256.\n */\n function clz(uint256 x) internal pure returns (uint256) {\n return ternary(x == 0, 256, 255 - log2(x));\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/types/Time.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.5.0) (utils/types/Time.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"../math/Math.sol\";\nimport {SafeCast} from \"../math/SafeCast.sol\";\n\n/**\n * @dev This library provides helpers for manipulating time-related objects.\n *\n * It uses the following types:\n * - `uint48` for timepoints\n * - `uint32` for durations\n *\n * While the library doesn't provide specific types for timepoints and duration, it does provide:\n * - a `Delay` type to represent duration that can be programmed to change value automatically at a given point\n * - additional helper functions\n */\nlibrary Time {\n using Time for *;\n\n /**\n * @dev Get the block timestamp as a Timepoint.\n */\n function timestamp() internal view returns (uint48) {\n return SafeCast.toUint48(block.timestamp);\n }\n\n /**\n * @dev Get the block number as a Timepoint.\n */\n function blockNumber() internal view returns (uint48) {\n return SafeCast.toUint48(block.number);\n }\n\n // ==================================================== Delay =====================================================\n /**\n * @dev A `Delay` is a uint32 duration that can be programmed to change value automatically at a given point in the\n * future. The \"effect\" timepoint describes when the transition happens from the \"old\" value to the \"new\" value.\n * This allows updating the delay applied to some operation while keeping some guarantees.\n *\n * In particular, the {update} function guarantees that if the delay is reduced, the old delay still applies for\n * some time. For example if the delay is currently 7 days to do an upgrade, the admin should not be able to set\n * the delay to 0 and upgrade immediately. If the admin wants to reduce the delay, the old delay (7 days) should\n * still apply for some time.\n *\n *\n * The `Delay` type is 112 bits long, and packs the following:\n *\n * ```\n * | [uint48]: effect date (timepoint)\n * | | [uint32]: value before (duration)\n * \u2193 \u2193 \u2193 [uint32]: value after (duration)\n * 0xAAAAAAAAAAAABBBBBBBBCCCCCCCC\n * ```\n *\n * NOTE: The {get} and {withUpdate} functions operate using timestamps. Block number based delays are not currently\n * supported.\n */\n type Delay is uint112;\n\n /**\n * @dev Wrap a duration into a Delay to add the one-step \"update in the future\" feature\n */\n function toDelay(uint32 duration) internal pure returns (Delay) {\n return Delay.wrap(duration);\n }\n\n /**\n * @dev Get the value at a given timepoint plus the pending value and effect timepoint if there is a scheduled\n * change after this timepoint. If the effect timepoint is 0, then the pending value should not be considered.\n */\n function _getFullAt(\n Delay self,\n uint48 timepoint\n ) private pure returns (uint32 valueBefore, uint32 valueAfter, uint48 effect) {\n (valueBefore, valueAfter, effect) = self.unpack();\n return effect <= timepoint ? (valueAfter, 0, 0) : (valueBefore, valueAfter, effect);\n }\n\n /**\n * @dev Get the current value plus the pending value and effect timepoint if there is a scheduled change. If the\n * effect timepoint is 0, then the pending value should not be considered.\n */\n function getFull(Delay self) internal view returns (uint32 valueBefore, uint32 valueAfter, uint48 effect) {\n return _getFullAt(self, timestamp());\n }\n\n /**\n * @dev Get the current value.\n */\n function get(Delay self) internal view returns (uint32) {\n (uint32 delay, , ) = self.getFull();\n return delay;\n }\n\n /**\n * @dev Update a Delay object so that it takes a new duration after a timepoint that is automatically computed to\n * enforce the old delay at the moment of the update. Returns the updated Delay object and the timestamp when the\n * new delay becomes effective.\n */\n function withUpdate(\n Delay self,\n uint32 newValue,\n uint32 minSetback\n ) internal view returns (Delay updatedDelay, uint48 effect) {\n uint32 value = self.get();\n uint32 setback = uint32(Math.max(minSetback, value > newValue ? value - newValue : 0));\n effect = timestamp() + setback;\n return (pack(value, newValue, effect), effect);\n }\n\n /**\n * @dev Split a delay into its components: valueBefore, valueAfter and effect (transition timepoint).\n */\n function unpack(Delay self) internal pure returns (uint32 valueBefore, uint32 valueAfter, uint48 effect) {\n uint112 raw = Delay.unwrap(self);\n\n valueAfter = uint32(raw);\n valueBefore = uint32(raw >> 32);\n effect = uint48(raw >> 64);\n\n return (valueBefore, valueAfter, effect);\n }\n\n /**\n * @dev pack the components into a Delay object.\n */\n function pack(uint32 valueBefore, uint32 valueAfter, uint48 effect) internal pure returns (Delay) {\n return Delay.wrap((uint112(effect) << 64) | (uint112(valueBefore) << 32) | uint112(valueAfter));\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/cryptography/Hashes.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.3.0) (utils/cryptography/Hashes.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Library of standard hash functions.\n *\n * _Available since v5.1._\n */\nlibrary Hashes {\n /**\n * @dev Commutative Keccak256 hash of a sorted pair of bytes32. Frequently used when working with merkle proofs.\n *\n * NOTE: Equivalent to the `standardNodeHash` in our https://github.com/OpenZeppelin/merkle-tree[JavaScript library].\n */\n function commutativeKeccak256(bytes32 a, bytes32 b) internal pure returns (bytes32) {\n return a < b ? efficientKeccak256(a, b) : efficientKeccak256(b, a);\n }\n\n /**\n * @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory.\n */\n function efficientKeccak256(bytes32 a, bytes32 b) internal pure returns (bytes32 value) {\n assembly (\"memory-safe\") {\n mstore(0x00, a)\n mstore(0x20, b)\n value := keccak256(0x00, 0x40)\n }\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Collection of common custom errors used in multiple contracts\n *\n * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.\n * It is recommended to avoid relying on the error API for critical functionality.\n *\n * _Available since v5.1._\n */\nlibrary Errors {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error InsufficientBalance(uint256 balance, uint256 needed);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedCall();\n\n /**\n * @dev The deployment failed.\n */\n error FailedDeployment();\n\n /**\n * @dev A necessary precompile is missing.\n */\n error MissingPrecompile(address);\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/LowLevelCall.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.6.0) (utils/LowLevelCall.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Library of low level call functions that implement different calling strategies to deal with the return data.\n *\n * WARNING: Using this library requires an advanced understanding of Solidity and how the EVM works. It is recommended\n * to use the {Address} library instead.\n */\nlibrary LowLevelCall {\n /// @dev Performs a Solidity function call using a low level `call` and ignoring the return data.\n function callNoReturn(address target, bytes memory data) internal returns (bool success) {\n return callNoReturn(target, 0, data);\n }\n\n /// @dev Same as {callNoReturn-address-bytes}, but allows specifying the value to be sent in the call.\n function callNoReturn(address target, uint256 value, bytes memory data) internal returns (bool success) {\n assembly (\"memory-safe\") {\n success := call(gas(), target, value, add(data, 0x20), mload(data), 0x00, 0x00)\n }\n }\n\n /// @dev Performs a Solidity function call using a low level `call` and returns the first 64 bytes of the result\n /// in the scratch space of memory. Useful for functions that return a tuple with two single-word values.\n ///\n /// WARNING: Do not assume that the results are zero if `success` is false. Memory can be already allocated\n /// and this function doesn't zero it out.\n function callReturn64Bytes(\n address target,\n bytes memory data\n ) internal returns (bool success, bytes32 result1, bytes32 result2) {\n return callReturn64Bytes(target, 0, data);\n }\n\n /// @dev Same as {callReturn64Bytes-address-bytes}, but allows specifying the value to be sent in the call.\n function callReturn64Bytes(\n address target,\n uint256 value,\n bytes memory data\n ) internal returns (bool success, bytes32 result1, bytes32 result2) {\n assembly (\"memory-safe\") {\n success := call(gas(), target, value, add(data, 0x20), mload(data), 0x00, 0x40)\n result1 := mload(0x00)\n result2 := mload(0x20)\n }\n }\n\n /// @dev Performs a Solidity function call using a low level `staticcall` and ignoring the return data.\n function staticcallNoReturn(address target, bytes memory data) internal view returns (bool success) {\n assembly (\"memory-safe\") {\n success := staticcall(gas(), target, add(data, 0x20), mload(data), 0x00, 0x00)\n }\n }\n\n /// @dev Performs a Solidity function call using a low level `staticcall` and returns the first 64 bytes of the result\n /// in the scratch space of memory. Useful for functions that return a tuple with two single-word values.\n ///\n /// WARNING: Do not assume that the results are zero if `success` is false. Memory can be already allocated\n /// and this function doesn't zero it out.\n function staticcallReturn64Bytes(\n address target,\n bytes memory data\n ) internal view returns (bool success, bytes32 result1, bytes32 result2) {\n assembly (\"memory-safe\") {\n success := staticcall(gas(), target, add(data, 0x20), mload(data), 0x00, 0x40)\n result1 := mload(0x00)\n result2 := mload(0x20)\n }\n }\n\n /// @dev Performs a Solidity function call using a low level `delegatecall` and ignoring the return data.\n function delegatecallNoReturn(address target, bytes memory data) internal returns (bool success) {\n assembly (\"memory-safe\") {\n success := delegatecall(gas(), target, add(data, 0x20), mload(data), 0x00, 0x00)\n }\n }\n\n /// @dev Performs a Solidity function call using a low level `delegatecall` and returns the first 64 bytes of the result\n /// in the scratch space of memory. Useful for functions that return a tuple with two single-word values.\n ///\n /// WARNING: Do not assume that the results are zero if `success` is false. Memory can be already allocated\n /// and this function doesn't zero it out.\n function delegatecallReturn64Bytes(\n address target,\n bytes memory data\n ) internal returns (bool success, bytes32 result1, bytes32 result2) {\n assembly (\"memory-safe\") {\n success := delegatecall(gas(), target, add(data, 0x20), mload(data), 0x00, 0x40)\n result1 := mload(0x00)\n result2 := mload(0x20)\n }\n }\n\n /// @dev Returns the size of the return data buffer.\n function returnDataSize() internal pure returns (uint256 size) {\n assembly (\"memory-safe\") {\n size := returndatasize()\n }\n }\n\n /// @dev Returns a buffer containing the return data from the last call.\n function returnData() internal pure returns (bytes memory result) {\n assembly (\"memory-safe\") {\n result := mload(0x40)\n mstore(result, returndatasize())\n returndatacopy(add(result, 0x20), 0x00, returndatasize())\n mstore(0x40, add(result, add(0x20, returndatasize())))\n }\n }\n\n /// @dev Revert with the return data from the last call.\n function bubbleRevert() internal pure {\n assembly (\"memory-safe\") {\n let fmp := mload(0x40)\n returndatacopy(fmp, 0x00, returndatasize())\n revert(fmp, returndatasize())\n }\n }\n\n function bubbleRevert(bytes memory returndata) internal pure {\n assembly (\"memory-safe\") {\n revert(add(returndata, 0x20), mload(returndata))\n }\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/Panic.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Helper library for emitting standardized panic codes.\n *\n * ```solidity\n * contract Example {\n * using Panic for uint256;\n *\n * // Use any of the declared internal constants\n * function foo() { Panic.GENERIC.panic(); }\n *\n * // Alternatively\n * function foo() { Panic.panic(Panic.GENERIC); }\n * }\n * ```\n *\n * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].\n *\n * _Available since v5.1._\n */\n// slither-disable-next-line unused-state\nlibrary Panic {\n /// @dev generic / unspecified error\n uint256 internal constant GENERIC = 0x00;\n /// @dev used by the assert() builtin\n uint256 internal constant ASSERT = 0x01;\n /// @dev arithmetic underflow or overflow\n uint256 internal constant UNDER_OVERFLOW = 0x11;\n /// @dev division or modulo by zero\n uint256 internal constant DIVISION_BY_ZERO = 0x12;\n /// @dev enum conversion error\n uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;\n /// @dev invalid encoding in storage\n uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;\n /// @dev empty array pop\n uint256 internal constant EMPTY_ARRAY_POP = 0x31;\n /// @dev array out of bounds access\n uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;\n /// @dev resource error (too large allocation or too large array)\n uint256 internal constant RESOURCE_ERROR = 0x41;\n /// @dev calling invalid internal function\n uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;\n\n /// @dev Reverts with a panic code. Recommended to use with\n /// the internal constants with predefined codes.\n function panic(uint256 code) internal pure {\n assembly (\"memory-safe\") {\n mstore(0x00, 0x4e487b71)\n mstore(0x20, code)\n revert(0x1c, 0x24)\n }\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/math/SafeCast.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.6.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeCast {\n /**\n * @dev Value doesn't fit in a uint of `bits` size.\n */\n error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);\n\n /**\n * @dev An int value doesn't fit in a uint of `bits` size.\n */\n error SafeCastOverflowedIntToUint(int256 value);\n\n /**\n * @dev Value doesn't fit in an int of `bits` size.\n */\n error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);\n\n /**\n * @dev A uint value doesn't fit in an int of `bits` size.\n */\n error SafeCastOverflowedUintToInt(uint256 value);\n\n /**\n * @dev Returns the downcasted uint248 from uint256, reverting on\n * overflow (when the input is greater than largest uint248).\n *\n * Counterpart to Solidity's `uint248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n if (value > type(uint248).max) {\n revert SafeCastOverflowedUintDowncast(248, value);\n }\n return uint248(value);\n }\n\n /**\n * @dev Returns the downcasted uint240 from uint256, reverting on\n * overflow (when the input is greater than largest uint240).\n *\n * Counterpart to Solidity's `uint240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n if (value > type(uint240).max) {\n revert SafeCastOverflowedUintDowncast(240, value);\n }\n return uint240(value);\n }\n\n /**\n * @dev Returns the downcasted uint232 from uint256, reverting on\n * overflow (when the input is greater than largest uint232).\n *\n * Counterpart to Solidity's `uint232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n if (value > type(uint232).max) {\n revert SafeCastOverflowedUintDowncast(232, value);\n }\n return uint232(value);\n }\n\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n if (value > type(uint224).max) {\n revert SafeCastOverflowedUintDowncast(224, value);\n }\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint216 from uint256, reverting on\n * overflow (when the input is greater than largest uint216).\n *\n * Counterpart to Solidity's `uint216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n if (value > type(uint216).max) {\n revert SafeCastOverflowedUintDowncast(216, value);\n }\n return uint216(value);\n }\n\n /**\n * @dev Returns the downcasted uint208 from uint256, reverting on\n * overflow (when the input is greater than largest uint208).\n *\n * Counterpart to Solidity's `uint208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n if (value > type(uint208).max) {\n revert SafeCastOverflowedUintDowncast(208, value);\n }\n return uint208(value);\n }\n\n /**\n * @dev Returns the downcasted uint200 from uint256, reverting on\n * overflow (when the input is greater than largest uint200).\n *\n * Counterpart to Solidity's `uint200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n if (value > type(uint200).max) {\n revert SafeCastOverflowedUintDowncast(200, value);\n }\n return uint200(value);\n }\n\n /**\n * @dev Returns the downcasted uint192 from uint256, reverting on\n * overflow (when the input is greater than largest uint192).\n *\n * Counterpart to Solidity's `uint192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n if (value > type(uint192).max) {\n revert SafeCastOverflowedUintDowncast(192, value);\n }\n return uint192(value);\n }\n\n /**\n * @dev Returns the downcasted uint184 from uint256, reverting on\n * overflow (when the input is greater than largest uint184).\n *\n * Counterpart to Solidity's `uint184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n if (value > type(uint184).max) {\n revert SafeCastOverflowedUintDowncast(184, value);\n }\n return uint184(value);\n }\n\n /**\n * @dev Returns the downcasted uint176 from uint256, reverting on\n * overflow (when the input is greater than largest uint176).\n *\n * Counterpart to Solidity's `uint176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n if (value > type(uint176).max) {\n revert SafeCastOverflowedUintDowncast(176, value);\n }\n return uint176(value);\n }\n\n /**\n * @dev Returns the downcasted uint168 from uint256, reverting on\n * overflow (when the input is greater than largest uint168).\n *\n * Counterpart to Solidity's `uint168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n if (value > type(uint168).max) {\n revert SafeCastOverflowedUintDowncast(168, value);\n }\n return uint168(value);\n }\n\n /**\n * @dev Returns the downcasted uint160 from uint256, reverting on\n * overflow (when the input is greater than largest uint160).\n *\n * Counterpart to Solidity's `uint160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n if (value > type(uint160).max) {\n revert SafeCastOverflowedUintDowncast(160, value);\n }\n return uint160(value);\n }\n\n /**\n * @dev Returns the downcasted uint152 from uint256, reverting on\n * overflow (when the input is greater than largest uint152).\n *\n * Counterpart to Solidity's `uint152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n if (value > type(uint152).max) {\n revert SafeCastOverflowedUintDowncast(152, value);\n }\n return uint152(value);\n }\n\n /**\n * @dev Returns the downcasted uint144 from uint256, reverting on\n * overflow (when the input is greater than largest uint144).\n *\n * Counterpart to Solidity's `uint144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n if (value > type(uint144).max) {\n revert SafeCastOverflowedUintDowncast(144, value);\n }\n return uint144(value);\n }\n\n /**\n * @dev Returns the downcasted uint136 from uint256, reverting on\n * overflow (when the input is greater than largest uint136).\n *\n * Counterpart to Solidity's `uint136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n if (value > type(uint136).max) {\n revert SafeCastOverflowedUintDowncast(136, value);\n }\n return uint136(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n if (value > type(uint128).max) {\n revert SafeCastOverflowedUintDowncast(128, value);\n }\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint120 from uint256, reverting on\n * overflow (when the input is greater than largest uint120).\n *\n * Counterpart to Solidity's `uint120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n if (value > type(uint120).max) {\n revert SafeCastOverflowedUintDowncast(120, value);\n }\n return uint120(value);\n }\n\n /**\n * @dev Returns the downcasted uint112 from uint256, reverting on\n * overflow (when the input is greater than largest uint112).\n *\n * Counterpart to Solidity's `uint112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n if (value > type(uint112).max) {\n revert SafeCastOverflowedUintDowncast(112, value);\n }\n return uint112(value);\n }\n\n /**\n * @dev Returns the downcasted uint104 from uint256, reverting on\n * overflow (when the input is greater than largest uint104).\n *\n * Counterpart to Solidity's `uint104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n if (value > type(uint104).max) {\n revert SafeCastOverflowedUintDowncast(104, value);\n }\n return uint104(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n if (value > type(uint96).max) {\n revert SafeCastOverflowedUintDowncast(96, value);\n }\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint88 from uint256, reverting on\n * overflow (when the input is greater than largest uint88).\n *\n * Counterpart to Solidity's `uint88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n if (value > type(uint88).max) {\n revert SafeCastOverflowedUintDowncast(88, value);\n }\n return uint88(value);\n }\n\n /**\n * @dev Returns the downcasted uint80 from uint256, reverting on\n * overflow (when the input is greater than largest uint80).\n *\n * Counterpart to Solidity's `uint80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n if (value > type(uint80).max) {\n revert SafeCastOverflowedUintDowncast(80, value);\n }\n return uint80(value);\n }\n\n /**\n * @dev Returns the downcasted uint72 from uint256, reverting on\n * overflow (when the input is greater than largest uint72).\n *\n * Counterpart to Solidity's `uint72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n if (value > type(uint72).max) {\n revert SafeCastOverflowedUintDowncast(72, value);\n }\n return uint72(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n if (value > type(uint64).max) {\n revert SafeCastOverflowedUintDowncast(64, value);\n }\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint56 from uint256, reverting on\n * overflow (when the input is greater than largest uint56).\n *\n * Counterpart to Solidity's `uint56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n if (value > type(uint56).max) {\n revert SafeCastOverflowedUintDowncast(56, value);\n }\n return uint56(value);\n }\n\n /**\n * @dev Returns the downcasted uint48 from uint256, reverting on\n * overflow (when the input is greater than largest uint48).\n *\n * Counterpart to Solidity's `uint48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n if (value > type(uint48).max) {\n revert SafeCastOverflowedUintDowncast(48, value);\n }\n return uint48(value);\n }\n\n /**\n * @dev Returns the downcasted uint40 from uint256, reverting on\n * overflow (when the input is greater than largest uint40).\n *\n * Counterpart to Solidity's `uint40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n if (value > type(uint40).max) {\n revert SafeCastOverflowedUintDowncast(40, value);\n }\n return uint40(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n if (value > type(uint32).max) {\n revert SafeCastOverflowedUintDowncast(32, value);\n }\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint24 from uint256, reverting on\n * overflow (when the input is greater than largest uint24).\n *\n * Counterpart to Solidity's `uint24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n if (value > type(uint24).max) {\n revert SafeCastOverflowedUintDowncast(24, value);\n }\n return uint24(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n if (value > type(uint16).max) {\n revert SafeCastOverflowedUintDowncast(16, value);\n }\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n if (value > type(uint8).max) {\n revert SafeCastOverflowedUintDowncast(8, value);\n }\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n if (value < 0) {\n revert SafeCastOverflowedIntToUint(value);\n }\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int248 from int256, reverting on\n * overflow (when the input is less than smallest int248 or\n * greater than largest int248).\n *\n * Counterpart to Solidity's `int248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n */\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(248, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int240 from int256, reverting on\n * overflow (when the input is less than smallest int240 or\n * greater than largest int240).\n *\n * Counterpart to Solidity's `int240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n */\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(240, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int232 from int256, reverting on\n * overflow (when the input is less than smallest int232 or\n * greater than largest int232).\n *\n * Counterpart to Solidity's `int232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n */\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(232, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int224 from int256, reverting on\n * overflow (when the input is less than smallest int224 or\n * greater than largest int224).\n *\n * Counterpart to Solidity's `int224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n */\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(224, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int216 from int256, reverting on\n * overflow (when the input is less than smallest int216 or\n * greater than largest int216).\n *\n * Counterpart to Solidity's `int216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n */\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(216, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int208 from int256, reverting on\n * overflow (when the input is less than smallest int208 or\n * greater than largest int208).\n *\n * Counterpart to Solidity's `int208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n */\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(208, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int200 from int256, reverting on\n * overflow (when the input is less than smallest int200 or\n * greater than largest int200).\n *\n * Counterpart to Solidity's `int200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n */\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(200, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int192 from int256, reverting on\n * overflow (when the input is less than smallest int192 or\n * greater than largest int192).\n *\n * Counterpart to Solidity's `int192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n */\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(192, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int184 from int256, reverting on\n * overflow (when the input is less than smallest int184 or\n * greater than largest int184).\n *\n * Counterpart to Solidity's `int184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n */\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(184, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int176 from int256, reverting on\n * overflow (when the input is less than smallest int176 or\n * greater than largest int176).\n *\n * Counterpart to Solidity's `int176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n */\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(176, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int168 from int256, reverting on\n * overflow (when the input is less than smallest int168 or\n * greater than largest int168).\n *\n * Counterpart to Solidity's `int168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n */\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(168, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int160 from int256, reverting on\n * overflow (when the input is less than smallest int160 or\n * greater than largest int160).\n *\n * Counterpart to Solidity's `int160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n */\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(160, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int152 from int256, reverting on\n * overflow (when the input is less than smallest int152 or\n * greater than largest int152).\n *\n * Counterpart to Solidity's `int152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n */\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(152, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int144 from int256, reverting on\n * overflow (when the input is less than smallest int144 or\n * greater than largest int144).\n *\n * Counterpart to Solidity's `int144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n */\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(144, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int136 from int256, reverting on\n * overflow (when the input is less than smallest int136 or\n * greater than largest int136).\n *\n * Counterpart to Solidity's `int136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n */\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(136, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n */\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(128, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int120 from int256, reverting on\n * overflow (when the input is less than smallest int120 or\n * greater than largest int120).\n *\n * Counterpart to Solidity's `int120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n */\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(120, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int112 from int256, reverting on\n * overflow (when the input is less than smallest int112 or\n * greater than largest int112).\n *\n * Counterpart to Solidity's `int112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n */\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(112, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int104 from int256, reverting on\n * overflow (when the input is less than smallest int104 or\n * greater than largest int104).\n *\n * Counterpart to Solidity's `int104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n */\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(104, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int96 from int256, reverting on\n * overflow (when the input is less than smallest int96 or\n * greater than largest int96).\n *\n * Counterpart to Solidity's `int96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n */\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(96, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int88 from int256, reverting on\n * overflow (when the input is less than smallest int88 or\n * greater than largest int88).\n *\n * Counterpart to Solidity's `int88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n */\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(88, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int80 from int256, reverting on\n * overflow (when the input is less than smallest int80 or\n * greater than largest int80).\n *\n * Counterpart to Solidity's `int80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n */\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(80, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int72 from int256, reverting on\n * overflow (when the input is less than smallest int72 or\n * greater than largest int72).\n *\n * Counterpart to Solidity's `int72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n */\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(72, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n */\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(64, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int56 from int256, reverting on\n * overflow (when the input is less than smallest int56 or\n * greater than largest int56).\n *\n * Counterpart to Solidity's `int56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n */\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(56, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int48 from int256, reverting on\n * overflow (when the input is less than smallest int48 or\n * greater than largest int48).\n *\n * Counterpart to Solidity's `int48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n */\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(48, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int40 from int256, reverting on\n * overflow (when the input is less than smallest int40 or\n * greater than largest int40).\n *\n * Counterpart to Solidity's `int40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n */\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(40, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n */\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(32, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int24 from int256, reverting on\n * overflow (when the input is less than smallest int24 or\n * greater than largest int24).\n *\n * Counterpart to Solidity's `int24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n */\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(24, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n */\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(16, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n */\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(8, value);\n }\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n if (value > uint256(type(int256).max)) {\n revert SafeCastOverflowedUintToInt(value);\n }\n return int256(value);\n }\n\n /**\n * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.\n */\n function toUint(bool b) internal pure returns (uint256 u) {\n assembly (\"memory-safe\") {\n u := iszero(iszero(b))\n }\n }\n}\n" + } + }, + "settings": { + "remappings": [ + "forge-std/=lib/forge-std/src/", + "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", + "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", + "@openzeppelin/foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/", + "@uma/contracts/=lib/protocol/packages/core/contracts/", + "ds-test/=lib/permit2/lib/forge-std/lib/ds-test/src/", + "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", + "forge-gas-snapshot/=lib/permit2/lib/forge-gas-snapshot/src/", + "halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/", + "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", + "openzeppelin-contracts/=lib/openzeppelin-contracts/", + "openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/", + "permit2/=lib/permit2/", + "protocol/=lib/protocol/", + "solmate/=lib/permit2/lib/solmate/" + ], + "optimizer": { + "enabled": true, + "runs": 1 + }, + "metadata": { + "useLiteralContent": false, + "bytecodeHash": "ipfs", + "appendCBOR": true + }, + "outputSelection": { + "*": { + "*": [ + "evm.bytecode", + "evm.deployedBytecode", + "devdoc", + "userdoc", + "metadata", + "abi" + ] + } + }, + "evmVersion": "cancun", + "viaIR": true + } +} diff --git a/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/bytecode-reproduction.json b/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/bytecode-reproduction.json new file mode 100644 index 0000000..4bed80d --- /dev/null +++ b/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/bytecode-reproduction.json @@ -0,0 +1,111 @@ +{ + "chainId": 137, + "blockNumber": 95573288, + "blockHash": "0xfa7f5ccfc98241b34e95586909c3606e6a7473a1bf142f1938de59541598dd9c", + "signedProposerProxy": "0x632dA7EcAD445C090DaFe1B03c24c113bD0edD13", + "implementationSlot": "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc", + "implementation": "0x1307ce44a51af6d84ad2e346d7655f1b7d20d856", + "contracts": { + "access-manager": { + "address": "0xfa6f0ff6c719001cba691ff12ceaa9c49acdcb66", + "runtimeBytes": 8768, + "rawCompilerRuntimeMatches": true, + "immutableReferences": {}, + "immutableValueRule": "UUPS __self must equal the implementation address; no arbitrary byte masking", + "exactRuntimeIncludingMetadataMatches": true, + "onchainKeccak256": "0x9bb503f05d0dc3393bdcf782e23b52c70019c828aed9f25a3329d92b3efd8428", + "reproducedKeccak256": "0x9bb503f05d0dc3393bdcf782e23b52c70019c828aed9f25a3329d92b3efd8428", + "compiler": { + "version": "0.8.30+commit.73712a01" + }, + "compilerSettings": { + "remappings": [ + "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", + "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", + "@openzeppelin/foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/", + "@uma/contracts/=lib/protocol/packages/core/contracts/", + "ds-test/=lib/permit2/lib/forge-std/lib/ds-test/src/", + "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", + "forge-gas-snapshot/=lib/permit2/lib/forge-gas-snapshot/src/", + "forge-std/=lib/forge-std/src/", + "halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/", + "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", + "openzeppelin-contracts/=lib/openzeppelin-contracts/", + "openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/", + "permit2/=lib/permit2/", + "protocol/=lib/protocol/", + "solmate/=lib/permit2/lib/solmate/" + ], + "optimizer": { + "enabled": true, + "runs": 1 + }, + "metadata": { + "bytecodeHash": "ipfs" + }, + "compilationTarget": { + "lib/openzeppelin-contracts/contracts/access/manager/AccessManager.sol": "AccessManager" + }, + "evmVersion": "cancun", + "libraries": {}, + "viaIR": true + } + }, + "signed-proposer-implementation": { + "address": "0x1307ce44a51af6d84ad2e346d7655f1b7d20d856", + "runtimeBytes": 13795, + "rawCompilerRuntimeMatches": false, + "immutableReferences": { + "652": [ + { + "start": 5009, + "length": 32 + }, + { + "start": 5174, + "length": 32 + } + ] + }, + "immutableValueRule": "UUPS __self must equal the implementation address; no arbitrary byte masking", + "exactRuntimeIncludingMetadataMatches": true, + "onchainKeccak256": "0xbc198f557cff5fc69b0d8c3aee31d8cbd8d1c048275259fc291f9ae950453f10", + "reproducedKeccak256": "0xbc198f557cff5fc69b0d8c3aee31d8cbd8d1c048275259fc291f9ae950453f10", + "compiler": { + "version": "0.8.30+commit.73712a01" + }, + "compilerSettings": { + "remappings": [ + "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", + "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", + "@openzeppelin/foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/", + "@uma/contracts/=lib/protocol/packages/core/contracts/", + "ds-test/=lib/permit2/lib/forge-std/lib/ds-test/src/", + "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", + "forge-gas-snapshot/=lib/permit2/lib/forge-gas-snapshot/src/", + "forge-std/=lib/forge-std/src/", + "halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/", + "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", + "openzeppelin-contracts/=lib/openzeppelin-contracts/", + "openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/", + "permit2/=lib/permit2/", + "protocol/=lib/protocol/", + "solmate/=lib/permit2/lib/solmate/" + ], + "optimizer": { + "enabled": true, + "runs": 1 + }, + "metadata": { + "bytecodeHash": "ipfs" + }, + "compilationTarget": { + "src/optimistic-oracle-v2/implementation/SignedProposer.sol": "SignedProposer" + }, + "evmVersion": "prague", + "libraries": {}, + "viaIR": true + } + } + } +} diff --git a/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/deployment.json b/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/deployment.json new file mode 100644 index 0000000..c6e5f85 --- /dev/null +++ b/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/deployment.json @@ -0,0 +1,196 @@ +{ + "chainId": 137, + "whitelist": "0x0044C7b41206A4EB4183C1b37D6Ba65261173c42", + "verifiedAtBlock": 95573288, + "verifiedBlockHash": "0xfa7f5ccfc98241b34e95586909c3606e6a7473a1bf142f1938de59541598dd9c", + "owner": "0x632dA7EcAD445C090DaFe1B03c24c113bD0edD13", + "members": [ + "0x632dA7EcAD445C090DaFe1B03c24c113bD0edD13" + ], + "enabled": true, + "runtimeKeccak256": "0x086f94e78f61895eb3b08f67be1b92989ff5b7e233abdaca63e7217ce2f2a7e7", + "runtimeMatchesPinnedBuild": true, + "source": { + "repository": "UMAprotocol/managed-oracle", + "revision": "886c23b88e7210dc3eac16f03a900ac36811862d", + "contract": "src/common/implementation/AddressWhitelist.sol:AddressWhitelist", + "constructorArguments": [], + "openzeppelinRevision": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "protocolRevision": "6a23be19d8a0dbee4475db9ff52ce4d9572212b5", + "forgeStdRevision": "77041d2ce690e692d6e03cc812b57d1ddaa4d505" + }, + "compiler": { + "version": "0.8.30+commit.73712a01", + "optimizer": true, + "optimizerRuns": 1, + "viaIR": true, + "evmVersion": "prague" + }, + "transactions": [ + { + "hash": "0x7b8b4a1c5f5ff149cf84af9d1323892ff82d9d5202a67eee862a1b3cc13870b4", + "nonce": 14944, + "blockNumber": 95570673, + "blockHash": "0x60327a314a9b3def8232b7b837eb354b70667df16da9820fffa4f3f4f9b83908", + "from": "0x9a8f92a830a5cb89a3816e3d267cb7791c16b04d", + "to": null, + "value": "0", + "status": 1, + "contractAddress": "0x0044c7b41206a4eb4183c1b37d6ba65261173c42", + "input": null, + "logs": [ + { + "address": "0x0044c7b41206a4eb4183c1b37d6ba65261173c42", + "blockHash": "0x60327a314a9b3def8232b7b837eb354b70667df16da9820fffa4f3f4f9b83908", + "blockNumber": "0x5b24af1", + "blockTimestamp": "0x6ad0af97", + "data": "0x", + "logIndex": "0x363", + "removed": false, + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000009a8f92a830a5cb89a3816e3d267cb7791c16b04d" + ], + "transactionHash": "0x7b8b4a1c5f5ff149cf84af9d1323892ff82d9d5202a67eee862a1b3cc13870b4", + "transactionIndex": "0x3d" + }, + { + "address": "0x0000000000000000000000000000000000001010", + "blockHash": "0x60327a314a9b3def8232b7b837eb354b70667df16da9820fffa4f3f4f9b83908", + "blockNumber": "0x5b24af1", + "blockTimestamp": "0x6ad0af97", + "data": "0x0000000000000000000000000000000000000000000000000111095aefbf3000000000000000000000000000000000000000000000000002afb50772054b7f880000000000000000000000000000000000000000000713c9f3d75739f7bcab73000000000000000000000000000000000000000000000002aea3fe17158c4f880000000000000000000000000000000000000000000713c9f4e86094e77bdb73", + "logIndex": "0x364", + "removed": false, + "topics": [ + "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", + "0x0000000000000000000000000000000000000000000000000000000000001010", + "0x0000000000000000000000009a8f92a830a5cb89a3816e3d267cb7791c16b04d", + "0x0000000000000000000000007ee41d8a25641000661b1ef5e6ae8a00400466b0" + ], + "transactionHash": "0x7b8b4a1c5f5ff149cf84af9d1323892ff82d9d5202a67eee862a1b3cc13870b4", + "transactionIndex": "0x3d" + } + ] + }, + { + "hash": "0x5658e6d4e666d14d6afe29e6e156a9ed4d6f1fc82e8af8760ae9d929d2fa302f", + "nonce": 14945, + "blockNumber": 95570755, + "blockHash": "0x21a67d643cbf9912274790cedf31df0cf2730211752b13eec8ce8946fcdece69", + "from": "0x9a8f92a830a5cb89a3816e3d267cb7791c16b04d", + "to": "0x0044c7b41206a4eb4183c1b37d6ba65261173c42", + "value": "0", + "status": 1, + "contractAddress": null, + "input": "0xe43252d7000000000000000000000000632da7ecad445c090dafe1b03c24c113bd0edd13", + "logs": [ + { + "address": "0x0044c7b41206a4eb4183c1b37d6ba65261173c42", + "blockHash": "0x21a67d643cbf9912274790cedf31df0cf2730211752b13eec8ce8946fcdece69", + "blockNumber": "0x5b24b43", + "blockTimestamp": "0x6ad0b012", + "data": "0x", + "logIndex": "0x28f", + "removed": false, + "topics": [ + "0xa850ae9193f515cbae8d35e8925bd2be26627fc91bce650b8652ed254e9cab03", + "0x000000000000000000000000632da7ecad445c090dafe1b03c24c113bd0edd13" + ], + "transactionHash": "0x5658e6d4e666d14d6afe29e6e156a9ed4d6f1fc82e8af8760ae9d929d2fa302f", + "transactionIndex": "0x36" + }, + { + "address": "0x0000000000000000000000000000000000001010", + "blockHash": "0x21a67d643cbf9912274790cedf31df0cf2730211752b13eec8ce8946fcdece69", + "blockNumber": "0x5b24b43", + "blockTimestamp": "0x6ad0b012", + "data": "0x00000000000000000000000000000000000000000000000000359df31ebd4900000000000000000000000000000000000000000000000002ad2124541a5928980000000000000000000000000000000000000000000713e154d312c0da8defbf000000000000000000000000000000000000000000000002aceb8660fb9bdf980000000000000000000000000000000000000000000713e15508b0b3f94b38bf", + "logIndex": "0x290", + "removed": false, + "topics": [ + "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", + "0x0000000000000000000000000000000000000000000000000000000000001010", + "0x0000000000000000000000009a8f92a830a5cb89a3816e3d267cb7791c16b04d", + "0x0000000000000000000000007ee41d8a25641000661b1ef5e6ae8a00400466b0" + ], + "transactionHash": "0x5658e6d4e666d14d6afe29e6e156a9ed4d6f1fc82e8af8760ae9d929d2fa302f", + "transactionIndex": "0x36" + } + ] + }, + { + "hash": "0x9ad99421fdcc1126ef7a2bf69f6d9a81199d4d5cb81f24167bc15e1e7bf7377d", + "nonce": 14946, + "blockNumber": 95570769, + "blockHash": "0x4262de5b19e81f6b88795df6ef5e6b935d9cfd3edf8ef61dd322f88c0e313dde", + "from": "0x9a8f92a830a5cb89a3816e3d267cb7791c16b04d", + "to": "0x0044c7b41206a4eb4183c1b37d6ba65261173c42", + "value": "0", + "status": 1, + "contractAddress": null, + "input": "0xf2fde38b000000000000000000000000632da7ecad445c090dafe1b03c24c113bd0edd13", + "logs": [ + { + "address": "0x0044c7b41206a4eb4183c1b37d6ba65261173c42", + "blockHash": "0x4262de5b19e81f6b88795df6ef5e6b935d9cfd3edf8ef61dd322f88c0e313dde", + "blockNumber": "0x5b24b51", + "blockTimestamp": "0x6ad0b027", + "data": "0x", + "logIndex": "0x431", + "removed": false, + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000009a8f92a830a5cb89a3816e3d267cb7791c16b04d", + "0x000000000000000000000000632da7ecad445c090dafe1b03c24c113bd0edd13" + ], + "transactionHash": "0x9ad99421fdcc1126ef7a2bf69f6d9a81199d4d5cb81f24167bc15e1e7bf7377d", + "transactionIndex": "0x4a" + }, + { + "address": "0x0000000000000000000000000000000000001010", + "blockHash": "0x4262de5b19e81f6b88795df6ef5e6b935d9cfd3edf8ef61dd322f88c0e313dde", + "blockNumber": "0x5b24b51", + "blockTimestamp": "0x6ad0b027", + "data": "0x00000000000000000000000000000000000000000000000000112aff1ae01000000000000000000000000000000000000000000000000002ac8d1f5db71ac6d00000000000000000000000000000000000000000000713e59b7356f2c00a4075000000000000000000000000000000000000000000000002ac7bf45e9c3ab6d00000000000000000000000000000000000000000000713e59b8481f1daea5075", + "logIndex": "0x432", + "removed": false, + "topics": [ + "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", + "0x0000000000000000000000000000000000000000000000000000000000001010", + "0x0000000000000000000000009a8f92a830a5cb89a3816e3d267cb7791c16b04d", + "0x0000000000000000000000007ee41d8a25641000661b1ef5e6ae8a00400466b0" + ], + "transactionHash": "0x9ad99421fdcc1126ef7a2bf69f6d9a81199d4d5cb81f24167bc15e1e7bf7377d", + "transactionIndex": "0x4a" + } + ] + } + ], + "compilerSettings": { + "remappings": [ + "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", + "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", + "@openzeppelin/foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/", + "@uma/contracts/=lib/protocol/packages/core/contracts/", + "forge-std/=lib/forge-std/src/", + "openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/", + "permit2/=lib/permit2/", + "protocol/=lib/protocol/" + ], + "optimizer": { + "enabled": true, + "runs": 1 + }, + "metadata": { + "bytecodeHash": "ipfs" + }, + "compilationTarget": { + "src/common/implementation/AddressWhitelist.sol": "AddressWhitelist" + }, + "evmVersion": "prague", + "libraries": {}, + "viaIR": true + } +} diff --git a/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/reviewed-source-provenance.json b/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/reviewed-source-provenance.json new file mode 100644 index 0000000..1252b13 --- /dev/null +++ b/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/reviewed-source-provenance.json @@ -0,0 +1,350 @@ +{ + "access-manager": { + "sourceCount": 13, + "allSourceFilesMatch": true, + "sourceMatches": [ + { + "path": "lib/openzeppelin-contracts/contracts/access/manager/AccessManager.sol", + "referenceCommit": "5fd1781b1454fd1ef8e722282f86f9293cacf256", + "exactSourceMatch": true, + "sha256": "f731720ea832da3c2a3a0f50907edbd503035bb764dddcd265a89067edde7ff3" + }, + { + "path": "lib/openzeppelin-contracts/contracts/access/manager/IAccessManager.sol", + "referenceCommit": "5fd1781b1454fd1ef8e722282f86f9293cacf256", + "exactSourceMatch": true, + "sha256": "d4efe804c460c8cce4d76c777b512e88ff200e14f9c8be884cd5f69cc0d12e35" + }, + { + "path": "lib/openzeppelin-contracts/contracts/access/manager/IAccessManaged.sol", + "referenceCommit": "5fd1781b1454fd1ef8e722282f86f9293cacf256", + "exactSourceMatch": true, + "sha256": "2ef4db4c7c678372fe79af348ce3d60d4cf7136d195daf7a9bc2e434ffcbaacd" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/Address.sol", + "referenceCommit": "5fd1781b1454fd1ef8e722282f86f9293cacf256", + "exactSourceMatch": true, + "sha256": "73e54e15285455f0e01e136c3663732641537614723ae5dbd820eb3cb036b1fd" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/Context.sol", + "referenceCommit": "5fd1781b1454fd1ef8e722282f86f9293cacf256", + "exactSourceMatch": true, + "sha256": "847fda5460fee70f56f4200f59b82ae622bb03c79c77e67af010e31b7e2cc5b6" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/Multicall.sol", + "referenceCommit": "5fd1781b1454fd1ef8e722282f86f9293cacf256", + "exactSourceMatch": true, + "sha256": "bb203e6a32bb3f377e6b0c8269642ca2816f815deb4a533f35ef42eef0beda5c" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/math/Math.sol", + "referenceCommit": "5fd1781b1454fd1ef8e722282f86f9293cacf256", + "exactSourceMatch": true, + "sha256": "bdfdbe133991c0c78042957ff5cd97167926fcaf6d15664f3835a076cb066457" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/types/Time.sol", + "referenceCommit": "5fd1781b1454fd1ef8e722282f86f9293cacf256", + "exactSourceMatch": true, + "sha256": "8085f943150cce1a10aa843f83519960c3010efe5792a9ee58f87c1993d33472" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/cryptography/Hashes.sol", + "referenceCommit": "5fd1781b1454fd1ef8e722282f86f9293cacf256", + "exactSourceMatch": true, + "sha256": "ecdbce11c5ecdf32b306e26b8ab1b878327c08154b4ccd04518b6b64b298cf31" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/Errors.sol", + "referenceCommit": "5fd1781b1454fd1ef8e722282f86f9293cacf256", + "exactSourceMatch": true, + "sha256": "0704b9d6c032cca8512a3bc3f30f49f86f1f03102d2896a3d23e794b82efea66" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/LowLevelCall.sol", + "referenceCommit": "5fd1781b1454fd1ef8e722282f86f9293cacf256", + "exactSourceMatch": true, + "sha256": "e128cbe9c6c406d5a42c26e4079c0a95b369ce552f2d0c3dfd2fcb836c5708f2" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/Panic.sol", + "referenceCommit": "5fd1781b1454fd1ef8e722282f86f9293cacf256", + "exactSourceMatch": true, + "sha256": "270fc8401c1a13fae6a7a4a2dd6e381b95d658896701e51f0d3e2688acab3dec" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/math/SafeCast.sol", + "referenceCommit": "5fd1781b1454fd1ef8e722282f86f9293cacf256", + "exactSourceMatch": true, + "sha256": "5779bc848bde39f1ad7bc02b4f708a0040888e0083b1a33f119cd94639350134" + } + ] + }, + "signed-proposer-implementation": { + "sourceCount": 41, + "allSourceFilesMatch": true, + "sourceMatches": [ + { + "path": "src/optimistic-oracle-v2/implementation/SignedProposer.sol", + "referenceCommit": "24a5930ba82bb9a91fb3251d8d7ff243b5d95a7a", + "exactSourceMatch": true, + "sha256": "92576b21a9dbf5e57f92c1d6d0eee1d16b00f16438fc0160f5d64fbfc6a10b52" + }, + { + "path": "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "01b6f5c4fa45fd38822b286ecef6daf983d27306dd6362496fa71b3e4600b72c" + }, + { + "path": "lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "ac1fd9fa99b194a8db8dfa9ae8e3ff44feaa8f16668241fd2b66ae8b47d7c082" + }, + { + "path": "lib/openzeppelin-contracts-upgradeable/contracts/access/AccessControlUpgradeable.sol", + "referenceCommit": "e725abddf1e01cf05ace496e950fc8e243cc7cab", + "exactSourceMatch": true, + "sha256": "a5dee9f239e3334a7e3149dc9e72e2b0e7421813fb94660695b855384da6191e" + }, + { + "path": "lib/openzeppelin-contracts-upgradeable/contracts/utils/MulticallUpgradeable.sol", + "referenceCommit": "e725abddf1e01cf05ace496e950fc8e243cc7cab", + "exactSourceMatch": true, + "sha256": "28874e9eb73a2dcf03367ad26d89fd38d83f08509685c404a618f86435a8dd6d" + }, + { + "path": "lib/openzeppelin-contracts-upgradeable/contracts/utils/ReentrancyGuardUpgradeable.sol", + "referenceCommit": "e725abddf1e01cf05ace496e950fc8e243cc7cab", + "exactSourceMatch": true, + "sha256": "11b45418823fd6e961d8db5cf5c2795b08f51f88a66f8e37a38fcd052ee711a4" + }, + { + "path": "src/optimistic-oracle-v2/interfaces/OptimisticOracleV2Interface.sol", + "referenceCommit": "24a5930ba82bb9a91fb3251d8d7ff243b5d95a7a", + "exactSourceMatch": true, + "sha256": "caca611f84e16144aebea327a1d787eb2e8807b96c5366a527f92a3b4672cf8c" + }, + { + "path": "src/optimistic-oracle-v2/interfaces/SignedProposerOracleInterface.sol", + "referenceCommit": "24a5930ba82bb9a91fb3251d8d7ff243b5d95a7a", + "exactSourceMatch": true, + "sha256": "2a35a39977f0a5e1ec8ededd503542554e41982cfe069c9fef209ecadc372236" + }, + { + "path": "lib/permit2/src/interfaces/ISignatureTransfer.sol", + "referenceCommit": "cc56ad0f3439c502c246fc5cfcc3db92bb8b7219", + "exactSourceMatch": true, + "sha256": "8e7f355d7751cf96e81069c17fb97a3ec973c9391fbbb58ad3fb6e75be5cb19b" + }, + { + "path": "src/common/implementation/AddressWhitelist.sol", + "referenceCommit": "24a5930ba82bb9a91fb3251d8d7ff243b5d95a7a", + "exactSourceMatch": true, + "sha256": "bcdc89e39b8ad27f8ac5f31c7cccfc35afafe7ccddc60df5befc27df9e36b16b" + }, + { + "path": "src/common/interfaces/AddressWhitelistInterface.sol", + "referenceCommit": "24a5930ba82bb9a91fb3251d8d7ff243b5d95a7a", + "exactSourceMatch": true, + "sha256": "4ee8b240ab89f53bdd53c1570612deed03fd5dce1514235767aecb0b4618cf9e" + }, + { + "path": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol", + "referenceCommit": "e725abddf1e01cf05ace496e950fc8e243cc7cab", + "exactSourceMatch": true, + "sha256": "2d07bcf9728190a5c807cf68defc3f3c52aa098d04770d44af37f30abade38d5" + }, + { + "path": "src/common/implementation/TryMulticall.sol", + "referenceCommit": "24a5930ba82bb9a91fb3251d8d7ff243b5d95a7a", + "exactSourceMatch": true, + "sha256": "581fc1ee43985a3aa91a92387e6951a580b927a94b2af9e82f734d4db6a9974a" + }, + { + "path": "lib/openzeppelin-contracts/contracts/interfaces/IERC1363.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "9c3a75a925a6dac9e88b03cddc58d42fe3131b0aaaad84408521f3f7af2f991b" + }, + { + "path": "lib/openzeppelin-contracts/contracts/access/IAccessControl.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "140304b7e99d517c57a13f391dfd3b550ca633a507f7b2af130f391b6cd89cc5" + }, + { + "path": "lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol", + "referenceCommit": "e725abddf1e01cf05ace496e950fc8e243cc7cab", + "exactSourceMatch": true, + "sha256": "a08e16324da33a9d666dc07a22ae58031c242a3869f6808e55b4b82fc70cb209" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "9055c2994b37dea1a41b7b7926dcb510f05dbe2540b0aafc5fbee9558fffd0ca" + }, + { + "path": "lib/openzeppelin-contracts-upgradeable/contracts/utils/introspection/ERC165Upgradeable.sol", + "referenceCommit": "e725abddf1e01cf05ace496e950fc8e243cc7cab", + "exactSourceMatch": true, + "sha256": "d2105a1e3ba533399fb408105267329c2c134fcb18043a9c024d1b6e81982fc9" + }, + { + "path": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol", + "referenceCommit": "e725abddf1e01cf05ace496e950fc8e243cc7cab", + "exactSourceMatch": true, + "sha256": "f527a063813c2bf60c153fb08e38539578935402894fcc36fac42324ca325d3b" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/Address.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "f1a9255dbc40cf9ae7c786abed3b022691a9d24bca0c7f05dc60e63421d405ab" + }, + { + "path": "lib/protocol/packages/core/contracts/data-verification-mechanism/interfaces/FinderInterface.sol", + "referenceCommit": "6a23be19d8a0dbee4475db9ff52ce4d9572212b5", + "exactSourceMatch": true, + "sha256": "b0ff51388845ed1351066936ad6f80439f8021add0e80b9f823cf09a32ce4863" + }, + { + "path": "lib/permit2/src/interfaces/IEIP712.sol", + "referenceCommit": "cc56ad0f3439c502c246fc5cfcc3db92bb8b7219", + "exactSourceMatch": true, + "sha256": "e386407da496dbe874c10a81801c55744fb2922a51389a51c79001422e81e0cd" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "61a2b12c96857aaa35f48aeda67a4281637a42494c0b3795be0ae976aa7b3793" + }, + { + "path": "lib/openzeppelin-contracts/contracts/access/Ownable.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "38578bd71c0a909840e67202db527cc6b4e6b437e0f39f0c909da32c1e30cb81" + }, + { + "path": "lib/protocol/packages/core/contracts/common/implementation/Lockable.sol", + "referenceCommit": "6a23be19d8a0dbee4475db9ff52ce4d9572212b5", + "exactSourceMatch": true, + "sha256": "5269b16b024a4000ef9c5fc33586a56058e40696de18e5dce3bcfb565704ba8d" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/structs/EnumerableSet.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "53507e71995d0e76d29d6dd897d0bcc3f069fd81f03cb431d7342bdfcc0d5345" + }, + { + "path": "lib/openzeppelin-contracts/contracts/interfaces/draft-IERC1822.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "73653312bc2eda0ec231553a5295242eaef2d4f46a023532d45fe76cbd0f565f" + }, + { + "path": "lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Utils.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "58c5b19893bf3d7f9e1aa0edc5b908b915eb7af4381800deb425a6e5331f4432" + }, + { + "path": "lib/openzeppelin-contracts/contracts/interfaces/IERC20.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "0158e2d3e0e28bedd99eec13dcf1a8aa3a70a5b7e4bb2ad709609c95fcc740d1" + }, + { + "path": "lib/openzeppelin-contracts/contracts/interfaces/IERC165.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "dfb3f56fa928a7c6cae41a7ce2c86b9210fa18d33fa26389099d66a0fa790368" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/Errors.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "0704b9d6c032cca8512a3bc3f30f49f86f1f03102d2896a3d23e794b82efea66" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/Context.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "847fda5460fee70f56f4200f59b82ae622bb03c79c77e67af010e31b7e2cc5b6" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/Arrays.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "8320f75b46c18204dd6f2b3654058129625b849a95c3a55a44ae531f77f0eca9" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/math/Math.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "92fee281fd46a1b058b190cf21d6b1a528f0433a907850ae1c9bcf36c5c0cd98" + }, + { + "path": "lib/openzeppelin-contracts/contracts/proxy/beacon/IBeacon.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "c1c9726bbb0ec4c540c7c98059dcded69a8586b46c168036672381033ee76239" + }, + { + "path": "lib/openzeppelin-contracts/contracts/interfaces/IERC1967.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "c4e901318ab6d4963582c62c62ce988a34c68dbae71846b67decacde79e9a317" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "75704538dcb223239280c6726d9a31cf769a7816718517c997fc7d63bdb70778" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/Comparators.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "52fb1c8f57967d42a3214bde4a8a414ab25c2e3a844d00e171ca56487024e009" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/SlotDerivation.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "daddbbeb265c87b7172548d58baede96b167cd89c6c7884ff2705676fab69438" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/Panic.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "270fc8401c1a13fae6a7a4a2dd6e381b95d658896701e51f0d3e2688acab3dec" + }, + { + "path": "lib/openzeppelin-contracts/contracts/utils/math/SafeCast.sol", + "referenceCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "exactSourceMatch": true, + "sha256": "9769274bf53f26a7c7896c526ea1980dc9bea5bf5c2a5fd04870008c4afc1de9" + } + ] + }, + "signedProposerReviewedDelta": { + "reportHead": "621b4d3788e2c2437aee994d1f303b8a3d57ad51", + "releaseCommit": "24a5930ba82bb9a91fb3251d8d7ff243b5d95a7a", + "codeTokensMatchReportHeadPlusReviewedN03Fix": true, + "functionalDelta": "payments memory -> calldata, reviewed as N-03 / PR90 at 38eb19f0ba5e0fbdb12f7e3f844a3bb2e2a0d5cc", + "otherDelta": "Documentation changes covered by N-04 / PR91 and accepted L-05 / PR89", + "fixRefs": { + "N-03": "38eb19f0ba5e0fbdb12f7e3f844a3bb2e2a0d5cc", + "N-04": "10b4d1cb2072752bd99864758022cd61f5212e07", + "L-05": "1a0a4172efab2f11f35b9f7c6fa3aa3880b1822c" + } + } +} diff --git a/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/signed-proposer-implementation-standard-input.json b/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/signed-proposer-implementation-standard-input.json new file mode 100644 index 0000000..dfb9299 --- /dev/null +++ b/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/signed-proposer-implementation-standard-input.json @@ -0,0 +1,170 @@ +{ + "language": "Solidity", + "sources": { + "src/optimistic-oracle-v2/implementation/SignedProposer.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.27;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {SafeERC20} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport {AccessControlUpgradeable} from \"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\";\nimport {MulticallUpgradeable} from \"@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol\";\nimport {ReentrancyGuardUpgradeable} from \"@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol\";\nimport {OptimisticOracleV2Interface} from \"../interfaces/OptimisticOracleV2Interface.sol\";\nimport {SignedProposerOracleInterface} from \"../interfaces/SignedProposerOracleInterface.sol\";\nimport {ISignatureTransfer} from \"permit2/src/interfaces/ISignatureTransfer.sol\";\nimport {AddressWhitelist} from \"../../common/implementation/AddressWhitelist.sol\";\nimport {AddressWhitelistInterface} from \"../../common/interfaces/AddressWhitelistInterface.sol\";\nimport {UUPSUpgradeable} from \"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol\";\nimport {TryMulticall} from \"../../common/implementation/TryMulticall.sol\";\n\n/**\n * @title SignedProposer\n * @custom:security-contact bugs@umaproject.org\n * @notice Allows proposers to sign Permit2 witness proposals off-chain and have them submitted by\n * a delegated relayer. The proposal parameters are embedded as the Permit2 witness so a single\n * signature authorises both the token transfer and a specific proposal or ordered proposal batch.\n *\n * The signer is set as the proposer (receiving rewards on settlement).\n *\n * SignedProposer resolves the effective proposer whitelist from ManagedOptimisticOracleV2 at\n * runtime. If the proposer is not already allowed, it attempts to temporarily add the proposer\n * before the oracle call and remove them immediately after. This requires SignedProposer to be\n * authorized by the resolved whitelist.\n *\n * It is assumed signers and delegated proposers verify `proposal.oracle` is an intended oracle\n * instance before signing or relaying. That oracle address is used as both the ERC20 allowance\n * spender and the `proposePriceFor` call target, so executing an unintended oracle can spend up to\n * the signer-approved Permit2 amount for that proposal.\n *\n * Deploy behind an ERC1967Proxy and initialize atomically. The default admin authorizes UUPS\n * upgrades; the proxy remains the Permit2 spender and whitelist owner across upgrades.\n *\n * The contract is permissioned:\n * - `DEFAULT_ADMIN_ROLE` \u2014 manages roles, payments, whitelist ownership, and upgrades.\n * - `DELEGATED_PROPOSER_ROLE` \u2014 fully trusted, company-controlled relayers that may call\n * `propose`, `proposeBatch`, and `tryMulticall`.\n * - `WHITELIST_ADMIN_ROLE` \u2014 may directly add/remove entries on whitelists owned by this contract.\n *\n * @dev Inherited `multicall` deliberately accepts any caller and selector and executes atomically. Self-delegatecall\n * preserves `msg.sender`, so every externally reachable function must enforce its own authorization, including functions\n * added in future versions. The `multicall` entry point does not provide a reentrancy guard; functions that need one must\n * apply their own. `tryMulticall` instead restricts the caller to delegated proposers, accepts only `propose`, and rejects\n * nested partial-success batches. Each `tryMulticall` child uses its own permit and nonce; failed children preserve their\n * permits. `proposeBatch` restricts the caller to delegated proposers and holds a reentrancy guard across an ordered,\n * same-token batch for one signer. It funds the batch with one Permit2 signature and nonce, isolates child failures, and\n * refunds unused funds at completion. A completed batch consumes the shared nonce even if every child fails; retries\n * require a fresh signature. These restrictions do not apply to the atomic `multicall` entry point.\n */\ncontract SignedProposer is\n AccessControlUpgradeable,\n MulticallUpgradeable,\n ReentrancyGuardUpgradeable,\n UUPSUpgradeable,\n TryMulticall\n{\n using SafeERC20 for IERC20;\n\n // \u2500\u2500\u2500 Structs \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n /// @notice Proposal witness fields shared by individual permits and batch items.\n struct Proposal {\n address oracle;\n address requester;\n bytes32 identifier;\n uint256 timestamp;\n bytes ancillaryData;\n int256 proposedPrice;\n uint256 maxPayment;\n }\n\n /// @notice One signed batch item; maxAmount covers this proposal's bond and payment.\n struct BatchProposal {\n Proposal proposal;\n uint256 maxAmount;\n }\n\n // \u2500\u2500\u2500 Roles \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n bytes32 public constant DELEGATED_PROPOSER_ROLE = keccak256(\"DELEGATED_PROPOSER_ROLE\");\n bytes32 public constant WHITELIST_ADMIN_ROLE = keccak256(\"WHITELIST_ADMIN_ROLE\");\n\n // \u2500\u2500\u2500 Constants \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n uint256 private constant MAX_BATCH_REVERT_DATA_SIZE = 256;\n\n bytes32 public constant PROPOSAL_TYPEHASH = keccak256(\n \"Proposal(address oracle,address requester,bytes32 identifier,uint256 timestamp,bytes ancillaryData,int256 proposedPrice,uint256 maxPayment)\"\n );\n\n /// @dev Appended by Permit2 to build the full PermitWitnessTransferFrom EIP-712 type.\n string public constant WITNESS_TYPE_STRING =\n \"Proposal witness)Proposal(address oracle,address requester,bytes32 identifier,uint256 timestamp,bytes ancillaryData,int256 proposedPrice,uint256 maxPayment)TokenPermissions(address token,uint256 amount)\";\n\n bytes32 public constant BATCH_PROPOSAL_TYPEHASH = keccak256(\n \"BatchProposal(Proposal proposal,uint256 maxAmount)Proposal(address oracle,address requester,bytes32 identifier,uint256 timestamp,bytes ancillaryData,int256 proposedPrice,uint256 maxPayment)\"\n );\n bytes32 public constant BATCH_WITNESS_TYPEHASH = keccak256(\n \"BatchWitness(BatchProposal[] proposals)BatchProposal(Proposal proposal,uint256 maxAmount)Proposal(address oracle,address requester,bytes32 identifier,uint256 timestamp,bytes ancillaryData,int256 proposedPrice,uint256 maxPayment)\"\n );\n string public constant BATCH_WITNESS_TYPE_STRING =\n \"BatchWitness witness)BatchProposal(Proposal proposal,uint256 maxAmount)BatchWitness(BatchProposal[] proposals)Proposal(address oracle,address requester,bytes32 identifier,uint256 timestamp,bytes ancillaryData,int256 proposedPrice,uint256 maxPayment)TokenPermissions(address token,uint256 amount)\";\n\n // \u2500\u2500\u2500 Storage \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n ISignatureTransfer public permit2;\n\n // \u2500\u2500\u2500 Events \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n event ProposalExecuted(\n address indexed proposer,\n address indexed oracle,\n address indexed requester,\n bytes32 identifier,\n uint256 timestamp,\n int256 proposedPrice,\n uint256 totalBond,\n uint256 payment\n );\n\n event PaymentWithdrawn(address indexed token, address indexed to, uint256 amount);\n\n /// @dev revertDataHash hashes at most the first 256 bytes of child revert data.\n event BatchProposalFailed(\n uint256 indexed index, bytes32 indexed proposalHash, bytes4 errorSelector, bytes32 revertDataHash\n );\n event BatchExecuted(\n address indexed proposer, address indexed token, uint256 indexed nonce, uint256 spent, uint256 refund\n );\n\n error EmptyBatch();\n error BatchLengthMismatch();\n error BatchAmountMismatch(uint256 totalBudget, uint256 permitAmount);\n error OnlySelf();\n error ZeroAddress();\n error PaymentExceedsMaxPayment();\n error PermitTransferAmountMismatch(uint256 expectedAmount, uint256 receivedAmount);\n error PermitTokenMismatch(address requestCurrency, address permitToken);\n error CannotRemoveSelfFromWhitelist();\n error NewOwnerNotWhitelisted(address newOwner);\n\n // \u2500\u2500\u2500 Constructor \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor() {\n _disableInitializers();\n }\n\n /// @notice Initializes the proxy with its Permit2 contract and role/upgrade administrator.\n function initialize(ISignatureTransfer _permit2, address admin) external initializer {\n if (address(_permit2) == address(0) || admin == address(0)) revert ZeroAddress();\n __AccessControl_init();\n __Multicall_init();\n __ReentrancyGuard_init();\n __UUPSUpgradeable_init();\n permit2 = _permit2;\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @dev Reuses the existing admin role rather than introducing a separate upgrade authority.\n function _authorizeUpgrade(address) internal override onlyRole(DEFAULT_ADMIN_ROLE) {}\n\n // \u2500\u2500\u2500 Propose \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n /**\n * @notice Execute a proposal using a Permit2 witness signature.\n * @dev The signer must have approved the canonical Permit2 contract for the bond token. The\n * proposal parameters are embedded as the Permit2 witness, so one signature authorises both\n * the token transfer and the specific proposal. Token amount, nonce, and deadline are in the\n * permit \u2014 not the witness.\n *\n * `proposal.maxPayment` caps the retained order-flow payment the relayer may charge.\n * `permit.permitted.amount` is the proposer's aggregate spend cap covering both `totalBond`\n * and `payment`.\n *\n * Before the Permit2 transfer, this contract verifies that the permit token matches the\n * request currency recorded by the oracle. Permit2 then transfers `permit.permitted.amount`\n * to this contract. The oracle then pulls the exact bond during `proposePriceFor`, and any\n * excess above `totalBond + payment` is refunded to the proposer. The call reverts if\n * `payment > proposal.maxPayment` or if `payment + totalBond > permit.permitted.amount`.\n *\n * @param proposal The proposal parameters (oracle-specific fields only).\n * @param proposer Address of the proposer / token owner (verified by Permit2).\n * @param permit The Permit2 transfer parameters (token, amount, nonce, deadline).\n * @param signature Permit2 EIP-712 signature from the proposer.\n * @param payment Amount retained by the contract as order-flow payment. Must not exceed the\n * signer-approved `proposal.maxPayment`.\n * @return totalBond The exact bond amount the oracle pulled for the proposal.\n */\n function propose(\n Proposal calldata proposal,\n address proposer,\n ISignatureTransfer.PermitTransferFrom calldata permit,\n bytes calldata signature,\n uint256 payment\n ) external onlyRole(DELEGATED_PROPOSER_ROLE) nonReentrant returns (uint256 totalBond) {\n if (payment > proposal.maxPayment) revert PaymentExceedsMaxPayment();\n IERC20 currency = _getRequestCurrency(proposal);\n if (address(currency) != permit.permitted.token) {\n revert PermitTokenMismatch(address(currency), permit.permitted.token);\n }\n _permit2Transfer(permit, proposer, signature, _hashProposal(proposal), WITNESS_TYPE_STRING);\n totalBond = _executeProposal(proposal, proposer, currency, permit.permitted.amount, payment, true);\n }\n\n /**\n * @notice Execute a same-token batch for one signer using one Permit2 witness signature.\n * @dev The ordered proposals and their individual budgets are signed. Their budgets must sum\n * exactly to permit.permitted.amount. Each child rolls back independently on failure; only\n * successful bonds/payments are charged, and all unused funds are refunded once at the end.\n * A completed batch consumes its nonce even if every child fails. Invalid signatures, invalid\n * batch shape/funding, a failed final refund, or insufficient outer gas revert the whole batch.\n * Delegated relayers are fully trusted to select per-item payments and supply sufficient gas.\n * A payment above maxPayment, or one leaving insufficient budget for the bond, fails that item\n * without reverting the batch. Such failures, including relayer mistakes, consume the shared\n * nonce on batch completion; unused funds are refunded and retries require a fresh signature.\n * As with tryMulticall, there is no per-child gas cap or guarantee against gas starvation.\n * @param proposals Signed proposal fields and bond-plus-payment budgets, in execution order.\n * @param proposer Signer, token owner, and refund recipient for the entire batch.\n * @param permit Single-token Permit2 authorization covering the sum of all item budgets.\n * @param signature One signature over the permit and BatchWitness.\n * @param payments Actual per-item payments, bounded by each signed proposal.maxPayment.\n * @return successes Per-item execution results. Failed items require a fresh signed batch to retry.\n */\n function proposeBatch(\n BatchProposal[] calldata proposals,\n address proposer,\n ISignatureTransfer.PermitTransferFrom calldata permit,\n bytes calldata signature,\n uint256[] calldata payments\n ) external onlyRole(DELEGATED_PROPOSER_ROLE) nonReentrant returns (bool[] memory successes) {\n uint256 length = proposals.length;\n if (length == 0) revert EmptyBatch();\n if (length != payments.length) revert BatchLengthMismatch();\n\n // Permit2 needs the full ordered witness before it can authenticate and fund the batch.\n // This first pass hashes each item once and checks the total budget; the second executes\n // the funded items. A permissioned relayer must still prove the signer's exact authorization.\n bytes32[] memory hashes = new bytes32[](length);\n uint256 totalBudget;\n for (uint256 i; i < length; ++i) {\n hashes[i] = _hashBatchProposal(proposals[i]);\n totalBudget += proposals[i].maxAmount;\n }\n if (totalBudget != permit.permitted.amount) {\n revert BatchAmountMismatch(totalBudget, permit.permitted.amount);\n }\n bytes32 witness = keccak256(abi.encode(BATCH_WITNESS_TYPEHASH, keccak256(abi.encodePacked(hashes))));\n _permit2Transfer(permit, proposer, signature, witness, BATCH_WITNESS_TYPE_STRING);\n\n IERC20 currency = IERC20(permit.permitted.token);\n // Deduct only successful bond + payment spends; failed budgets remain refundable.\n uint256 refund = permit.permitted.amount;\n successes = new bool[](length);\n for (uint256 i; i < length; ++i) {\n bytes memory callData =\n abi.encodeCall(this.executeBatchProposal, (proposals[i], proposer, currency, payments[i]));\n bool success;\n uint256 spent;\n bytes4 errorSelector;\n bytes32 revertDataHash;\n // Avoid allocating the complete child revert payload in the parent frame.\n assembly (\"memory-safe\") {\n success := call(gas(), address(), 0, add(callData, 0x20), mload(callData), 0, 0)\n switch success\n case 1 {\n // The self-only helper returns exactly one uint256; never accept a missing spend value.\n if iszero(eq(returndatasize(), 0x20)) { revert(0, 0) }\n returndatacopy(0, 0, 0x20)\n spent := mload(0)\n }\n default {\n let size := returndatasize()\n if gt(size, MAX_BATCH_REVERT_DATA_SIZE) { size := MAX_BATCH_REVERT_DATA_SIZE }\n let data := mload(0x40)\n returndatacopy(data, 0, size)\n if iszero(lt(size, 4)) { errorSelector := mload(data) }\n revertDataHash := keccak256(data, size)\n }\n }\n successes[i] = success;\n if (success) {\n refund -= spent;\n } else {\n emit BatchProposalFailed(i, hashes[i], errorSelector, revertDataHash);\n }\n }\n if (refund > 0) currency.safeTransfer(proposer, refund);\n emit BatchExecuted(proposer, address(currency), permit.nonce, permit.permitted.amount - refund, refund);\n }\n\n /// @dev Only the funded batch may enter this call boundary. The outer nonReentrant guard stays\n /// active throughout child execution; token/oracle callbacks cannot enter propose or proposeBatch.\n /// An external self-call lets the parent catch failures and roll back every effect of this child.\n function executeBatchProposal(BatchProposal calldata item, address proposer, IERC20 currency, uint256 payment)\n external\n returns (uint256 spent)\n {\n if (msg.sender != address(this)) revert OnlySelf();\n if (payment > item.proposal.maxPayment) revert PaymentExceedsMaxPayment();\n IERC20 requestCurrency = _getRequestCurrency(item.proposal);\n if (requestCurrency != currency) {\n revert PermitTokenMismatch(address(requestCurrency), address(currency));\n }\n // Defer refunds to the outer batch; the individual cap still bounds this oracle's allowance.\n spent = _executeProposal(item.proposal, proposer, currency, item.maxAmount, payment, false) + payment;\n }\n\n // \u2500\u2500\u2500 Internals \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n function _checkTryMulticallCaller() internal view override {\n _checkRole(DELEGATED_PROPOSER_ROLE);\n }\n\n function _tryMulticallSelector() internal pure override returns (bytes4) {\n return SignedProposer.propose.selector;\n }\n\n function _getRequestCurrency(Proposal calldata proposal) internal view returns (IERC20) {\n OptimisticOracleV2Interface.Request memory request = OptimisticOracleV2Interface(proposal.oracle).getRequest(\n proposal.requester, proposal.identifier, proposal.timestamp, proposal.ancillaryData\n );\n return request.currency;\n }\n\n function _hashProposal(Proposal calldata proposal) internal pure returns (bytes32) {\n return keccak256(\n abi.encode(\n PROPOSAL_TYPEHASH,\n proposal.oracle,\n proposal.requester,\n proposal.identifier,\n proposal.timestamp,\n keccak256(proposal.ancillaryData),\n proposal.proposedPrice,\n proposal.maxPayment\n )\n );\n }\n\n function _hashBatchProposal(BatchProposal calldata item) internal pure returns (bytes32) {\n return keccak256(abi.encode(BATCH_PROPOSAL_TYPEHASH, _hashProposal(item.proposal), item.maxAmount));\n }\n\n function _permit2Transfer(\n ISignatureTransfer.PermitTransferFrom calldata permit,\n address proposer,\n bytes calldata signature,\n bytes32 witness,\n string memory witnessTypeString\n ) internal {\n IERC20 currency = IERC20(permit.permitted.token);\n uint256 balanceBefore = currency.balanceOf(address(this));\n\n permit2.permitWitnessTransferFrom(\n permit,\n ISignatureTransfer.SignatureTransferDetails({to: address(this), requestedAmount: permit.permitted.amount}),\n proposer,\n witness,\n witnessTypeString,\n signature\n );\n\n uint256 balanceAfter = currency.balanceOf(address(this));\n uint256 received = balanceAfter >= balanceBefore ? balanceAfter - balanceBefore : 0;\n if (received != permit.permitted.amount) {\n revert PermitTransferAmountMismatch(permit.permitted.amount, received);\n }\n }\n\n function _executeProposal(\n Proposal calldata proposal,\n address proposer,\n IERC20 currency,\n uint256 maxAmount,\n uint256 payment,\n bool refundExcess\n ) internal returns (uint256 totalBond) {\n AddressWhitelistInterface whitelist = _getEffectiveProposerWhitelist(proposal);\n bool addedToWhitelist;\n if (!whitelist.isOnWhitelist(proposer)) {\n whitelist.addToWhitelist(proposer);\n addedToWhitelist = true;\n }\n\n // Grant oracle allowance only for proposePriceFor; whitelist hooks must not observe live approval.\n currency.forceApprove(proposal.oracle, maxAmount - payment);\n totalBond = _proposePriceFor(proposal, proposer, currency);\n // Revoke any leftover allowance the oracle didn't spend.\n currency.forceApprove(proposal.oracle, 0);\n if (addedToWhitelist) whitelist.removeFromWhitelist(proposer);\n\n uint256 excess = maxAmount - totalBond - payment;\n if (refundExcess && excess > 0) currency.safeTransfer(proposer, excess);\n\n emit ProposalExecuted(\n proposer,\n proposal.oracle,\n proposal.requester,\n proposal.identifier,\n proposal.timestamp,\n proposal.proposedPrice,\n totalBond,\n payment\n );\n }\n\n /// @dev Calls proposePriceFor and returns the actual bond based on balance change.\n function _proposePriceFor(Proposal calldata proposal, address proposer, IERC20 currency)\n internal\n returns (uint256)\n {\n uint256 balanceBefore = currency.balanceOf(address(this));\n\n OptimisticOracleV2Interface(proposal.oracle).proposePriceFor(\n proposer,\n proposal.requester,\n proposal.identifier,\n proposal.timestamp,\n proposal.ancillaryData,\n proposal.proposedPrice\n );\n\n return balanceBefore - currency.balanceOf(address(this));\n }\n\n function _getEffectiveProposerWhitelist(Proposal calldata proposal)\n internal\n view\n returns (AddressWhitelistInterface whitelist)\n {\n SignedProposerOracleInterface oracle = SignedProposerOracleInterface(proposal.oracle);\n whitelist = oracle.getCustomProposerWhitelist(proposal.requester, proposal.identifier, proposal.ancillaryData);\n if (address(whitelist) == address(0)) whitelist = oracle.defaultProposerWhitelist();\n }\n\n // \u2500\u2500\u2500 Role management \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n /**\n * @notice Adds a delegated proposer.\n * @dev Only callable by the default admin (checked in grantRole of AccessControl).\n * @param account The delegated proposer to add.\n */\n function addDelegatedProposer(address account) external {\n grantRole(DELEGATED_PROPOSER_ROLE, account);\n }\n\n /**\n * @notice Removes a delegated proposer.\n * @dev Only callable by the default admin (checked in revokeRole of AccessControl).\n * @param account The delegated proposer to remove.\n */\n function removeDelegatedProposer(address account) external {\n revokeRole(DELEGATED_PROPOSER_ROLE, account);\n }\n\n /**\n * @notice Adds a whitelist admin.\n * @dev Only callable by the default admin (checked in grantRole of AccessControl).\n * @param account The whitelist admin to add.\n */\n function addWhitelistAdmin(address account) external {\n grantRole(WHITELIST_ADMIN_ROLE, account);\n }\n\n /**\n * @notice Removes a whitelist admin.\n * @dev Only callable by the default admin (checked in revokeRole of AccessControl).\n * @param account The whitelist admin to remove.\n */\n function removeWhitelistAdmin(address account) external {\n revokeRole(WHITELIST_ADMIN_ROLE, account);\n }\n\n // \u2500\u2500\u2500 Whitelist management \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n /**\n * @notice Add an address to a whitelist owned by this contract.\n * @param whitelist The AddressWhitelist contract to modify.\n * @param account The address to add.\n */\n function addToWhitelist(AddressWhitelist whitelist, address account) external onlyRole(WHITELIST_ADMIN_ROLE) {\n whitelist.addToWhitelist(account);\n }\n\n /**\n * @notice Remove an address from a whitelist owned by this contract.\n * @param whitelist The AddressWhitelist contract to modify.\n * @param account The address to remove.\n */\n function removeFromWhitelist(AddressWhitelist whitelist, address account) external onlyRole(WHITELIST_ADMIN_ROLE) {\n if (account == address(this)) revert CannotRemoveSelfFromWhitelist();\n whitelist.removeFromWhitelist(account);\n }\n\n /**\n * @notice Transfer ownership of a whitelist owned by this contract.\n * @dev `newOwner` must be on the whitelist before ownership transfer so replacement relays\n * can continue to satisfy ManagedOptimisticOracleV2's sender whitelist check.\n * @param whitelist The AddressWhitelist contract to transfer.\n * @param newOwner The new owner of the whitelist.\n */\n function transferWhitelistOwnership(AddressWhitelist whitelist, address newOwner)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (!whitelist.isOnWhitelist(newOwner)) revert NewOwnerNotWhitelisted(newOwner);\n whitelist.transferOwnership(newOwner);\n }\n\n // \u2500\u2500\u2500 Payment withdrawal \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n /**\n * @notice Withdraw accumulated order-flow payments from the contract.\n * @param token The ERC20 token to withdraw.\n * @param to The address to send the tokens to.\n * @param amount The amount to withdraw.\n */\n function withdrawPayments(IERC20 token, address to, uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE) {\n token.safeTransfer(to, amount);\n emit PaymentWithdrawn(address(token), to, amount);\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)\n\npragma solidity >=0.4.16;\n\n/**\n * @dev Interface of the ERC-20 standard as defined in the ERC.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the value of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the value of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 value) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n * caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 value) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\n * allowance mechanism. `value` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n" + }, + "lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\nimport {IERC1363} from \"../../../interfaces/IERC1363.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC-20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n /**\n * @dev An operation with an ERC-20 token failed.\n */\n error SafeERC20FailedOperation(address token);\n\n /**\n * @dev Indicates a failed `decreaseAllowance` request.\n */\n error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));\n }\n\n /**\n * @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.\n */\n function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {\n return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));\n }\n\n /**\n * @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.\n */\n function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {\n return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n *\n * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the \"client\"\n * smart contract uses ERC-7674 to set temporary allowances, then the \"client\" smart contract should avoid using\n * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract\n * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.\n */\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n forceApprove(token, spender, oldAllowance + value);\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no\n * value, non-reverting calls are assumed to be successful.\n *\n * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the \"client\"\n * smart contract uses ERC-7674 to set temporary allowances, then the \"client\" smart contract should avoid using\n * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract\n * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.\n */\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {\n unchecked {\n uint256 currentAllowance = token.allowance(address(this), spender);\n if (currentAllowance < requestedDecrease) {\n revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);\n }\n forceApprove(token, spender, currentAllowance - requestedDecrease);\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n *\n * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function\n * only sets the \"standard\" allowance. Any temporary allowance will remain active, in addition to the value being\n * set here.\n */\n function forceApprove(IERC20 token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no\n * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when\n * targeting contracts.\n *\n * Reverts if the returned value is other than `true`.\n */\n function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {\n if (to.code.length == 0) {\n safeTransfer(token, to, value);\n } else if (!token.transferAndCall(to, value, data)) {\n revert SafeERC20FailedOperation(address(token));\n }\n }\n\n /**\n * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target\n * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when\n * targeting contracts.\n *\n * Reverts if the returned value is other than `true`.\n */\n function transferFromAndCallRelaxed(\n IERC1363 token,\n address from,\n address to,\n uint256 value,\n bytes memory data\n ) internal {\n if (to.code.length == 0) {\n safeTransferFrom(token, from, to, value);\n } else if (!token.transferFromAndCall(from, to, value, data)) {\n revert SafeERC20FailedOperation(address(token));\n }\n }\n\n /**\n * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no\n * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when\n * targeting contracts.\n *\n * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.\n * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}\n * once without retrying, and relies on the returned value to be true.\n *\n * Reverts if the returned value is other than `true`.\n */\n function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {\n if (to.code.length == 0) {\n forceApprove(token, to, value);\n } else if (!token.approveAndCall(to, value, data)) {\n revert SafeERC20FailedOperation(address(token));\n }\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n uint256 returnSize;\n uint256 returnValue;\n assembly (\"memory-safe\") {\n let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)\n // bubble errors\n if iszero(success) {\n let ptr := mload(0x40)\n returndatacopy(ptr, 0, returndatasize())\n revert(ptr, returndatasize())\n }\n returnSize := returndatasize()\n returnValue := mload(0)\n }\n\n if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {\n revert SafeERC20FailedOperation(address(token));\n }\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\n bool success;\n uint256 returnSize;\n uint256 returnValue;\n assembly (\"memory-safe\") {\n success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)\n returnSize := returndatasize()\n returnValue := mload(0)\n }\n return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);\n }\n}\n" + }, + "lib/openzeppelin-contracts-upgradeable/contracts/access/AccessControlUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.20;\n\nimport {IAccessControl} from \"@openzeppelin/contracts/access/IAccessControl.sol\";\nimport {ContextUpgradeable} from \"../utils/ContextUpgradeable.sol\";\nimport {IERC165} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport {ERC165Upgradeable} from \"../utils/introspection/ERC165Upgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account => bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role => RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) & ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /// @inheritdoc IERC165\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` from `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n" + }, + "lib/openzeppelin-contracts-upgradeable/contracts/utils/MulticallUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.3.0) (utils/Multicall.sol)\n\npragma solidity ^0.8.20;\n\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\nimport {ContextUpgradeable} from \"./ContextUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides a function to batch together multiple calls in a single external call.\n *\n * Consider any assumption about calldata validation performed by the sender may be violated if it's not especially\n * careful about sending transactions invoking {multicall}. For example, a relay address that filters function\n * selectors won't filter calls nested within a {multicall} operation.\n *\n * NOTE: Since 5.0.1 and 4.9.4, this contract identifies non-canonical contexts (i.e. `msg.sender` is not {Context-_msgSender}).\n * If a non-canonical context is identified, the following self `delegatecall` appends the last bytes of `msg.data`\n * to the subcall. This makes it safe to use with {ERC2771Context}. Contexts that don't affect the resolution of\n * {Context-_msgSender} are not propagated to subcalls.\n */\nabstract contract MulticallUpgradeable is Initializable, ContextUpgradeable {\n function __Multicall_init() internal onlyInitializing {\n }\n\n function __Multicall_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev Receives and executes a batch of function calls on this contract.\n * @custom:oz-upgrades-unsafe-allow-reachable delegatecall\n */\n function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) {\n bytes memory context = msg.sender == _msgSender()\n ? new bytes(0)\n : msg.data[msg.data.length - _contextSuffixLength():];\n\n results = new bytes[](data.length);\n for (uint256 i = 0; i < data.length; i++) {\n results[i] = Address.functionDelegateCall(address(this), bytes.concat(data[i], context));\n }\n return results;\n }\n}\n" + }, + "lib/openzeppelin-contracts-upgradeable/contracts/utils/ReentrancyGuardUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)\n\npragma solidity ^0.8.20;\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,\n * consider using {ReentrancyGuardTransient} instead.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant NOT_ENTERED = 1;\n uint256 private constant ENTERED = 2;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard\n struct ReentrancyGuardStorage {\n uint256 _status;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.ReentrancyGuard\")) - 1)) & ~bytes32(uint256(0xff))\n bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;\n\n function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {\n assembly {\n $.slot := ReentrancyGuardStorageLocation\n }\n }\n\n /**\n * @dev Unauthorized reentrant call.\n */\n error ReentrancyGuardReentrantCall();\n\n function __ReentrancyGuard_init() internal onlyInitializing {\n __ReentrancyGuard_init_unchained();\n }\n\n function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();\n $._status = NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _nonReentrantBefore();\n _;\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();\n // On the first call to nonReentrant, _status will be NOT_ENTERED\n if ($._status == ENTERED) {\n revert ReentrancyGuardReentrantCall();\n }\n\n // Any calls to nonReentrant after this point will fail\n $._status = ENTERED;\n }\n\n function _nonReentrantAfter() private {\n ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n $._status = NOT_ENTERED;\n }\n\n /**\n * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n * `nonReentrant` function in the call stack.\n */\n function _reentrancyGuardEntered() internal view returns (bool) {\n ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();\n return $._status == ENTERED;\n }\n}\n" + }, + "src/optimistic-oracle-v2/interfaces/OptimisticOracleV2Interface.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\n// Ported from https://github.com/UMAprotocol/protocol/blob/%40uma/core%402.62.0/packages/core/contracts/optimistic-oracle-v2/interfaces/OptimisticOracleV2Interface.sol\n// to be compatible for use in upgradeable contracts and OpenZeppelin v5.x. This also uses custom errors, named imports\n// and linting from Foundry.\n\npragma solidity ^0.8.4;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {FinderInterface} from \"@uma/contracts/data-verification-mechanism/interfaces/FinderInterface.sol\";\n\n/**\n * @title Financial contract facing Oracle interface.\n * @dev Interface used by financial contracts to interact with the Oracle. Voters will use a different interface.\n */\nabstract contract OptimisticOracleV2Interface {\n /// @notice Thrown when a request is not in the expected Invalid state.\n error RequestStateNotInvalid();\n /// @notice Thrown when a request is not in the expected Requested state.\n error RequestStateNotRequested();\n /// @notice Thrown when a request is not in the expected Proposed state.\n error RequestStateNotProposed();\n /// @notice Thrown when an identifier is not supported by the identifier whitelist.\n error UnsupportedIdentifier();\n /// @notice Thrown when a currency is not supported by the collateral whitelist.\n error UnsupportedCurrency();\n /// @notice Thrown when a timestamp is in the future.\n error TimestampInFuture();\n /// @notice Thrown when ancillary data exceeds the allowed limit.\n error AncillaryDataTooLong();\n /// @notice Thrown when a proposer address is zero.\n error ProposerAddressCannotBeZero();\n /// @notice Thrown when trying to propose the \"too early\" response for event-based requests.\n error CannotProposeTooEarly();\n /// @notice Thrown when a disputer address is zero.\n error DisputerAddressCannotBeZero();\n /// @notice Thrown when liveness period is too large.\n error LivenessTooLarge();\n /// @notice Thrown when liveness period cannot be zero.\n error LivenessCannotBeZero();\n /// @notice Thrown when trying to settle a request that is not settleable.\n error RequestNotSettleable();\n /// @notice Thrown when trying to claim a non-existent deferred payout.\n error NoDeferredPayoutToClaim();\n /// @notice Thrown when settle claim repayment address is zero.\n error RepaymentAddressCannotBeZero();\n\n event RequestPrice(\n address indexed requester,\n bytes32 identifier,\n uint256 timestamp,\n bytes ancillaryData,\n address currency,\n uint256 reward,\n uint256 finalFee\n );\n event RewardUpdated(\n address indexed requester,\n bytes32 identifier,\n uint256 timestamp,\n bytes ancillaryData,\n address updater,\n uint256 oldReward,\n uint256 newReward\n );\n /// @notice Emitted when the proposal bond associated with a price request is updated.\n /// @param requester sender of the initial price request.\n /// @param identifier price identifier identifying the existing request.\n /// @param timestamp timestamp identifying the existing request.\n /// @param ancillaryData ancillary data of the price being requested.\n /// @param oldBond previous custom bond amount.\n /// @param newBond new custom bond amount.\n event BondUpdated(\n address indexed requester,\n bytes32 identifier,\n uint256 timestamp,\n bytes ancillaryData,\n uint256 oldBond,\n uint256 newBond\n );\n /// @notice Emitted when the custom liveness associated with a price request is updated.\n /// @param requester sender of the initial price request.\n /// @param identifier price identifier identifying the existing request.\n /// @param timestamp timestamp identifying the existing request.\n /// @param ancillaryData ancillary data of the price being requested.\n /// @param oldCustomLiveness previous custom liveness value.\n /// @param newCustomLiveness new custom liveness value.\n event CustomLivenessUpdated(\n address indexed requester,\n bytes32 identifier,\n uint256 timestamp,\n bytes ancillaryData,\n uint256 oldCustomLiveness,\n uint256 newCustomLiveness\n );\n event ProposePrice(\n address indexed requester,\n address indexed proposer,\n bytes32 identifier,\n uint256 timestamp,\n bytes ancillaryData,\n int256 proposedPrice,\n uint256 expirationTimestamp,\n address currency\n );\n event DisputePrice(\n address indexed requester,\n address indexed proposer,\n address indexed disputer,\n bytes32 identifier,\n uint256 timestamp,\n bytes ancillaryData,\n int256 proposedPrice\n );\n event Settle(\n address indexed requester,\n address indexed proposer,\n address indexed disputer,\n bytes32 identifier,\n uint256 timestamp,\n bytes ancillaryData,\n int256 price,\n uint256 payout\n );\n event PayoutDeferred(address indexed currency, address indexed deferredRecipient, uint256 amount);\n event ClaimedDeferredPayout(\n address indexed currency, address indexed deferredRecipient, address indexed repaymentAddress, uint256 amount\n );\n // Struct representing the state of a price request.\n\n enum State {\n Invalid, // Never requested.\n Requested, // Requested, no other actions taken.\n Proposed, // Proposed, but not expired or disputed yet.\n Expired, // Proposed, not disputed, past liveness.\n Disputed, // Disputed, but no DVM price returned yet.\n Resolved, // Disputed and DVM price is available.\n Settled // Final price has been set in the contract (can get here from Expired or Resolved).\n\n }\n\n struct RequestSettings {\n bool eventBased; // True if the request is set to be event-based.\n bool refundOnDispute; // True if the requester should be refunded their reward on dispute.\n bool callbackOnPriceProposed; // True if callbackOnPriceProposed callback is required.\n bool callbackOnPriceDisputed; // True if callbackOnPriceDisputed callback is required.\n bool callbackOnPriceSettled; // True if callbackOnPriceSettled callback is required.\n uint256 bond; // Bond that the proposer and disputer must pay on top of the final fee.\n uint256 customLiveness; // Custom liveness value set by the requester.\n }\n\n // Struct representing a price request.\n struct Request {\n address proposer; // Address of the proposer.\n address disputer; // Address of the disputer.\n IERC20 currency; // ERC20 token used to pay rewards and fees.\n bool settled; // True if the request is settled.\n RequestSettings requestSettings; // Custom settings associated with a request.\n int256 proposedPrice; // Price that the proposer submitted.\n int256 resolvedPrice; // Price resolved once the request is settled.\n uint256 expirationTime; // Time at which the request auto-settles without a dispute.\n uint256 reward; // Amount of the currency to pay to the proposer on settlement.\n uint256 finalFee; // Final fee to pay to the Store upon request to the DVM.\n uint256 proposalTime; // Time of the proposal.\n }\n\n // This value must be <= the Voting contract's `ancillaryBytesLimit` value otherwise it is possible\n // that a price can be requested to this contract successfully, but cannot be disputed because the DVM refuses\n // to accept a price request made with ancillary data length over a certain size.\n uint256 public constant ANCILLARY_BYTES_LIMIT = 8192;\n\n /// @notice Deprecated compatibility getter. Use `ANCILLARY_BYTES_LIMIT()` instead.\n /// @dev Preserves the selector published by earlier OptimisticOracleV2 deployments.\n function ancillaryBytesLimit() external pure returns (uint256) {\n return ANCILLARY_BYTES_LIMIT;\n }\n\n function defaultLiveness() external view virtual returns (uint256);\n\n function finder() external view virtual returns (FinderInterface);\n\n function getCurrentTime() external view virtual returns (uint256);\n\n // Note: this is required so that typechain generates a return value with named fields.\n mapping(bytes32 => Request) public requests;\n\n /**\n * @notice Requests a new price.\n * @param identifier price identifier being requested.\n * @param timestamp timestamp of the price being requested.\n * @param ancillaryData ancillary data representing additional args being passed with the price request.\n * @param currency ERC20 token used for payment of rewards and fees. Must be approved for use with the DVM.\n * @param reward reward offered to a successful proposer. Will be pulled from the caller. Note: this can be 0,\n * which could make sense if the contract requests and proposes the value in the same call or\n * provides its own reward system.\n * @return totalBond default bond (final fee) + final fee that the proposer and disputer will be required to pay.\n * This can be changed with a subsequent call to setBond().\n */\n function requestPrice(\n bytes32 identifier,\n uint256 timestamp,\n bytes memory ancillaryData,\n IERC20 currency,\n uint256 reward\n ) external virtual returns (uint256 totalBond);\n\n /**\n * @notice Set the proposal bond associated with a price request.\n * @param identifier price identifier to identify the existing request.\n * @param timestamp timestamp to identify the existing request.\n * @param ancillaryData ancillary data of the price being requested.\n * @param bond custom bond amount to set.\n * @return totalBond new bond + final fee that the proposer and disputer will be required to pay. This can be\n * changed again with a subsequent call to setBond().\n */\n function setBond(bytes32 identifier, uint256 timestamp, bytes memory ancillaryData, uint256 bond)\n external\n virtual\n returns (uint256 totalBond);\n\n /**\n * @notice Updates the reward associated with a price request.\n * @dev Only callable by the requester while the request is in the Requested state. The requester funds increases\n * and receives decreases, which may be deferred if the transfer fails.\n * @param identifier price identifier to identify the existing request.\n * @param timestamp timestamp to identify the existing request.\n * @param ancillaryData ancillary data of the price being requested.\n * @param newReward new reward amount, which can be zero.\n */\n function setReward(bytes32 identifier, uint256 timestamp, bytes memory ancillaryData, uint256 newReward)\n external\n virtual;\n\n /**\n * @notice Sets the request to refund the reward if the proposal is disputed. This can help to \"hedge\" the caller\n * in the event of a dispute-caused delay. Note: in the event of a dispute, the winner still receives the other's\n * bond, so there is still profit to be made even if the reward is refunded.\n * @param identifier price identifier to identify the existing request.\n * @param timestamp timestamp to identify the existing request.\n * @param ancillaryData ancillary data of the price being requested.\n */\n function setRefundOnDispute(bytes32 identifier, uint256 timestamp, bytes memory ancillaryData) external virtual;\n\n /**\n * @notice Sets a custom liveness value for the request. Liveness is the amount of time a proposal must wait before\n * being auto-resolved.\n * @param identifier price identifier to identify the existing request.\n * @param timestamp timestamp to identify the existing request.\n * @param ancillaryData ancillary data of the price being requested.\n * @param customLiveness new custom liveness.\n */\n function setCustomLiveness(\n bytes32 identifier,\n uint256 timestamp,\n bytes memory ancillaryData,\n uint256 customLiveness\n ) external virtual;\n\n /**\n * @notice Sets the request to be an \"event-based\" request.\n * @dev Calling this method has a few impacts on the request:\n *\n * 1. The timestamp at which the request is evaluated is the time of the proposal, not the timestamp associated\n * with the request.\n *\n * 2. The proposer cannot propose the \"too early\" value (TOO_EARLY_RESPONSE). This is to ensure that a proposer who\n * prematurely proposes a response loses their bond.\n *\n * 3. RefundOnDispute is automatically set, meaning disputes trigger the reward to be automatically refunded to\n * the requesting contract.\n *\n * @param identifier price identifier to identify the existing request.\n * @param timestamp timestamp to identify the existing request.\n * @param ancillaryData ancillary data of the price being requested.\n */\n function setEventBased(bytes32 identifier, uint256 timestamp, bytes memory ancillaryData) external virtual;\n\n /**\n * @notice Sets which callbacks should be enabled for the request.\n * @param identifier price identifier to identify the existing request.\n * @param timestamp timestamp to identify the existing request.\n * @param ancillaryData ancillary data of the price being requested.\n * @param callbackOnPriceProposed whether to enable the callback onPriceProposed.\n * @param callbackOnPriceDisputed whether to enable the callback onPriceDisputed.\n * @param callbackOnPriceSettled whether to enable the callback onPriceSettled.\n */\n function setCallbacks(\n bytes32 identifier,\n uint256 timestamp,\n bytes memory ancillaryData,\n bool callbackOnPriceProposed,\n bool callbackOnPriceDisputed,\n bool callbackOnPriceSettled\n ) external virtual;\n\n /**\n * @notice Proposes a price value on another address' behalf. Note: this address will receive any rewards that come\n * from this proposal. However, any bonds are pulled from the caller.\n * @param proposer address to set as the proposer.\n * @param requester sender of the initial price request.\n * @param identifier price identifier to identify the existing request.\n * @param timestamp timestamp to identify the existing request.\n * @param ancillaryData ancillary data of the price being requested.\n * @param proposedPrice price being proposed.\n * @return totalBond the amount that's pulled from the caller's wallet as a bond. The bond will be returned to\n * the proposer once settled if the proposal is correct.\n */\n function proposePriceFor(\n address proposer,\n address requester,\n bytes32 identifier,\n uint256 timestamp,\n bytes memory ancillaryData,\n int256 proposedPrice\n ) public virtual returns (uint256 totalBond);\n\n /**\n * @notice Proposes a price value for an existing price request.\n * @param requester sender of the initial price request.\n * @param identifier price identifier to identify the existing request.\n * @param timestamp timestamp to identify the existing request.\n * @param ancillaryData ancillary data of the price being requested.\n * @param proposedPrice price being proposed.\n * @return totalBond the amount that's pulled from the proposer's wallet as a bond. The bond will be returned to\n * the proposer once settled if the proposal is correct.\n */\n function proposePrice(\n address requester,\n bytes32 identifier,\n uint256 timestamp,\n bytes memory ancillaryData,\n int256 proposedPrice\n ) external virtual returns (uint256 totalBond);\n\n /**\n * @notice Disputes a price request with an active proposal on another address' behalf. Note: this address will\n * receive any rewards that come from this dispute. However, any bonds are pulled from the caller.\n * @param disputer address to set as the disputer.\n * @param requester sender of the initial price request.\n * @param identifier price identifier to identify the existing request.\n * @param timestamp timestamp to identify the existing request.\n * @param ancillaryData ancillary data of the price being requested.\n * @return totalBond the amount that's pulled from the caller's wallet as a bond. The bond will be returned to\n * the disputer once settled if the dispute was value (the proposal was incorrect).\n */\n function disputePriceFor(\n address disputer,\n address requester,\n bytes32 identifier,\n uint256 timestamp,\n bytes memory ancillaryData\n ) public virtual returns (uint256 totalBond);\n\n /**\n * @notice Disputes a price value for an existing price request with an active proposal.\n * @param requester sender of the initial price request.\n * @param identifier price identifier to identify the existing request.\n * @param timestamp timestamp to identify the existing request.\n * @param ancillaryData ancillary data of the price being requested.\n * @return totalBond the amount that's pulled from the disputer's wallet as a bond. The bond will be returned to\n * the disputer once settled if the dispute was valid (the proposal was incorrect).\n */\n function disputePrice(address requester, bytes32 identifier, uint256 timestamp, bytes memory ancillaryData)\n external\n virtual\n returns (uint256 totalBond);\n\n /**\n * @notice Retrieves a price that was previously requested by a caller. Reverts if the request is not settled\n * or settleable. Note: this method is not view so that this call may actually settle the price request if it\n * hasn't been settled.\n * @param identifier price identifier to identify the existing request.\n * @param timestamp timestamp to identify the existing request.\n * @param ancillaryData ancillary data of the price being requested.\n * @return resolved price.\n */\n function settleAndGetPrice(bytes32 identifier, uint256 timestamp, bytes memory ancillaryData)\n external\n virtual\n returns (int256);\n\n /**\n * @notice Attempts to settle an outstanding price request. Will revert if it isn't settleable.\n * @param requester sender of the initial price request.\n * @param identifier price identifier to identify the existing request.\n * @param timestamp timestamp to identify the existing request.\n * @param ancillaryData ancillary data of the price being requested.\n * @return payout the amount that the \"winner\" (proposer or disputer) receives on settlement. This amount includes\n * the returned bonds as well as additional rewards.\n */\n function settle(address requester, bytes32 identifier, uint256 timestamp, bytes memory ancillaryData)\n external\n virtual\n returns (uint256 payout);\n\n /**\n * @notice Claims the deferred payout for a given currency to the provided repayment address.\n * @param currency ERC20 token used for the deferred payout.\n * @param repaymentAddress address to which the payout will be sent (can be different from the deferred recipient).\n */\n function claimDeferredPayout(IERC20 currency, address repaymentAddress) external virtual;\n\n /**\n * @notice Gets the current reward for a price request.\n * @param requester sender of the initial price request.\n * @param identifier price identifier to identify the existing request.\n * @param timestamp timestamp to identify the existing request.\n * @param ancillaryData ancillary data of the price being requested.\n * @return reward current reward amount.\n */\n function getRequestReward(address requester, bytes32 identifier, uint256 timestamp, bytes memory ancillaryData)\n public\n view\n virtual\n returns (uint256 reward);\n\n /**\n * @notice Gets the current data structure containing all information about a price request.\n * @param requester sender of the initial price request.\n * @param identifier price identifier to identify the existing request.\n * @param timestamp timestamp to identify the existing request.\n * @param ancillaryData ancillary data of the price being requested.\n * @return the Request data structure.\n */\n function getRequest(address requester, bytes32 identifier, uint256 timestamp, bytes memory ancillaryData)\n public\n view\n virtual\n returns (Request memory);\n\n /**\n * @notice Returns the state of a price request.\n * @param requester sender of the initial price request.\n * @param identifier price identifier to identify the existing request.\n * @param timestamp timestamp to identify the existing request.\n * @param ancillaryData ancillary data of the price being requested.\n * @return the State enum value.\n */\n function getState(address requester, bytes32 identifier, uint256 timestamp, bytes memory ancillaryData)\n public\n view\n virtual\n returns (State);\n\n /**\n * @notice Checks if a given request has resolved or been settled (i.e the optimistic oracle has a price).\n * @param requester sender of the initial price request.\n * @param identifier price identifier to identify the existing request.\n * @param timestamp timestamp to identify the existing request.\n * @param ancillaryData ancillary data of the price being requested.\n * @return true if price has resolved or settled, false otherwise.\n */\n function hasPrice(address requester, bytes32 identifier, uint256 timestamp, bytes memory ancillaryData)\n public\n view\n virtual\n returns (bool);\n\n function stampAncillaryData(bytes memory ancillaryData, address requester)\n public\n view\n virtual\n returns (bytes memory);\n\n /**\n * @dev Reserve storage slots for future versions of this base contract to add state variables without affecting the\n * storage layout of child contracts. Decrement the size of __gap whenever state variables are added. This is at the\n * bottom of contract to make sure its always at the end of storage.\n * See https://docs.openzeppelin.com/upgrades-plugins/writing-upgradeable#storage-gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "src/optimistic-oracle-v2/interfaces/SignedProposerOracleInterface.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.4;\n\nimport {AddressWhitelistInterface} from \"../../common/interfaces/AddressWhitelistInterface.sol\";\n\ninterface SignedProposerOracleInterface {\n function defaultProposerWhitelist() external view returns (AddressWhitelistInterface);\n\n function getCustomProposerWhitelist(address requester, bytes32 identifier, bytes memory ancillaryData)\n external\n view\n returns (AddressWhitelistInterface);\n}\n" + }, + "lib/permit2/src/interfaces/ISignatureTransfer.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {IEIP712} from \"./IEIP712.sol\";\n\n/// @title SignatureTransfer\n/// @notice Handles ERC20 token transfers through signature based actions\n/// @dev Requires user's token approval on the Permit2 contract\ninterface ISignatureTransfer is IEIP712 {\n /// @notice Thrown when the requested amount for a transfer is larger than the permissioned amount\n /// @param maxAmount The maximum amount a spender can request to transfer\n error InvalidAmount(uint256 maxAmount);\n\n /// @notice Thrown when the number of tokens permissioned to a spender does not match the number of tokens being transferred\n /// @dev If the spender does not need to transfer the number of tokens permitted, the spender can request amount 0 to be transferred\n error LengthMismatch();\n\n /// @notice Emits an event when the owner successfully invalidates an unordered nonce.\n event UnorderedNonceInvalidation(address indexed owner, uint256 word, uint256 mask);\n\n /// @notice The token and amount details for a transfer signed in the permit transfer signature\n struct TokenPermissions {\n // ERC20 token address\n address token;\n // the maximum amount that can be spent\n uint256 amount;\n }\n\n /// @notice The signed permit message for a single token transfer\n struct PermitTransferFrom {\n TokenPermissions permitted;\n // a unique value for every token owner's signature to prevent signature replays\n uint256 nonce;\n // deadline on the permit signature\n uint256 deadline;\n }\n\n /// @notice Specifies the recipient address and amount for batched transfers.\n /// @dev Recipients and amounts correspond to the index of the signed token permissions array.\n /// @dev Reverts if the requested amount is greater than the permitted signed amount.\n struct SignatureTransferDetails {\n // recipient address\n address to;\n // spender requested amount\n uint256 requestedAmount;\n }\n\n /// @notice Used to reconstruct the signed permit message for multiple token transfers\n /// @dev Do not need to pass in spender address as it is required that it is msg.sender\n /// @dev Note that a user still signs over a spender address\n struct PermitBatchTransferFrom {\n // the tokens and corresponding amounts permitted for a transfer\n TokenPermissions[] permitted;\n // a unique value for every token owner's signature to prevent signature replays\n uint256 nonce;\n // deadline on the permit signature\n uint256 deadline;\n }\n\n /// @notice A map from token owner address and a caller specified word index to a bitmap. Used to set bits in the bitmap to prevent against signature replay protection\n /// @dev Uses unordered nonces so that permit messages do not need to be spent in a certain order\n /// @dev The mapping is indexed first by the token owner, then by an index specified in the nonce\n /// @dev It returns a uint256 bitmap\n /// @dev The index, or wordPosition is capped at type(uint248).max\n function nonceBitmap(address, uint256) external view returns (uint256);\n\n /// @notice Transfers a token using a signed permit message\n /// @dev Reverts if the requested amount is greater than the permitted signed amount\n /// @param permit The permit data signed over by the owner\n /// @param owner The owner of the tokens to transfer\n /// @param transferDetails The spender's requested transfer details for the permitted token\n /// @param signature The signature to verify\n function permitTransferFrom(\n PermitTransferFrom memory permit,\n SignatureTransferDetails calldata transferDetails,\n address owner,\n bytes calldata signature\n ) external;\n\n /// @notice Transfers a token using a signed permit message\n /// @notice Includes extra data provided by the caller to verify signature over\n /// @dev The witness type string must follow EIP712 ordering of nested structs and must include the TokenPermissions type definition\n /// @dev Reverts if the requested amount is greater than the permitted signed amount\n /// @param permit The permit data signed over by the owner\n /// @param owner The owner of the tokens to transfer\n /// @param transferDetails The spender's requested transfer details for the permitted token\n /// @param witness Extra data to include when checking the user signature\n /// @param witnessTypeString The EIP-712 type definition for remaining string stub of the typehash\n /// @param signature The signature to verify\n function permitWitnessTransferFrom(\n PermitTransferFrom memory permit,\n SignatureTransferDetails calldata transferDetails,\n address owner,\n bytes32 witness,\n string calldata witnessTypeString,\n bytes calldata signature\n ) external;\n\n /// @notice Transfers multiple tokens using a signed permit message\n /// @param permit The permit data signed over by the owner\n /// @param owner The owner of the tokens to transfer\n /// @param transferDetails Specifies the recipient and requested amount for the token transfer\n /// @param signature The signature to verify\n function permitTransferFrom(\n PermitBatchTransferFrom memory permit,\n SignatureTransferDetails[] calldata transferDetails,\n address owner,\n bytes calldata signature\n ) external;\n\n /// @notice Transfers multiple tokens using a signed permit message\n /// @dev The witness type string must follow EIP712 ordering of nested structs and must include the TokenPermissions type definition\n /// @notice Includes extra data provided by the caller to verify signature over\n /// @param permit The permit data signed over by the owner\n /// @param owner The owner of the tokens to transfer\n /// @param transferDetails Specifies the recipient and requested amount for the token transfer\n /// @param witness Extra data to include when checking the user signature\n /// @param witnessTypeString The EIP-712 type definition for remaining string stub of the typehash\n /// @param signature The signature to verify\n function permitWitnessTransferFrom(\n PermitBatchTransferFrom memory permit,\n SignatureTransferDetails[] calldata transferDetails,\n address owner,\n bytes32 witness,\n string calldata witnessTypeString,\n bytes calldata signature\n ) external;\n\n /// @notice Invalidates the bits specified in mask for the bitmap at the word position\n /// @dev The wordPos is maxed at type(uint248).max\n /// @param wordPos A number to index the nonceBitmap at\n /// @param mask A bitmap masked against msg.sender's current bitmap at the word position\n function invalidateUnorderedNonces(uint256 wordPos, uint256 mask) external;\n}\n" + }, + "src/common/implementation/AddressWhitelist.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\n// Based on https://github.com/UMAprotocol/protocol/blob/%40uma/core%402.62.0/packages/core/contracts/common/implementation/AddressWhitelist.sol\n// adding the functionality to check if the whitelist is enabled and to be compatible with OpenZeppelin v5.x. This also\n// uses named imports and linting from Foundry.\n\npragma solidity ^0.8.0;\n\nimport {AddressWhitelistInterface} from \"../interfaces/AddressWhitelistInterface.sol\";\nimport {ERC165} from \"@openzeppelin/contracts/utils/introspection/ERC165.sol\";\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {Lockable} from \"@uma/contracts/common/implementation/Lockable.sol\";\nimport {EnumerableSet} from \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\n/**\n * @title A contract to track a whitelist of addresses.\n * @custom:security-contact bugs@umaproject.org\n */\ncontract AddressWhitelist is AddressWhitelistInterface, Ownable, Lockable, ERC165 {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n // Holds the entire whitelist of addresses. Order is not guaranteed and may change over time.\n EnumerableSet.AddressSet whitelistedSet;\n\n event AddedToWhitelist(address indexed addedAddress);\n event RemovedFromWhitelist(address indexed removedAddress);\n\n /**\n * @notice Constructor to initialize the contract.\n * @dev This makes it compatible with v5.x of OpenZeppelin's Ownable contract.\n */\n constructor() Ownable(msg.sender) {}\n\n /**\n * @notice Adds an address to the whitelist.\n * @param newElement the new address to add.\n */\n function addToWhitelist(address newElement) external override nonReentrant onlyOwner {\n bool added = whitelistedSet.add(newElement);\n if (added) {\n emit AddedToWhitelist(newElement);\n }\n }\n\n /**\n * @notice Removes an address from the whitelist.\n * @param elementToRemove the existing address to remove.\n */\n function removeFromWhitelist(address elementToRemove) external override nonReentrant onlyOwner {\n bool removed = whitelistedSet.remove(elementToRemove);\n if (removed) {\n emit RemovedFromWhitelist(elementToRemove);\n }\n }\n\n /**\n * @notice Checks whether an address is on the whitelist.\n * @param elementToCheck the address to check.\n * @return True if `elementToCheck` is on the whitelist, or False.\n */\n function isOnWhitelist(address elementToCheck) public view virtual override nonReentrantView returns (bool) {\n return whitelistedSet.contains(elementToCheck);\n }\n\n /**\n * @notice Gets all addresses that are currently included in the whitelist.\n * @dev Returns a copy of the entire set via EnumerableSet.values(). This operation is O(n) in the number of\n * addresses and theoretically unbounded. In practice, in the context of `ManagedOptimisticOracleV2.sol` this list\n * is expected to remain small, so this method is not expected to run out of gas.\n * Order of addresses is arbitrary and not guaranteed to be stable across calls.\n * @return activeWhitelist the list of addresses on the whitelist.\n */\n function getWhitelist() external view override nonReentrantView returns (address[] memory activeWhitelist) {\n return whitelistedSet.values();\n }\n\n /**\n * @notice Checks if the whitelist is enabled.\n * @dev For this implementation, the whitelist is always considered enabled.\n * @return enabled Always returns true.\n */\n function isWhitelistEnabled() external pure override returns (bool enabled) {\n return true;\n }\n\n /**\n * @notice Returns true if this contract implements the interface defined by interfaceId.\n * @param interfaceId The interface identifier, as specified in ERC-165.\n * @return True if the contract implements the interface defined by interfaceId.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(AddressWhitelistInterface).interfaceId || super.supportsInterface(interfaceId);\n }\n}\n" + }, + "src/common/interfaces/AddressWhitelistInterface.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\n// Based on https://github.com/UMAprotocol/protocol/blob/%40uma/core%402.62.0/packages/core/contracts/common/interfaces/AddressWhitelistInterface.sol\n// adding the functionality to check if the whitelist is enabled.\n\npragma solidity ^0.8.0;\n\ninterface AddressWhitelistInterface {\n function addToWhitelist(address newElement) external;\n\n function removeFromWhitelist(address newElement) external;\n\n function isOnWhitelist(address newElement) external view returns (bool);\n\n function getWhitelist() external view returns (address[] memory);\n\n function isWhitelistEnabled() external view returns (bool);\n}\n" + }, + "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/UUPSUpgradeable.sol)\n\npragma solidity ^0.8.22;\n\nimport {IERC1822Proxiable} from \"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\";\nimport {ERC1967Utils} from \"@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol\";\nimport {Initializable} from \"./Initializable.sol\";\n\n/**\n * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an\n * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.\n *\n * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is\n * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing\n * `UUPSUpgradeable` with a custom implementation of upgrades.\n *\n * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.\n */\nabstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address private immutable __self = address(this);\n\n /**\n * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`\n * and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,\n * while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.\n * If the getter returns `\"5.0.0\"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must\n * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function\n * during an upgrade.\n */\n string public constant UPGRADE_INTERFACE_VERSION = \"5.0.0\";\n\n /**\n * @dev The call is from an unauthorized context.\n */\n error UUPSUnauthorizedCallContext();\n\n /**\n * @dev The storage `slot` is unsupported as a UUID.\n */\n error UUPSUnsupportedProxiableUUID(bytes32 slot);\n\n /**\n * @dev Check that the execution is being performed through a delegatecall call and that the execution context is\n * a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case\n * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a\n * function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to\n * fail.\n */\n modifier onlyProxy() {\n _checkProxy();\n _;\n }\n\n /**\n * @dev Check that the execution is not being performed through a delegate call. This allows a function to be\n * callable on the implementing contract but not through proxies.\n */\n modifier notDelegated() {\n _checkNotDelegated();\n _;\n }\n\n function __UUPSUpgradeable_init() internal onlyInitializing {\n }\n\n function __UUPSUpgradeable_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the\n * implementation. It is used to validate the implementation's compatibility when performing an upgrade.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.\n */\n function proxiableUUID() external view virtual notDelegated returns (bytes32) {\n return ERC1967Utils.IMPLEMENTATION_SLOT;\n }\n\n /**\n * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call\n * encoded in `data`.\n *\n * Calls {_authorizeUpgrade}.\n *\n * Emits an {Upgraded} event.\n *\n * @custom:oz-upgrades-unsafe-allow-reachable delegatecall\n */\n function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {\n _authorizeUpgrade(newImplementation);\n _upgradeToAndCallUUPS(newImplementation, data);\n }\n\n /**\n * @dev Reverts if the execution is not performed via delegatecall or the execution\n * context is not of a proxy with an ERC-1967 compliant implementation pointing to self.\n */\n function _checkProxy() internal view virtual {\n if (\n address(this) == __self || // Must be called through delegatecall\n ERC1967Utils.getImplementation() != __self // Must be called through an active proxy\n ) {\n revert UUPSUnauthorizedCallContext();\n }\n }\n\n /**\n * @dev Reverts if the execution is performed via delegatecall.\n * See {notDelegated}.\n */\n function _checkNotDelegated() internal view virtual {\n if (address(this) != __self) {\n // Must not be called through delegatecall\n revert UUPSUnauthorizedCallContext();\n }\n }\n\n /**\n * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by\n * {upgradeToAndCall}.\n *\n * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.\n *\n * ```solidity\n * function _authorizeUpgrade(address) internal onlyOwner {}\n * ```\n */\n function _authorizeUpgrade(address newImplementation) internal virtual;\n\n /**\n * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.\n *\n * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value\n * is expected to be the implementation slot in ERC-1967.\n *\n * Emits an {IERC1967-Upgraded} event.\n */\n function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {\n revert UUPSUnsupportedProxiableUUID(slot);\n }\n ERC1967Utils.upgradeToAndCall(newImplementation, data);\n } catch {\n // The implementation is not UUPS\n revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);\n }\n }\n}\n" + }, + "src/common/implementation/TryMulticall.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.27;\n\n/**\n * @title TryMulticall\n * @notice Executes allowed self-delegatecalls without reverting successful siblings.\n * @custom:security-contact bugs@umaproject.org\n */\nabstract contract TryMulticall {\n /// @custom:storage-location erc7201:uma.storage.TryMulticall\n struct TryMulticallStorage {\n bool entered;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"uma.storage.TryMulticall\")) - 1)) & ~bytes32(uint256(0xff))\n bytes32 private constant TRY_MULTICALL_STORAGE_LOCATION =\n 0x0dd1bd2d495db0d62878fd399d4ab6dc237ff1584371e8862b3e045d79dcd000;\n\n /// @notice Emitted when a child execution attempt returns unsuccessfully.\n /// @dev Empty failure metadata can mean either an empty revert or an out-of-gas child. This event does not prove\n /// the submitted operation itself is invalid; callers may retry it with a different gas allocation.\n /// `revertDataHash` hashes at most the first 256 bytes of revert data; larger payloads are truncated before hashing.\n event ProposalCallFailed(\n uint256 indexed index, bytes32 indexed callHash, bytes4 errorSelector, bytes32 revertDataHash\n );\n\n error TryMulticallReentrantCall();\n error TryMulticallInvalidSelector(uint256 index, bytes4 selector);\n\n uint256 private constant MAX_REVERT_DATA_SIZE = 256;\n\n /**\n * @notice Executes allowed calls independently and returns their execution-attempt success values.\n * @dev Self-delegatecall preserves the original caller. Failed calls copy and hash at most 256 bytes of revert\n * data. There is no child gas cap. Under EIP-150, an out-of-gas child can return `false` while leaving the outer call\n * enough gas to continue, but later children may receive too little gas and also return `false`. If the remaining\n * outer gas cannot finish the loop or encode the result, the full batch reverts. A `false` value therefore means\n * only that the corresponding execution attempt failed; it does not prove the submitted operation is invalid.\n */\n function tryMulticall(bytes[] calldata calls) external returns (bool[] memory successes) {\n _checkTryMulticallCaller();\n TryMulticallStorage storage $ = _getTryMulticallStorage();\n if ($.entered) revert TryMulticallReentrantCall();\n\n uint256 callsLength = calls.length;\n bytes4 allowedSelector = _tryMulticallSelector();\n for (uint256 i; i < callsLength; ++i) {\n bytes calldata callData = calls[i];\n bytes4 selector = callData.length >= 4 ? bytes4(callData[:4]) : bytes4(0);\n if (selector != allowedSelector) revert TryMulticallInvalidSelector(i, selector);\n }\n\n successes = new bool[](callsLength);\n $.entered = true;\n for (uint256 i; i < callsLength; ++i) {\n bytes memory callData = calls[i];\n bool success;\n bytes4 errorSelector;\n bytes32 revertDataHash;\n assembly (\"memory-safe\") {\n success := delegatecall(gas(), address(), add(callData, 0x20), mload(callData), 0, 0)\n if iszero(success) {\n let size := returndatasize()\n if gt(size, MAX_REVERT_DATA_SIZE) { size := MAX_REVERT_DATA_SIZE }\n let data := mload(0x40)\n returndatacopy(data, 0, size)\n if iszero(lt(size, 4)) { errorSelector := mload(data) }\n revertDataHash := keccak256(data, size)\n }\n }\n successes[i] = success;\n\n if (!success) {\n emit ProposalCallFailed(i, keccak256(callData), errorSelector, revertDataHash);\n }\n }\n $.entered = false;\n }\n\n function _getTryMulticallStorage() private pure returns (TryMulticallStorage storage $) {\n assembly {\n $.slot := TRY_MULTICALL_STORAGE_LOCATION\n }\n }\n\n function _checkTryMulticallCaller() internal view virtual;\n\n function _tryMulticallSelector() internal view virtual returns (bytes4);\n}\n" + }, + "lib/openzeppelin-contracts/contracts/interfaces/IERC1363.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)\n\npragma solidity >=0.6.2;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC165} from \"./IERC165.sol\";\n\n/**\n * @title IERC1363\n * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].\n *\n * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract\n * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.\n */\ninterface IERC1363 is IERC20, IERC165 {\n /*\n * Note: the ERC-165 identifier for this interface is 0xb0202a11.\n * 0xb0202a11 ===\n * bytes4(keccak256('transferAndCall(address,uint256)')) ^\n * bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^\n * bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^\n * bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^\n * bytes4(keccak256('approveAndCall(address,uint256)')) ^\n * bytes4(keccak256('approveAndCall(address,uint256,bytes)'))\n */\n\n /**\n * @dev Moves a `value` amount of tokens from the caller's account to `to`\n * and then calls {IERC1363Receiver-onTransferReceived} on `to`.\n * @param to The address which you want to transfer to.\n * @param value The amount of tokens to be transferred.\n * @return A boolean value indicating whether the operation succeeded unless throwing.\n */\n function transferAndCall(address to, uint256 value) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from the caller's account to `to`\n * and then calls {IERC1363Receiver-onTransferReceived} on `to`.\n * @param to The address which you want to transfer to.\n * @param value The amount of tokens to be transferred.\n * @param data Additional data with no specified format, sent in call to `to`.\n * @return A boolean value indicating whether the operation succeeded unless throwing.\n */\n function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism\n * and then calls {IERC1363Receiver-onTransferReceived} on `to`.\n * @param from The address which you want to send tokens from.\n * @param to The address which you want to transfer to.\n * @param value The amount of tokens to be transferred.\n * @return A boolean value indicating whether the operation succeeded unless throwing.\n */\n function transferFromAndCall(address from, address to, uint256 value) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism\n * and then calls {IERC1363Receiver-onTransferReceived} on `to`.\n * @param from The address which you want to send tokens from.\n * @param to The address which you want to transfer to.\n * @param value The amount of tokens to be transferred.\n * @param data Additional data with no specified format, sent in call to `to`.\n * @return A boolean value indicating whether the operation succeeded unless throwing.\n */\n function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);\n\n /**\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.\n * @param spender The address which will spend the funds.\n * @param value The amount of tokens to be spent.\n * @return A boolean value indicating whether the operation succeeded unless throwing.\n */\n function approveAndCall(address spender, uint256 value) external returns (bool);\n\n /**\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.\n * @param spender The address which will spend the funds.\n * @param value The amount of tokens to be spent.\n * @param data Additional data with no specified format, sent in call to `spender`.\n * @return A boolean value indicating whether the operation succeeded unless throwing.\n */\n function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);\n}\n" + }, + "lib/openzeppelin-contracts/contracts/access/IAccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (access/IAccessControl.sol)\n\npragma solidity >=0.8.4;\n\n/**\n * @dev External interface of AccessControl declared to support ERC-165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted to signal this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).\n * Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n" + }, + "lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)\n\npragma solidity >=0.4.16;\n\n/**\n * @dev Interface of the ERC-165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[ERC].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" + }, + "lib/openzeppelin-contracts-upgradeable/contracts/utils/introspection/ERC165Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport {Initializable} from \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /// @inheritdoc IERC165\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" + }, + "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) & ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reinitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 && isTopLevelCall;\n bool construction = initialized == 1 && address(this).code.length == 0;\n\n if (!initialSetup && !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized >= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Pointer to storage slot. Allows integrators to override it with a custom storage location.\n *\n * NOTE: Consider following the ERC-7201 formula to derive storage locations.\n */\n function _initializableStorageSlot() internal pure virtual returns (bytes32) {\n return INITIALIZABLE_STORAGE;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n bytes32 slot = _initializableStorageSlot();\n assembly {\n $.slot := slot\n }\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (utils/Address.sol)\n\npragma solidity ^0.8.20;\n\nimport {Errors} from \"./Errors.sol\";\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance < amount) {\n revert Errors.InsufficientBalance(address(this).balance, amount);\n }\n\n (bool success, bytes memory returndata) = recipient.call{value: amount}(\"\");\n if (!success) {\n _revert(returndata);\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {Errors.FailedCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance < value) {\n revert Errors.InsufficientBalance(address(this).balance, value);\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case\n * of an unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 && target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {Errors.FailedCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n assembly (\"memory-safe\") {\n revert(add(returndata, 0x20), mload(returndata))\n }\n } else {\n revert Errors.FailedCall();\n }\n }\n}\n" + }, + "lib/protocol/packages/core/contracts/data-verification-mechanism/interfaces/FinderInterface.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.0;\n\n/**\n * @title Provides addresses of the live contracts implementing certain interfaces.\n * @dev Examples are the Oracle or Store interfaces.\n */\ninterface FinderInterface {\n /**\n * @notice Updates the address of the contract that implements `interfaceName`.\n * @param interfaceName bytes32 encoding of the interface name that is either changed or registered.\n * @param implementationAddress address of the deployed contract that implements the interface.\n */\n function changeImplementationAddress(bytes32 interfaceName, address implementationAddress) external;\n\n /**\n * @notice Gets the address of the contract that implements the given `interfaceName`.\n * @param interfaceName queried interface.\n * @return implementationAddress address of the deployed contract that implements the interface.\n */\n function getImplementationAddress(bytes32 interfaceName) external view returns (address);\n}\n" + }, + "lib/permit2/src/interfaces/IEIP712.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IEIP712 {\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /// @inheritdoc IERC165\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "lib/protocol/packages/core/contracts/common/implementation/Lockable.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.0;\n\n/**\n * @title A contract that provides modifiers to prevent reentrancy to state-changing and view-only methods. This contract\n * is inspired by https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/ReentrancyGuard.sol\n * and https://github.com/balancer-labs/balancer-core/blob/master/contracts/BPool.sol.\n */\ncontract Lockable {\n bool private _notEntered;\n\n constructor() {\n // Storing an initial non-zero value makes deployment a bit more expensive, but in exchange the refund on every\n // call to nonReentrant will be lower in amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to increase the likelihood of the full\n // refund coming into effect.\n _notEntered = true;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant` function is not supported. It is possible to\n * prevent this from happening by making the `nonReentrant` function external, and making it call a `private`\n * function that does the actual state modification.\n */\n modifier nonReentrant() {\n _preEntranceCheck();\n _preEntranceSet();\n _;\n _postEntranceReset();\n }\n\n /**\n * @dev Designed to prevent a view-only method from being re-entered during a call to a `nonReentrant()` state-changing method.\n */\n modifier nonReentrantView() {\n _preEntranceCheck();\n _;\n }\n\n // Internal methods are used to avoid copying the require statement's bytecode to every `nonReentrant()` method.\n // On entry into a function, `_preEntranceCheck()` should always be called to check if the function is being\n // re-entered. Then, if the function modifies state, it should call `_postEntranceSet()`, perform its logic, and\n // then call `_postEntranceReset()`.\n // View-only methods can simply call `_preEntranceCheck()` to make sure that it is not being re-entered.\n function _preEntranceCheck() internal view {\n // On the first call to nonReentrant, _notEntered will be true\n require(_notEntered, \"ReentrancyGuard: reentrant call\");\n }\n\n function _preEntranceSet() internal {\n // Any calls to nonReentrant after this point will fail\n _notEntered = false;\n }\n\n function _postEntranceReset() internal {\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _notEntered = true;\n }\n\n // These functions are intended to be used by child contracts to temporarily disable and re-enable the guard.\n // Intended use:\n // _startReentrantGuardDisabled();\n // ...\n // _endReentrantGuardDisabled();\n //\n // IMPORTANT: these should NEVER be used in a method that isn't inside a nonReentrant block. Otherwise, it's\n // possible to permanently lock your contract.\n function _startReentrantGuardDisabled() internal {\n _notEntered = true;\n }\n\n function _endReentrantGuardDisabled() internal {\n _notEntered = false;\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/structs/EnumerableSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^0.8.20;\n\nimport {Arrays} from \"../Arrays.sol\";\nimport {Math} from \"../math/Math.sol\";\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n * - Set can be cleared (all elements removed) in O(n).\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * The following types are supported:\n *\n * - `bytes32` (`Bytes32Set`) since v3.3.0\n * - `address` (`AddressSet`) since v3.3.0\n * - `uint256` (`UintSet`) since v3.3.0\n * - `string` (`StringSet`) since v5.4.0\n * - `bytes` (`BytesSet`) since v5.4.0\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value => uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes all the values from a set. O(n).\n *\n * WARNING: This function has an unbounded cost that scales with set size. Developers should keep in mind that\n * using it may render the function uncallable if the set grows to the point where clearing it consumes too much\n * gas to fit in a block.\n */\n function _clear(Set storage set) private {\n uint256 len = _length(set);\n for (uint256 i = 0; i < len; ++i) {\n delete set._positions[set._values[i]];\n }\n Arrays.unsafeSetLength(set._values, 0);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n /**\n * @dev Return a slice of the set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set, uint256 start, uint256 end) private view returns (bytes32[] memory) {\n unchecked {\n end = Math.min(end, _length(set));\n start = Math.min(start, end);\n\n uint256 len = end - start;\n bytes32[] memory result = new bytes32[](len);\n for (uint256 i = 0; i < len; ++i) {\n result[i] = Arrays.unsafeAccess(set._values, start + i).value;\n }\n return result;\n }\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Removes all the values from a set. O(n).\n *\n * WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the\n * function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.\n */\n function clear(Bytes32Set storage set) internal {\n _clear(set._inner);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n assembly (\"memory-safe\") {\n result := store\n }\n\n return result;\n }\n\n /**\n * @dev Return a slice of the set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set, uint256 start, uint256 end) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner, start, end);\n bytes32[] memory result;\n\n assembly (\"memory-safe\") {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes all the values from a set. O(n).\n *\n * WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the\n * function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.\n */\n function clear(AddressSet storage set) internal {\n _clear(set._inner);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n assembly (\"memory-safe\") {\n result := store\n }\n\n return result;\n }\n\n /**\n * @dev Return a slice of the set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set, uint256 start, uint256 end) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner, start, end);\n address[] memory result;\n\n assembly (\"memory-safe\") {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes all the values from a set. O(n).\n *\n * WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the\n * function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.\n */\n function clear(UintSet storage set) internal {\n _clear(set._inner);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n assembly (\"memory-safe\") {\n result := store\n }\n\n return result;\n }\n\n /**\n * @dev Return a slice of the set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set, uint256 start, uint256 end) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner, start, end);\n uint256[] memory result;\n\n assembly (\"memory-safe\") {\n result := store\n }\n\n return result;\n }\n\n struct StringSet {\n // Storage of set values\n string[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(string value => uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(StringSet storage set, string memory value) internal returns (bool) {\n if (!contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(StringSet storage set, string memory value) internal returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n string memory lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes all the values from a set. O(n).\n *\n * WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the\n * function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.\n */\n function clear(StringSet storage set) internal {\n uint256 len = length(set);\n for (uint256 i = 0; i < len; ++i) {\n delete set._positions[set._values[i]];\n }\n Arrays.unsafeSetLength(set._values, 0);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(StringSet storage set, string memory value) internal view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(StringSet storage set) internal view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(StringSet storage set, uint256 index) internal view returns (string memory) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(StringSet storage set) internal view returns (string[] memory) {\n return set._values;\n }\n\n /**\n * @dev Return a slice of the set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(StringSet storage set, uint256 start, uint256 end) internal view returns (string[] memory) {\n unchecked {\n end = Math.min(end, length(set));\n start = Math.min(start, end);\n\n uint256 len = end - start;\n string[] memory result = new string[](len);\n for (uint256 i = 0; i < len; ++i) {\n result[i] = Arrays.unsafeAccess(set._values, start + i).value;\n }\n return result;\n }\n }\n\n struct BytesSet {\n // Storage of set values\n bytes[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes value => uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(BytesSet storage set, bytes memory value) internal returns (bool) {\n if (!contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(BytesSet storage set, bytes memory value) internal returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes memory lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes all the values from a set. O(n).\n *\n * WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the\n * function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.\n */\n function clear(BytesSet storage set) internal {\n uint256 len = length(set);\n for (uint256 i = 0; i < len; ++i) {\n delete set._positions[set._values[i]];\n }\n Arrays.unsafeSetLength(set._values, 0);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(BytesSet storage set, bytes memory value) internal view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(BytesSet storage set) internal view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(BytesSet storage set, uint256 index) internal view returns (bytes memory) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(BytesSet storage set) internal view returns (bytes[] memory) {\n return set._values;\n }\n\n /**\n * @dev Return a slice of the set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(BytesSet storage set, uint256 start, uint256 end) internal view returns (bytes[] memory) {\n unchecked {\n end = Math.min(end, length(set));\n start = Math.min(start, end);\n\n uint256 len = end - start;\n bytes[] memory result = new bytes[](len);\n for (uint256 i = 0; i < len; ++i) {\n result[i] = Arrays.unsafeAccess(set._values, start + i).value;\n }\n return result;\n }\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/interfaces/draft-IERC1822.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity >=0.4.16;\n\n/**\n * @dev ERC-1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n" + }, + "lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Utils.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (proxy/ERC1967/ERC1967Utils.sol)\n\npragma solidity ^0.8.21;\n\nimport {IBeacon} from \"../beacon/IBeacon.sol\";\nimport {IERC1967} from \"../../interfaces/IERC1967.sol\";\nimport {Address} from \"../../utils/Address.sol\";\nimport {StorageSlot} from \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This library provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.\n */\nlibrary ERC1967Utils {\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1.\n */\n // solhint-disable-next-line private-vars-leading-underscore\n bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev The `implementation` of the proxy is invalid.\n */\n error ERC1967InvalidImplementation(address implementation);\n\n /**\n * @dev The `admin` of the proxy is invalid.\n */\n error ERC1967InvalidAdmin(address admin);\n\n /**\n * @dev The `beacon` of the proxy is invalid.\n */\n error ERC1967InvalidBeacon(address beacon);\n\n /**\n * @dev An upgrade function sees `msg.value > 0` that may be lost.\n */\n error ERC1967NonPayable();\n\n /**\n * @dev Returns the current implementation address.\n */\n function getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the ERC-1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n if (newImplementation.code.length == 0) {\n revert ERC1967InvalidImplementation(newImplementation);\n }\n StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Performs implementation upgrade with additional setup call if data is nonempty.\n * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected\n * to avoid stuck value in the contract.\n *\n * Emits an {IERC1967-Upgraded} event.\n */\n function upgradeToAndCall(address newImplementation, bytes memory data) internal {\n _setImplementation(newImplementation);\n emit IERC1967.Upgraded(newImplementation);\n\n if (data.length > 0) {\n Address.functionDelegateCall(newImplementation, data);\n } else {\n _checkNonPayable();\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1.\n */\n // solhint-disable-next-line private-vars-leading-underscore\n bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Returns the current admin.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using\n * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the ERC-1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n if (newAdmin == address(0)) {\n revert ERC1967InvalidAdmin(address(0));\n }\n StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {IERC1967-AdminChanged} event.\n */\n function changeAdmin(address newAdmin) internal {\n emit IERC1967.AdminChanged(getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is the keccak-256 hash of \"eip1967.proxy.beacon\" subtracted by 1.\n */\n // solhint-disable-next-line private-vars-leading-underscore\n bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Returns the current beacon.\n */\n function getBeacon() internal view returns (address) {\n return StorageSlot.getAddressSlot(BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the ERC-1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n if (newBeacon.code.length == 0) {\n revert ERC1967InvalidBeacon(newBeacon);\n }\n\n StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;\n\n address beaconImplementation = IBeacon(newBeacon).implementation();\n if (beaconImplementation.code.length == 0) {\n revert ERC1967InvalidImplementation(beaconImplementation);\n }\n }\n\n /**\n * @dev Change the beacon and trigger a setup call if data is nonempty.\n * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected\n * to avoid stuck value in the contract.\n *\n * Emits an {IERC1967-BeaconUpgraded} event.\n *\n * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since\n * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for\n * efficiency.\n */\n function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {\n _setBeacon(newBeacon);\n emit IERC1967.BeaconUpgraded(newBeacon);\n\n if (data.length > 0) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n } else {\n _checkNonPayable();\n }\n }\n\n /**\n * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract\n * if an upgrade doesn't perform an initialization call.\n */\n function _checkNonPayable() private {\n if (msg.value > 0) {\n revert ERC1967NonPayable();\n }\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/interfaces/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)\n\npragma solidity >=0.4.16;\n\nimport {IERC20} from \"../token/ERC20/IERC20.sol\";\n" + }, + "lib/openzeppelin-contracts/contracts/interfaces/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)\n\npragma solidity >=0.4.16;\n\nimport {IERC165} from \"../utils/introspection/IERC165.sol\";\n" + }, + "lib/openzeppelin-contracts/contracts/utils/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Collection of common custom errors used in multiple contracts\n *\n * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.\n * It is recommended to avoid relying on the error API for critical functionality.\n *\n * _Available since v5.1._\n */\nlibrary Errors {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error InsufficientBalance(uint256 balance, uint256 needed);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedCall();\n\n /**\n * @dev The deployment failed.\n */\n error FailedDeployment();\n\n /**\n * @dev A necessary precompile is missing.\n */\n error MissingPrecompile(address);\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/Arrays.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (utils/Arrays.sol)\n// This file was procedurally generated from scripts/generate/templates/Arrays.js.\n\npragma solidity ^0.8.20;\n\nimport {Comparators} from \"./Comparators.sol\";\nimport {SlotDerivation} from \"./SlotDerivation.sol\";\nimport {StorageSlot} from \"./StorageSlot.sol\";\nimport {Math} from \"./math/Math.sol\";\n\n/**\n * @dev Collection of functions related to array types.\n */\nlibrary Arrays {\n using SlotDerivation for bytes32;\n using StorageSlot for bytes32;\n\n /**\n * @dev Sort an array of uint256 (in memory) following the provided comparator function.\n *\n * This function does the sorting \"in place\", meaning that it overrides the input. The object is returned for\n * convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array.\n *\n * NOTE: this function's cost is `O(n \u00b7 log(n))` in average and `O(n\u00b2)` in the worst case, with n the length of the\n * array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful\n * when executing this as part of a transaction. If the array being sorted is too large, the sort operation may\n * consume more gas than is available in a block, leading to potential DoS.\n *\n * IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.\n */\n function sort(\n uint256[] memory array,\n function(uint256, uint256) pure returns (bool) comp\n ) internal pure returns (uint256[] memory) {\n _quickSort(_begin(array), _end(array), comp);\n return array;\n }\n\n /**\n * @dev Variant of {sort} that sorts an array of uint256 in increasing order.\n */\n function sort(uint256[] memory array) internal pure returns (uint256[] memory) {\n sort(array, Comparators.lt);\n return array;\n }\n\n /**\n * @dev Sort an array of address (in memory) following the provided comparator function.\n *\n * This function does the sorting \"in place\", meaning that it overrides the input. The object is returned for\n * convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array.\n *\n * NOTE: this function's cost is `O(n \u00b7 log(n))` in average and `O(n\u00b2)` in the worst case, with n the length of the\n * array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful\n * when executing this as part of a transaction. If the array being sorted is too large, the sort operation may\n * consume more gas than is available in a block, leading to potential DoS.\n *\n * IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.\n */\n function sort(\n address[] memory array,\n function(address, address) pure returns (bool) comp\n ) internal pure returns (address[] memory) {\n sort(_castToUint256Array(array), _castToUint256Comp(comp));\n return array;\n }\n\n /**\n * @dev Variant of {sort} that sorts an array of address in increasing order.\n */\n function sort(address[] memory array) internal pure returns (address[] memory) {\n sort(_castToUint256Array(array), Comparators.lt);\n return array;\n }\n\n /**\n * @dev Sort an array of bytes32 (in memory) following the provided comparator function.\n *\n * This function does the sorting \"in place\", meaning that it overrides the input. The object is returned for\n * convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array.\n *\n * NOTE: this function's cost is `O(n \u00b7 log(n))` in average and `O(n\u00b2)` in the worst case, with n the length of the\n * array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful\n * when executing this as part of a transaction. If the array being sorted is too large, the sort operation may\n * consume more gas than is available in a block, leading to potential DoS.\n *\n * IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.\n */\n function sort(\n bytes32[] memory array,\n function(bytes32, bytes32) pure returns (bool) comp\n ) internal pure returns (bytes32[] memory) {\n sort(_castToUint256Array(array), _castToUint256Comp(comp));\n return array;\n }\n\n /**\n * @dev Variant of {sort} that sorts an array of bytes32 in increasing order.\n */\n function sort(bytes32[] memory array) internal pure returns (bytes32[] memory) {\n sort(_castToUint256Array(array), Comparators.lt);\n return array;\n }\n\n /**\n * @dev Performs a quick sort of a segment of memory. The segment sorted starts at `begin` (inclusive), and stops\n * at end (exclusive). Sorting follows the `comp` comparator.\n *\n * Invariant: `begin <= end`. This is the case when initially called by {sort} and is preserved in subcalls.\n *\n * IMPORTANT: Memory locations between `begin` and `end` are not validated/zeroed. This function should\n * be used only if the limits are within a memory array.\n */\n function _quickSort(uint256 begin, uint256 end, function(uint256, uint256) pure returns (bool) comp) private pure {\n unchecked {\n if (end - begin < 0x40) return;\n\n // Use first element as pivot\n uint256 pivot = _mload(begin);\n // Position where the pivot should be at the end of the loop\n uint256 pos = begin;\n\n for (uint256 it = begin + 0x20; it < end; it += 0x20) {\n if (comp(_mload(it), pivot)) {\n // If the value stored at the iterator's position comes before the pivot, we increment the\n // position of the pivot and move the value there.\n pos += 0x20;\n _swap(pos, it);\n }\n }\n\n _swap(begin, pos); // Swap pivot into place\n _quickSort(begin, pos, comp); // Sort the left side of the pivot\n _quickSort(pos + 0x20, end, comp); // Sort the right side of the pivot\n }\n }\n\n /**\n * @dev Pointer to the memory location of the first element of `array`.\n */\n function _begin(uint256[] memory array) private pure returns (uint256 ptr) {\n assembly (\"memory-safe\") {\n ptr := add(array, 0x20)\n }\n }\n\n /**\n * @dev Pointer to the memory location of the first memory word (32bytes) after `array`. This is the memory word\n * that comes just after the last element of the array.\n */\n function _end(uint256[] memory array) private pure returns (uint256 ptr) {\n unchecked {\n return _begin(array) + array.length * 0x20;\n }\n }\n\n /**\n * @dev Load memory word (as a uint256) at location `ptr`.\n */\n function _mload(uint256 ptr) private pure returns (uint256 value) {\n assembly {\n value := mload(ptr)\n }\n }\n\n /**\n * @dev Swaps the elements memory location `ptr1` and `ptr2`.\n */\n function _swap(uint256 ptr1, uint256 ptr2) private pure {\n assembly {\n let value1 := mload(ptr1)\n let value2 := mload(ptr2)\n mstore(ptr1, value2)\n mstore(ptr2, value1)\n }\n }\n\n /// @dev Helper: low level cast address memory array to uint256 memory array\n function _castToUint256Array(address[] memory input) private pure returns (uint256[] memory output) {\n assembly {\n output := input\n }\n }\n\n /// @dev Helper: low level cast bytes32 memory array to uint256 memory array\n function _castToUint256Array(bytes32[] memory input) private pure returns (uint256[] memory output) {\n assembly {\n output := input\n }\n }\n\n /// @dev Helper: low level cast address comp function to uint256 comp function\n function _castToUint256Comp(\n function(address, address) pure returns (bool) input\n ) private pure returns (function(uint256, uint256) pure returns (bool) output) {\n assembly {\n output := input\n }\n }\n\n /// @dev Helper: low level cast bytes32 comp function to uint256 comp function\n function _castToUint256Comp(\n function(bytes32, bytes32) pure returns (bool) input\n ) private pure returns (function(uint256, uint256) pure returns (bool) output) {\n assembly {\n output := input\n }\n }\n\n /**\n * @dev Searches a sorted `array` and returns the first index that contains\n * a value greater or equal to `element`. If no such index exists (i.e. all\n * values in the array are strictly less than `element`), the array length is\n * returned. Time complexity O(log n).\n *\n * NOTE: The `array` is expected to be sorted in ascending order, and to\n * contain no repeated elements.\n *\n * IMPORTANT: Deprecated. This implementation behaves as {lowerBound} but lacks\n * support for repeated elements in the array. The {lowerBound} function should\n * be used instead.\n */\n function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {\n uint256 low = 0;\n uint256 high = array.length;\n\n if (high == 0) {\n return 0;\n }\n\n while (low < high) {\n uint256 mid = Math.average(low, high);\n\n // Note that mid will always be strictly less than high (i.e. it will be a valid array index)\n // because Math.average rounds towards zero (it does integer division with truncation).\n if (unsafeAccess(array, mid).value > element) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.\n if (low > 0 && unsafeAccess(array, low - 1).value == element) {\n return low - 1;\n } else {\n return low;\n }\n }\n\n /**\n * @dev Searches an `array` sorted in ascending order and returns the first\n * index that contains a value greater or equal than `element`. If no such index\n * exists (i.e. all values in the array are strictly less than `element`), the array\n * length is returned. Time complexity O(log n).\n *\n * See C++'s https://en.cppreference.com/w/cpp/algorithm/lower_bound[lower_bound].\n */\n function lowerBound(uint256[] storage array, uint256 element) internal view returns (uint256) {\n uint256 low = 0;\n uint256 high = array.length;\n\n if (high == 0) {\n return 0;\n }\n\n while (low < high) {\n uint256 mid = Math.average(low, high);\n\n // Note that mid will always be strictly less than high (i.e. it will be a valid array index)\n // because Math.average rounds towards zero (it does integer division with truncation).\n if (unsafeAccess(array, mid).value < element) {\n // this cannot overflow because mid < high\n unchecked {\n low = mid + 1;\n }\n } else {\n high = mid;\n }\n }\n\n return low;\n }\n\n /**\n * @dev Searches an `array` sorted in ascending order and returns the first\n * index that contains a value strictly greater than `element`. If no such index\n * exists (i.e. all values in the array are strictly less than `element`), the array\n * length is returned. Time complexity O(log n).\n *\n * See C++'s https://en.cppreference.com/w/cpp/algorithm/upper_bound[upper_bound].\n */\n function upperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {\n uint256 low = 0;\n uint256 high = array.length;\n\n if (high == 0) {\n return 0;\n }\n\n while (low < high) {\n uint256 mid = Math.average(low, high);\n\n // Note that mid will always be strictly less than high (i.e. it will be a valid array index)\n // because Math.average rounds towards zero (it does integer division with truncation).\n if (unsafeAccess(array, mid).value > element) {\n high = mid;\n } else {\n // this cannot overflow because mid < high\n unchecked {\n low = mid + 1;\n }\n }\n }\n\n return low;\n }\n\n /**\n * @dev Same as {lowerBound}, but with an array in memory.\n */\n function lowerBoundMemory(uint256[] memory array, uint256 element) internal pure returns (uint256) {\n uint256 low = 0;\n uint256 high = array.length;\n\n if (high == 0) {\n return 0;\n }\n\n while (low < high) {\n uint256 mid = Math.average(low, high);\n\n // Note that mid will always be strictly less than high (i.e. it will be a valid array index)\n // because Math.average rounds towards zero (it does integer division with truncation).\n if (unsafeMemoryAccess(array, mid) < element) {\n // this cannot overflow because mid < high\n unchecked {\n low = mid + 1;\n }\n } else {\n high = mid;\n }\n }\n\n return low;\n }\n\n /**\n * @dev Same as {upperBound}, but with an array in memory.\n */\n function upperBoundMemory(uint256[] memory array, uint256 element) internal pure returns (uint256) {\n uint256 low = 0;\n uint256 high = array.length;\n\n if (high == 0) {\n return 0;\n }\n\n while (low < high) {\n uint256 mid = Math.average(low, high);\n\n // Note that mid will always be strictly less than high (i.e. it will be a valid array index)\n // because Math.average rounds towards zero (it does integer division with truncation).\n if (unsafeMemoryAccess(array, mid) > element) {\n high = mid;\n } else {\n // this cannot overflow because mid < high\n unchecked {\n low = mid + 1;\n }\n }\n }\n\n return low;\n }\n\n /**\n * @dev Access an array in an \"unsafe\" way. Skips solidity \"index-out-of-range\" check.\n *\n * WARNING: Only use if you are certain `pos` is lower than the array length.\n */\n function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) {\n bytes32 slot;\n assembly (\"memory-safe\") {\n slot := arr.slot\n }\n return slot.deriveArray().offset(pos).getAddressSlot();\n }\n\n /**\n * @dev Access an array in an \"unsafe\" way. Skips solidity \"index-out-of-range\" check.\n *\n * WARNING: Only use if you are certain `pos` is lower than the array length.\n */\n function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) {\n bytes32 slot;\n assembly (\"memory-safe\") {\n slot := arr.slot\n }\n return slot.deriveArray().offset(pos).getBytes32Slot();\n }\n\n /**\n * @dev Access an array in an \"unsafe\" way. Skips solidity \"index-out-of-range\" check.\n *\n * WARNING: Only use if you are certain `pos` is lower than the array length.\n */\n function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) {\n bytes32 slot;\n assembly (\"memory-safe\") {\n slot := arr.slot\n }\n return slot.deriveArray().offset(pos).getUint256Slot();\n }\n\n /**\n * @dev Access an array in an \"unsafe\" way. Skips solidity \"index-out-of-range\" check.\n *\n * WARNING: Only use if you are certain `pos` is lower than the array length.\n */\n function unsafeAccess(bytes[] storage arr, uint256 pos) internal pure returns (StorageSlot.BytesSlot storage) {\n bytes32 slot;\n assembly (\"memory-safe\") {\n slot := arr.slot\n }\n return slot.deriveArray().offset(pos).getBytesSlot();\n }\n\n /**\n * @dev Access an array in an \"unsafe\" way. Skips solidity \"index-out-of-range\" check.\n *\n * WARNING: Only use if you are certain `pos` is lower than the array length.\n */\n function unsafeAccess(string[] storage arr, uint256 pos) internal pure returns (StorageSlot.StringSlot storage) {\n bytes32 slot;\n assembly (\"memory-safe\") {\n slot := arr.slot\n }\n return slot.deriveArray().offset(pos).getStringSlot();\n }\n\n /**\n * @dev Access an array in an \"unsafe\" way. Skips solidity \"index-out-of-range\" check.\n *\n * WARNING: Only use if you are certain `pos` is lower than the array length.\n */\n function unsafeMemoryAccess(address[] memory arr, uint256 pos) internal pure returns (address res) {\n assembly {\n res := mload(add(add(arr, 0x20), mul(pos, 0x20)))\n }\n }\n\n /**\n * @dev Access an array in an \"unsafe\" way. Skips solidity \"index-out-of-range\" check.\n *\n * WARNING: Only use if you are certain `pos` is lower than the array length.\n */\n function unsafeMemoryAccess(bytes32[] memory arr, uint256 pos) internal pure returns (bytes32 res) {\n assembly {\n res := mload(add(add(arr, 0x20), mul(pos, 0x20)))\n }\n }\n\n /**\n * @dev Access an array in an \"unsafe\" way. Skips solidity \"index-out-of-range\" check.\n *\n * WARNING: Only use if you are certain `pos` is lower than the array length.\n */\n function unsafeMemoryAccess(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res) {\n assembly {\n res := mload(add(add(arr, 0x20), mul(pos, 0x20)))\n }\n }\n\n /**\n * @dev Access an array in an \"unsafe\" way. Skips solidity \"index-out-of-range\" check.\n *\n * WARNING: Only use if you are certain `pos` is lower than the array length.\n */\n function unsafeMemoryAccess(bytes[] memory arr, uint256 pos) internal pure returns (bytes memory res) {\n assembly {\n res := mload(add(add(arr, 0x20), mul(pos, 0x20)))\n }\n }\n\n /**\n * @dev Access an array in an \"unsafe\" way. Skips solidity \"index-out-of-range\" check.\n *\n * WARNING: Only use if you are certain `pos` is lower than the array length.\n */\n function unsafeMemoryAccess(string[] memory arr, uint256 pos) internal pure returns (string memory res) {\n assembly {\n res := mload(add(add(arr, 0x20), mul(pos, 0x20)))\n }\n }\n\n /**\n * @dev Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden.\n *\n * WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.\n */\n function unsafeSetLength(address[] storage array, uint256 len) internal {\n assembly (\"memory-safe\") {\n sstore(array.slot, len)\n }\n }\n\n /**\n * @dev Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden.\n *\n * WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.\n */\n function unsafeSetLength(bytes32[] storage array, uint256 len) internal {\n assembly (\"memory-safe\") {\n sstore(array.slot, len)\n }\n }\n\n /**\n * @dev Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden.\n *\n * WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.\n */\n function unsafeSetLength(uint256[] storage array, uint256 len) internal {\n assembly (\"memory-safe\") {\n sstore(array.slot, len)\n }\n }\n\n /**\n * @dev Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden.\n *\n * WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.\n */\n function unsafeSetLength(bytes[] storage array, uint256 len) internal {\n assembly (\"memory-safe\") {\n sstore(array.slot, len)\n }\n }\n\n /**\n * @dev Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden.\n *\n * WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.\n */\n function unsafeSetLength(string[] storage array, uint256 len) internal {\n assembly (\"memory-safe\") {\n sstore(array.slot, len)\n }\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/math/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.3.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\nimport {Panic} from \"../Panic.sol\";\nimport {SafeCast} from \"./SafeCast.sol\";\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n enum Rounding {\n Floor, // Toward negative infinity\n Ceil, // Toward positive infinity\n Trunc, // Toward zero\n Expand // Away from zero\n }\n\n /**\n * @dev Return the 512-bit addition of two uint256.\n *\n * The result is stored in two 256 variables such that sum = high * 2\u00b2\u2075\u2076 + low.\n */\n function add512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {\n assembly (\"memory-safe\") {\n low := add(a, b)\n high := lt(low, a)\n }\n }\n\n /**\n * @dev Return the 512-bit multiplication of two uint256.\n *\n * The result is stored in two 256 variables such that product = high * 2\u00b2\u2075\u2076 + low.\n */\n function mul512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {\n // 512-bit multiply [high low] = x * y. Compute the product mod 2\u00b2\u2075\u2076 and mod 2\u00b2\u2075\u2076 - 1, then use\n // the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = high * 2\u00b2\u2075\u2076 + low.\n assembly (\"memory-safe\") {\n let mm := mulmod(a, b, not(0))\n low := mul(a, b)\n high := sub(sub(mm, low), lt(mm, low))\n }\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, with a success flag (no overflow).\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n unchecked {\n uint256 c = a + b;\n success = c >= a;\n result = c * SafeCast.toUint(success);\n }\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, with a success flag (no overflow).\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n unchecked {\n uint256 c = a - b;\n success = c <= a;\n result = c * SafeCast.toUint(success);\n }\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with a success flag (no overflow).\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n unchecked {\n uint256 c = a * b;\n assembly (\"memory-safe\") {\n // Only true when the multiplication doesn't overflow\n // (c / a == b) || (a == 0)\n success := or(eq(div(c, a), b), iszero(a))\n }\n // equivalent to: success ? c : 0\n result = c * SafeCast.toUint(success);\n }\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a success flag (no division by zero).\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n unchecked {\n success = b > 0;\n assembly (\"memory-safe\") {\n // The `DIV` opcode returns zero when the denominator is 0.\n result := div(a, b)\n }\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n unchecked {\n success = b > 0;\n assembly (\"memory-safe\") {\n // The `MOD` opcode returns zero when the denominator is 0.\n result := mod(a, b)\n }\n }\n }\n\n /**\n * @dev Unsigned saturating addition, bounds to `2\u00b2\u2075\u2076 - 1` instead of overflowing.\n */\n function saturatingAdd(uint256 a, uint256 b) internal pure returns (uint256) {\n (bool success, uint256 result) = tryAdd(a, b);\n return ternary(success, result, type(uint256).max);\n }\n\n /**\n * @dev Unsigned saturating subtraction, bounds to zero instead of overflowing.\n */\n function saturatingSub(uint256 a, uint256 b) internal pure returns (uint256) {\n (, uint256 result) = trySub(a, b);\n return result;\n }\n\n /**\n * @dev Unsigned saturating multiplication, bounds to `2\u00b2\u2075\u2076 - 1` instead of overflowing.\n */\n function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256) {\n (bool success, uint256 result) = tryMul(a, b);\n return ternary(success, result, type(uint256).max);\n }\n\n /**\n * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.\n *\n * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.\n * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute\n * one branch when needed, making this function more expensive.\n */\n function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {\n unchecked {\n // branchless ternary works because:\n // b ^ (a ^ b) == a\n // b ^ 0 == b\n return b ^ ((a ^ b) * SafeCast.toUint(condition));\n }\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return ternary(a > b, a, b);\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return ternary(a < b, a, b);\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds towards infinity instead\n * of rounding towards zero.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n if (b == 0) {\n // Guarantee the same behavior as in a regular Solidity division.\n Panic.panic(Panic.DIVISION_BY_ZERO);\n }\n\n // The following calculation ensures accurate ceiling division without overflow.\n // Since a is non-zero, (a - 1) / b will not overflow.\n // The largest possible result occurs when (a - 1) / b is type(uint256).max,\n // but the largest value we can obtain is type(uint256).max - 1, which happens\n // when a = type(uint256).max and b = 1.\n unchecked {\n return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);\n }\n }\n\n /**\n * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n * denominator == 0.\n *\n * Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n * Uniswap Labs also under MIT license.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n (uint256 high, uint256 low) = mul512(x, y);\n\n // Handle non-overflow cases, 256 by 256 division.\n if (high == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return low / denominator;\n }\n\n // Make sure the result is less than 2\u00b2\u2075\u2076. Also prevents denominator == 0.\n if (denominator <= high) {\n Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));\n }\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [high low].\n uint256 remainder;\n assembly (\"memory-safe\") {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n high := sub(high, gt(remainder, low))\n low := sub(low, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n uint256 twos = denominator & (0 - denominator);\n assembly (\"memory-safe\") {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [high low] by twos.\n low := div(low, twos)\n\n // Flip twos such that it is 2\u00b2\u2075\u2076 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from high into low.\n low |= high * twos;\n\n // Invert denominator mod 2\u00b2\u2075\u2076. Now that denominator is an odd number, it has an inverse modulo 2\u00b2\u2075\u2076 such\n // that denominator * inv \u2261 1 mod 2\u00b2\u2075\u2076. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv \u2261 1 mod 2\u2074.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\n // works in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2\u2078\n inverse *= 2 - denominator * inverse; // inverse mod 2\u00b9\u2076\n inverse *= 2 - denominator * inverse; // inverse mod 2\u00b3\u00b2\n inverse *= 2 - denominator * inverse; // inverse mod 2\u2076\u2074\n inverse *= 2 - denominator * inverse; // inverse mod 2\u00b9\u00b2\u2078\n inverse *= 2 - denominator * inverse; // inverse mod 2\u00b2\u2075\u2076\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2\u00b2\u2075\u2076. Since the preconditions guarantee that the outcome is\n // less than 2\u00b2\u2075\u2076, this is the final result. We don't need to compute the high bits of the result and high\n // is no longer required.\n result = low * inverse;\n return result;\n }\n }\n\n /**\n * @dev Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);\n }\n\n /**\n * @dev Calculates floor(x * y >> n) with full precision. Throws if result overflows a uint256.\n */\n function mulShr(uint256 x, uint256 y, uint8 n) internal pure returns (uint256 result) {\n unchecked {\n (uint256 high, uint256 low) = mul512(x, y);\n if (high >= 1 << n) {\n Panic.panic(Panic.UNDER_OVERFLOW);\n }\n return (high << (256 - n)) | (low >> n);\n }\n }\n\n /**\n * @dev Calculates x * y >> n with full precision, following the selected rounding direction.\n */\n function mulShr(uint256 x, uint256 y, uint8 n, Rounding rounding) internal pure returns (uint256) {\n return mulShr(x, y, n) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, 1 << n) > 0);\n }\n\n /**\n * @dev Calculate the modular multiplicative inverse of a number in Z/nZ.\n *\n * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.\n * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.\n *\n * If the input value is not inversible, 0 is returned.\n *\n * 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\n * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.\n */\n function invMod(uint256 a, uint256 n) internal pure returns (uint256) {\n unchecked {\n if (n == 0) return 0;\n\n // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)\n // Used to compute integers x and y such that: ax + ny = gcd(a, n).\n // When the gcd is 1, then the inverse of a modulo n exists and it's x.\n // ax + ny = 1\n // ax = 1 + (-y)n\n // ax \u2261 1 (mod n) # x is the inverse of a modulo n\n\n // If the remainder is 0 the gcd is n right away.\n uint256 remainder = a % n;\n uint256 gcd = n;\n\n // Therefore the initial coefficients are:\n // ax + ny = gcd(a, n) = n\n // 0a + 1n = n\n int256 x = 0;\n int256 y = 1;\n\n while (remainder != 0) {\n uint256 quotient = gcd / remainder;\n\n (gcd, remainder) = (\n // The old remainder is the next gcd to try.\n remainder,\n // Compute the next remainder.\n // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd\n // where gcd is at most n (capped to type(uint256).max)\n gcd - remainder * quotient\n );\n\n (x, y) = (\n // Increment the coefficient of a.\n y,\n // Decrement the coefficient of n.\n // Can overflow, but the result is casted to uint256 so that the\n // next value of y is \"wrapped around\" to a value between 0 and n - 1.\n x - y * int256(quotient)\n );\n }\n\n if (gcd != 1) return 0; // No inverse exists.\n return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.\n }\n }\n\n /**\n * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.\n *\n * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is\n * prime, then `a**(p-1) \u2261 1 mod p`. As a consequence, we have `a * a**(p-2) \u2261 1 mod p`, which means that\n * `a**(p-2)` is the modular multiplicative inverse of a in Fp.\n *\n * NOTE: this function does NOT check that `p` is a prime greater than `2`.\n */\n function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {\n unchecked {\n return Math.modExp(a, p - 2, p);\n }\n }\n\n /**\n * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)\n *\n * Requirements:\n * - modulus can't be zero\n * - underlying staticcall to precompile must succeed\n *\n * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make\n * sure the chain you're using it on supports the precompiled contract for modular exponentiation\n * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,\n * the underlying function will succeed given the lack of a revert, but the result may be incorrectly\n * interpreted as 0.\n */\n function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {\n (bool success, uint256 result) = tryModExp(b, e, m);\n if (!success) {\n Panic.panic(Panic.DIVISION_BY_ZERO);\n }\n return result;\n }\n\n /**\n * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).\n * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying\n * to operate modulo 0 or if the underlying precompile reverted.\n *\n * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain\n * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in\n * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack\n * of a revert, but the result may be incorrectly interpreted as 0.\n */\n function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {\n if (m == 0) return (false, 0);\n assembly (\"memory-safe\") {\n let ptr := mload(0x40)\n // | Offset | Content | Content (Hex) |\n // |-----------|------------|--------------------------------------------------------------------|\n // | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n // | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n // | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n // | 0x60:0x7f | value of b | 0x<.............................................................b> |\n // | 0x80:0x9f | value of e | 0x<.............................................................e> |\n // | 0xa0:0xbf | value of m | 0x<.............................................................m> |\n mstore(ptr, 0x20)\n mstore(add(ptr, 0x20), 0x20)\n mstore(add(ptr, 0x40), 0x20)\n mstore(add(ptr, 0x60), b)\n mstore(add(ptr, 0x80), e)\n mstore(add(ptr, 0xa0), m)\n\n // Given the result < m, it's guaranteed to fit in 32 bytes,\n // so we can use the memory scratch space located at offset 0.\n success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)\n result := mload(0x00)\n }\n }\n\n /**\n * @dev Variant of {modExp} that supports inputs of arbitrary length.\n */\n function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {\n (bool success, bytes memory result) = tryModExp(b, e, m);\n if (!success) {\n Panic.panic(Panic.DIVISION_BY_ZERO);\n }\n return result;\n }\n\n /**\n * @dev Variant of {tryModExp} that supports inputs of arbitrary length.\n */\n function tryModExp(\n bytes memory b,\n bytes memory e,\n bytes memory m\n ) internal view returns (bool success, bytes memory result) {\n if (_zeroBytes(m)) return (false, new bytes(0));\n\n uint256 mLen = m.length;\n\n // Encode call args in result and move the free memory pointer\n result = abi.encodePacked(b.length, e.length, mLen, b, e, m);\n\n assembly (\"memory-safe\") {\n let dataPtr := add(result, 0x20)\n // Write result on top of args to avoid allocating extra memory.\n success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)\n // Overwrite the length.\n // result.length > returndatasize() is guaranteed because returndatasize() == m.length\n mstore(result, mLen)\n // Set the memory pointer after the returned data.\n mstore(0x40, add(dataPtr, mLen))\n }\n }\n\n /**\n * @dev Returns whether the provided byte array is zero.\n */\n function _zeroBytes(bytes memory byteArray) private pure returns (bool) {\n for (uint256 i = 0; i < byteArray.length; ++i) {\n if (byteArray[i] != 0) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\n * towards zero.\n *\n * This method is based on Newton's method for computing square roots; the algorithm is restricted to only\n * using integer operations.\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n unchecked {\n // Take care of easy edge cases when a == 0 or a == 1\n if (a <= 1) {\n return a;\n }\n\n // In this function, we use Newton's method to get a root of `f(x) := x\u00b2 - a`. It involves building a\n // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between\n // the current value as `\u03b5_n = | x_n - sqrt(a) |`.\n //\n // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root\n // of the target. (i.e. `2**(e-1) \u2264 sqrt(a) < 2**e`). We know that `e \u2264 128` because `(2\u00b9\u00b2\u2078)\u00b2 = 2\u00b2\u2075\u2076` is\n // bigger than any uint256.\n //\n // By noticing that\n // `2**(e-1) \u2264 sqrt(a) < 2**e \u2192 (2**(e-1))\u00b2 \u2264 a < (2**e)\u00b2 \u2192 2**(2*e-2) \u2264 a < 2**(2*e)`\n // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar\n // to the msb function.\n uint256 aa = a;\n uint256 xn = 1;\n\n if (aa >= (1 << 128)) {\n aa >>= 128;\n xn <<= 64;\n }\n if (aa >= (1 << 64)) {\n aa >>= 64;\n xn <<= 32;\n }\n if (aa >= (1 << 32)) {\n aa >>= 32;\n xn <<= 16;\n }\n if (aa >= (1 << 16)) {\n aa >>= 16;\n xn <<= 8;\n }\n if (aa >= (1 << 8)) {\n aa >>= 8;\n xn <<= 4;\n }\n if (aa >= (1 << 4)) {\n aa >>= 4;\n xn <<= 2;\n }\n if (aa >= (1 << 2)) {\n xn <<= 1;\n }\n\n // We now have x_n such that `x_n = 2**(e-1) \u2264 sqrt(a) < 2**e = 2 * x_n`. This implies \u03b5_n \u2264 2**(e-1).\n //\n // We can refine our estimation by noticing that the middle of that interval minimizes the error.\n // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to \u03b5_n \u2264 2**(e-2).\n // This is going to be our x_0 (and \u03b5_0)\n xn = (3 * xn) >> 1; // \u03b5_0 := | x_0 - sqrt(a) | \u2264 2**(e-2)\n\n // From here, Newton's method give us:\n // x_{n+1} = (x_n + a / x_n) / 2\n //\n // One should note that:\n // x_{n+1}\u00b2 - a = ((x_n + a / x_n) / 2)\u00b2 - a\n // = ((x_n\u00b2 + a) / (2 * x_n))\u00b2 - a\n // = (x_n\u2074 + 2 * a * x_n\u00b2 + a\u00b2) / (4 * x_n\u00b2) - a\n // = (x_n\u2074 + 2 * a * x_n\u00b2 + a\u00b2 - 4 * a * x_n\u00b2) / (4 * x_n\u00b2)\n // = (x_n\u2074 - 2 * a * x_n\u00b2 + a\u00b2) / (4 * x_n\u00b2)\n // = (x_n\u00b2 - a)\u00b2 / (2 * x_n)\u00b2\n // = ((x_n\u00b2 - a) / (2 * x_n))\u00b2\n // \u2265 0\n // Which proves that for all n \u2265 1, sqrt(a) \u2264 x_n\n //\n // This gives us the proof of quadratic convergence of the sequence:\n // \u03b5_{n+1} = | x_{n+1} - sqrt(a) |\n // = | (x_n + a / x_n) / 2 - sqrt(a) |\n // = | (x_n\u00b2 + a - 2*x_n*sqrt(a)) / (2 * x_n) |\n // = | (x_n - sqrt(a))\u00b2 / (2 * x_n) |\n // = | \u03b5_n\u00b2 / (2 * x_n) |\n // = \u03b5_n\u00b2 / | (2 * x_n) |\n //\n // For the first iteration, we have a special case where x_0 is known:\n // \u03b5_1 = \u03b5_0\u00b2 / | (2 * x_0) |\n // \u2264 (2**(e-2))\u00b2 / (2 * (2**(e-1) + 2**(e-2)))\n // \u2264 2**(2*e-4) / (3 * 2**(e-1))\n // \u2264 2**(e-3) / 3\n // \u2264 2**(e-3-log2(3))\n // \u2264 2**(e-4.5)\n //\n // For the following iterations, we use the fact that, 2**(e-1) \u2264 sqrt(a) \u2264 x_n:\n // \u03b5_{n+1} = \u03b5_n\u00b2 / | (2 * x_n) |\n // \u2264 (2**(e-k))\u00b2 / (2 * 2**(e-1))\n // \u2264 2**(2*e-2*k) / 2**e\n // \u2264 2**(e-2*k)\n xn = (xn + a / xn) >> 1; // \u03b5_1 := | x_1 - sqrt(a) | \u2264 2**(e-4.5) -- special case, see above\n xn = (xn + a / xn) >> 1; // \u03b5_2 := | x_2 - sqrt(a) | \u2264 2**(e-9) -- general case with k = 4.5\n xn = (xn + a / xn) >> 1; // \u03b5_3 := | x_3 - sqrt(a) | \u2264 2**(e-18) -- general case with k = 9\n xn = (xn + a / xn) >> 1; // \u03b5_4 := | x_4 - sqrt(a) | \u2264 2**(e-36) -- general case with k = 18\n xn = (xn + a / xn) >> 1; // \u03b5_5 := | x_5 - sqrt(a) | \u2264 2**(e-72) -- general case with k = 36\n xn = (xn + a / xn) >> 1; // \u03b5_6 := | x_6 - sqrt(a) | \u2264 2**(e-144) -- general case with k = 72\n\n // Because e \u2264 128 (as discussed during the first estimation phase), we know have reached a precision\n // \u03b5_6 \u2264 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either\n // sqrt(a) or sqrt(a) + 1.\n return xn - SafeCast.toUint(xn > a / xn);\n }\n }\n\n /**\n * @dev Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);\n }\n }\n\n /**\n * @dev Return the log in base 2 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log2(uint256 x) internal pure returns (uint256 r) {\n // If value has upper 128 bits set, log2 result is at least 128\n r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;\n // If upper 64 bits of 128-bit half set, add 64 to result\n r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;\n // If upper 32 bits of 64-bit half set, add 32 to result\n r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;\n // If upper 16 bits of 32-bit half set, add 16 to result\n r |= SafeCast.toUint((x >> r) > 0xffff) << 4;\n // If upper 8 bits of 16-bit half set, add 8 to result\n r |= SafeCast.toUint((x >> r) > 0xff) << 3;\n // If upper 4 bits of 8-bit half set, add 4 to result\n r |= SafeCast.toUint((x >> r) > 0xf) << 2;\n\n // Shifts value right by the current result and use it as an index into this lookup table:\n //\n // | x (4 bits) | index | table[index] = MSB position |\n // |------------|---------|-----------------------------|\n // | 0000 | 0 | table[0] = 0 |\n // | 0001 | 1 | table[1] = 0 |\n // | 0010 | 2 | table[2] = 1 |\n // | 0011 | 3 | table[3] = 1 |\n // | 0100 | 4 | table[4] = 2 |\n // | 0101 | 5 | table[5] = 2 |\n // | 0110 | 6 | table[6] = 2 |\n // | 0111 | 7 | table[7] = 2 |\n // | 1000 | 8 | table[8] = 3 |\n // | 1001 | 9 | table[9] = 3 |\n // | 1010 | 10 | table[10] = 3 |\n // | 1011 | 11 | table[11] = 3 |\n // | 1100 | 12 | table[12] = 3 |\n // | 1101 | 13 | table[13] = 3 |\n // | 1110 | 14 | table[14] = 3 |\n // | 1111 | 15 | table[15] = 3 |\n //\n // The lookup table is represented as a 32-byte value with the MSB positions for 0-15 in the last 16 bytes.\n assembly (\"memory-safe\") {\n r := or(r, byte(shr(r, x), 0x0000010102020202030303030303030300000000000000000000000000000000))\n }\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);\n }\n }\n\n /**\n * @dev Return the log in base 10 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);\n }\n }\n\n /**\n * @dev Return the log in base 256 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 x) internal pure returns (uint256 r) {\n // If value has upper 128 bits set, log2 result is at least 128\n r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;\n // If upper 64 bits of 128-bit half set, add 64 to result\n r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;\n // If upper 32 bits of 64-bit half set, add 32 to result\n r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;\n // If upper 16 bits of 32-bit half set, add 16 to result\n r |= SafeCast.toUint((x >> r) > 0xffff) << 4;\n // Add 1 if upper 8 bits of 16-bit half set, and divide accumulated result by 8\n return (r >> 3) | SafeCast.toUint((x >> r) > 0xff);\n }\n\n /**\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);\n }\n }\n\n /**\n * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n */\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n return uint8(rounding) % 2 == 1;\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/proxy/beacon/IBeacon.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (proxy/beacon/IBeacon.sol)\n\npragma solidity >=0.4.16;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {UpgradeableBeacon} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" + }, + "lib/openzeppelin-contracts/contracts/interfaces/IERC1967.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1967.sol)\n\npragma solidity >=0.4.11;\n\n/**\n * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.\n */\ninterface IERC1967 {\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Emitted when the beacon is changed.\n */\n event BeaconUpgraded(address indexed beacon);\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC-1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\n * // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(newImplementation.code.length > 0);\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * TIP: Consider using this library along with {SlotDerivation}.\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n struct Int256Slot {\n int256 value;\n }\n\n struct StringSlot {\n string value;\n }\n\n struct BytesSlot {\n bytes value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n assembly (\"memory-safe\") {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns a `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n assembly (\"memory-safe\") {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns a `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n assembly (\"memory-safe\") {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns a `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n assembly (\"memory-safe\") {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns a `Int256Slot` with member `value` located at `slot`.\n */\n function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {\n assembly (\"memory-safe\") {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns a `StringSlot` with member `value` located at `slot`.\n */\n function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n assembly (\"memory-safe\") {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n */\n function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n assembly (\"memory-safe\") {\n r.slot := store.slot\n }\n }\n\n /**\n * @dev Returns a `BytesSlot` with member `value` located at `slot`.\n */\n function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n assembly (\"memory-safe\") {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n */\n function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n assembly (\"memory-safe\") {\n r.slot := store.slot\n }\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/Comparators.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/Comparators.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides a set of functions to compare values.\n *\n * _Available since v5.1._\n */\nlibrary Comparators {\n function lt(uint256 a, uint256 b) internal pure returns (bool) {\n return a < b;\n }\n\n function gt(uint256 a, uint256 b) internal pure returns (bool) {\n return a > b;\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/SlotDerivation.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.3.0) (utils/SlotDerivation.sol)\n// This file was procedurally generated from scripts/generate/templates/SlotDerivation.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Library for computing storage (and transient storage) locations from namespaces and deriving slots\n * corresponding to standard patterns. The derivation method for array and mapping matches the storage layout used by\n * the solidity language / compiler.\n *\n * See https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays[Solidity docs for mappings and dynamic arrays.].\n *\n * Example usage:\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using StorageSlot for bytes32;\n * using SlotDerivation for bytes32;\n *\n * // Declare a namespace\n * string private constant _NAMESPACE = \"\"; // eg. OpenZeppelin.Slot\n *\n * function setValueInNamespace(uint256 key, address newValue) internal {\n * _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value = newValue;\n * }\n *\n * function getValueInNamespace(uint256 key) internal view returns (address) {\n * return _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value;\n * }\n * }\n * ```\n *\n * TIP: Consider using this library along with {StorageSlot}.\n *\n * NOTE: This library provides a way to manipulate storage locations in a non-standard way. Tooling for checking\n * upgrade safety will ignore the slots accessed through this library.\n *\n * _Available since v5.1._\n */\nlibrary SlotDerivation {\n /**\n * @dev Derive an ERC-7201 slot from a string (namespace).\n */\n function erc7201Slot(string memory namespace) internal pure returns (bytes32 slot) {\n assembly (\"memory-safe\") {\n mstore(0x00, sub(keccak256(add(namespace, 0x20), mload(namespace)), 1))\n slot := and(keccak256(0x00, 0x20), not(0xff))\n }\n }\n\n /**\n * @dev Add an offset to a slot to get the n-th element of a structure or an array.\n */\n function offset(bytes32 slot, uint256 pos) internal pure returns (bytes32 result) {\n unchecked {\n return bytes32(uint256(slot) + pos);\n }\n }\n\n /**\n * @dev Derive the location of the first element in an array from the slot where the length is stored.\n */\n function deriveArray(bytes32 slot) internal pure returns (bytes32 result) {\n assembly (\"memory-safe\") {\n mstore(0x00, slot)\n result := keccak256(0x00, 0x20)\n }\n }\n\n /**\n * @dev Derive the location of a mapping element from the key.\n */\n function deriveMapping(bytes32 slot, address key) internal pure returns (bytes32 result) {\n assembly (\"memory-safe\") {\n mstore(0x00, and(key, shr(96, not(0))))\n mstore(0x20, slot)\n result := keccak256(0x00, 0x40)\n }\n }\n\n /**\n * @dev Derive the location of a mapping element from the key.\n */\n function deriveMapping(bytes32 slot, bool key) internal pure returns (bytes32 result) {\n assembly (\"memory-safe\") {\n mstore(0x00, iszero(iszero(key)))\n mstore(0x20, slot)\n result := keccak256(0x00, 0x40)\n }\n }\n\n /**\n * @dev Derive the location of a mapping element from the key.\n */\n function deriveMapping(bytes32 slot, bytes32 key) internal pure returns (bytes32 result) {\n assembly (\"memory-safe\") {\n mstore(0x00, key)\n mstore(0x20, slot)\n result := keccak256(0x00, 0x40)\n }\n }\n\n /**\n * @dev Derive the location of a mapping element from the key.\n */\n function deriveMapping(bytes32 slot, uint256 key) internal pure returns (bytes32 result) {\n assembly (\"memory-safe\") {\n mstore(0x00, key)\n mstore(0x20, slot)\n result := keccak256(0x00, 0x40)\n }\n }\n\n /**\n * @dev Derive the location of a mapping element from the key.\n */\n function deriveMapping(bytes32 slot, int256 key) internal pure returns (bytes32 result) {\n assembly (\"memory-safe\") {\n mstore(0x00, key)\n mstore(0x20, slot)\n result := keccak256(0x00, 0x40)\n }\n }\n\n /**\n * @dev Derive the location of a mapping element from the key.\n */\n function deriveMapping(bytes32 slot, string memory key) internal pure returns (bytes32 result) {\n assembly (\"memory-safe\") {\n let length := mload(key)\n let begin := add(key, 0x20)\n let end := add(begin, length)\n let cache := mload(end)\n mstore(end, slot)\n result := keccak256(begin, add(length, 0x20))\n mstore(end, cache)\n }\n }\n\n /**\n * @dev Derive the location of a mapping element from the key.\n */\n function deriveMapping(bytes32 slot, bytes memory key) internal pure returns (bytes32 result) {\n assembly (\"memory-safe\") {\n let length := mload(key)\n let begin := add(key, 0x20)\n let end := add(begin, length)\n let cache := mload(end)\n mstore(end, slot)\n result := keccak256(begin, add(length, 0x20))\n mstore(end, cache)\n }\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/Panic.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Helper library for emitting standardized panic codes.\n *\n * ```solidity\n * contract Example {\n * using Panic for uint256;\n *\n * // Use any of the declared internal constants\n * function foo() { Panic.GENERIC.panic(); }\n *\n * // Alternatively\n * function foo() { Panic.panic(Panic.GENERIC); }\n * }\n * ```\n *\n * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].\n *\n * _Available since v5.1._\n */\n// slither-disable-next-line unused-state\nlibrary Panic {\n /// @dev generic / unspecified error\n uint256 internal constant GENERIC = 0x00;\n /// @dev used by the assert() builtin\n uint256 internal constant ASSERT = 0x01;\n /// @dev arithmetic underflow or overflow\n uint256 internal constant UNDER_OVERFLOW = 0x11;\n /// @dev division or modulo by zero\n uint256 internal constant DIVISION_BY_ZERO = 0x12;\n /// @dev enum conversion error\n uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;\n /// @dev invalid encoding in storage\n uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;\n /// @dev empty array pop\n uint256 internal constant EMPTY_ARRAY_POP = 0x31;\n /// @dev array out of bounds access\n uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;\n /// @dev resource error (too large allocation or too large array)\n uint256 internal constant RESOURCE_ERROR = 0x41;\n /// @dev calling invalid internal function\n uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;\n\n /// @dev Reverts with a panic code. Recommended to use with\n /// the internal constants with predefined codes.\n function panic(uint256 code) internal pure {\n assembly (\"memory-safe\") {\n mstore(0x00, 0x4e487b71)\n mstore(0x20, code)\n revert(0x1c, 0x24)\n }\n }\n}\n" + }, + "lib/openzeppelin-contracts/contracts/utils/math/SafeCast.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeCast {\n /**\n * @dev Value doesn't fit in an uint of `bits` size.\n */\n error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);\n\n /**\n * @dev An int value doesn't fit in an uint of `bits` size.\n */\n error SafeCastOverflowedIntToUint(int256 value);\n\n /**\n * @dev Value doesn't fit in an int of `bits` size.\n */\n error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);\n\n /**\n * @dev An uint value doesn't fit in an int of `bits` size.\n */\n error SafeCastOverflowedUintToInt(uint256 value);\n\n /**\n * @dev Returns the downcasted uint248 from uint256, reverting on\n * overflow (when the input is greater than largest uint248).\n *\n * Counterpart to Solidity's `uint248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n if (value > type(uint248).max) {\n revert SafeCastOverflowedUintDowncast(248, value);\n }\n return uint248(value);\n }\n\n /**\n * @dev Returns the downcasted uint240 from uint256, reverting on\n * overflow (when the input is greater than largest uint240).\n *\n * Counterpart to Solidity's `uint240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n if (value > type(uint240).max) {\n revert SafeCastOverflowedUintDowncast(240, value);\n }\n return uint240(value);\n }\n\n /**\n * @dev Returns the downcasted uint232 from uint256, reverting on\n * overflow (when the input is greater than largest uint232).\n *\n * Counterpart to Solidity's `uint232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n if (value > type(uint232).max) {\n revert SafeCastOverflowedUintDowncast(232, value);\n }\n return uint232(value);\n }\n\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n if (value > type(uint224).max) {\n revert SafeCastOverflowedUintDowncast(224, value);\n }\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint216 from uint256, reverting on\n * overflow (when the input is greater than largest uint216).\n *\n * Counterpart to Solidity's `uint216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n if (value > type(uint216).max) {\n revert SafeCastOverflowedUintDowncast(216, value);\n }\n return uint216(value);\n }\n\n /**\n * @dev Returns the downcasted uint208 from uint256, reverting on\n * overflow (when the input is greater than largest uint208).\n *\n * Counterpart to Solidity's `uint208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n if (value > type(uint208).max) {\n revert SafeCastOverflowedUintDowncast(208, value);\n }\n return uint208(value);\n }\n\n /**\n * @dev Returns the downcasted uint200 from uint256, reverting on\n * overflow (when the input is greater than largest uint200).\n *\n * Counterpart to Solidity's `uint200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n if (value > type(uint200).max) {\n revert SafeCastOverflowedUintDowncast(200, value);\n }\n return uint200(value);\n }\n\n /**\n * @dev Returns the downcasted uint192 from uint256, reverting on\n * overflow (when the input is greater than largest uint192).\n *\n * Counterpart to Solidity's `uint192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n if (value > type(uint192).max) {\n revert SafeCastOverflowedUintDowncast(192, value);\n }\n return uint192(value);\n }\n\n /**\n * @dev Returns the downcasted uint184 from uint256, reverting on\n * overflow (when the input is greater than largest uint184).\n *\n * Counterpart to Solidity's `uint184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n if (value > type(uint184).max) {\n revert SafeCastOverflowedUintDowncast(184, value);\n }\n return uint184(value);\n }\n\n /**\n * @dev Returns the downcasted uint176 from uint256, reverting on\n * overflow (when the input is greater than largest uint176).\n *\n * Counterpart to Solidity's `uint176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n if (value > type(uint176).max) {\n revert SafeCastOverflowedUintDowncast(176, value);\n }\n return uint176(value);\n }\n\n /**\n * @dev Returns the downcasted uint168 from uint256, reverting on\n * overflow (when the input is greater than largest uint168).\n *\n * Counterpart to Solidity's `uint168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n if (value > type(uint168).max) {\n revert SafeCastOverflowedUintDowncast(168, value);\n }\n return uint168(value);\n }\n\n /**\n * @dev Returns the downcasted uint160 from uint256, reverting on\n * overflow (when the input is greater than largest uint160).\n *\n * Counterpart to Solidity's `uint160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n if (value > type(uint160).max) {\n revert SafeCastOverflowedUintDowncast(160, value);\n }\n return uint160(value);\n }\n\n /**\n * @dev Returns the downcasted uint152 from uint256, reverting on\n * overflow (when the input is greater than largest uint152).\n *\n * Counterpart to Solidity's `uint152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n if (value > type(uint152).max) {\n revert SafeCastOverflowedUintDowncast(152, value);\n }\n return uint152(value);\n }\n\n /**\n * @dev Returns the downcasted uint144 from uint256, reverting on\n * overflow (when the input is greater than largest uint144).\n *\n * Counterpart to Solidity's `uint144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n if (value > type(uint144).max) {\n revert SafeCastOverflowedUintDowncast(144, value);\n }\n return uint144(value);\n }\n\n /**\n * @dev Returns the downcasted uint136 from uint256, reverting on\n * overflow (when the input is greater than largest uint136).\n *\n * Counterpart to Solidity's `uint136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n if (value > type(uint136).max) {\n revert SafeCastOverflowedUintDowncast(136, value);\n }\n return uint136(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n if (value > type(uint128).max) {\n revert SafeCastOverflowedUintDowncast(128, value);\n }\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint120 from uint256, reverting on\n * overflow (when the input is greater than largest uint120).\n *\n * Counterpart to Solidity's `uint120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n if (value > type(uint120).max) {\n revert SafeCastOverflowedUintDowncast(120, value);\n }\n return uint120(value);\n }\n\n /**\n * @dev Returns the downcasted uint112 from uint256, reverting on\n * overflow (when the input is greater than largest uint112).\n *\n * Counterpart to Solidity's `uint112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n if (value > type(uint112).max) {\n revert SafeCastOverflowedUintDowncast(112, value);\n }\n return uint112(value);\n }\n\n /**\n * @dev Returns the downcasted uint104 from uint256, reverting on\n * overflow (when the input is greater than largest uint104).\n *\n * Counterpart to Solidity's `uint104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n if (value > type(uint104).max) {\n revert SafeCastOverflowedUintDowncast(104, value);\n }\n return uint104(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n if (value > type(uint96).max) {\n revert SafeCastOverflowedUintDowncast(96, value);\n }\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint88 from uint256, reverting on\n * overflow (when the input is greater than largest uint88).\n *\n * Counterpart to Solidity's `uint88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n if (value > type(uint88).max) {\n revert SafeCastOverflowedUintDowncast(88, value);\n }\n return uint88(value);\n }\n\n /**\n * @dev Returns the downcasted uint80 from uint256, reverting on\n * overflow (when the input is greater than largest uint80).\n *\n * Counterpart to Solidity's `uint80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n if (value > type(uint80).max) {\n revert SafeCastOverflowedUintDowncast(80, value);\n }\n return uint80(value);\n }\n\n /**\n * @dev Returns the downcasted uint72 from uint256, reverting on\n * overflow (when the input is greater than largest uint72).\n *\n * Counterpart to Solidity's `uint72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n if (value > type(uint72).max) {\n revert SafeCastOverflowedUintDowncast(72, value);\n }\n return uint72(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n if (value > type(uint64).max) {\n revert SafeCastOverflowedUintDowncast(64, value);\n }\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint56 from uint256, reverting on\n * overflow (when the input is greater than largest uint56).\n *\n * Counterpart to Solidity's `uint56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n if (value > type(uint56).max) {\n revert SafeCastOverflowedUintDowncast(56, value);\n }\n return uint56(value);\n }\n\n /**\n * @dev Returns the downcasted uint48 from uint256, reverting on\n * overflow (when the input is greater than largest uint48).\n *\n * Counterpart to Solidity's `uint48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n if (value > type(uint48).max) {\n revert SafeCastOverflowedUintDowncast(48, value);\n }\n return uint48(value);\n }\n\n /**\n * @dev Returns the downcasted uint40 from uint256, reverting on\n * overflow (when the input is greater than largest uint40).\n *\n * Counterpart to Solidity's `uint40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n if (value > type(uint40).max) {\n revert SafeCastOverflowedUintDowncast(40, value);\n }\n return uint40(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n if (value > type(uint32).max) {\n revert SafeCastOverflowedUintDowncast(32, value);\n }\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint24 from uint256, reverting on\n * overflow (when the input is greater than largest uint24).\n *\n * Counterpart to Solidity's `uint24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n if (value > type(uint24).max) {\n revert SafeCastOverflowedUintDowncast(24, value);\n }\n return uint24(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n if (value > type(uint16).max) {\n revert SafeCastOverflowedUintDowncast(16, value);\n }\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n if (value > type(uint8).max) {\n revert SafeCastOverflowedUintDowncast(8, value);\n }\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n if (value < 0) {\n revert SafeCastOverflowedIntToUint(value);\n }\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int248 from int256, reverting on\n * overflow (when the input is less than smallest int248 or\n * greater than largest int248).\n *\n * Counterpart to Solidity's `int248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n */\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(248, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int240 from int256, reverting on\n * overflow (when the input is less than smallest int240 or\n * greater than largest int240).\n *\n * Counterpart to Solidity's `int240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n */\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(240, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int232 from int256, reverting on\n * overflow (when the input is less than smallest int232 or\n * greater than largest int232).\n *\n * Counterpart to Solidity's `int232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n */\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(232, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int224 from int256, reverting on\n * overflow (when the input is less than smallest int224 or\n * greater than largest int224).\n *\n * Counterpart to Solidity's `int224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n */\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(224, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int216 from int256, reverting on\n * overflow (when the input is less than smallest int216 or\n * greater than largest int216).\n *\n * Counterpart to Solidity's `int216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n */\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(216, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int208 from int256, reverting on\n * overflow (when the input is less than smallest int208 or\n * greater than largest int208).\n *\n * Counterpart to Solidity's `int208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n */\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(208, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int200 from int256, reverting on\n * overflow (when the input is less than smallest int200 or\n * greater than largest int200).\n *\n * Counterpart to Solidity's `int200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n */\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(200, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int192 from int256, reverting on\n * overflow (when the input is less than smallest int192 or\n * greater than largest int192).\n *\n * Counterpart to Solidity's `int192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n */\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(192, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int184 from int256, reverting on\n * overflow (when the input is less than smallest int184 or\n * greater than largest int184).\n *\n * Counterpart to Solidity's `int184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n */\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(184, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int176 from int256, reverting on\n * overflow (when the input is less than smallest int176 or\n * greater than largest int176).\n *\n * Counterpart to Solidity's `int176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n */\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(176, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int168 from int256, reverting on\n * overflow (when the input is less than smallest int168 or\n * greater than largest int168).\n *\n * Counterpart to Solidity's `int168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n */\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(168, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int160 from int256, reverting on\n * overflow (when the input is less than smallest int160 or\n * greater than largest int160).\n *\n * Counterpart to Solidity's `int160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n */\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(160, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int152 from int256, reverting on\n * overflow (when the input is less than smallest int152 or\n * greater than largest int152).\n *\n * Counterpart to Solidity's `int152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n */\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(152, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int144 from int256, reverting on\n * overflow (when the input is less than smallest int144 or\n * greater than largest int144).\n *\n * Counterpart to Solidity's `int144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n */\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(144, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int136 from int256, reverting on\n * overflow (when the input is less than smallest int136 or\n * greater than largest int136).\n *\n * Counterpart to Solidity's `int136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n */\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(136, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n */\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(128, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int120 from int256, reverting on\n * overflow (when the input is less than smallest int120 or\n * greater than largest int120).\n *\n * Counterpart to Solidity's `int120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n */\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(120, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int112 from int256, reverting on\n * overflow (when the input is less than smallest int112 or\n * greater than largest int112).\n *\n * Counterpart to Solidity's `int112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n */\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(112, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int104 from int256, reverting on\n * overflow (when the input is less than smallest int104 or\n * greater than largest int104).\n *\n * Counterpart to Solidity's `int104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n */\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(104, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int96 from int256, reverting on\n * overflow (when the input is less than smallest int96 or\n * greater than largest int96).\n *\n * Counterpart to Solidity's `int96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n */\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(96, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int88 from int256, reverting on\n * overflow (when the input is less than smallest int88 or\n * greater than largest int88).\n *\n * Counterpart to Solidity's `int88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n */\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(88, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int80 from int256, reverting on\n * overflow (when the input is less than smallest int80 or\n * greater than largest int80).\n *\n * Counterpart to Solidity's `int80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n */\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(80, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int72 from int256, reverting on\n * overflow (when the input is less than smallest int72 or\n * greater than largest int72).\n *\n * Counterpart to Solidity's `int72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n */\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(72, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n */\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(64, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int56 from int256, reverting on\n * overflow (when the input is less than smallest int56 or\n * greater than largest int56).\n *\n * Counterpart to Solidity's `int56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n */\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(56, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int48 from int256, reverting on\n * overflow (when the input is less than smallest int48 or\n * greater than largest int48).\n *\n * Counterpart to Solidity's `int48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n */\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(48, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int40 from int256, reverting on\n * overflow (when the input is less than smallest int40 or\n * greater than largest int40).\n *\n * Counterpart to Solidity's `int40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n */\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(40, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n */\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(32, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int24 from int256, reverting on\n * overflow (when the input is less than smallest int24 or\n * greater than largest int24).\n *\n * Counterpart to Solidity's `int24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n */\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(24, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n */\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(16, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n */\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(8, value);\n }\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n if (value > uint256(type(int256).max)) {\n revert SafeCastOverflowedUintToInt(value);\n }\n return int256(value);\n }\n\n /**\n * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.\n */\n function toUint(bool b) internal pure returns (uint256 u) {\n assembly (\"memory-safe\") {\n u := iszero(iszero(b))\n }\n }\n}\n" + } + }, + "settings": { + "remappings": [ + "forge-std/=lib/forge-std/src/", + "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", + "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", + "@openzeppelin/foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/", + "@uma/contracts/=lib/protocol/packages/core/contracts/", + "permit2/=lib/permit2/", + "ds-test/=lib/permit2/lib/forge-std/lib/ds-test/src/", + "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", + "forge-gas-snapshot/=lib/permit2/lib/forge-gas-snapshot/src/", + "halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/", + "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", + "openzeppelin-contracts/=lib/openzeppelin-contracts/", + "openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/", + "protocol/=lib/protocol/", + "solmate/=lib/permit2/lib/solmate/" + ], + "optimizer": { + "enabled": true, + "runs": 1 + }, + "metadata": { + "useLiteralContent": false, + "bytecodeHash": "ipfs", + "appendCBOR": true + }, + "outputSelection": { + "*": { + "*": [ + "evm.bytecode", + "evm.deployedBytecode", + "devdoc", + "userdoc", + "metadata", + "abi" + ] + } + }, + "evmVersion": "prague", + "viaIR": true + } +} diff --git a/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/verified-code-pins.json b/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/verified-code-pins.json new file mode 100644 index 0000000..e5efb08 --- /dev/null +++ b/script/production/deployments/polygon-poly-v2-whitelist-2026-10-15/verified-code-pins.json @@ -0,0 +1,83 @@ +{ + "status": "verified_pins_ready_not_deployed_not_activated", + "verificationDate": "2026-10-15", + "chainId": 137, + "blockNumber": 95573288, + "blockHash": "0xfa7f5ccfc98241b34e95586909c3606e6a7473a1bf142f1938de59541598dd9c", + "pins": { + "POLYMARKET_V2_INITIALIZER_ACCESS_MANAGER_CODE_HASH": "0x9bb503f05d0dc3393bdcf782e23b52c70019c828aed9f25a3329d92b3efd8428", + "POLYMARKET_V2_INITIALIZER_SIGNED_PROPOSER_CODE_HASH": "0xbc198f557cff5fc69b0d8c3aee31d8cbd8d1c048275259fc291f9ae950453f10" + }, + "accessManager": { + "address": "0xfa6f0ff6c719001cba691ff12ceaa9c49acdcb66", + "reference": "OpenZeppelin Contracts v5.6.1", + "referenceCommit": "5fd1781b1454fd1ef8e722282f86f9293cacf256", + "verifiedSourceFiles": 13, + "canonicalSourceMatches": true, + "fullRuntimeIncludingMetadataMatches": true, + "compiler": "0.8.30+commit.73712a01", + "optimizerRuns": 1, + "viaIR": true, + "evmVersion": "cancun", + "sourceURL": "https://polygonscan.com/address/0xfa6f0ff6c719001cba691ff12ceaa9c49acdcb66#code", + "reviewScope": "Unmodified canonical OpenZeppelin release and its 13-source dependency closure; this AccessManager is outside the UMA-specific OOReporter/SignedProposer diff audit." + }, + "signedProposer": { + "proxy": "0x632dA7EcAD445C090DaFe1B03c24c113bD0edD13", + "implementation": "0x1307ce44a51af6d84ad2e346d7655f1b7d20d856", + "implementationSlot": "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc", + "releaseCommit": "24a5930ba82bb9a91fb3251d8d7ff243b5d95a7a", + "auditedPR79Head": "621b4d3788e2c2437aee994d1f303b8a3d57ad51", + "fixReviewRefs": { + "N-03": "38eb19f0ba5e0fbdb12f7e3f844a3bb2e2a0d5cc", + "N-04": "10b4d1cb2072752bd99864758022cd61f5212e07", + "L-05": "1a0a4172efab2f11f35b9f7c6fa3aa3880b1822c" + }, + "verifiedSourceFiles": 41, + "releaseAndPinnedDependenciesMatch": true, + "codeTokensMatchAuditedHeadPlusReviewedN03Fix": true, + "fullRuntimeIncludingMetadataMatches": true, + "immutableReferences": { + "652": [ + { + "start": 5009, + "length": 32 + }, + { + "start": 5174, + "length": 32 + } + ] + }, + "immutableResolution": "Verified each __self slot contains exactly the implementation address; no other bytes masked or normalized.", + "compiler": "0.8.30+commit.73712a01", + "optimizerRuns": 1, + "viaIR": true, + "evmVersion": "prague", + "openzeppelinContractsVersion": "v5.4.0", + "openzeppelinContractsCommit": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0", + "openzeppelinUpgradeableVersion": "v5.4.0", + "openzeppelinUpgradeableCommit": "e725abddf1e01cf05ace496e950fc8e243cc7cab", + "sourceURL": "https://polygonscan.com/address/0x1307ce44a51af6d84ad2e346d7655f1b7d20d856#code", + "auditURL": "https://audits.openzeppelin.com/risk-labs/uma-26-retainer-01-ooreporter-consolidation-and-signedproposer-batching", + "auditFindingStatus": { + "N-03": "resolved", + "N-04": "resolved", + "L-05": "acknowledged_not_resolved" + }, + "acceptedAuditBehavior": "L-05 remains acknowledged, not resolved under the previously accepted fully trusted relayer model; no claim that all audit findings were fixed." + }, + "evidenceFiles": { + "bytecode-reproduction.json": "7f231090871997071e9698020e09610de2f547b2a5863c22ab131d1bbd55cbce", + "reviewed-source-provenance.json": "4e4daddb1cb81597e3133a75060cd126d8ecc8ca9be3c8c74f671f21488560af", + "access-manager-standard-input.json": "c8028150715decacf141321b9b52d9bf430abba63d2fa57405245dadd15f0676", + "signed-proposer-implementation-standard-input.json": "c0252d74bce4cf867ce629534331ea117a65abfd798eaffc5e9de6768f7ff39a" + }, + "productionChanged": false, + "signed": false, + "broadcast": false, + "limits": [ + "Verification is tied to the recorded block and implementations. Recheck the implementation slot and runtime pins before activation.", + "This is deployment/source provenance verification, not a new audit of the integration or its privileged actors." + ] +}